diff --git a/CHANGELOG.md b/CHANGELOG.md index 758dd64..66fbf07 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,8 @@ All notable changes to this project are recorded here. The format follows - Telemetry with a class on every value, the eight-dimension scorecard, and `sisi status` as the one report (recent units, then trends by project, risk profile, model and policy version). - Scratch pruning of old session state, on a counter at session start. +- `sisi workers note` and `sisi workers only`; `sisi learn --withdraw`; failure evidence stored + with failed checks; `sisi help` grouped by reader with full text under `sisi help COMMAND`. - The end-of-turn gate is rebuilt on risk profiles (docs/records.md, "The end-of-turn gate"): it enforces exactly the `requirements` row of `canon/risk.json` for the profile (a contract, checks with `covers`, invariants, a requirement list, a risk note, an `approach`, independent evidence), @@ -51,6 +53,9 @@ All notable changes to this project are recorded here. The format follows ### Changed - The package version is read from the VERSION file, the one source of truth. +- A contract must declare `risk.profile`; a mandatory check that is not-applicable and has + never passed counts as never run; a pause also ends when `sisi verify` runs; `sisi status` + shows the last five units; `sisi update` on an installed copy runs the migration step. - The README is rewritten and shortened; contributions are judged against SPEC.md by requirement id. diff --git a/README.md b/README.md index c851840..1158d73 100644 --- a/README.md +++ b/README.md @@ -86,7 +86,7 @@ to report a problem privately. ## Where to read more - [SPEC.md](SPEC.md) — the standard sisi is built and judged against. -- [docs/target.md](docs/target.md) — how sisi meets that standard. +- [docs/design.md](docs/design.md) — how sisi meets that standard. - `sisi help` — every command, with no per-command reference kept in this file. - [docs/README.md](docs/README.md) — the index of the remaining documentation. - [CONTRIBUTING.md](CONTRIBUTING.md) — how to run the tests and send a change. diff --git a/SECURITY.md b/SECURITY.md index 776a69b..f630332 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -65,3 +65,13 @@ delivery for good. Please report security problems privately, using a private security advisory on the GitHub repository (github.com/swaits/sisi, "Security" tab, "Report a vulnerability"). Do not open a public issue for something that could be exploited. Include the version (`sisi --version`), what you did, and what happened. + +## What these mechanisms do and do not guarantee + +The trust list guarantees only that an untrusted project's contract does not run; it does not +make a trusted contract safe. Protected rules guarantee that a cycle or overlay cannot change +them; they do not stop someone who can write the product folder. Owner approval guarantees +that a consequential change waits and that a decision without a terminal is refused unless +relayed approval is allowed in config; it does not prove who was at the terminal. The +delivery ledger guarantees that only rows sisi's own commands wrote, as written, are +delivered; it does not prove the content of a row is true. diff --git a/docs/README.md b/docs/README.md index 656ad88..273162b 100644 --- a/docs/README.md +++ b/docs/README.md @@ -4,9 +4,9 @@ |---|---| | [../README.md](../README.md) | learn what sisi is, install it and try it | | [../SPEC.md](../SPEC.md) | read the standard sisi is built and judged against | -| [target.md](target.md) | see how sisi meets that standard | -| [design.md](design.md) | understand why sisi works the way it does, and what is built versus only designed | +| [design.md](design.md) | see how sisi meets that standard, and why it works the way it does | | [records.md](records.md) | know what a closed work unit records, the five verification statuses, telemetry classes and `sisi status` | +| [evaluation.md](evaluation.md) | see how policy versions are compared by replaying past work | | [learning.md](learning.md) | how a recorded lesson takes effect, is measured, strengthened, consolidated or withdrawn | | [workers.md](workers.md) | how the agent tools and models on the machine are found, chosen between by measured results, and run | | [personal-data.md](personal-data.md) | know where sisi keeps what it learns, how the overlay works, and what an update touches | diff --git a/docs/design.md b/docs/design.md index 030b7f8..38990f2 100644 --- a/docs/design.md +++ b/docs/design.md @@ -1,409 +1,350 @@ -# sisi: design +# How sisi meets SPEC.md -Status: this document describes the design of sisi and marks what is built and what is not. The section -"What is built" lists both. Where the text below says "sisi does" something that the list marks as not built, -read it as the intended design. +This document describes sisi as it is built. Section numbers in brackets are sections of +`SPEC.md`, which is the standard. Where this document and the specification disagree, the +specification wins. For the dated record of how the rebuild was decided, see +`docs/reconciliation/`. -## Intent +**sisi** is still improving: this design describes the current system, and the learning loop +in section 8 is how it changes. -AI coding tools execute well and understand poorly. An agent does not know what success means, so it guesses, -and sometimes it damages work that was already good. Nobody can list every such failure in advance, so the -system has to find them itself. +## 1. What sisi is -The end state: a person states a product and gets a verified product. Five objectives, each with the number -that shows it: +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: -| Objective | Shown by | +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.jsonl`, `findings.jsonl`, `units.jsonl`, `delegations.jsonl`, `worker-notes.json`, the mechanisms promoted from learnings, worker facts | 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. A release is made from the running launcher's folder. | + +`sisi update` on an installed copy runs the migration step for the old store as part of the +update. The specification's "organization-wide" scope is the product. A user's learning reaches the +product only through `sisi promote` / `--export`, scrubbed. + +## 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`. The floor is a minimum, not a verdict: it was +measured against independent labels (`measured` in `canon/risk.json`) and agrees about five +times in six, which is why the declared profile sits above it. A learning of mechanism type `policy` may adjust the user's table. +A contract must declare `risk.profile`; it 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 and an `approach` | 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); an `approach` is the +contract's `approach` object with `chosen`, `why` and at least one alternative. Text such as `TODO`, +`n/a` or `none` fills no field. The table is held as data in `canon/risk.json` (`requirements`, with +machine keys beside the prose ones) and read by the gate. "Risk note" is +`risk.blast_radius` and `risk.rollback`. "Independent evidence" is an accepted review delegation +in the ledger for this project inside the unit's window with a check stronger than `none`, or a passing check +marked `"independent": true` that names who or what produced it in `"by"`. + +## 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. The pause also ends when the tree changes or `sisi verify` runs. 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 mandatory check that is `not-applicable` and + has never passed counts as never run. A unit that closes with deferred or human-pending + checks is `delivered-with-deferred` and the record lists them. Failed checks keep their + failure evidence with the result, so a later reader can see what failed without re-running. +- **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