Learning loop hardening: docs, approval wording, rollback only restores the cycle's own files, due notice no longer hides errors
This commit is contained in:
1 parent
4821a1b6a4
commit
2ca45f8103
9 files changed
+152
-90
No files matched your search
+5
-1
@@ -86,7 +86,11 @@ the user store (a learning cycle applied to the copy, not to the real store): it
|
|||||||
sample of dev cases plus every counterexample under the current policy and the candidate
|
sample of dev cases plus every counterexample under the current policy and the candidate
|
||||||
and prints the comparison, before anyone is asked to approve the change [11.6]. The
|
and prints the comparison, before anyone is asked to approve the change [11.6]. The
|
||||||
learning loop calls the same code as `sisi.evaluate.compare_for_candidate(dir, sample)`,
|
learning loop calls the same code as `sisi.evaluate.compare_for_candidate(dir, sample)`,
|
||||||
and calls `sisi.evaluate.validate_check(case)` before promoting a command check.
|
and calls `sisi.evaluate.validate_command(repo, before, after, cmd)` before promoting a command
|
||||||
|
check: `validated` only if the command ran and failed at `before` and ran and passed at `after`
|
||||||
|
(program present at both commits; not 126/127, a timeout or a signal), `before` an ancestor of
|
||||||
|
`after`, in a repository on the trust list. A stored case is replayed the same way by
|
||||||
|
`validate_check(case)`.
|
||||||
|
|
||||||
## Independent judging
|
## Independent judging
|
||||||
|
|
||||||
|
|||||||
+104
-46
@@ -36,20 +36,40 @@ sisi retro --finding "<what happened, with the evidence>" --cause "<root cause>"
|
|||||||
[--same-as ID]
|
[--same-as ID]
|
||||||
```
|
```
|
||||||
|
|
||||||
At least one finding per closed unit; generic findings ("be more careful") are refused.
|
At least one finding per closed unit. A finding that is only generic advice is refused wherever
|
||||||
Search terms, topics and short lines are derived by the tool, never demanded. A finding
|
the filler appears ("be more careful when writing tests in future"); a short specific one is
|
||||||
that resembles an existing learning is attached to it as a recurrence candidate — it is
|
accepted ("Tests flaked on CI: 3 of 10 runs"). Things that look like keys, tokens or passwords are
|
||||||
recorded, not refused. Learnings recorded in a subagent session are held as candidates
|
replaced by `<redacted>` before a finding or a learning is stored. Search terms, topics and short
|
||||||
until a parent retro adopts them (`--same-as`).
|
lines are derived by the tool, never demanded.
|
||||||
|
|
||||||
|
A finding that resembles a learning **in force in this project** is attached to it as a recurrence,
|
||||||
|
and the match is printed; `--new` records the finding as a learning of its own instead. Resemblance
|
||||||
|
searches nothing else. `--same-as ID` names the learning it repeats; for a learning from another
|
||||||
|
project the finding must plainly be the same thing, and it is that project's own evidence (a unit
|
||||||
|
there) that adds the provenance, never the resemblance. A unit is counted once for a learning, so
|
||||||
|
repeating a retro in one unit inflates nothing.
|
||||||
|
|
||||||
|
Recorded by a subagent means what the hooks recorded: tick marks a session that started as a
|
||||||
|
subagent, and the watch hook records, for each shell command, whether its hook payload came from
|
||||||
|
a subagent (an agent id or a subagent transcript path). `sisi retro` reads that session record; no
|
||||||
|
environment variable decides it. A subagent's learning is held as a candidate and attaches to nothing;
|
||||||
|
the parent adopts it with `sisi retro --adopt ID`, never by resemblance. `--target ID` names the rule,
|
||||||
|
recipe or technique a learning concerns, so `sisi rule`, `sisi done` and `sisi verifiers show` can
|
||||||
|
list the learnings behind it.
|
||||||
|
|
||||||
## Scope is earned
|
## Scope is earned
|
||||||
|
|
||||||
A learning is in force in the project it came from at once. It is delivered in other
|
A learning is in force in the project it came from at once. It is delivered in other projects only
|
||||||
projects only when its provenance holds at least two units in at least two projects, or
|
when its provenance holds at least two units in at least two projects (`organization` scope), or it is
|
||||||
it is an owner statement. One incident never becomes a universal rule. Text delivered
|
an owner statement made at user scope; a project-scoped statement is delivered only in its project. One
|
||||||
into a prompt is framed as background information to weigh, never as an instruction,
|
incident never becomes a universal rule. Text delivered into a prompt is framed as background
|
||||||
and only learnings that entered through sisi's own commands (`retro`, `learn`, `cycle`,
|
information to weigh, never as an instruction. Relevance is scored against the learning's own terms, so
|
||||||
migration) are ever delivered. Silence is the default.
|
a long prompt does not dilute a real match; silence is the default.
|
||||||
|
|
||||||
|
Only rows that sisi's own commands wrote, as they wrote them, are delivered or acted on. Each such
|
||||||
|
command appends the id and content digest of what it wrote to `learnings-ledger.jsonl`, in the same
|
||||||
|
commit as the row; a row added by hand, or edited by hand, has no matching entry and is never delivered
|
||||||
|
(`sisi lessons` and the learning report name it). A later sisi write does not launder it.
|
||||||
|
|
||||||
## The cycle
|
## The cycle
|
||||||
|
|
||||||
@@ -64,57 +84,95 @@ adjustment (`overlay/risk-adjustments.json`), a routing adjustment
|
|||||||
refused by the cycle; they go to the backlog shown in the learning report and to the
|
refused by the cycle; they go to the backlog shown in the learning report and to the
|
||||||
contribution export.
|
contribution export.
|
||||||
|
|
||||||
`sisi cycle apply FILE` treats the file as untrusted input and validates everything
|
`sisi cycle apply FILE` treats the file as untrusted input and plans everything before writing anything —
|
||||||
before changing anything — a refusal applies nothing:
|
the budget and every other check run first, and a refusal applies nothing. If applying then fails part-way
|
||||||
|
(a full disk), every file the cycle wrote is restored.
|
||||||
|
|
||||||
- **Replay before promotion.** A command check is run in a temporary git worktree at
|
- **A mechanism reaches only what its learning earned.** Each entry written carries the learning id,
|
||||||
the before-commit and the after-commit of the unit it came from; it must fail before
|
the scope the learning has earned (`learning.earned_scope`: its origin project unless it earned more)
|
||||||
the fix and pass after. Only then is the learning `validated`. What cannot be
|
and the origin project. Enforced checks, risk and routing adjustments are filtered by project when read.
|
||||||
replayed is promoted as `unvalidated` and always reported as such. A replay that
|
A scope or `every_project` flag in the cycle file is a request for more, never the gate.
|
||||||
fails refuses the whole cycle. Replay never touches the user's working tree.
|
- **Replay before promotion** (`evaluate.validate_command`, the one replay implementation). A command check
|
||||||
- **Protected rules** (`canon/protected.json`: verification before done, truthful
|
is run in a temporary git worktree at the before-commit and the after-commit, and is `validated` only
|
||||||
reporting, this governance) cannot be replaced or disabled by a cycle at all.
|
if it **ran and failed** before the fix (not exit 126/127, not a timeout, not killed by a signal; its
|
||||||
- **Consequential changes wait for the owner**: disabling any other rule, widening a
|
program, and a script given to an interpreter, must exist at *both* commits) and ran and passed after.
|
||||||
scope to all projects, or a command check for every project is stored as pending and
|
The repository must be the learning's origin project and on the trust list, and `before` must be an
|
||||||
takes effect only after `sisi approve ID --yes|--no`. Session start prints one line
|
ancestor of `after`; otherwise the result is `unvalidated`, with the reason. A replay that ran and
|
||||||
while a decision is waiting.
|
behaved wrongly refuses the whole cycle. Replay never touches the working tree.
|
||||||
|
- **Protected rules** (`canon/protected.json`) cannot be replaced or disabled by a cycle or by
|
||||||
|
`sisi overlay`. If the file cannot be read, no rule can be changed.
|
||||||
|
- **Consequential changes wait for the owner**: more scope than the learning earned; an enforced command
|
||||||
|
not proven by replay (or that would run outside its origin project); a risk pattern that lowers a
|
||||||
|
profile; any replacement or disabling of a rule; rule text or a library entry from a learning confined to
|
||||||
|
one project; `sisi overlay replace-rule` and `disable-rule`. They are stored as pending and take effect
|
||||||
|
only after `sisi approve ID --yes|--no`.
|
||||||
|
- **`sisi approve`** with no arguments lists every waiting change in full: the command, the pattern and
|
||||||
|
profile, the rule text as a diff, why it needs the owner, and the replay result. A decision made without
|
||||||
|
a terminal (an agent, a script) is refused unless the user config sets `learning.agent_relayed_approval`;
|
||||||
|
every decision is recorded in `approvals.jsonl` (when, session, terminal or not, `relayed by an agent`).
|
||||||
|
Session start prints one line while a decision is waiting, telling the agent to ask the owner through
|
||||||
|
the host's question dialog and to give him the command to run himself. SECURITY.md says what this does and
|
||||||
|
does not guarantee.
|
||||||
- **Flagged learnings must be acted on** (below); a cycle that ignores one is refused.
|
- **Flagged learnings must be acted on** (below); a cycle that ignores one is refused.
|
||||||
- Each change is its own commit in the user store, and the cycle records the
|
- Each change is its own commit in the user store, and each cycle (and each approval) is recorded with the
|
||||||
before/after commits, so `sisi cycle revert [ID]` restores the store exactly.
|
files and learning fields it changed. `sisi cycle revert [ID]` undoes exactly those: statements, findings
|
||||||
|
and recurrences recorded after the cycle survive, and a revert is refused if a later change touched the
|
||||||
|
same file.
|
||||||
|
- A learning that was validated but waits for the owner has status `validated`; once promoted and a unit in
|
||||||
|
its scope has closed, or it has recurred, `monitored`.
|
||||||
|
|
||||||
## Monitoring
|
## Monitoring
|
||||||
|
|
||||||
A recurrence after promotion counts against the learning. Two flag it "not working";
|
A recurrence after promotion counts against the learning (once per unit). Two flag it "not working";
|
||||||
the next cycle must revise or revert it. `sisi status --learning` prints
|
the next cycle must revise or revert it. `sisi status --learning` prints
|
||||||
`learning.learning_report()`: per promoted learning the units since promotion, the
|
`learning.learning_report()`: per promoted learning the units in its own scope since promotion
|
||||||
recurrences, whether it is validated or unvalidated, and the verdict, plus the
|
(read from `units.jsonl` in the user store, one JSON object per line with `id`, `project`, `closed_at`,
|
||||||
realization rate (promoted learnings holding with no recurrence over at least five
|
`risk`; the file may not exist yet, which counts as none), the recurrences, whether it is validated or
|
||||||
relevant units) — or "too few" when the numbers are small. No claim of improvement is
|
unvalidated, and the verdict, plus the realization rate (promoted learnings holding with no recurrence over
|
||||||
printed from counts of records.
|
at least five units in their scope) — or "too few" when the numbers are small. A project-scoped learning
|
||||||
|
counts only its project's units. No claim of improvement is printed from counts of records.
|
||||||
|
|
||||||
## Owner statements
|
## Owner statements
|
||||||
|
|
||||||
One path: `sisi learn "<what you want>"` writes an owner statement into the same
|
One path: `sisi learn "<what you want>"` writes an owner statement into the same learning store, live
|
||||||
learning store, live at once and delivered in every project; `sisi oracle` prints them.
|
at once; `sisi oracle` prints the ones in force in the current project. A user-scope statement is
|
||||||
The old `learn.jsonl` / `oracle.md` stores were merged into it by migration.
|
delivered everywhere, a project-scoped one only in its project. The record says whether the quoted words
|
||||||
|
appear in a human-typed message of the session transcript (`typed by the owner`) or not, or no transcript is
|
||||||
|
available (`relayed by an agent`); it is never blocked, and `sisi oracle` shows the relayed ones as such.
|
||||||
|
`sisi learn --withdraw ID --reason "..."` withdraws a statement recorded by mistake: kept in its history,
|
||||||
|
never delivered again.
|
||||||
|
|
||||||
## Migration
|
## Migration
|
||||||
|
|
||||||
`sisi update` (and `sisi migrate`) runs the learning migration once, with a backup
|
`sisi update` (and `sisi migrate`, and `sisi learn`/`sisi oracle`) run the learning migration whenever the
|
||||||
first and idempotently: old lesson rows become learning records with honest statuses (a
|
old store exists and the `learnings-migrated.json` marker does not: a backup first, merged by legacy id
|
||||||
lesson folded into prose is `implemented`, always unvalidated; nothing becomes
|
(a lesson already carried over is not carried twice; a learning recorded before the first migration does
|
||||||
`validated`), occurrences become provenance, impressions — sisi's own showings — are
|
not stop it). Old lesson rows become learning records with honest statuses (a lesson folded into prose
|
||||||
dropped, and owner statements join the same store. A store with only the old sqlite
|
is `implemented`, always unvalidated; nothing becomes `validated`); occurrences become provenance with the
|
||||||
database is read from the database itself. Learnings whose provenance does not meet
|
old `repo` values normalised to the project key new code uses, and only occurrences that attach to a
|
||||||
the two-units-two-projects rule are delivered only in their origin project, whatever
|
lesson are counted; impressions, sightings and pattern rows are not carried (the backup keeps them);
|
||||||
scope they once claimed.
|
owner statements join the same store with their scope, duplicates dropped. Malformed lines are counted and
|
||||||
|
reported, not hidden. A migrated learning is earned beyond its project only under the same
|
||||||
|
two-units-two-projects rule as a new one. The sqlite store is read too.
|
||||||
|
|
||||||
|
## The product
|
||||||
|
|
||||||
|
`sisi promote --export` writes the contribution file for `tool` learnings and for learnings that earned
|
||||||
|
organization scope (scrubbed: no history, no user or project names); `sisi promote L-NNNN [--apply]`
|
||||||
|
writes the rule or recipe such a learning was folded into into the source folder and marks the learning
|
||||||
|
`in_product`. `sisi handover` lists the project-scope learnings and statements waiting to be filed in
|
||||||
|
their own project's documents. `sisi rule ID`, `sisi done ID` and `sisi verifiers show ID` list the
|
||||||
|
learnings in scope that target that entry.
|
||||||
|
|
||||||
## Seams for other parts of sisi
|
## Seams for other parts of sisi
|
||||||
|
|
||||||
- `learning.findings_for_unit(project, unit_id)` — the findings a unit record stores.
|
- `learning.findings_for_unit(project, unit_id)` — the findings a unit record stores.
|
||||||
- `learning.learning_report()` — the text `sisi status --learning` prints. It replaces
|
- `learning.learning_report()` — the text `sisi status --learning` prints. It replaces
|
||||||
`sisi improve`, `sisi backlog` and `sisi lessons digest`, which are deleted.
|
`sisi improve`, `sisi backlog` and `sisi lessons digest`, which are deleted.
|
||||||
- `cycle.enforced_results(contract, project, ...)` — what `sisi verify` runs.
|
- `cycle.enforced_results(contract, project, ...)` — what `sisi verify` runs, filtered by project.
|
||||||
- `cycle.due_notice()` — the one session-start line (cycle due, decision waiting).
|
- `cycle.risk_patterns(cwd)` — the learned risk patterns that apply in a project (`risk.load_patterns`).
|
||||||
|
- `cycle.routing_adjustments(project)` — the learned routing adjustments that apply in a project.
|
||||||
|
- `cycle.due_notice()` — the session-start lines (cycle due, decision waiting).
|
||||||
- `retro.satisfied(repo, since, fp)` and `retro.TEMPLATE` — what the gate asks.
|
- `retro.satisfied(repo, since, fp)` and `retro.TEMPLATE` — what the gate asks.
|
||||||
- `learning.delivery_text(project, query)` — what the prompt hook may add.
|
- `learning.delivery_text(project, query, targets=())` — what the prompt hook may add.
|
||||||
|
- `evaluate.validate_command(repo, before, after, cmd)` — the replay.
|
||||||
+24
-20
@@ -199,20 +199,18 @@ def proposed(rows=None):
|
|||||||
|
|
||||||
|
|
||||||
def due_notice(session=None):
|
def due_notice(session=None):
|
||||||
"""Session-start lines: a cycle is due, and/or a decision waits for the owner."""
|
"""Session-start lines: a cycle is due, and/or a decision waits for the owner. The callers
|
||||||
try:
|
(tick, the gate) catch and log a failure; it is not hidden here."""
|
||||||
n = len(proposed())
|
n = len(proposed())
|
||||||
fl = len(L.flagged())
|
fl = len(L.flagged())
|
||||||
lines = []
|
lines = []
|
||||||
if n >= DUE_AFTER or fl:
|
if n >= DUE_AFTER or fl:
|
||||||
lines.append("sisi: a learning cycle is due (%d proposed learning(s)%s; `sisi cycle` prints the brief)"
|
lines.append("sisi: a learning cycle is due (%d proposed learning(s)%s; `sisi cycle` prints the brief)"
|
||||||
% (n, ", %d flagged not working" % fl if fl else ""))
|
% (n, ", %d flagged not working" % fl if fl else ""))
|
||||||
pend = L.pending_notice()
|
pend = L.pending_notice()
|
||||||
if pend:
|
if pend:
|
||||||
lines.append(pend)
|
lines.append(pend)
|
||||||
return "\n".join(lines)
|
return "\n".join(lines)
|
||||||
except Exception:
|
|
||||||
return ""
|
|
||||||
|
|
||||||
|
|
||||||
def brief_text():
|
def brief_text():
|
||||||
@@ -586,9 +584,14 @@ def _transact(label, fn):
|
|||||||
lines, touched, added = fn()
|
lines, touched, added = fn()
|
||||||
except BaseException:
|
except BaseException:
|
||||||
if before:
|
if before:
|
||||||
changed = _changed(before, "HEAD")
|
changed = set(_changed(before, "HEAD"))
|
||||||
_restore_files(before, changed)
|
changed |= {x for x in pdata.git("diff", "--name-only", "HEAD", check=False).stdout.splitlines() if x}
|
||||||
pdata.commit("cycle aborted: store restored", changed or None)
|
changed |= {x for x in pdata.git("ls-files", "--others", "--exclude-standard", "--", "overlay",
|
||||||
|
check=False).stdout.splitlines() if x}
|
||||||
|
changed = sorted(changed)
|
||||||
|
if changed:
|
||||||
|
_restore_files(before, changed)
|
||||||
|
pdata.commit("cycle aborted: store restored", changed)
|
||||||
try:
|
try:
|
||||||
overlay.build_canon()
|
overlay.build_canon()
|
||||||
except Exception:
|
except Exception:
|
||||||
@@ -692,7 +695,8 @@ def revert_cycle(cid=None):
|
|||||||
gone = set(rec.get("pending_added") or [])
|
gone = set(rec.get("pending_added") or [])
|
||||||
if gone:
|
if gone:
|
||||||
L.save_pending([i for i in L.load_pending() if i.get("id") not in gone], "revert %s: parked changes dropped" % rec["id"])
|
L.save_pending([i for i in L.load_pending() if i.get("id") not in gone], "revert %s: parked changes dropped" % rec["id"])
|
||||||
pdata.commit("revert %s" % rec["id"], files or None)
|
if files:
|
||||||
|
pdata.commit("revert %s" % rec["id"], files)
|
||||||
rec["reverted"] = L.now()
|
rec["reverted"] = L.now()
|
||||||
pdata.write_text("cycles/%s.json" % rec["id"], json.dumps(rec, indent=2, sort_keys=True) + "\n")
|
pdata.write_text("cycles/%s.json" % rec["id"], json.dumps(rec, indent=2, sort_keys=True) + "\n")
|
||||||
pdata.commit("revert %s recorded" % rec["id"], ["cycles/%s.json" % rec["id"]])
|
pdata.commit("revert %s recorded" % rec["id"], ["cycles/%s.json" % rec["id"]])
|
||||||
@@ -722,7 +726,7 @@ def relay_allowed():
|
|||||||
|
|
||||||
|
|
||||||
def describe_pending(item):
|
def describe_pending(item):
|
||||||
"""The full action, in words and text, so the owner can see exactly what he approves."""
|
"""The full action, in words and text, so the owner can see exactly what is approved."""
|
||||||
a = item.get("action") or {}
|
a = item.get("action") or {}
|
||||||
rec = L.get(L.load_learnings(), item.get("learning") or "")
|
rec = L.get(L.load_learnings(), item.get("learning") or "")
|
||||||
out = ["%s: %s" % (item["id"], (a.get("action") if a.get("action") != "promote" else
|
out = ["%s: %s" % (item["id"], (a.get("action") if a.get("action") != "promote" else
|
||||||
@@ -858,7 +862,7 @@ def cmd_approve(argv):
|
|||||||
print("\n".join(describe_pending(item)), file=sys.stderr)
|
print("\n".join(describe_pending(item)), file=sys.stderr)
|
||||||
print("sisi approve: refused. A decision must be made by the owner in a terminal: this was run "
|
print("sisi approve: refused. A decision must be made by the owner in a terminal: this was run "
|
||||||
"without one (an agent, a script, a pipe). Show the owner what it does (the listing above) "
|
"without one (an agent, a script, a pipe). Show the owner what it does (the listing above) "
|
||||||
"and give him the command to type himself. To allow an agent to relay a decision, set "
|
"and give the owner the command to type. To allow an agent to relay a decision, set "
|
||||||
"learning.agent_relayed_approval in the user config (off by default).", file=sys.stderr)
|
"learning.agent_relayed_approval in the user config (off by default).", file=sys.stderr)
|
||||||
return 2
|
return 2
|
||||||
relayed = True
|
relayed = True
|
||||||
|
|||||||
+5
-5
@@ -110,7 +110,7 @@ def is_subagent_session():
|
|||||||
if sess.get("subagent"):
|
if sess.get("subagent"):
|
||||||
return True
|
return True
|
||||||
for sh in reversed(sess.get("shells") or []):
|
for sh in reversed(sess.get("shells") or []):
|
||||||
if isinstance(sh, dict) and "retro" in str(sh.get("cmd") or ""):
|
if isinstance(sh, dict) and sh.get("retro"):
|
||||||
return bool(sh.get("subagent"))
|
return bool(sh.get("subagent"))
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@@ -474,7 +474,7 @@ def new_record(finding, cause, impact, disposition, project, unit,
|
|||||||
"provenance": [{"unit": unit, "project": pk, "ts": now(), "kind": "origin"}],
|
"provenance": [{"unit": unit, "project": pk, "ts": now(), "kind": "origin"}],
|
||||||
"terms": derive_terms(finding, cause, change or ""),
|
"terms": derive_terms(finding, cause, change or ""),
|
||||||
"owner_statement": bool(owner_statement), "candidate": bool(subagent),
|
"owner_statement": bool(owner_statement), "candidate": bool(subagent),
|
||||||
"entered_via": entered_via, "recurrences_after_promotion": 0,
|
"recurrences_after_promotion": 0,
|
||||||
"flagged_not_working": False, "promoted_at": now() if owner_statement else None,
|
"flagged_not_working": False, "promoted_at": now() if owner_statement else None,
|
||||||
"mechanism_ref": None, "replay": replay, "created": now(),
|
"mechanism_ref": None, "replay": replay, "created": now(),
|
||||||
}
|
}
|
||||||
@@ -741,9 +741,9 @@ def pending_notice():
|
|||||||
if not n:
|
if not n:
|
||||||
return ""
|
return ""
|
||||||
return ("sisi: %d learning change(s) wait for the owner's decision. Ask the owner through the host's "
|
return ("sisi: %d learning change(s) wait for the owner's decision. Ask the owner through the host's "
|
||||||
"question dialog (`sisi approve` lists each change in full; show him what it would do) and give "
|
"question dialog (`sisi approve` lists each change in full; show the owner what it would do) and give "
|
||||||
"him the command to run himself in a terminal: `sisi approve ID --yes` or `--no`. "
|
"the owner the command to run in a terminal: `sisi approve ID --yes` or `--no`. "
|
||||||
"Do not run it for him." % n)
|
"Do not run it for the owner." % n)
|
||||||
|
|
||||||
|
|
||||||
# ---- owner statements (one path: learn writes, oracle prints) ---------------------
|
# ---- owner statements (one path: learn writes, oracle prints) ---------------------
|
||||||
|
|||||||
+2
-2
@@ -355,7 +355,7 @@ def migrate_learnings():
|
|||||||
"detail": "migrated from the old lesson store; never replay-validated"},
|
"detail": "migrated from the old lesson store; never replay-validated"},
|
||||||
"status": status, "version": 1, "confidence": "low", "provenance": prov,
|
"status": status, "version": 1, "confidence": "low", "provenance": prov,
|
||||||
"terms": L.derive_terms(old.get("moment") or "", old.get("cause") or "", old.get("change") or ""),
|
"terms": L.derive_terms(old.get("moment") or "", old.get("cause") or "", old.get("change") or ""),
|
||||||
"owner_statement": False, "candidate": False, "entered_via": "migration",
|
"owner_statement": False, "candidate": False,
|
||||||
"recurrences_after_promotion": 0, "flagged_not_working": False,
|
"recurrences_after_promotion": 0, "flagged_not_working": False,
|
||||||
"promoted_at": None, "mechanism_ref": old.get("folded_into"),
|
"promoted_at": None, "mechanism_ref": old.get("folded_into"),
|
||||||
"replay": None, "created": old.get("created") or L.now()}
|
"replay": None, "created": old.get("created") or L.now()}
|
||||||
@@ -391,7 +391,7 @@ def migrate_learnings():
|
|||||||
"provenance": [{"unit": "owner", "project": proj, "ts": r.get("ts") or "", "kind": "origin"}],
|
"provenance": [{"unit": "owner", "project": proj, "ts": r.get("ts") or "", "kind": "origin"}],
|
||||||
"terms": L.derive_terms(text), "owner_statement": True, "candidate": False,
|
"terms": L.derive_terms(text), "owner_statement": True, "candidate": False,
|
||||||
"statement_origin": "migrated from the old statement file",
|
"statement_origin": "migrated from the old statement file",
|
||||||
"entered_via": "migration", "recurrences_after_promotion": 0,
|
"recurrences_after_promotion": 0,
|
||||||
"flagged_not_working": False, "promoted_at": r.get("ts") or L.now(),
|
"flagged_not_working": False, "promoted_at": r.get("ts") or L.now(),
|
||||||
"mechanism_ref": None, "replay": None, "created": r.get("ts") or L.now()}
|
"mechanism_ref": None, "replay": None, "created": r.get("ts") or L.now()}
|
||||||
rows.append(rec)
|
rows.append(rec)
|
||||||
|
|||||||
+1
-1
@@ -521,7 +521,7 @@ def _export_core(path=None):
|
|||||||
pr = r.get("proposed") or {}
|
pr = r.get("proposed") or {}
|
||||||
lines += ["## Learning %s (%s%s)" % (r["id"], pr.get("mechanism") or "policy",
|
lines += ["## Learning %s (%s%s)" % (r["id"], pr.get("mechanism") or "policy",
|
||||||
", target " + pr["target"] if pr.get("target") else ""), ""]
|
", target " + pr["target"] if pr.get("target") else ""), ""]
|
||||||
if r.get("title"):
|
if r.get("title") and r["title"] != pr.get("description"):
|
||||||
lines += [str(r["title"]), ""]
|
lines += [str(r["title"]), ""]
|
||||||
lines += [str(pr.get("description") or ""), ""]
|
lines += [str(pr.get("description") or ""), ""]
|
||||||
if r.get("expected_effect"):
|
if r.get("expected_effect"):
|
||||||
|
|||||||
+4
-7
@@ -394,13 +394,10 @@ def _print_lessons(query, extra="", targets=()):
|
|||||||
|
|
||||||
|
|
||||||
def _print_cycle_notice():
|
def _print_cycle_notice():
|
||||||
try:
|
from . import cycle
|
||||||
from . import cycle
|
line = cycle.due_notice()
|
||||||
line = cycle.due_notice()
|
if line:
|
||||||
if line:
|
print(line)
|
||||||
print(line)
|
|
||||||
except Exception:
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
def cmd_show(args):
|
def cmd_show(args):
|
||||||
|
|||||||
+5
-4
@@ -109,12 +109,13 @@ def _session(sid, d, cwd):
|
|||||||
|
|
||||||
|
|
||||||
def note_shell(sess, cmd, payload):
|
def note_shell(sess, cmd, payload):
|
||||||
"""Record, for the learning loop, who ran this shell command: whether its hook payload came
|
"""Record, for the learning loop, who ran this shell command: whether it names a retro, and whether
|
||||||
from a subagent (an agent id or a subagent transcript path). `sisi retro` reads this from the
|
its hook payload came from a subagent (an agent id or a subagent transcript path). `sisi retro`
|
||||||
session record to quarantine what a subagent records; it never trusts the caller's environment."""
|
reads this from the session record to quarantine what a subagent records; it never trusts the
|
||||||
|
caller's environment. The command text itself is not kept."""
|
||||||
from . import workers
|
from . import workers
|
||||||
shells = sess.setdefault("shells", [])
|
shells = sess.setdefault("shells", [])
|
||||||
shells.append({"cmd": (cmd or "")[:200], "subagent": bool(workers.is_subagent_payload(payload)),
|
shells.append({"retro": "retro" in (cmd or ""), "subagent": bool(workers.is_subagent_payload(payload)),
|
||||||
"ts": time.time()})
|
"ts": time.time()})
|
||||||
del shells[:-8]
|
del shells[:-8]
|
||||||
|
|
||||||
|
|||||||
@@ -751,8 +751,8 @@ class Approval(Base):
|
|||||||
line = L.pending_notice()
|
line = L.pending_notice()
|
||||||
self.assertIn("question dialog", line)
|
self.assertIn("question dialog", line)
|
||||||
self.assertIn("sisi approve", line)
|
self.assertIn("sisi approve", line)
|
||||||
self.assertIn("yourself" if "yourself" in line else "himself", line)
|
self.assertIn("command to run in a terminal", line)
|
||||||
self.assertIn("Do not run it for him", line)
|
self.assertIn("Do not run it for the owner", line)
|
||||||
from sisi import cycle
|
from sisi import cycle
|
||||||
self.assertIn(line, cycle.due_notice())
|
self.assertIn(line, cycle.due_notice())
|
||||||
|
|
||||||
@@ -1032,8 +1032,6 @@ class Cycle(Base):
|
|||||||
"--cause", "the suite runs everything serially", "--impact", "time",
|
"--cause", "the suite runs everything serially", "--impact", "time",
|
||||||
"--disposition", "promote", "--change", "run independent checks in parallel",
|
"--disposition", "promote", "--change", "run independent checks in parallel",
|
||||||
"--mechanism", "infrastructure", "--expect", "faster runs", "--validate", "time the suite")
|
"--mechanism", "infrastructure", "--expect", "faster runs", "--validate", "time the suite")
|
||||||
self.earn("L-0002", finding="another unrelated slowness appeared in the test run today",
|
|
||||||
cause="the suite runs everything serially") # so a rule is not simply parked for scope
|
|
||||||
big = "## Huge {#huge-rule}\n\n" + "\n".join("line %d of the rule" % i for i in range(400)) + "\n\nWhy: no.\n"
|
big = "## Huge {#huge-rule}\n\n" + "\n".join("line %d of the rule" % i for i in range(400)) + "\n\nWhy: no.\n"
|
||||||
with open(L.learnings_path()) as f:
|
with open(L.learnings_path()) as f:
|
||||||
before = f.read()
|
before = f.read()
|
||||||
|
|||||||
Reference in new issue
Block a user