From 08072324f47432fc4d54b1f461f3f50023a94785 Mon Sep 17 00:00:00 2001 From: Stephen Waits Date: Mon, 23 Nov 2026 10:49:46 -0700 Subject: [PATCH] Target design: how sisi meets SPEC.md Co-Authored-By: Claude Fable 5.2 --- docs/target.md | 322 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 322 insertions(+) create mode 100644 docs/target.md diff --git a/docs/target.md b/docs/target.md new file mode 100644 index 0000000..a9c5d53 --- /dev/null +++ b/docs/target.md @@ -0,0 +1,322 @@ +# Target design + +How sisi meets `SPEC.md`. This is the build reference for the reconciliation that started on +2026-11-23; `docs/reconciliation/critique.md` says what was wrong, this says what replaces it. +Section numbers in brackets are sections of `SPEC.md`. Where this document and the +specification disagree, the specification wins. + +## 1. What sisi is + +sisi is the operating layer that makes a host AI coding tool behave as the engineering +organization the specification describes, makes that behaviour observable, and improves it from +evidence. The host tool supplies the agent. sisi supplies five things: + +1. **An operating policy**: a short rulebook of strategic direction, always loaded. The agent + works out the tactics. +2. **Records**: the work unit, its verification record, its telemetry and its scorecard. +3. **Gates**: executable checks at the moments a host exposes (session start, prompt, tool + use, end of turn). +4. **A learning loop**: evidence, learning record, mechanism, validation, promotion, + monitoring, revert. +5. **An orchestration record**: which workers exist, what they cost, how they performed. + +Standing constraints from the owner, which bind every part: + +- Python standard library only. No scheduler: anything periodic is a counter checked during + normal use. +- Works in any host tool, and uses the host's native mechanisms first. +- Nothing in the product names a specific model, price, person or version. +- A behaviour is wanted either as a mechanism or as policy that is measured. Prose that + nothing checks or measures is removed. +- One of everything. When something is replaced, the old one is deleted in the same change. + +## 2. Where things live [12] + +| Layer | Path | Holds | Rule | +|---|---|---|---| +| Product | the clone and its stable copy | code, `SPEC.md`, base rulebook, library, default risk table, strategy text | True for every project and every user. Never written at run time. A test scans it for owner-specific names, model ids, prices and home paths. | +| User | `~/.local/share/sisi` (a git repository) | owner statements, learnings and the mechanisms promoted from them, the delegation ledger, worker facts, one summary line per closed unit | This user, all projects. | +| Project | `/.sisi/` | the open contract, closed unit records, project risk overrides | This project only. Project knowledge itself goes in the project's own docs (handover). | +| Scratch | `~/.local/state/sisi` | session state, caches, logs | May be deleted. Pruned by age during normal use. | + +The specification's "organization-wide" scope is the product. A user's learning reaches the +product only through `sisi promote` / `--export`, scrubbed, as today. + +## 3. Risk profiles [5.3, 9, Appendix A] + +Ceremony is set by risk, not by the size of a diff. The profiles, lowest first: +`trivial`, `isolated`, `logic`, `integration`, `data`, `critical`, `release`. + +`sisi risk [--json]` computes a **floor** from the paths changed since the unit started, using +`canon/risk.json`: glob and keyword patterns mapped to profiles. Defaults: documentation, text +and styling only is `trivial`; one module's behaviour is `isolated`; algorithms, parsing, money +and state machines are `logic`; several top-level packages or a public interface is +`integration`; schema, persistence and migration is `data`; authorization, secrets, crypto, +payments, concurrency primitives, installers and hooks is `critical`. A project may override +in `.sisi/risk.json`. A learning of mechanism type `policy` may adjust the user's table. +The contract's `risk.profile` may raise the floor freely and lower it only with `risk.why`; +the record keeps both the floor and the declared profile. + +What a profile requires. The gate enforces exactly this table and nothing else: + +| Profile | Contract | Checks | Requirement model | Risk note | Independent evidence | Retro at close | +|---|---|---|---|---|---|---| +| trivial | no | the diff; a targeted check when one exists | no | no | no | only on an anomaly (two send-backs, or a human correction) | +| isolated | yes | at least one that is not vacuous | no | no | no | yes | +| logic | yes | as isolated, each with `covers` | no | no | no | yes | +| integration | yes | as logic, plus invariants | yes | yes | no | yes | +| data, critical | yes | as integration | yes | yes | yes | yes | +| release | yes | every check (`--all`) | yes | yes | yes | yes | + +"Requirement model" is the contract's `requirements` list (section 4). "Risk note" is +`risk.blast_radius` and `risk.rollback`. "Independent evidence" is a judged review delegation +in the ledger for this unit, or a passing check marked `"independent": true`. + +## 4. The work unit [10] + +The open unit is `.sisi/contract.json`. New fields are optional unless the profile requires them. + +```json +{ + "id": "…", "parent": "request or workstream id", + "goal": "the human's words", "scope": {"in": ["…"], "out": ["…"]}, + "requirements": [ + {"id": "q1", "kind": "explicit|implied|contextual|anticipated|experiential", + "text": "…", "decision": "now|architect|defer|ignore", "why": "…", "check": "check id or null"} + ], + "risk": {"profile": "logic", "why": "…", "blast_radius": "…", "rollback": "…"}, + "checks": [ + {"id": "…", "claim": "…", "cmd": "…", "expect": {"exit": 0}, "rung": 2, "tier": "fast", + "covers": "the failure this would catch", "when_changed": ["src/parser/**"], + "mandatory": true, "independent": false} + ], + "invariants": [], "assumptions": [], "questions": [], + "deferred": [{"what": "…", "why": "…", "safe_because": "…"}], + "limitations": [], "plan": [] +} +``` + +- `sisi contract init` starts a unit. If the previous unit is closed it is replaced. If it is + still open the command refuses and names `sisi unit close --abandon ""`, which + records the disposition [10.3]. +- `sisi unit close` archives the unit to `.sisi/units/.json` and appends one summary line + to the user store's `units.jsonl`. The archived record carries the fourteen items of [10.2]: + id and parent; outcome and scope; requirements; acceptance checks and invariants; risk + profile (floor and declared); plan and the workers used; models and budgets; start, end and + telemetry; changed artifacts; every verification result; deferred checks, limitations and + open risks; delivery status; the scorecard; the retro findings and the learnings they made. + It also carries the **policy version**: a hash of the effective rulebook, the enforced checks + and the risk table, so every unit says which policies were in force [11.6]. +- `sisi unit pause ""` records a wait and lets the turn end with no + demands. Wait time is telemetry [6.1]. +- `sisi unit show [ID]` prints a record. Nothing is ever overwritten or lost. +- Delivery status is one of `delivered`, `delivered-with-deferred`, `deviation` (a check was + waived), `unverified` (the gate released after its send-backs ran out), `abandoned`. + +## 5. Verification [5.4, 5.5, 5.6, 6.4] + +- **Five statuses**: `passed`, `failed`, `skipped`, `not-applicable`, `not-run`, each of the + last three with a reason. A timeout is `not-run (timed out)`. A check that needs a person is + `not-run (needs human)`. Nothing that did not run is ever reported as passed. +- **What blocks**: a `failed` check, or a mandatory check that is `not-run` for any reason other + than a recorded deferral or needing a human. A unit that closes with deferred or + human-pending checks is `delivered-with-deferred` and the record lists them. +- **Selection by change**: a check with `when_changed` runs only when a changed path matches; + otherwise it is `skipped (not affected by this change)`. A check without it always runs. + `--all` runs everything. The reason is recorded, which is the justification [5.4] asks for. +- **Reuse**: a check whose inputs (the tree restricted to its `when_changed`, or the whole + tree) are identical to those of its last pass is `skipped (reused: passed at