Choosing the approach is a checked step; three tiers for where knowledge lives; patterns
ci / tests (macos-latest, python 3.10) (push) Canceled after 0s
ci / tests (macos-latest, python 3.11) (push) Canceled after 0s
ci / tests (macos-latest, python 3.13) (push) Canceled after 0s
ci / tests (macos-latest, python 3.9) (push) Canceled after 0s
ci / tests (ubuntu-latest, python 3.10) (push) Canceled after 0s
ci / tests (ubuntu-latest, python 3.11) (push) Canceled after 0s
ci / tests (ubuntu-latest, python 3.13) (push) Canceled after 0s
ci / tests (macos-latest, python 3.10) (push) Canceled after 0s
ci / tests (macos-latest, python 3.11) (push) Canceled after 0s
ci / tests (macos-latest, python 3.13) (push) Canceled after 0s
ci / tests (macos-latest, python 3.9) (push) Canceled after 0s
ci / tests (ubuntu-latest, python 3.10) (push) Canceled after 0s
ci / tests (ubuntu-latest, python 3.11) (push) Canceled after 0s
ci / tests (ubuntu-latest, python 3.13) (push) Canceled after 0s
A new first rule and a required design section in the contract for sizeable work, validated structurally and enforced by the end-of-turn check. Lessons and statements are tiered core, user or project; core items are queued for the product (sisi promote). The owner's statements take effect at once and form the principles document. Every retro names the general pattern behind its incident; learning rounds group lessons under patterns. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
1 parent
ba84772acf
commit
ec91e526a6
32 files changed
+2484
-251
No files matched your search
+65
-4
@@ -551,7 +551,49 @@ def _question_sendback(payload):
|
||||
return "block", ("sisi: you ended by asking the human a question in the text of your reply. Ask it through the "
|
||||
"tool's question dialog (%s), with options to pick from and the one you recommend marked — or "
|
||||
"decide it yourself, record the assumption, and finish without the question. "
|
||||
"(Rule 5 in full: `sisi rule 5`.)" % dialogs[0])
|
||||
"(The rule in full: `sisi rule decide-dont-ask`.)" % dialogs[0])
|
||||
|
||||
|
||||
def _measure_work(cwd, base=None):
|
||||
"""Growth of the work itself: sisi's own contract file is not product work and never counts."""
|
||||
m = gitutil.measure(cwd, base)
|
||||
rel = C.REL.replace(os.sep, "/")
|
||||
if rel in m["files"]:
|
||||
lines = m["lines"]
|
||||
try:
|
||||
with open(os.path.join(gitutil.root(cwd) or cwd, C.REL), "rb") as f:
|
||||
lines = max(0, lines - (f.read().count(b"\n") or 1))
|
||||
except OSError:
|
||||
pass
|
||||
return {"lines": lines, "files": [f for f in m["files"] if f != rel]}
|
||||
return m
|
||||
|
||||
|
||||
def _design_required(sess, cwd, top, g, payload, attr):
|
||||
"""The design section is required exactly where a contract is already required: a large
|
||||
change (the gate's growth thresholds). Small edits, subagents, and sessions that edited
|
||||
nothing here are exempt. Returns True when required, else None."""
|
||||
if payload.get("agent_id") or payload.get("agent_transcript_path"):
|
||||
return None # a subagent works to its parent's brief; the parent owns the design
|
||||
if attr is not None and not attr.get("writing") and not attr.get("unknown"):
|
||||
return None # this session edited nothing: no design is owed for others' work
|
||||
if not top:
|
||||
return None
|
||||
try:
|
||||
if sess.get("baseline") is not None:
|
||||
now = _measure_work(cwd, sess.get("head"))
|
||||
base = sess["baseline"]
|
||||
dl = max(0, now["lines"] - base["lines"])
|
||||
df = len(set(now["files"]) - set(base["files"]))
|
||||
else:
|
||||
m = _measure_work(cwd, gitutil.head(cwd))
|
||||
dl, df = m["lines"], len(m["files"])
|
||||
except Exception as e:
|
||||
store.log_error("gate-design-measure", e)
|
||||
return None
|
||||
if not (dl > int(g.get("growth_lines", 40)) or df > int(g.get("growth_files", 3))):
|
||||
return None
|
||||
return True
|
||||
|
||||
|
||||
def _decide(payload):
|
||||
@@ -742,6 +784,23 @@ def _decide(payload):
|
||||
kind=sess.get("last_kind", "fast"))
|
||||
|
||||
if path:
|
||||
if c is not None and not errs:
|
||||
try:
|
||||
if _design_required(sess, cwd, top, g, payload, attr):
|
||||
from . import design as _design
|
||||
derrs = _design.validate_design(c, cwd=project)
|
||||
if derrs:
|
||||
missing = "missing" if "design" not in c else "invalid"
|
||||
return ctx.block(
|
||||
"sisi: this is a large change and the contract's design section is %s "
|
||||
"(send-back {n}). Choosing the approach is a checked step: fill the "
|
||||
"design section before building (`sisi design` prints the owner's "
|
||||
"standing principles and the questions; `sisi oracle` prints the "
|
||||
"principles in his words). Do not report this work as done.\n\n%s"
|
||||
% (missing, "\n".join("- " + e for e in derrs)),
|
||||
c["id"] if c else None, project, kind="design")
|
||||
except Exception as e: # the design check must never break the gate
|
||||
store.log_error("gate-design", e)
|
||||
deadline = time.time() + float(g.get("budget_s", 120))
|
||||
if c is not None:
|
||||
errs = C.validate(c)
|
||||
@@ -807,7 +866,7 @@ def _decide(payload):
|
||||
if not top:
|
||||
return "allow", None
|
||||
if sess.get("baseline") is None:
|
||||
sess.update(baseline=gitutil.measure(cwd), head=gitutil.head(cwd), started=sess.get("started") or store.now())
|
||||
sess.update(baseline=_measure_work(cwd), head=gitutil.head(cwd), started=sess.get("started") or store.now())
|
||||
sess["baseline_fp"] = fp
|
||||
if attr is not None:
|
||||
sess["attr_baseline_gen"] = int(sess.get("attr_gen", 0) or 0)
|
||||
@@ -821,7 +880,7 @@ def _decide(payload):
|
||||
sess["head"] = w.get("head")
|
||||
sess["waiver_ns"] = w.get("ns", 0)
|
||||
sess["blocks"] = 0
|
||||
now = gitutil.measure(cwd, sess.get("head"))
|
||||
now = _measure_work(cwd, sess.get("head"))
|
||||
base = sess["baseline"]
|
||||
dl = max(0, now["lines"] - base["lines"])
|
||||
df = len(set(now["files"]) - set(base["files"]))
|
||||
@@ -832,7 +891,9 @@ def _decide(payload):
|
||||
return ctx.allow()
|
||||
return ctx.block("sisi: this session has changed %d lines and %d files since its start and there is no "
|
||||
"contract (send-back {n}). Write `.sisi/contract.json` (`sisi contract init` makes the "
|
||||
"skeleton; give it at least one check with a real command), then run `sisi verify`. If "
|
||||
"skeleton; give it at least one check with a real command, and for a change this size "
|
||||
"fill its design section - `sisi design` prints the owner's principles and the "
|
||||
"questions), then run `sisi verify`. If "
|
||||
"the change needs no checks, run `sisi contract waive \"<reason>\"` instead." % (dl, df))
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user