The end-of-turn gate rebuilt on risk profiles; non-findings refused as retro findings
The gate enforces exactly what the profile requires, lists everything missing in one message, closes a green unit when a finding is recorded, lets a paused unit stop silently, never blocks a subagent, records a release as unverified, and says at commit time when the checks have not passed on the tree. Size thresholds and the floors file are gone. 'It went well' and similar are refused as findings. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
commit
216f39e8f7
31 files changed
+2383
-1807
No files matched your search
+2
-1
@@ -6,9 +6,10 @@ __pycache__/
|
||||
.mypy_cache/
|
||||
.ruff_cache/
|
||||
|
||||
# sisi run-time state in a project: only the contract is tracked
|
||||
# sisi run-time state in a project: only the contract and the project's risk table are tracked
|
||||
.sisi/*
|
||||
!.sisi/contract.json
|
||||
!.sisi/risk.json
|
||||
|
||||
# scratch for delegated work
|
||||
.agent-work/
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"patterns": [
|
||||
{"glob": ["sisi/hookio.py", "sisi/tick.py", "sisi/prompt.py", "sisi/watch.py", "sisi/gate.py",
|
||||
"sisi/attribution.py", "sisi/questions.py", "sisi/assure.py", "bin/sisi"],
|
||||
"profile": "critical", "reason": "sisi's hooks and the end-of-turn gate: they run inside every session and decide when an agent may stop"},
|
||||
{"glob": ["sisi/wiring.py", "sisi/lifecycle.py", "sisi/adapters.py"],
|
||||
"profile": "critical", "reason": "sisi's installer, wiring and tool adapters: they edit other tools' configuration"},
|
||||
{"glob": ["sisi/hookjson.py"],
|
||||
"profile": "critical", "reason": "sisi's JSON editor: it rewrites other tools' settings files in place"},
|
||||
{"glob": ["sisi/release.py"],
|
||||
"profile": "critical", "reason": "sisi's release code: it publishes what users install"},
|
||||
{"glob": ["canon/core.md", "canon/risk.json", "sisi/risk.py", "sisi/rulecmd.py", "sisi/overlay.py"],
|
||||
"profile": "integration", "reason": "sisi's rulebook and risk table: every session and every gate decision reads them"}
|
||||
]
|
||||
}
|
||||
@@ -17,9 +17,25 @@ 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.
|
||||
- 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),
|
||||
in one send-back that lists everything missing; a retro is asked only when the checks are green and
|
||||
a unit is open, and a recorded retro closes the unit. A contract may declare a profile below its
|
||||
floor only with `risk.why`; `sisi status` shows such a unit as lowered and lists open and paused
|
||||
units with their age. `independent` checks name who or what produced them (`by`). A unit the gate
|
||||
released after its send-backs is `unverified` and says why. The gate notes, once, when a
|
||||
logic-or-higher change has no check stronger than example tests. A commit or merge with no passing
|
||||
`sisi verify` result for the tree prints a one-line notice. This repository's own `.sisi/risk.json`
|
||||
is tracked.
|
||||
|
||||
### Removed
|
||||
|
||||
- The gate's line-count thresholds (`gate.growth_lines`, `gate.growth_files`) and
|
||||
`canon/floors.json` (minimum rungs by self-declared check kind); `C.floors()` and
|
||||
`C.floor_failures()`; the `[floor ok]` marks of `sisi verifiers for --kind`; the gate's retro demand
|
||||
on every stop that edited anything and on subagents; its "someone else broke it" notice (a session
|
||||
is no longer sent back for another session's edits, so there is nothing to explain).
|
||||
- `sisi note` and `sisi propose`: use `sisi retro` or `sisi learn`. Existing notes and proposal
|
||||
files in a personal store are no longer read.
|
||||
- `sisi audit` and the audit module.
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
{
|
||||
"concurrency": 2,
|
||||
"parsing": 2,
|
||||
"money": 2,
|
||||
"state-machine": 2,
|
||||
"migration": 2
|
||||
}
|
||||
+7
-7
@@ -1,13 +1,13 @@
|
||||
{
|
||||
"profiles": ["trivial", "isolated", "logic", "integration", "data", "critical", "release"],
|
||||
"requirements": {
|
||||
"trivial": {"contract": false, "checks": "the diff; a targeted check when one exists", "requirement_model": false, "risk_note": false, "independent_evidence": false, "retro": "only on an anomaly (two send-backs, or a human correction)"},
|
||||
"isolated": {"contract": true, "checks": "at least one that is not vacuous", "requirement_model": false, "risk_note": false, "independent_evidence": false, "retro": "yes"},
|
||||
"logic": {"contract": true, "checks": "as isolated, each with covers", "requirement_model": false, "risk_note": false, "independent_evidence": false, "retro": "yes"},
|
||||
"integration": {"contract": true, "checks": "as logic, plus invariants", "requirement_model": true, "risk_note": true, "independent_evidence": false, "retro": "yes"},
|
||||
"data": {"contract": true, "checks": "as integration", "requirement_model": true, "risk_note": true, "independent_evidence": true, "retro": "yes"},
|
||||
"critical": {"contract": true, "checks": "as integration", "requirement_model": true, "risk_note": true, "independent_evidence": true, "retro": "yes"},
|
||||
"release": {"contract": true, "checks": "every check (--all)", "requirement_model": true, "risk_note": true, "independent_evidence": true, "retro": "yes"}
|
||||
"trivial": {"contract": false, "checks": "the diff; a targeted check when one exists", "requirement_model": false, "risk_note": false, "independent_evidence": false, "retro": "only on an anomaly (two send-backs, or a human correction)", "min_checks": 0, "covers": false, "invariants": false, "approach": false, "all_checks": false, "retro_when": "anomaly"},
|
||||
"isolated": {"contract": true, "checks": "at least one that is not vacuous", "requirement_model": false, "risk_note": false, "independent_evidence": false, "retro": "yes", "min_checks": 1, "covers": false, "invariants": false, "approach": false, "all_checks": false, "retro_when": "close"},
|
||||
"logic": {"contract": true, "checks": "as isolated, each with covers", "requirement_model": false, "risk_note": false, "independent_evidence": false, "retro": "yes", "min_checks": 1, "covers": true, "invariants": false, "approach": false, "all_checks": false, "retro_when": "close"},
|
||||
"integration": {"contract": true, "checks": "as logic, plus invariants", "requirement_model": true, "risk_note": true, "independent_evidence": false, "retro": "yes", "min_checks": 1, "covers": true, "invariants": true, "approach": true, "all_checks": false, "retro_when": "close"},
|
||||
"data": {"contract": true, "checks": "as integration", "requirement_model": true, "risk_note": true, "independent_evidence": true, "retro": "yes", "min_checks": 1, "covers": true, "invariants": true, "approach": true, "all_checks": false, "retro_when": "close"},
|
||||
"critical": {"contract": true, "checks": "as integration", "requirement_model": true, "risk_note": true, "independent_evidence": true, "retro": "yes", "min_checks": 1, "covers": true, "invariants": true, "approach": true, "all_checks": false, "retro_when": "close"},
|
||||
"release": {"contract": true, "checks": "every check (--all)", "requirement_model": true, "risk_note": true, "independent_evidence": true, "retro": "yes", "min_checks": 1, "covers": true, "invariants": true, "approach": true, "all_checks": true, "retro_when": "close"}
|
||||
},
|
||||
"patterns": [
|
||||
{"stage": "code", "glob": "**/*.{py,pyi,pyw,js,mjs,cjs,jsx,ts,tsx,mts,cts,vue,svelte,astro,java,kt,kts,scala,groovy,clj,cljs,go,rs,c,h,cc,cpp,cxx,hpp,hh,hxx,m,mm,cs,fs,vb,swift,dart,rb,php,pl,pm,lua,r,jl,ex,exs,erl,hs,ml,mli,nim,zig,sh,bash,zsh,fish,ps1,bat,cmd,sol,sv,vhd,tcl,awk,asm,sql}", "profile": "isolated", "reason": "source code: never trivial, whatever its name or directory"},
|
||||
|
||||
+1
-3
@@ -2,9 +2,7 @@
|
||||
"gate": {
|
||||
"enabled": true,
|
||||
"budget_s": 120,
|
||||
"max_blocks": 3,
|
||||
"growth_lines": 40,
|
||||
"growth_files": 3
|
||||
"max_blocks": 3
|
||||
},
|
||||
"verify": {
|
||||
"default_timeout_s": 60,
|
||||
|
||||
+5
-3
@@ -136,8 +136,10 @@ Claude Code supports a blocking stop hook. The equivalent in OpenCode, Codex and
|
||||
does not exist, verification is meant to run at the next session start and failures to be reported then (that
|
||||
fallback is a design intention, not built).
|
||||
|
||||
**Floors.** Some kinds of claim have a minimum rung. Concurrency, parsing, money, state machines and data
|
||||
migration may not rest on example tests alone. The floors are in `canon/floors.json`.
|
||||
**What a risk profile requires.** The strength of the evidence follows the risk of the change, not the kind a
|
||||
check declares for itself: logic and above need every check to say what it covers, integration and above need
|
||||
invariants, a requirement list, a risk note and an approach, and data, critical and release need independent
|
||||
evidence. The table is `requirements` in `canon/risk.json`; the gate enforces it and nothing else.
|
||||
|
||||
**Formal tooling is provisioned.** sisi keeps a verifier library: for each language and kind of claim, the
|
||||
tool, a working template and a worked example (Kani and Verus for Rust, TLA+ or Quint and Alloy for designs,
|
||||
@@ -311,7 +313,7 @@ Built and covered by tests:
|
||||
- The end-of-turn gate (`sisi gate`) and session-start hook (`sisi tick`), wired into Claude Code with a
|
||||
blocking hook; wiring (`sisi install`, `uninstall`, `doctor`) also points Codex and OpenCode at the rulebook,
|
||||
where nothing blocks.
|
||||
- The rulebook (`canon/core.md`), the minimum-rung floors, the verifier library and the recipes.
|
||||
- The rulebook (`canon/core.md`), the risk table, the verifier library and the recipes.
|
||||
- Retrospectives and lessons (`sisi retro`, `sisi lessons`), `sisi learn` live at once, time to delivery
|
||||
(`sisi time`).
|
||||
- Choosing the approach as a checked step: the contract design section, `sisi design`, the gate's
|
||||
|
||||
@@ -31,6 +31,46 @@ plainly `delivered`. `sisi contract waive` records a deviation; it turns nothing
|
||||
A pause records what the unit waits for. While nothing in the tree changes the gate asks
|
||||
nothing; a change ends the wait. Waiting time is telemetry.
|
||||
|
||||
## The end-of-turn gate
|
||||
|
||||
At each stop the gate asks, in order: did **this session** change anything since its last settled
|
||||
stop (its own edits only, read from its transcript and the before/after shell measurement, never another
|
||||
session's work in the same tree)? If not, the turn ends silently, as it does for a paused unit with no
|
||||
new change and for a closed unit. Otherwise it works out the profile and enforces what that profile's
|
||||
row of `canon/risk.json` requires, and nothing else:
|
||||
|
||||
| Profile | Required |
|
||||
|---|---|
|
||||
| trivial | nothing (the retro is asked once only if the unit shows two send-backs or a human correction) |
|
||||
| isolated | a contract with at least one check that can fail |
|
||||
| logic | as isolated; every check has `covers` |
|
||||
| integration | as logic; `invariants`, a `requirements` list (kind, text, decision), `risk.blast_radius` and `risk.rollback`, and an `approach` (chosen, why, an alternative) |
|
||||
| data, critical | as integration, plus independent evidence |
|
||||
| release | as data, plus every deep check passing on the tree |
|
||||
|
||||
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 with `"independent": true` and a `"by"`
|
||||
naming who or what produced it. Text such as `TODO`, `n/a` or `none` fills no field.
|
||||
|
||||
The profile is the floor (from the paths changed, see `sisi risk`) unless the contract declares a higher
|
||||
one. A contract may declare a lower one only with `risk.why`; the unit then runs at the declared profile and
|
||||
the record keeps floor, declared profile and reason, and `sisi status` shows it as lowered. Without a
|
||||
reason the floor applies. With no unit open the floor covers the paths this session changed since its last
|
||||
settled stop.
|
||||
|
||||
One send-back lists everything missing, each with the command or field that supplies it, within 25 lines.
|
||||
When the checks pass and everything required is present, a unit with recorded retro findings is closed and
|
||||
the turn ends; otherwise the gate says once, for that state of the tree, the two ways on: `sisi retro`
|
||||
(which records the findings and so closes the unit) or `sisi unit pause "<what it waits for>"`. A pause
|
||||
ends when the tree changes; `sisi contract init` refuses while a unit is open or paused; `sisi status`
|
||||
lists open and paused units with their age. Send-backs are bounded (`gate.max_blocks`); when they run out
|
||||
the gate lets the turn end, the unit's delivery status is `unverified`, the record says why, and the
|
||||
agent is told to say so in its report. A subagent's stop never blocks and never asks for a retro; what it
|
||||
observed (that it edited, and which files) is recorded for its parent's gate. When a logic-or-higher unit
|
||||
has no check stronger than examples (rung 2 or better) the gate says so once, without blocking, and the
|
||||
record stores whether the unit had one. A `git commit` or `git merge` whose unit has no passing result for the
|
||||
current tree prints a one-line notice (`sisi verify`) and is never blocked.
|
||||
|
||||
## Verification
|
||||
|
||||
Five statuses: `passed`, `failed`, `skipped`, `not-applicable`, `not-run`; the last three always
|
||||
|
||||
+28
-28
@@ -506,15 +506,15 @@
|
||||
{
|
||||
"id": "R-5.1-1",
|
||||
"status": "partial",
|
||||
"how": "The rung ladder, canon/floors.json and contract invariants ask for stronger evidence than a passing test",
|
||||
"evidence": "canon/floors.json",
|
||||
"how": "The rung ladder, the risk table's requirements (canon/risk.json: covers, invariants, independent evidence) and contract invariants ask for stronger evidence than a passing test",
|
||||
"evidence": "canon/risk.json",
|
||||
"gap": "A check still proves only that a command exited as expected; rung is agent-asserted and correctness kinds are not distinguished in any record."
|
||||
},
|
||||
{
|
||||
"id": "R-5.1-2",
|
||||
"status": "partial",
|
||||
"how": "The rung ladder, canon/floors.json and contract invariants ask for stronger evidence than a passing test",
|
||||
"evidence": "canon/floors.json",
|
||||
"how": "The rung ladder, the risk table's requirements (canon/risk.json: covers, invariants, independent evidence) and contract invariants ask for stronger evidence than a passing test",
|
||||
"evidence": "canon/risk.json",
|
||||
"gap": "A check still proves only that a command exited as expected; rung is agent-asserted and correctness kinds are not distinguished in any record."
|
||||
},
|
||||
{
|
||||
@@ -527,15 +527,15 @@
|
||||
{
|
||||
"id": "R-5.1-4",
|
||||
"status": "partial",
|
||||
"how": "The rung ladder, canon/floors.json and contract invariants ask for stronger evidence than a passing test",
|
||||
"evidence": "canon/floors.json",
|
||||
"how": "The rung ladder, the risk table's requirements (canon/risk.json: covers, invariants, independent evidence) and contract invariants ask for stronger evidence than a passing test",
|
||||
"evidence": "canon/risk.json",
|
||||
"gap": "A check still proves only that a command exited as expected; rung is agent-asserted and correctness kinds are not distinguished in any record."
|
||||
},
|
||||
{
|
||||
"id": "R-5.1-5",
|
||||
"status": "partial",
|
||||
"how": "The rung ladder, canon/floors.json and contract invariants ask for stronger evidence than a passing test",
|
||||
"evidence": "canon/floors.json",
|
||||
"how": "The rung ladder, the risk table's requirements (canon/risk.json: covers, invariants, independent evidence) and contract invariants ask for stronger evidence than a passing test",
|
||||
"evidence": "canon/risk.json",
|
||||
"gap": "A check still proves only that a command exited as expected; rung is agent-asserted and correctness kinds are not distinguished in any record."
|
||||
},
|
||||
{
|
||||
@@ -548,8 +548,8 @@
|
||||
{
|
||||
"id": "R-5.1-7",
|
||||
"status": "partial",
|
||||
"how": "The rung ladder, canon/floors.json and contract invariants ask for stronger evidence than a passing test",
|
||||
"evidence": "canon/floors.json",
|
||||
"how": "The rung ladder, the risk table's requirements (canon/risk.json: covers, invariants, independent evidence) and contract invariants ask for stronger evidence than a passing test",
|
||||
"evidence": "canon/risk.json",
|
||||
"gap": "A check still proves only that a command exited as expected; rung is agent-asserted and correctness kinds are not distinguished in any record."
|
||||
},
|
||||
{
|
||||
@@ -597,8 +597,8 @@
|
||||
{
|
||||
"id": "R-5.3-1",
|
||||
"status": "partial",
|
||||
"how": "canon/floors.json sets a minimum rung by self-declared check kind and the contract splits fast and deep tiers",
|
||||
"evidence": "canon/floors.json",
|
||||
"how": "canon/risk.json sets what each risk profile requires of a contract (checks with covers, invariants, an approach, independent evidence) and the contract splits fast and deep tiers",
|
||||
"evidence": "canon/risk.json",
|
||||
"gap": "Floors compare the rung label only, so cmd true at rung 1 satisfies a floor, and no impact, likelihood, blast-radius or reversibility assessment selects the depth."
|
||||
},
|
||||
{
|
||||
@@ -611,57 +611,57 @@
|
||||
{
|
||||
"id": "R-5.3-3",
|
||||
"status": "partial",
|
||||
"how": "canon/floors.json sets a minimum rung by self-declared check kind and the contract splits fast and deep tiers",
|
||||
"evidence": "canon/floors.json",
|
||||
"how": "canon/risk.json sets what each risk profile requires of a contract (checks with covers, invariants, an approach, independent evidence) and the contract splits fast and deep tiers",
|
||||
"evidence": "canon/risk.json",
|
||||
"gap": "Floors compare the rung label only, so cmd true at rung 1 satisfies a floor, and no impact, likelihood, blast-radius or reversibility assessment selects the depth."
|
||||
},
|
||||
{
|
||||
"id": "R-5.3-4",
|
||||
"status": "partial",
|
||||
"how": "canon/floors.json sets a minimum rung by self-declared check kind and the contract splits fast and deep tiers",
|
||||
"evidence": "canon/floors.json",
|
||||
"how": "canon/risk.json sets what each risk profile requires of a contract (checks with covers, invariants, an approach, independent evidence) and the contract splits fast and deep tiers",
|
||||
"evidence": "canon/risk.json",
|
||||
"gap": "Floors compare the rung label only, so cmd true at rung 1 satisfies a floor, and no impact, likelihood, blast-radius or reversibility assessment selects the depth."
|
||||
},
|
||||
{
|
||||
"id": "R-5.3-5",
|
||||
"status": "partial",
|
||||
"how": "canon/floors.json sets a minimum rung by self-declared check kind and the contract splits fast and deep tiers",
|
||||
"evidence": "canon/floors.json",
|
||||
"how": "canon/risk.json sets what each risk profile requires of a contract (checks with covers, invariants, an approach, independent evidence) and the contract splits fast and deep tiers",
|
||||
"evidence": "canon/risk.json",
|
||||
"gap": "Floors compare the rung label only, so cmd true at rung 1 satisfies a floor, and no impact, likelihood, blast-radius or reversibility assessment selects the depth."
|
||||
},
|
||||
{
|
||||
"id": "R-5.3-6",
|
||||
"status": "partial",
|
||||
"how": "canon/floors.json sets a minimum rung by self-declared check kind and the contract splits fast and deep tiers",
|
||||
"evidence": "canon/floors.json",
|
||||
"how": "canon/risk.json sets what each risk profile requires of a contract (checks with covers, invariants, an approach, independent evidence) and the contract splits fast and deep tiers",
|
||||
"evidence": "canon/risk.json",
|
||||
"gap": "Floors compare the rung label only, so cmd true at rung 1 satisfies a floor, and no impact, likelihood, blast-radius or reversibility assessment selects the depth."
|
||||
},
|
||||
{
|
||||
"id": "R-5.3-7",
|
||||
"status": "partial",
|
||||
"how": "canon/floors.json sets a minimum rung by self-declared check kind and the contract splits fast and deep tiers",
|
||||
"evidence": "canon/floors.json",
|
||||
"how": "canon/risk.json sets what each risk profile requires of a contract (checks with covers, invariants, an approach, independent evidence) and the contract splits fast and deep tiers",
|
||||
"evidence": "canon/risk.json",
|
||||
"gap": "Floors compare the rung label only, so cmd true at rung 1 satisfies a floor, and no impact, likelihood, blast-radius or reversibility assessment selects the depth."
|
||||
},
|
||||
{
|
||||
"id": "R-5.3-8",
|
||||
"status": "partial",
|
||||
"how": "canon/floors.json sets a minimum rung by self-declared check kind and the contract splits fast and deep tiers",
|
||||
"evidence": "canon/floors.json",
|
||||
"how": "canon/risk.json sets what each risk profile requires of a contract (checks with covers, invariants, an approach, independent evidence) and the contract splits fast and deep tiers",
|
||||
"evidence": "canon/risk.json",
|
||||
"gap": "Floors compare the rung label only, so cmd true at rung 1 satisfies a floor, and no impact, likelihood, blast-radius or reversibility assessment selects the depth."
|
||||
},
|
||||
{
|
||||
"id": "R-5.3-9",
|
||||
"status": "partial",
|
||||
"how": "canon/floors.json sets a minimum rung by self-declared check kind and the contract splits fast and deep tiers",
|
||||
"evidence": "canon/floors.json",
|
||||
"how": "canon/risk.json sets what each risk profile requires of a contract (checks with covers, invariants, an approach, independent evidence) and the contract splits fast and deep tiers",
|
||||
"evidence": "canon/risk.json",
|
||||
"gap": "Floors compare the rung label only, so cmd true at rung 1 satisfies a floor, and no impact, likelihood, blast-radius or reversibility assessment selects the depth."
|
||||
},
|
||||
{
|
||||
"id": "R-5.3-10",
|
||||
"status": "partial",
|
||||
"how": "canon/floors.json sets a minimum rung by self-declared check kind and the contract splits fast and deep tiers",
|
||||
"evidence": "canon/floors.json",
|
||||
"how": "canon/risk.json sets what each risk profile requires of a contract (checks with covers, invariants, an approach, independent evidence) and the contract splits fast and deep tiers",
|
||||
"evidence": "canon/risk.json",
|
||||
"gap": "Floors compare the rung label only, so cmd true at rung 1 satisfies a floor, and no impact, likelihood, blast-radius or reversibility assessment selects the depth."
|
||||
},
|
||||
{
|
||||
|
||||
+13
-4
@@ -64,13 +64,17 @@ What a profile requires. The gate enforces exactly this table and nothing else:
|
||||
| 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 |
|
||||
| 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). "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`.
|
||||
"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]
|
||||
|
||||
@@ -175,6 +179,11 @@ At the end of a turn in which the session changed something:
|
||||
(`sisi retro`), which closes the unit; or `sisi unit pause "<what it waits for>"`.
|
||||
5. A paused or closed unit with no new change passes silently.
|
||||
|
||||
In this build the retro is offered once for each state of the tree and a trivial change is asked
|
||||
nothing (unless the unit shows an anomaly); a recorded retro closes the unit. A session is judged only on
|
||||
its own edits, so another session's work in the same tree never sends it back. The detail is in
|
||||
docs/records.md, "The end-of-turn gate".
|
||||
|
||||
Send-backs stay bounded; when they run out the unit is released as `unverified` and recorded
|
||||
as such. Subagents are never sent back for a retro: a subagent's last message is its report to
|
||||
its parent and must stay that. The question-dialog gate stays as it is.
|
||||
|
||||
+175
@@ -0,0 +1,175 @@
|
||||
"""What a risk profile requires, and what is missing from a unit (target section 3).
|
||||
|
||||
The gate enforces the `requirements` table in canon/risk.json and nothing else. This module reads
|
||||
that table, looks at the contract and the evidence, and returns the missing items in plain words,
|
||||
each with the command or field that supplies it. It never decides anything about the tree itself.
|
||||
|
||||
The profile that applies is the floor (what the changed paths say, by sisi/risk.py) unless the
|
||||
contract declares a higher one. A contract may declare a lower one only by giving `risk.why`: the
|
||||
unit then runs at the declared profile and is recorded as lowered, with floor, declared profile and
|
||||
reason kept side by side (`sisi status` shows it).
|
||||
"""
|
||||
import os, time
|
||||
|
||||
from . import contract as C, harvest, risk, store
|
||||
|
||||
ORDER = {name: i for i, name in enumerate(risk.PROFILES)}
|
||||
|
||||
|
||||
def effective_profile(floor, c):
|
||||
"""(profile, info). `info` = {floor, declared, lowered, why, refused}: `refused` is set when a
|
||||
contract declared a lower profile without a reason, so the floor was kept."""
|
||||
rk = (c.get("risk") if isinstance(c, dict) else None) or {}
|
||||
declared = rk.get("profile") if rk.get("profile") in ORDER else None
|
||||
info = {"floor": floor, "declared": declared, "lowered": False, "why": rk.get("why"), "refused": False}
|
||||
if declared is None or ORDER[declared] >= ORDER[floor]:
|
||||
return (declared if declared and ORDER[declared] > ORDER[floor] else floor), info
|
||||
if C.is_placeholder(rk.get("why")):
|
||||
info["refused"] = True
|
||||
return floor, info
|
||||
info["lowered"] = True
|
||||
return declared, info
|
||||
|
||||
|
||||
def is_lowered(floor, declared, why):
|
||||
"""True when a unit declared a profile below its floor and gave a reason (what `sisi status` flags)."""
|
||||
return bool(floor in ORDER and declared in ORDER and ORDER[declared] < ORDER[floor]
|
||||
and not C.is_placeholder(why))
|
||||
|
||||
|
||||
def requirements(profile):
|
||||
return risk.requirements_for(profile)
|
||||
|
||||
|
||||
def stronger_technique(c):
|
||||
"""True when some check or invariant uses a technique stronger than example tests: a proof or
|
||||
model check (rung 1), or properties, fuzzing or a reference comparison (rung 2)."""
|
||||
items = list((c or {}).get("checks") or []) + list((c or {}).get("invariants") or [])
|
||||
return any(isinstance(x, dict) and x.get("rung") in (1, 2) for x in items)
|
||||
|
||||
|
||||
def _real(items, key):
|
||||
"""Entries of a list whose `key` says something (not empty, not a placeholder)."""
|
||||
return [x for x in items or [] if isinstance(x, dict) and not C.is_placeholder(x.get(key))]
|
||||
|
||||
|
||||
def _passing(r):
|
||||
return r.get("status") == "passed" or (r.get("status") == "skipped"
|
||||
and str(r.get("reason") or "").startswith("reused: passed"))
|
||||
|
||||
|
||||
def review_evidence(project, c, now=None):
|
||||
"""The accepted review delegations of this project inside the unit's window whose result was
|
||||
checked by something stronger than `none`. The ledger names a project by its folder name."""
|
||||
t0 = harvest.epoch(c["started"]) if isinstance(c.get("started"), str) else None
|
||||
if t0 is None:
|
||||
return []
|
||||
try:
|
||||
from . import workers
|
||||
dg = workers.delegations_for_project(os.path.basename(project.rstrip(os.sep)), t0,
|
||||
(time.time() if now is None else now) + 1) # a judgement rounds its time
|
||||
except Exception as e:
|
||||
store.log_error("assure-delegations", e)
|
||||
return []
|
||||
return [r for r in dg["delegations"] if r.get("type") == "review" and r.get("outcome") == "accepted"
|
||||
and r.get("check") not in (None, "", "none")]
|
||||
|
||||
|
||||
def independent_evidence(project, c, results, now=None):
|
||||
"""What stands behind a unit as independent evidence: a judged review in the ledger, or a
|
||||
passing check that is marked independent AND says by whom or what it was produced."""
|
||||
out = []
|
||||
for r in review_evidence(project, c, now):
|
||||
out.append("review by %s" % (r.get("worker") or "a reviewer"))
|
||||
named = {x.get("id"): x for x in list(c.get("checks") or []) + list(c.get("invariants") or [])
|
||||
if isinstance(x, dict) and x.get("independent") is True and not C.is_placeholder(x.get("by"))}
|
||||
for r in results or []:
|
||||
if r.get("id") in named and _passing(r):
|
||||
out.append("check %s by %s" % (r["id"], named[r["id"]]["by"]))
|
||||
return out
|
||||
|
||||
|
||||
def missing(profile, c, project, results=None, errors=None, deep_state=None, now=None):
|
||||
"""[(what is missing, how to supply it)] for this profile. `c` is None when no contract is open.
|
||||
`errors` are the contract's validation errors. Nothing is asked that the table does not require."""
|
||||
req = requirements(profile)
|
||||
out = []
|
||||
if not req.get("contract"):
|
||||
return out
|
||||
if c is None:
|
||||
out.append(("a contract for this %s change" % profile,
|
||||
"`sisi contract init`, then write at least one check that can fail"))
|
||||
c = {}
|
||||
absent = True
|
||||
else:
|
||||
absent = False
|
||||
if errors:
|
||||
shown = "; ".join(errors[:3]) + ("; and %d more" % (len(errors) - 3) if len(errors) > 3 else "")
|
||||
out.append(("a valid contract: %s" % shown, "fix it, then `sisi contract check`"))
|
||||
checks = [x for x in c.get("checks") or [] if isinstance(x, dict)]
|
||||
if not absent and not errors and int(req.get("min_checks", 0)) > len(checks):
|
||||
out.append(("at least one check that can fail", 'add it under "checks"'))
|
||||
if req.get("covers"):
|
||||
bare = [x.get("id") or "?" for x in checks if C.is_placeholder(x.get("covers"))]
|
||||
if bare or absent:
|
||||
out.append(("every check says what it covers" + (" (missing on %s)" % ", ".join(bare) if bare else ""),
|
||||
'"covers": the failure that check would catch'))
|
||||
if req.get("invariants") and not _real(c.get("invariants"), "claim"):
|
||||
out.append(("invariants: what must not get worse",
|
||||
'"invariants": a command that can fail, e.g. the existing tests'))
|
||||
if req.get("requirement_model") and not _real(c.get("requirements"), "text"):
|
||||
out.append(("a requirement list",
|
||||
'"requirements": entries with "kind", "text" and "decision" (now, architect, defer, ignore)'))
|
||||
if req.get("risk_note"):
|
||||
rk = c.get("risk") if isinstance(c.get("risk"), dict) else {}
|
||||
lacking = [k for k in ("blast_radius", "rollback") if C.is_placeholder(rk.get(k))]
|
||||
if lacking:
|
||||
out.append(("a risk note: %s" % " and ".join(lacking),
|
||||
'"risk": {"blast_radius": what this can break, "rollback": how to undo it}'))
|
||||
if req.get("approach"):
|
||||
ap = c.get("approach") if isinstance(c.get("approach"), dict) else {}
|
||||
if C.is_placeholder(ap.get("chosen")) or C.is_placeholder(ap.get("why")) \
|
||||
or not [a for a in ap.get("alternatives") or [] if not C.is_placeholder(a)]:
|
||||
out.append(("the approach: what you chose, why, and an alternative you rejected",
|
||||
'"approach": {"chosen", "why", "alternatives": [...]}'))
|
||||
if req.get("independent_evidence") and not independent_evidence(project, c, results, now):
|
||||
out.append(("independent evidence that someone or something else checked this",
|
||||
"a reviewer's judged result (`sisi delegate judge --type review --outcome accepted "
|
||||
"--check review`), or a passing check with \"independent\": true and \"by\": \"<who or what>\""))
|
||||
if req.get("all_checks") and deep_state is not None and deep_state not in ("fresh-pass", "none"):
|
||||
out.append(("every check, deep ones included, passing on this tree (release)",
|
||||
"`sisi verify --deep --background`, then `sisi verify --state`"))
|
||||
return out
|
||||
|
||||
|
||||
# ---------------------------------------------------------------- messages
|
||||
|
||||
MAX_LINES = 25
|
||||
|
||||
|
||||
def fit(lines, limit=MAX_LINES):
|
||||
"""No message to the agent is longer than `limit` lines: over it, the tail is replaced by one line
|
||||
saying how many were cut. Every line is also kept short."""
|
||||
flat = []
|
||||
for ln in lines:
|
||||
for sub in str(ln).split("\n"):
|
||||
flat.append(sub if len(sub) <= 300 else sub[:297] + "...")
|
||||
if len(flat) <= limit:
|
||||
return "\n".join(flat)
|
||||
return "\n".join(flat[:limit - 1] + ["... (%d more lines; run `sisi verify` for the full output)"
|
||||
% (len(flat) - limit + 1)])
|
||||
|
||||
|
||||
def failure_lines(results, per_check=4, checks=4):
|
||||
"""A short report of the blocking results: id, status, and the last lines of what they printed."""
|
||||
from . import verify as V
|
||||
out = []
|
||||
bad = V.blocking(results)
|
||||
for r in bad[:checks]:
|
||||
head = "- %s [%s%s]" % (r["id"], r["status"], (": " + r["reason"]) if r.get("reason") else "")
|
||||
out.append(head)
|
||||
tail = [ln for ln in str(r.get("tail") or "").splitlines() if ln.strip()][-per_check:]
|
||||
out += [" " + ln[:200] for ln in tail]
|
||||
if len(bad) > checks:
|
||||
out.append("- and %d more failing" % (len(bad) - checks))
|
||||
return out
|
||||
@@ -0,0 +1,297 @@
|
||||
"""Which edits were this session's own. The gate reads this, never another session's work.
|
||||
|
||||
Attribution reads this session's own transcript (Claude-Code-shaped JSONL: assistant records whose
|
||||
message.content holds tool_use blocks). Only bytes after the per-session offset stored in the session
|
||||
record are read, so a long transcript costs only its new tail; subagent transcripts found under
|
||||
<transcript-without-.jsonl>/subagents/** are read the same way and count as this session's edits.
|
||||
Edit/Write/MultiEdit/NotebookEdit (and any tool whose name says it writes) count, with the file paths
|
||||
in their input. Shell commands are measured by the before/after hooks (sisi/watch.py) where those are
|
||||
installed; where they are not, a shell command counts when it plausibly writes: a redirect, tee/dd-of,
|
||||
an in-place editor, git apply/checkout/restore/reset/clean/mv/rm, patch, cp/mv/rm/touch/mkdir, or any
|
||||
program that is not on the provably read-only list (test runners and interpreters therefore count:
|
||||
they can write).
|
||||
Known blind spots: a read-only-looking command that writes through indirection sisi cannot see, a
|
||||
daemon, a tool whose transcript is not Claude-Code JSONL, and writes made between the last complete
|
||||
transcript line and a crash. A missing or unreadable transcript, a corrupt line, or a shell command
|
||||
that cannot be tokenised is treated as an edit by this session (fail strict, never fail open here);
|
||||
so is an unread tail over 64 MB, which is skipped rather than scanned inside the gate's time budget.
|
||||
"""
|
||||
import json, os, re, shlex
|
||||
|
||||
EDIT_TOOLS = {"Edit", "Write", "MultiEdit", "NotebookEdit"}
|
||||
_READONLY_CMDS = {"ls", "cat", "head", "tail", "grep", "egrep", "fgrep", "rg", "ag", "wc", "file",
|
||||
"stat", "du", "df", "which", "type", "pwd", "date", "env", "printenv", "sort",
|
||||
"uniq", "cut", "tr", "jq", "yq", "diff", "cmp", "md5sum", "sha1sum", "sha256sum",
|
||||
"basename", "dirname", "realpath", "readlink", "ps", "top", "free", "uname",
|
||||
"hostname", "id", "whoami", "less", "more", "man", "help", "history"}
|
||||
_READONLY_GIT = {"status", "diff", "log", "show", "rev-parse", "ls-files", "ls-tree", "describe",
|
||||
"blame", "grep", "cat-file", "branch", "tag", "remote", "config", "add", "commit"}
|
||||
_GH_READ = {("run", "list"), ("run", "view"), ("run", "watch"), ("pr", "list"), ("pr", "view"),
|
||||
("pr", "status"), ("pr", "diff"), ("pr", "checks"), ("issue", "list"), ("issue", "view"),
|
||||
("issue", "status"), ("repo", "view"), ("repo", "list"), ("release", "list"),
|
||||
("release", "view"), ("workflow", "list"), ("workflow", "view"), ("auth", "status")}
|
||||
_WRITE_WORDS = ("edit", "write", "create", "delete", "move", "rename", "patch", "apply", "insert")
|
||||
_SHELL_WRITE_RE = re.compile(
|
||||
r">>?[^=]|\btee\b|\bdd\b[^;&|]*\bof=|\bsed\b[^;&|]*\s-[a-z]*i|\bperl\b[^;&|]*\s-[a-z]*i"
|
||||
r"|\bawk\b[^;&|]*inplace|\bgit\s+(apply|checkout|restore|reset|clean|mv|rm)\b"
|
||||
r"|\bpatch\b|\b(cp|mv|rm|touch|mkdir|rmdir|install|ln)\b", re.I)
|
||||
|
||||
|
||||
def shell_may_write(command):
|
||||
"""True: plausibly writes files. False: provably read-only. None: cannot be tokenised."""
|
||||
if not isinstance(command, str) or not command.strip():
|
||||
return False
|
||||
if _SHELL_WRITE_RE.search(command):
|
||||
return True
|
||||
try:
|
||||
lex = shlex.shlex(command, posix=True, punctuation_chars=True)
|
||||
lex.whitespace_split = True
|
||||
tokens = list(lex)
|
||||
except ValueError:
|
||||
return None
|
||||
segments, cur = [], []
|
||||
for tok in tokens:
|
||||
if tok in (";", "&", "|", "&&", "||"):
|
||||
segments.append(cur)
|
||||
cur = []
|
||||
else:
|
||||
cur.append(tok)
|
||||
segments.append(cur)
|
||||
for seg in segments:
|
||||
i = 0
|
||||
while i < len(seg) and (re.match(r"^[A-Za-z_][A-Za-z0-9_]*=", seg[i]) or seg[i] in ("sudo", "command", "exec", "time", "nice")):
|
||||
i += 1
|
||||
if i >= len(seg):
|
||||
continue
|
||||
prog = os.path.basename(seg[i])
|
||||
rest = seg[i + 1:]
|
||||
if prog in ("cd", "export", "unset", "set", "alias", "umask", "wait", "jobs", "fg", "bg",
|
||||
"exit", "return", "break", "continue", "shift", "readonly", "local", "declare",
|
||||
"typeset", "echo", "printf", "true", "false", ":", "test", "[", "[[", "eval"):
|
||||
if prog == "eval":
|
||||
return True
|
||||
continue
|
||||
if prog == "find":
|
||||
if any(a in ("-delete", "-exec", "-execdir", "-ok", "-okdir", "-fls", "-fprint") for a in rest):
|
||||
return True
|
||||
continue
|
||||
if prog == "git":
|
||||
sub = next((a for a in rest if not a.startswith("-")), "")
|
||||
if sub == "stash": # only listing a stash leaves the tree alone; push/pop/apply change it
|
||||
tail = rest[rest.index(sub) + 1:]
|
||||
if not tail or tail[0] in ("list", "show"):
|
||||
continue
|
||||
return True
|
||||
if sub in _READONLY_GIT and not (sub == "config" and any(not a.startswith("-") for a in rest[rest.index(sub) + 1:])):
|
||||
continue # add/commit touch .git only, never a working-tree file
|
||||
return True
|
||||
if prog == "gh":
|
||||
pair = tuple(a for a in rest if not a.startswith("-"))[:2]
|
||||
if pair in _GH_READ:
|
||||
continue
|
||||
if pair and pair[0] == "api" and not any(a in ("-X", "--method", "-f", "-F", "--field", "--raw-field")
|
||||
or a.startswith(("-f", "-F")) for a in rest):
|
||||
continue
|
||||
return True
|
||||
if prog == "sisi":
|
||||
# sisi writes only personal data and state, never the project — except contract
|
||||
# init/waive/trust, which do record something about (or in) this project.
|
||||
if rest and rest[0] == "contract":
|
||||
if len(rest) > 1 and rest[1] in ("init", "waive", "trust", "untrust"):
|
||||
return True
|
||||
continue
|
||||
continue
|
||||
if prog in _READONLY_CMDS:
|
||||
if prog in ("sed", "awk", "jq", "yq") and any("inplace" in a or a.startswith("-i") for a in rest):
|
||||
return True
|
||||
continue
|
||||
return True # interpreters, build/test runners, scripts, anything unlisted: can write
|
||||
return False
|
||||
|
||||
|
||||
def _input_files(inp):
|
||||
out = []
|
||||
if isinstance(inp, dict):
|
||||
for k in ("file_path", "notebook_path", "path", "filename", "filePath"):
|
||||
if isinstance(inp.get(k), str) and inp[k]:
|
||||
out.append(inp[k])
|
||||
return out
|
||||
|
||||
|
||||
def parse_chunk(data, measured=False):
|
||||
"""Parse complete JSONL bytes. Returns (edits, files, writing, corrupt, consumed_bytes, shell_edits).
|
||||
In measured mode Bash calls are not guessed from their text at all: the before/after tree
|
||||
measurement (sisi/watch.py) has already attributed whatever they actually changed — except
|
||||
`sisi contract init/waive/trust`, which record project state outside the measured files."""
|
||||
if data.endswith(b"\n") or not data:
|
||||
consumed, body = len(data), data
|
||||
else:
|
||||
cut = data.rfind(b"\n")
|
||||
tail = data[cut + 1:]
|
||||
try:
|
||||
json.loads(tail.decode("utf-8", "replace"))
|
||||
consumed, body = len(data), data # a complete final line without its newline yet
|
||||
except ValueError:
|
||||
consumed, body = cut + 1, data[:cut + 1] # partial line: leave it for the next read
|
||||
edits, files, writing, corrupt, shell_edits = 0, [], False, 0, 0
|
||||
for raw in body.split(b"\n"):
|
||||
if not raw.strip():
|
||||
continue
|
||||
if len(raw) > 131072 and b"tool_use" not in raw and b"Bash" not in raw:
|
||||
continue # a huge tool-result line: no tool call hides in it worth parsing
|
||||
try:
|
||||
d = json.loads(raw.decode("utf-8", "replace"))
|
||||
except ValueError:
|
||||
corrupt += 1
|
||||
edits += 1 # an unreadable line may be the edit we cannot see: count it
|
||||
writing = True
|
||||
continue
|
||||
if not isinstance(d, dict):
|
||||
continue
|
||||
content = (d.get("message") or {}).get("content") if isinstance(d.get("message"), dict) else None
|
||||
for x in content if isinstance(content, list) else []:
|
||||
if not isinstance(x, dict) or x.get("type") != "tool_use":
|
||||
continue
|
||||
name = x.get("name") or ""
|
||||
inp = x.get("input") if isinstance(x.get("input"), dict) else {}
|
||||
if name in EDIT_TOOLS or any(w in name.lower() for w in _WRITE_WORDS):
|
||||
edits += 1
|
||||
writing = True
|
||||
files += _input_files(inp)
|
||||
elif name in ("Bash", "Shell", "bash", "shell"):
|
||||
cmd = inp.get("command") if isinstance(inp.get("command"), str) else inp.get("cmd")
|
||||
if measured:
|
||||
if isinstance(cmd, str) and re.search(r"\bsisi\s+contract\s+(init|waive|trust|untrust)\b", cmd):
|
||||
edits += 1
|
||||
shell_edits += 1
|
||||
writing = True
|
||||
files.append(".sisi/contract.json")
|
||||
continue # everything else was measured, not guessed
|
||||
may = shell_may_write(cmd)
|
||||
if may is None:
|
||||
corrupt += 1
|
||||
edits += 1
|
||||
shell_edits += 1
|
||||
writing = True
|
||||
elif may:
|
||||
edits += 1
|
||||
shell_edits += 1
|
||||
writing = True
|
||||
return edits, files, writing, corrupt, consumed, shell_edits
|
||||
|
||||
|
||||
def _scan_one(sess, store_key, path):
|
||||
"""Advance one transcript's offset in the session record. Returns (edits, files, writing, unknown)."""
|
||||
offsets = sess.setdefault("attr_sub_offsets", {}) if store_key == "sub" else None
|
||||
try:
|
||||
size = os.path.getsize(os.path.expanduser(path))
|
||||
except OSError:
|
||||
return 0, [], False, True, 0 # missing or unreadable: unknown, treated as edited by the caller
|
||||
if store_key == "sub":
|
||||
offset = int(offsets.get(path, 0) or 0)
|
||||
else:
|
||||
offset = int(sess.get("attr_offset", 0) or 0)
|
||||
unknown = False
|
||||
if offset > size:
|
||||
offset, unknown = 0, True # truncated or replaced: rescan, and do not trust the gap
|
||||
if size - offset > 64 * 1024 * 1024:
|
||||
# Too much unread tail to scan inside the gate's budget: skip it and count it as a
|
||||
# possible edit by this session (strict), rather than guessing it was someone else's.
|
||||
if store_key == "sub":
|
||||
offsets[path] = size
|
||||
else:
|
||||
sess["attr_offset"] = size
|
||||
return 1, [], True, True, 0
|
||||
edits, files, writing, sh = 0, [], False, 0
|
||||
try:
|
||||
with open(os.path.expanduser(path), "rb") as f:
|
||||
f.seek(offset)
|
||||
data = f.read()
|
||||
except OSError:
|
||||
return 0, [], False, True, 0
|
||||
if data:
|
||||
e, fl, w, corrupt, consumed, sh = parse_chunk(data, measured=bool(sess.get("attr_measured")))
|
||||
edits, files, writing = e, fl, w
|
||||
unknown = unknown or corrupt > 0
|
||||
offset += consumed
|
||||
if store_key == "sub":
|
||||
offsets[path] = offset
|
||||
else:
|
||||
sess["attr_offset"] = offset
|
||||
return edits, files, writing, unknown, sh
|
||||
|
||||
|
||||
def subagent_transcripts(tp):
|
||||
"""Native subagent transcripts under this session's transcript, Claude Code layout."""
|
||||
if not isinstance(tp, str) or not tp.endswith(".jsonl"):
|
||||
return []
|
||||
root = os.path.join(os.path.expanduser(tp)[:-len(".jsonl")], "subagents")
|
||||
out = []
|
||||
for dirpath, dirs, names in os.walk(root):
|
||||
dirs.sort()
|
||||
for n in sorted(names):
|
||||
if n.startswith("agent-") and n.endswith(".jsonl"):
|
||||
out.append(os.path.join(dirpath, n))
|
||||
return out
|
||||
|
||||
|
||||
def update(sess, tp):
|
||||
"""Refresh this session's edit count from its own (and its native subagents') transcripts.
|
||||
|
||||
Returns {"gen", "writing", "unknown", "edits", "files", "shell_edits"} or None when no transcript
|
||||
path is known at all (the caller then falls back to comparing the tree with its last settled
|
||||
state). Fails towards edited: `unknown` is true whenever the transcript cannot be trusted."""
|
||||
if not isinstance(tp, str) or not tp:
|
||||
return None
|
||||
if sess.get("attr_tp") != tp:
|
||||
sess.update(attr_tp=tp, attr_offset=0, attr_gen=0, attr_writing=False, attr_files=[], attr_sub_offsets={})
|
||||
sess.setdefault("attr_gen", 0)
|
||||
unknown = False
|
||||
total, all_files, shell_total = 0, [], 0
|
||||
for key, path in [("main", tp)] + [("sub", s) for s in subagent_transcripts(tp)]:
|
||||
e, fl, w, unk, sh = _scan_one(sess, key, path)
|
||||
total += e
|
||||
shell_total += sh
|
||||
all_files += fl
|
||||
unknown = unknown or unk
|
||||
if w:
|
||||
sess["attr_writing"] = True
|
||||
sess["attr_gen"] = int(sess.get("attr_gen", 0)) + total
|
||||
if all_files:
|
||||
have = sess.setdefault("attr_files", [])
|
||||
for f in all_files:
|
||||
if f not in have:
|
||||
have.append(f)
|
||||
del have[:-500]
|
||||
if unknown:
|
||||
sess["attr_writing"] = True
|
||||
return {"gen": int(sess["attr_gen"]), "writing": bool(sess.get("attr_writing")), "unknown": bool(unknown),
|
||||
"edits": total, "files": all_files, "shell_edits": shell_total}
|
||||
|
||||
|
||||
def observed_edits(transcript):
|
||||
"""(edited, files, start_ts) from a subagent's own transcript: did it write, which files did its
|
||||
edit tools name, and when did it start (sisi's timestamp format, or None). A shell command that
|
||||
may write counts as an edit with no known file."""
|
||||
edited, files, start = False, [], None
|
||||
with open(os.path.expanduser(transcript), encoding="utf-8", errors="replace") as f:
|
||||
for line in f:
|
||||
try:
|
||||
d = json.loads(line)
|
||||
except ValueError:
|
||||
continue
|
||||
if not isinstance(d, dict):
|
||||
continue
|
||||
if start is None and isinstance(d.get("timestamp"), str) and len(d["timestamp"]) >= 19:
|
||||
start = d["timestamp"][:19] + "Z"
|
||||
content = (d.get("message") or {}).get("content") if isinstance(d.get("message"), dict) else None
|
||||
for x in content if isinstance(content, list) else []:
|
||||
if not (isinstance(x, dict) and x.get("type") == "tool_use"):
|
||||
continue
|
||||
inp = x.get("input") if isinstance(x.get("input"), dict) else {}
|
||||
if x.get("name") in EDIT_TOOLS:
|
||||
edited = True
|
||||
files += [f for f in _input_files(inp) if f not in files]
|
||||
elif x.get("name") in ("Bash", "Shell") and shell_may_write(inp.get("command")) is not False:
|
||||
edited = True
|
||||
return edited, files[:100], start
|
||||
@@ -175,10 +175,6 @@ def cmd_contract(args):
|
||||
errs = C.validate(c)
|
||||
for e in errs:
|
||||
print(" - " + e)
|
||||
if not errs:
|
||||
for f in C.floor_failures(c):
|
||||
errs.append(f["message"])
|
||||
print(" - " + f["message"])
|
||||
if not errs:
|
||||
for w in C.warnings(c):
|
||||
print("warning: " + w)
|
||||
|
||||
+21
-22
@@ -1,4 +1,4 @@
|
||||
"""Contract file: location, skeleton, validation, floors."""
|
||||
"""Contract file: location, skeleton, validation."""
|
||||
import json, os, re
|
||||
|
||||
from . import paths, gitutil
|
||||
@@ -108,14 +108,6 @@ def deferred_checks(c):
|
||||
return out
|
||||
|
||||
|
||||
def floors():
|
||||
try:
|
||||
with open(paths.canon("floors.json"), encoding="utf-8") as f:
|
||||
return {k: int(v) for k, v in json.load(f).items()}
|
||||
except (OSError, ValueError):
|
||||
return {}
|
||||
|
||||
|
||||
def _num(x):
|
||||
return isinstance(x, (int, float)) and not isinstance(x, bool)
|
||||
|
||||
@@ -124,6 +116,24 @@ def _str(x):
|
||||
return isinstance(x, str) and x.strip() != ""
|
||||
|
||||
|
||||
_PLACEHOLDER_WORDS = {"todo", "tbd", "tba", "fixme", "xxx", "wip", "none", "nothing", "no", "n/a", "na", "nil",
|
||||
"null", "unknown", "placeholder", "later", "see above", "same", "as above", "not applicable",
|
||||
"no risk", "no rollback", "none needed", "not needed", "nothing needed", "-", "--", "...",
|
||||
"?", "yes", "ok", "fine", "tests", "all"}
|
||||
|
||||
|
||||
def is_placeholder(x):
|
||||
"""True for text that fills a field without saying anything: empty, `TODO`, `n/a`, `none`,
|
||||
`tbd`, a bare punctuation mark, or anything that begins with TODO/TBD/FIXME. The gate asks for
|
||||
a requirement list, a risk note, an approach and a reason; these words do not provide one."""
|
||||
if not isinstance(x, str):
|
||||
return True
|
||||
t = " ".join(x.lower().split()).strip(" .,:;!-_*")
|
||||
if len(re.findall(r"[a-z0-9]", t)) < 3 and t not in ("ui",):
|
||||
return True
|
||||
return t in _PLACEHOLDER_WORDS or bool(re.match(r"^(todo|tbd|fixme|placeholder|xxx)\b", t))
|
||||
|
||||
|
||||
TIERS = ("fast", "deep")
|
||||
|
||||
|
||||
@@ -274,6 +284,8 @@ def _check_new_fields(ch, w, errs):
|
||||
for k in ("mandatory", "independent"):
|
||||
if k in ch and not isinstance(ch[k], bool):
|
||||
errs.append("%s: %s must be true or false" % (w, k))
|
||||
if "by" in ch and not _str(ch["by"]):
|
||||
errs.append(w + ": by must name who or what produced the independent evidence")
|
||||
|
||||
|
||||
def _validate_new_top(c, ids, errs):
|
||||
@@ -473,16 +485,3 @@ def validate(c):
|
||||
errs.append("questions[%d] needs q and default" % i)
|
||||
_validate_new_top(c, ids, errs)
|
||||
return errs
|
||||
|
||||
|
||||
def floor_failures(c, floor_map=None):
|
||||
"""Kinds with a floor where every check of that kind is weaker than the floor."""
|
||||
fm = floors() if floor_map is None else floor_map
|
||||
out = []
|
||||
for kind, fl in sorted(fm.items()):
|
||||
of_kind = [ch for ch in c.get("checks", []) if ch.get("kind") == kind]
|
||||
if of_kind and not any(ch["rung"] <= fl for ch in of_kind):
|
||||
out.append({"kind": kind, "floor": fl,
|
||||
"message": "floor: %s claims need a check at rung %d or stronger; best is rung %d"
|
||||
% (kind, fl, min(ch["rung"] for ch in of_kind))})
|
||||
return out
|
||||
+412
-820
File diff suppressed because it is too large.
Load diff
+6
-1
@@ -34,7 +34,12 @@ GENERIC_WORDS = set((
|
||||
"improving improvement quality thorough thoroughly review reviewing think thinking plan planning ahead "
|
||||
"going forward all any some general generally just really very much many bit little slightly again once "
|
||||
"ever also too so can could would will may might worse avoid mistakes mistake fine ok okay well everything "
|
||||
"anything something stuff careless carelessness sloppy rushed hasty lazy diligent diligence").split())
|
||||
"anything something stuff careless carelessness sloppy rushed hasty lazy diligent diligence "
|
||||
# a non-finding says only that nothing stood out ("it went well", "no problems, as expected")
|
||||
"went go goes gone smooth smoothly expected nicely perfect perfectly success successful successfully "
|
||||
"finished complete completed happened happen hitch hitches without notable remarkable report reported "
|
||||
"particular special specific cause causes reason reasons known unknown clear obvious say said "
|
||||
"passed pass green").split())
|
||||
|
||||
|
||||
class LearningError(Exception):
|
||||
|
||||
@@ -0,0 +1,130 @@
|
||||
"""Rule 5 at the end of a turn: a reply that ends by asking the human a question must have asked it
|
||||
through the tool's question dialog. Sent back at most once per final message, never a subagent."""
|
||||
import hashlib, json, os, re
|
||||
|
||||
from . import store
|
||||
|
||||
|
||||
def _session_key(payload, cwd):
|
||||
sid = payload.get("session_id")
|
||||
return sid if isinstance(sid, str) and sid else "cwd-" + hashlib.sha1(cwd.encode()).hexdigest()[:12]
|
||||
|
||||
|
||||
# ---------------------------------------------------------------- rule 5: ask through the dialog
|
||||
# Tools with a confirmed question dialog whose transcripts sisi can read in Claude-Code shape.
|
||||
# Codex's request_user_input is behind a flag that is off by default, OpenCode's question tool has
|
||||
# no readable transcript file here, and the other tools name no dialog at all, so they are exempt.
|
||||
QUESTION_DIALOG_TOOLS = {"claude-code": ("AskUserQuestion",), "qwen": ("ask_user_question",)}
|
||||
_RHETORICAL = (r"^who (wouldn'?t|couldn'?t|doesn'?t)\b", r"^what could possibly\b",
|
||||
r"^(isn'?t|aren'?t) it (obvious|clear)\b")
|
||||
|
||||
|
||||
def ends_with_question(text):
|
||||
"""True when a final message ends by asking the reader a question. The rule, exactly: after
|
||||
removing fenced code blocks, blockquote lines and inline code, the last sentence of the last
|
||||
paragraph ends with a question mark that is not inside a closing quote (a quoted question),
|
||||
and the sentence does not start with a known rhetorical form."""
|
||||
if not isinstance(text, str) or not text.strip():
|
||||
return False
|
||||
kept, in_fence = [], False
|
||||
for line in text.split("\n"):
|
||||
if line.strip().startswith("```"):
|
||||
in_fence = not in_fence
|
||||
continue
|
||||
if in_fence or line.lstrip().startswith(">"):
|
||||
continue
|
||||
kept.append(re.sub(r"`[^`]*`", "", line))
|
||||
paras = [p.strip() for p in re.split(r"\n\s*\n", "\n".join(kept)) if p.strip()]
|
||||
if not paras:
|
||||
return False
|
||||
para = " ".join(paras[-1].split())
|
||||
t = para.rstrip("*_ ")
|
||||
if t.endswith(('?"', "?\"", "?'", "?’", "?”")): # the question mark sits inside a quotation
|
||||
return False
|
||||
t = t.rstrip(')]*_ ')
|
||||
if not t.endswith("?"):
|
||||
return False
|
||||
start = max(t.rfind(".", 0, len(t) - 1), t.rfind("!", 0, len(t) - 1), t.rfind("?", 0, len(t) - 1)) + 1
|
||||
sentence = t[start:].strip().lower()
|
||||
return not any(re.match(p, sentence) for p in _RHETORICAL)
|
||||
|
||||
|
||||
def _last_turn(tp):
|
||||
"""(final assistant text, tool names used) after the last message the human typed, from the
|
||||
transcript tail. None when the turn cannot be bounded (the caller then exempts the turn)."""
|
||||
try:
|
||||
size = os.path.getsize(os.path.expanduser(tp))
|
||||
with open(os.path.expanduser(tp), "rb") as f:
|
||||
f.seek(max(0, size - 2 * 1024 * 1024))
|
||||
data = f.read()
|
||||
except OSError:
|
||||
return None
|
||||
from . import harvest
|
||||
recs = []
|
||||
for raw in data.split(b"\n"):
|
||||
if not raw.strip():
|
||||
continue
|
||||
try:
|
||||
d = json.loads(raw.decode("utf-8", "replace"))
|
||||
except ValueError:
|
||||
continue # a cut first line or a corrupt one: it cannot be the turn's evidence either way
|
||||
if isinstance(d, dict):
|
||||
recs.append(d)
|
||||
last_human = -1
|
||||
for i, d in enumerate(recs):
|
||||
if d.get("type") == "user":
|
||||
try:
|
||||
if harvest.typed_text(d)[0] is not None:
|
||||
last_human = i
|
||||
except Exception:
|
||||
pass
|
||||
if last_human < 0:
|
||||
return None
|
||||
final, tools = "", set()
|
||||
for d in recs[last_human + 1:]:
|
||||
content = (d.get("message") or {}).get("content") if isinstance(d.get("message"), dict) else None
|
||||
texts = []
|
||||
for x in content if isinstance(content, list) else []:
|
||||
if not isinstance(x, dict):
|
||||
continue
|
||||
if x.get("type") == "tool_use" and isinstance(x.get("name"), str):
|
||||
tools.add(x["name"])
|
||||
elif x.get("type") == "text" and isinstance(x.get("text"), str):
|
||||
texts.append(x["text"])
|
||||
if texts and d.get("type") in ("assistant", None):
|
||||
final = "\n".join(texts)
|
||||
return final, tools
|
||||
|
||||
|
||||
def sendback(payload):
|
||||
"""('block', reason) when this turn ended by asking in reply text and no question dialog was
|
||||
used in it; None otherwise. At most once per final message, keyed by its hash in the session
|
||||
record, so a session can never be trapped. Subagents and dialog-less tools are exempt."""
|
||||
tool = store.tool()
|
||||
dialogs = QUESTION_DIALOG_TOOLS.get(tool or "")
|
||||
if not dialogs:
|
||||
return None
|
||||
if payload.get("agent_id") or payload.get("agent_transcript_path"):
|
||||
return None # a subagent has no human to ask through a dialog
|
||||
cwd = payload.get("cwd") if isinstance(payload.get("cwd"), str) and os.path.isdir(payload.get("cwd")) else os.getcwd()
|
||||
sid = _session_key(payload, cwd)
|
||||
sess = store.load_session(sid)
|
||||
tp = payload.get("transcript_path") if isinstance(payload.get("transcript_path"), str) else sess.get("transcript_path")
|
||||
if not isinstance(tp, str) or not tp:
|
||||
return None
|
||||
turn = _last_turn(tp)
|
||||
if not turn:
|
||||
return None
|
||||
final, tools = turn
|
||||
if any(d in tools for d in dialogs) or not ends_with_question(final):
|
||||
return None
|
||||
key = hashlib.sha1(final.encode("utf-8", "replace")).hexdigest()[:16]
|
||||
if sess.get("q_block_key") == key:
|
||||
return None
|
||||
sess["q_block_key"] = key
|
||||
sess["req_blocks"] = int(sess.get("req_blocks", 0)) + 1
|
||||
store.save_session(sid, sess)
|
||||
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. "
|
||||
"(The rule in full: `sisi rule decide-dont-ask`.)" % dialogs[0])
|
||||
+74
-6
@@ -5,7 +5,7 @@ Missing data is unavailable with value None: never zero, never good. No single s
|
||||
ever computed or printed. Check statistics and escape candidates (work declared verified
|
||||
that then turned out wrong) live here too: they feed the correctness and intent dimensions.
|
||||
"""
|
||||
import json, os, re
|
||||
import json, os, re, time
|
||||
|
||||
from . import harvest, store
|
||||
|
||||
@@ -186,6 +186,7 @@ def build_scorecard(c, results, telemetry, delivery_status):
|
||||
"techniques": val(sorted({"rung %s" % x.get("rung") for x in items.values()} |
|
||||
{str(x.get("kind")) for x in items.values() if x.get("kind")}), "measured"),
|
||||
"checks_seen_failing": val(sum(1 for r in latest.values() if r.get("seen_failing")), "measured"),
|
||||
"stronger_than_examples": val(any(x.get("rung") in (1, 2) for x in items.values()), "measured"),
|
||||
"independent_evidence": val(any(norm_status((latest.get(cid) or {}).get("status")) == "passed"
|
||||
for cid, x in items.items() if x.get("independent")), "measured"),
|
||||
"deviation": val(delivery_status == "deviation", "measured"),
|
||||
@@ -345,8 +346,74 @@ def format_dimension(dim, vals):
|
||||
("; %d unavailable" % n_un) if n_un else "")
|
||||
|
||||
|
||||
def format_status(units, learning=False, recent=5):
|
||||
def _age(iso, now=None):
|
||||
"""'3h', '2d', '15m' since an ISO UTC time; '?' when it cannot be read."""
|
||||
from . import harvest
|
||||
t = harvest.epoch(iso) if isinstance(iso, str) else None
|
||||
if t is None:
|
||||
return "?"
|
||||
s = max(0, (time.time() if now is None else now) - t)
|
||||
return "%dd" % (s // 86400) if s >= 86400 else "%dh" % (s // 3600) if s >= 3600 else "%dm" % (s // 60)
|
||||
|
||||
|
||||
def open_units(cwd=None):
|
||||
"""The unit that is open or paused in this project, as display rows. A unit that waits (paused)
|
||||
says what for and for how long; one that was declared below its floor says so, with the reason."""
|
||||
from . import contract as C, unit as U, assure
|
||||
out = []
|
||||
try:
|
||||
p = C.find(cwd or os.getcwd())
|
||||
c = C.load(p) if p else None
|
||||
except (OSError, ValueError):
|
||||
return out
|
||||
if not isinstance(c, dict) or not c.get("id") or c.get("status") == "closed" or C.is_unedited_skeleton(c):
|
||||
return out
|
||||
project = C.project_dir(p)
|
||||
row = {"id": c["id"], "status": c.get("status", "open"), "age": _age(c.get("started")), "goal": c.get("goal") or ""}
|
||||
if row["status"] == "paused":
|
||||
pz = next((x for x in reversed(c.get("pauses") or []) if isinstance(x, dict) and not x.get("until")), {})
|
||||
row["waiting_for"], row["paused_for"] = pz.get("what"), _age(pz.get("since"))
|
||||
rk = c.get("risk") or {}
|
||||
floor, _ = U.risk_floor(c, project)
|
||||
floor = floor.get("value") if isinstance(floor, dict) else floor
|
||||
if assure.is_lowered(floor, rk.get("profile"), rk.get("why")):
|
||||
row["lowered"] = "declared %s below the floor %s: %s" % (rk.get("profile"), floor, rk.get("why"))
|
||||
if c.get("unverified"):
|
||||
row["unverified"] = "; ".join(c["unverified"].get("why") or [])
|
||||
out.append(row)
|
||||
return out
|
||||
|
||||
|
||||
def _lowered_note(u):
|
||||
rk = u.get("risk") or {}
|
||||
if not rk.get("lowered"):
|
||||
return ""
|
||||
floor = rk.get("floor")
|
||||
floor = floor.get("value") if isinstance(floor, dict) else floor
|
||||
return " [lowered: declared %s, floor %s%s]" % (rk.get("declared"), floor,
|
||||
(": " + str(rk["why"])) if rk.get("why") else "")
|
||||
|
||||
|
||||
def format_open(rows):
|
||||
lines = []
|
||||
for r in rows:
|
||||
if r["status"] == "paused":
|
||||
lines.append("paused %-24s age %s waiting for: %s (for %s)" % (r["id"], r["age"], r.get("waiting_for") or "?", r.get("paused_for")))
|
||||
else:
|
||||
lines.append("open %-24s age %s %s" % (r["id"], r["age"], r["goal"][:80]))
|
||||
if r.get("lowered"):
|
||||
lines.append(" lowered: " + r["lowered"])
|
||||
if r.get("unverified"):
|
||||
lines.append(" released unverified by the gate: " + r["unverified"])
|
||||
return lines
|
||||
|
||||
|
||||
def format_status(units, learning=False, recent=5, opened=()):
|
||||
lines = []
|
||||
if opened:
|
||||
lines.append("units in progress:")
|
||||
lines += [" " + ln for ln in format_open(opened)]
|
||||
lines.append("")
|
||||
if not units:
|
||||
lines.append("sisi status: no closed work units yet. Close one with `sisi unit close`; "
|
||||
"its scorecard will appear here.")
|
||||
@@ -354,8 +421,8 @@ def format_status(units, learning=False, recent=5):
|
||||
lines.append("recent units (newest first, %d closed in all):" % len(units))
|
||||
for u in list(reversed(units))[:recent]:
|
||||
lines.append("")
|
||||
lines.append("%s %s [%s] %s" % (u.get("id"), str(u.get("ended") or "")[:10],
|
||||
u.get("delivery_status"), u.get("goal") or ""))
|
||||
lines.append("%s %s [%s] %s%s" % (u.get("id"), str(u.get("ended") or "")[:10],
|
||||
u.get("delivery_status"), u.get("goal") or "", _lowered_note(u)))
|
||||
sc = u.get("scorecard") or {}
|
||||
for dim, vals in sc.items():
|
||||
lines.append(format_dimension(dim, vals))
|
||||
@@ -385,8 +452,9 @@ def format_status(units, learning=False, recent=5):
|
||||
|
||||
def cmd_status(args=(), cwd=None, out=print):
|
||||
units = load_unit_summaries(cwd)
|
||||
opened = open_units(cwd)
|
||||
if "--json" in args:
|
||||
out(json.dumps({"units": units, "trends": trends(units)}, indent=2, default=str))
|
||||
out(json.dumps({"open": opened, "units": units, "trends": trends(units)}, indent=2, default=str))
|
||||
return 0
|
||||
out(format_status(units, learning="--learning" in args))
|
||||
out(format_status(units, learning="--learning" in args, opened=opened))
|
||||
return 0
|
||||
+2
-2
@@ -5,7 +5,7 @@ from . import paths
|
||||
|
||||
FILES = {"results": "results.jsonl",
|
||||
"learn": "learn.jsonl", "quarantine": "learn.jsonl", "waivers": "waivers.jsonl",
|
||||
"deliveries": "deliveries.jsonl", "units": "units.jsonl"}
|
||||
"deliveries": "deliveries.jsonl", "units": "units.jsonl", "subagents": "subagents.jsonl"}
|
||||
|
||||
|
||||
def _migrate_learn():
|
||||
@@ -154,7 +154,7 @@ def stamp(extra):
|
||||
return rec
|
||||
|
||||
|
||||
DEFAULTS = {"gate": {"enabled": True, "budget_s": 120, "max_blocks": 3, "growth_lines": 40, "growth_files": 3},
|
||||
DEFAULTS = {"gate": {"enabled": True, "budget_s": 120, "max_blocks": 3},
|
||||
"verify": {"default_timeout_s": 60, "fast_limit_s": 60},
|
||||
"retro": {"required": True},
|
||||
"scratch": {"session_max_age_days": 30, "prune_every": 20, "prune_max_delete": 1000,
|
||||
|
||||
+1
-2
@@ -75,8 +75,7 @@ def main(args=()):
|
||||
rec["attr_offset"] = os.path.getsize(os.path.expanduser(payload["transcript_path"]))
|
||||
except OSError:
|
||||
rec["attr_offset"] = 0
|
||||
rec.update(attr_gen=0, attr_pass_gen=0, attr_retro_gen=0, attr_baseline_gen=0,
|
||||
attr_writing=False, attr_files=[], attr_sub_offsets={})
|
||||
rec.update(attr_gen=0, seen_gen=0, dirty=False, attr_writing=False, attr_files=[], attr_sub_offsets={})
|
||||
from . import contract as C, gitutil
|
||||
if gitutil.root(cwd):
|
||||
rec["head"] = gitutil.head(cwd)
|
||||
|
||||
+29
-3
@@ -137,14 +137,14 @@ def _row_epoch(r):
|
||||
|
||||
|
||||
def policy_version(project, c):
|
||||
"""Hash of the policies in force: the effective rulebook, the floors and risk tables,
|
||||
"""Hash of the policies in force: the effective rulebook, the risk tables,
|
||||
the enforced checks, and the gate/verify config."""
|
||||
h = hashlib.sha256()
|
||||
rulebook = paths.generated()
|
||||
if not os.path.exists(rulebook):
|
||||
rulebook = paths.canon("core.md")
|
||||
# named by role, never by path: the same policies hash the same in any clone or project
|
||||
for role, p in (("rulebook", rulebook), ("floors", paths.canon("floors.json")),
|
||||
for role, p in (("rulebook", rulebook),
|
||||
("risk table", paths.canon("risk.json")),
|
||||
("project risk table", os.path.join(project, ".sisi", "risk.json"))):
|
||||
try:
|
||||
@@ -458,6 +458,8 @@ def decide_status(c, rows, abandon=None):
|
||||
return "abandoned", block, unrun
|
||||
if c.get("deviations"):
|
||||
return "deviation", block, unrun
|
||||
if c.get("unverified"): # the gate released the unit after its send-backs and nothing has verified it since
|
||||
return "unverified", block, unrun
|
||||
if block:
|
||||
released = any(r.get("check") == "gate" and r.get("status") == "unverified" for r in rows)
|
||||
return ("unverified" if released else None), block, unrun
|
||||
@@ -480,6 +482,8 @@ def build_record(c, project, delivery_status, ended_epoch, abandon_reason=None,
|
||||
unrun = never_run(latest)
|
||||
floor, floor_reasons = risk_floor(c, project)
|
||||
declared = c.get("risk") or {}
|
||||
from . import assure
|
||||
floor_name = floor.get("value") if isinstance(floor, dict) else floor
|
||||
rec = {
|
||||
"id": c["id"], "parent": c.get("parent"),
|
||||
"goal": c.get("goal"), "scope": c.get("scope") or {"in": [], "out": []},
|
||||
@@ -488,7 +492,10 @@ def build_record(c, project, delivery_status, ended_epoch, abandon_reason=None,
|
||||
"checks": c.get("checks") or [], "invariants": c.get("invariants") or [],
|
||||
"risk": {"floor": floor, "floor_reasons": floor_reasons,
|
||||
"declared": declared.get("profile"), "why": declared.get("why"),
|
||||
"lowered": assure.is_lowered(floor_name, declared.get("profile"), declared.get("why")),
|
||||
"blast_radius": declared.get("blast_radius"), "rollback": declared.get("rollback")},
|
||||
"stronger_technique": assure.stronger_technique(c),
|
||||
"released_unverified": c.get("unverified"),
|
||||
"approach": c.get("approach"),
|
||||
"plan": c.get("plan") or [],
|
||||
"workers": delegation_rows,
|
||||
@@ -521,7 +528,7 @@ def summary_line(rec):
|
||||
floor = (risk.get("floor") or {}).get("value") if isinstance(risk.get("floor"), dict) else risk.get("floor")
|
||||
return {"id": rec["id"], "parent": rec.get("parent"), "project": rec.get("project"),
|
||||
"goal": rec.get("goal"), "delivery_status": rec.get("delivery_status"),
|
||||
"risk": {"declared": risk.get("declared"), "floor": floor},
|
||||
"risk": {"declared": risk.get("declared"), "floor": floor, "lowered": bool(risk.get("lowered"))},
|
||||
"models": rec.get("models") or [], "policy_version": rec.get("policy_version"),
|
||||
"started": rec.get("started"), "ended": rec.get("ended"), "closed_at": rec.get("closed_at"),
|
||||
"scorecard": rec.get("scorecard")}
|
||||
@@ -637,6 +644,25 @@ def resume(c, contract_path):
|
||||
return True
|
||||
|
||||
|
||||
def verified_for_tree(c, project, contract_path):
|
||||
"""True when the unit's fast checks have a run that passed on exactly the tree as it is now
|
||||
(what the commit-time notice asks). A run that was skipped or reused counts only if nothing in
|
||||
it blocks and something passed. False when no run is recorded for this tree."""
|
||||
from . import verify as V
|
||||
fp = V.tree_fp(project, contract_path)
|
||||
if fp is None:
|
||||
return True # outside git there is no tree to compare: nothing to say
|
||||
runs = {}
|
||||
for r in _unit_results(c, project, c.get("started")):
|
||||
if r.get("fp") == fp and r.get("tier", "fast") == "fast" and r.get("run") and r.get("item") in ("check", "invariant"):
|
||||
runs.setdefault(r["run"], []).append(r)
|
||||
for rows in runs.values():
|
||||
if not V.blocking(rows) and any(r.get("status") == "passed" or str(r.get("reason") or "").startswith("reused: passed")
|
||||
for r in rows):
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
def summary_for_retro(project):
|
||||
"""What `sisi retro` prints: the open unit's scorecard so far and what stands out in it."""
|
||||
p = os.path.join(project, C.REL)
|
||||
|
||||
+1
-10
@@ -433,21 +433,12 @@ def cmd_for(args):
|
||||
ranked = [(s + (1.0 if inst[e["path"]] == "yes" else 0.0), e) for s, e in cands]
|
||||
ranked.sort(key=lambda x: (-round(x[0], 1), x[1]["rung"], x[1]["id"]))
|
||||
top = ranked[:8]
|
||||
fl = None
|
||||
if "kind" in opts:
|
||||
fl = C.floors().get(opts["kind"].lower())
|
||||
if fl:
|
||||
print("Floor: %s claims need rung %d or stronger (canon/floors.json). Results marked [floor ok] satisfy it.\n"
|
||||
% (opts["kind"], fl))
|
||||
if not top:
|
||||
print("no verifier matches that description; try `sisi verifiers` to browse")
|
||||
_print_lessons(desc)
|
||||
return 0
|
||||
for i, (f, e) in enumerate(top, 1):
|
||||
mark = ""
|
||||
if fl:
|
||||
mark = " [floor ok]" if e["rung"] <= fl else " [below floor]"
|
||||
print("%d. %s rung %s cost %s installed: %s%s%s" % (i, e["id"], e["rung"], e["cost"] or "-", inst[e["path"]], mark, origin_tag(e)))
|
||||
print("%d. %s rung %s cost %s installed: %s%s" % (i, e["id"], e["rung"], e["cost"] or "-", inst[e["path"]], origin_tag(e)))
|
||||
print(" %s" % (e["answers"] or e["title"]))
|
||||
print("\nsisi verifiers show ID for set-up and a worked example")
|
||||
_print_lessons(desc, extra=" ".join(e["id"] for _, e in top[:3]), targets=tuple(e["id"] for _, e in top))
|
||||
|
||||
@@ -285,11 +285,6 @@ def run(c, project, deadline=None, default_timeout=60, tiers=("fast",), changed=
|
||||
dirty_cache = True
|
||||
if dirty_cache:
|
||||
_save_cache(cache)
|
||||
for f in (C.floor_failures(c) if "fast" in tiers else []):
|
||||
res.append({"item": "floor", "tier": "fast", "id": "floor:" + f["kind"], "kind": f["kind"], "rung": None,
|
||||
"claim": f["message"], "status": "failed", "reason": None, "duration_s": 0.0,
|
||||
"tail": f["message"], "mandatory": True, "independent": False, "covers": None,
|
||||
"seen_failing": True, "saved_s": 0.0})
|
||||
if "fast" in tiers: # enforced lessons ride the same path as floors (personal overlay, trusted commands)
|
||||
try:
|
||||
from . import cycle
|
||||
|
||||
+31
-1
@@ -12,7 +12,7 @@ that errs strict, which is the safe side. A pending before-record with no after
|
||||
killed) is likewise treated as this session having edited, with no known paths (a sentinel).
|
||||
Both hooks fail open: any error is logged and the tool call proceeds.
|
||||
"""
|
||||
import json, os, time
|
||||
import json, os, re, time
|
||||
|
||||
from . import gitutil, paths, store
|
||||
|
||||
@@ -191,6 +191,28 @@ def changed_since_pass(sid, cwd):
|
||||
return gitutil.snapshot_diff(pend, gitutil.snapshot(cwd))
|
||||
|
||||
|
||||
_COMMIT_RE = re.compile(r"(?:^|[;&|(]\s*)(?:\w+=\S+\s+)*git\s+(?:(?:-C|-c)\s+\S+\s+|--[\w-]+\s+)*(?:commit|merge)\b")
|
||||
|
||||
|
||||
def commit_notice(payload):
|
||||
"""One line, never a block: the command is a `git commit` or `git merge` and the open unit's fast
|
||||
checks have no passing result for the tree as it is now. None when there is nothing to say."""
|
||||
tool, cmd, _ev, cwd, _sid = extract(payload)
|
||||
if not is_shell(tool, cmd) or not _COMMIT_RE.search(cmd):
|
||||
return None
|
||||
from . import contract as C, trust, unit
|
||||
path = C.find(cwd)
|
||||
if not path or not trust.is_trusted(C.project_dir(path)):
|
||||
return None
|
||||
c = C.load(path)
|
||||
if not isinstance(c, dict) or c.get("status", "open") != "open" or C.is_unedited_skeleton(c) or C.validate(c):
|
||||
return None
|
||||
if unit.verified_for_tree(c, C.project_dir(path), path):
|
||||
return None
|
||||
return ("sisi: unit %s has no passing `sisi verify` result for the tree you are about to commit; run "
|
||||
"`sisi verify` first (a notice, not a block)." % c.get("id"))
|
||||
|
||||
|
||||
def main(args=()):
|
||||
try:
|
||||
from . import gate
|
||||
@@ -198,6 +220,14 @@ def main(args=()):
|
||||
_tool, _cmd, ev, _cwd, _sid = extract(payload)
|
||||
if "--before" in args or ev in BEFORE_EVENTS:
|
||||
before(payload)
|
||||
try:
|
||||
line = commit_notice(payload)
|
||||
if line:
|
||||
import sys
|
||||
sys.stdout.write(json.dumps({"systemMessage": line, "hookSpecificOutput": {
|
||||
"hookEventName": "PreToolUse", "additionalContext": line}}) + "\n")
|
||||
except Exception as e:
|
||||
store.log_error("watch-commit-notice", e)
|
||||
elif "--after" in args or ev in AFTER_EVENTS:
|
||||
after(payload)
|
||||
except Exception as e: # fail open: a tool call must never be held up by measurement
|
||||
|
||||
@@ -40,17 +40,6 @@ class ContractTests(SisiCase):
|
||||
def test_rung_5_6_valid_without_cmd(self):
|
||||
self.assertEqual(C.validate(contract([check("a", "true"), human("h", 5), human("i", 6)])), [])
|
||||
|
||||
def test_floors(self):
|
||||
weak = contract([check("m", "true", rung=3, kind="money")])
|
||||
self.assertEqual(len(C.floor_failures(weak)), 1)
|
||||
self.assertEqual(C.floor_failures(contract([check("m", "true", rung=2, kind="money")])), [])
|
||||
# one strong check among weak ones satisfies the floor
|
||||
self.assertEqual(C.floor_failures(contract([check("m", "true", rung=3, kind="money"),
|
||||
check("n", "true", rung=1, kind="money")])), [])
|
||||
self.assertEqual(C.floor_failures(contract([check("u", "true", rung=4, kind="ui")])), [])
|
||||
for k in ("concurrency", "parsing", "money", "state-machine", "migration"):
|
||||
self.assertEqual(C.floors()[k], 2)
|
||||
|
||||
def test_find_stops_at_git_root(self):
|
||||
self.git_init()
|
||||
self.write_contract(contract([check("a", "true")]))
|
||||
|
||||
@@ -169,6 +169,10 @@ class DeliveryRowTests(SisiCase):
|
||||
|
||||
def test_send_backs_and_check_time_are_counted_for_the_request(self):
|
||||
self.write_contract(contract([check("bad", "sleep 0.3; exit 1")]))
|
||||
with open(self.tp, "a") as f: # the agent edited a source file this turn
|
||||
f.write(json.dumps({"type": "assistant", "timestamp": "2026-01-01T00:00:00.000Z", "message": {
|
||||
"role": "assistant", "content": [{"type": "tool_use", "name": "Edit",
|
||||
"input": {"file_path": os.path.join(self.proj, "app.py")}}]}}) + "\n")
|
||||
r = self.hook(transcript_path=self.tp)
|
||||
self.assertEqual(json.loads(r.stdout)["decision"], "block")
|
||||
self.assertEqual(self.rows(), []) # a send-back is not a delivery
|
||||
|
||||
+141
-15
@@ -2,35 +2,161 @@ import json, os, unittest
|
||||
from support import *
|
||||
|
||||
|
||||
def load(path):
|
||||
with open(path) as f:
|
||||
return json.load(f)
|
||||
|
||||
|
||||
def tool_line(name, inp):
|
||||
return {"type": "assistant", "timestamp": "2026-01-01T00:00:00.000Z",
|
||||
"message": {"role": "assistant", "content": [{"type": "tool_use", "name": name, "input": inp}]}}
|
||||
|
||||
|
||||
class EndToEnd(SisiCase):
|
||||
"""R-5.3-1, R-9-1, R-10.3-1..7, R-15-13, R-17-3, R-17-5, R-17-7: the real hook entry points with
|
||||
Claude-Code-shaped hook JSON, in a temp home and a temp git project, from install to a closed unit
|
||||
and a unit the gate had to release as unverified."""
|
||||
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
os.environ["SISI_RETRO_REQUIRED"] = "1"
|
||||
self.addCleanup(lambda: os.environ.__setitem__("SISI_RETRO_REQUIRED", "0"))
|
||||
|
||||
def hook(self, event, **extra):
|
||||
p = dict({"session_id": "e2e", "cwd": self.proj, "transcript_path": self.tp, "hook_event_name": event}, **extra)
|
||||
return self.sisi("tick" if event == "SessionStart" else "gate", stdin=json.dumps(p))
|
||||
|
||||
def stop(self):
|
||||
r = self.hook("Stop", stop_hook_active=False)
|
||||
self.assertEqual(r.returncode, 0, r.stderr)
|
||||
if not r.stdout.strip():
|
||||
return "allow", None
|
||||
d = json.loads(r.stdout)
|
||||
return ("block", d["reason"]) if d.get("decision") == "block" else ("allow", d.get("systemMessage"))
|
||||
|
||||
def agent_writes(self, rel, text, tool="Write"):
|
||||
p = os.path.join(self.proj, rel)
|
||||
os.makedirs(os.path.dirname(p), exist_ok=True)
|
||||
with open(p, "a" if tool == "Edit" else "w") as f:
|
||||
f.write(text)
|
||||
with open(self.tp, "a") as f:
|
||||
f.write(json.dumps(tool_line(tool, {"file_path": p})) + "\n")
|
||||
|
||||
def agent_runs(self, command, *argv):
|
||||
with open(self.tp, "a") as f:
|
||||
f.write(json.dumps(tool_line("Bash", {"command": command})) + "\n")
|
||||
return self.sisi(*argv)
|
||||
|
||||
def finding(self, n):
|
||||
r = self.sisi("retro", "--finding", "`cargo test` run %d took 4 minutes with no fuzz verifier in the project" % n,
|
||||
"--cause", "the recipe never named a fuzz verifier for parsers", "--impact", "time",
|
||||
"--disposition", "promote",
|
||||
"--change", "Add the fuzz verifier to the parser-or-codec recipe Checks, variant %d" % n,
|
||||
"--mechanism", "verification", "--expect", "parser work gets a fuzz check",
|
||||
"--validate", "run the recipe checks on a parser change", env={"SISI_SESSION_ID": "e2e"})
|
||||
self.assertEqual(r.returncode, 0, r.stdout + r.stderr)
|
||||
|
||||
def test_full_flow(self):
|
||||
for d in (".claude", ".codex", ".config/opencode"):
|
||||
os.makedirs(os.path.join(self.home, d))
|
||||
with open(os.path.join(self.home, ".claude", "settings.json"), "w") as f:
|
||||
json.dump({"hooks": {"SessionStart": [{"matcher": "*", "hooks": [{"type": "command", "command": "existing"}]}]}}, f)
|
||||
self.git_init()
|
||||
with open(os.path.join(self.proj, "README.md"), "w") as f:
|
||||
f.write("# project\n")
|
||||
self.assertEqual(self.sisi("install").returncode, 0)
|
||||
doc = self.sisi("doctor").stdout
|
||||
self.assertIn("claude-code wired", doc)
|
||||
payload = json.dumps({"session_id": "e2e", "cwd": self.proj, "hook_event_name": "SessionStart", "source": "startup"})
|
||||
self.assertEqual(self.sisi("tick", stdin=payload).stdout, "")
|
||||
stop = json.dumps({"session_id": "e2e", "cwd": self.proj, "hook_event_name": "Stop", "stop_hook_active": False})
|
||||
self.assertIn("claude-code wired", self.sisi("doctor").stdout)
|
||||
self.tp = os.path.join(self.tmp, "e2e.jsonl")
|
||||
with open(self.tp, "w") as f:
|
||||
f.write(json.dumps({"type": "user", "timestamp": "2026-01-01T00:00:00.000Z",
|
||||
"message": {"role": "user", "content": "build the feature"}}) + "\n")
|
||||
self.assertEqual(self.hook("SessionStart", source="startup").stdout, "")
|
||||
|
||||
self.write_contract(contract([check("feature", "test -f %s/done.txt" % self.proj, rung=3)]))
|
||||
r = self.sisi("gate", stdin=stop)
|
||||
self.assertEqual(r.returncode, 0)
|
||||
d = json.loads(r.stdout)
|
||||
self.assertEqual(d["decision"], "block")
|
||||
self.assertIn("feature", d["reason"])
|
||||
# a documentation change: silent, nothing run, nothing asked
|
||||
self.agent_writes("README.md", "more words\n", "Edit")
|
||||
self.assertEqual(self.stop(), ("allow", None))
|
||||
|
||||
open(os.path.join(self.proj, "done.txt"), "w").close()
|
||||
r = self.sisi("gate", stdin=stop)
|
||||
self.assertEqual((r.returncode, r.stdout), (0, ""))
|
||||
# a source change with no contract: sent back, with what it needs
|
||||
self.agent_writes("app.py", "def feature():\n return 1\n")
|
||||
a, msg = self.stop()
|
||||
self.assertEqual(a, "block")
|
||||
self.assertIn("a contract for this isolated change", msg)
|
||||
self.assertIn("sisi contract init", msg)
|
||||
|
||||
self.assertEqual(self.sisi("unit", "close").returncode, 0)
|
||||
# a contract with a failing check: sent back with the failure
|
||||
self.agent_runs("sisi contract init --goal 'build the feature'", "contract", "init", "--goal", "build the feature")
|
||||
c = load(os.path.join(self.proj, ".sisi", "contract.json"))
|
||||
c["id"] = "feature"
|
||||
c["checks"] = [{"id": "feature", "claim": "done.flag exists", "kind": "general", "rung": 3,
|
||||
"cmd": "test -f done.flag", "expect": {"exit": 0}}]
|
||||
self.agent_writes(os.path.join(".sisi", "contract.json"), json.dumps(c))
|
||||
a, msg = self.stop()
|
||||
self.assertEqual(a, "block")
|
||||
self.assertIn("feature", msg)
|
||||
self.assertIn("Failing checks", msg)
|
||||
|
||||
# fixed: the two ways on are offered
|
||||
self.agent_writes("done.flag", "ok\n")
|
||||
a, msg = self.stop()
|
||||
self.assertEqual(a, "block")
|
||||
self.assertIn("sisi retro", msg)
|
||||
self.assertIn("sisi unit pause", msg)
|
||||
|
||||
# paused: silent
|
||||
self.assertEqual(self.agent_runs("sisi unit pause 'the reviewer'", "unit", "pause", "the reviewer").returncode, 0)
|
||||
self.assertEqual(self.stop(), ("allow", None))
|
||||
self.assertIn("paused", self.sisi("status").stdout)
|
||||
|
||||
# a new change ends the wait; everything is green, so the two ways on come again
|
||||
self.agent_writes("app.py", "# a change\n", "Edit")
|
||||
a, msg = self.stop()
|
||||
self.assertEqual(a, "block")
|
||||
self.assertEqual(load(os.path.join(self.proj, ".sisi", "contract.json"))["status"], "open")
|
||||
|
||||
# the retro is recorded: the unit closes, is archived, and the stop is silent
|
||||
self.finding(1)
|
||||
self.assertEqual(self.stop(), ("allow", None))
|
||||
rec = load(os.path.join(self.proj, ".sisi", "units", "feature.json"))
|
||||
self.assertEqual(rec["delivery_status"], "delivered")
|
||||
out = self.sisi("status").stdout
|
||||
self.assertIn("[delivered]", out)
|
||||
self.assertIn("correctness and assurance", out)
|
||||
|
||||
# a migration with no independent evidence: sent back with the list
|
||||
self.agent_writes("migrations/001_users.sql", "CREATE TABLE users (id integer);\n")
|
||||
self.agent_runs("sisi contract init --goal 'add users'", "contract", "init", "--goal", "add users")
|
||||
c = load(os.path.join(self.proj, ".sisi", "contract.json"))
|
||||
c["id"] = "users"
|
||||
c["checks"] = [{"id": "schema", "claim": "the migration file is present", "kind": "migration", "rung": 3,
|
||||
"cmd": "test -f migrations/001_users.sql", "expect": {"exit": 0},
|
||||
"covers": "the migration is deleted"}]
|
||||
c["invariants"] = [{"id": "readme", "claim": "the readme stays", "cmd": "test -f README.md", "expect": {"exit": 0}}]
|
||||
c["requirements"] = [{"id": "r1", "kind": "explicit", "text": "a users table exists", "decision": "now"}]
|
||||
c["risk"] = {"blast_radius": "one new table; nothing reads it yet", "rollback": "drop the table"}
|
||||
c["approach"] = {"chosen": "a plain SQL migration", "why": "the project already uses them",
|
||||
"alternatives": ["an ORM auto-migration: hides the schema"]}
|
||||
self.agent_writes(os.path.join(".sisi", "contract.json"), json.dumps(c))
|
||||
a, msg = self.stop()
|
||||
self.assertEqual(a, "block")
|
||||
self.assertIn("this data change is not ready to hand over (send-back 1 of 3)", msg)
|
||||
self.assertIn("independent evidence", msg)
|
||||
self.assertLessEqual(len(msg.splitlines()), 25)
|
||||
self.migration_message = msg
|
||||
|
||||
# three send-backs in a row, then released as unverified and recorded
|
||||
self.assertEqual(self.stop()[0], "block")
|
||||
self.assertEqual(self.stop()[0], "block")
|
||||
a, msg = self.stop()
|
||||
self.assertEqual(a, "allow")
|
||||
self.assertIn("UNVERIFIED", msg)
|
||||
rows = [r for r in self.results() if r.get("check") == "gate" and r.get("status") == "unverified"]
|
||||
self.assertEqual(len(rows), 1)
|
||||
self.assertIn("independent evidence", rows[0]["reason"])
|
||||
self.assertIn("released unverified by the gate", self.sisi("status").stdout)
|
||||
self.assertEqual(self.sisi("unit", "close").returncode, 0)
|
||||
rec = load(os.path.join(self.proj, ".sisi", "units", "users.json"))
|
||||
self.assertEqual(rec["delivery_status"], "unverified")
|
||||
|
||||
self.assertEqual(self.sisi("uninstall").returncode, 0)
|
||||
|
||||
|
||||
|
||||
+931
-833
File diff suppressed because it is too large.
Load diff
+1
-1
@@ -345,7 +345,7 @@ class PauseTests(UnitCase):
|
||||
self.assertEqual(c["pauses"][0]["what"], "the owner's decision")
|
||||
stop = json.dumps({"session_id": "p1", "cwd": self.proj, "hook_event_name": "Stop", "stop_hook_active": False})
|
||||
self.sisi("tick", stdin=json.dumps({"session_id": "p1", "cwd": self.proj, "hook_event_name": "SessionStart"}))
|
||||
open(os.path.join(self.proj, "new.txt"), "w").write("x") # a change after the pause
|
||||
open(os.path.join(self.proj, "new.py"), "w").write("x = 1\n") # a change after the pause
|
||||
self.assertIn("block", self.sisi("gate", stdin=stop).stdout)
|
||||
self.assertEqual(C.load(self.contract_path)["status"], "open") # the wait ended
|
||||
self.assertTrue(C.load(self.contract_path)["pauses"][0]["until"])
|
||||
|
||||
@@ -161,17 +161,6 @@ class ShowAndChooseTests(LibCase):
|
||||
out = self.sisi("verifiers", "for", "widget").stdout
|
||||
self.assertEqual(len([l for l in out.splitlines() if l[:1].isdigit()]), 8)
|
||||
|
||||
def test_for_kind_floor_marking(self):
|
||||
self.seed()
|
||||
out = self.sisi("verifiers", "for", "parsing round trip", "--kind", "parsing").stdout
|
||||
self.assertIn("Floor: parsing claims need rung 2", out)
|
||||
self.assertIn("[floor ok]", out)
|
||||
self.put("prove/weakparse.md", vfile("weakparse", rung=4, kinds="parsing", answers="Does parsing look fine?"))
|
||||
out = self.sisi("verifiers", "for", "parsing looks fine", "--kind", "parsing").stdout
|
||||
self.assertIn("[below floor]", out)
|
||||
out = self.sisi("verifiers", "for", "page looks", "--kind", "ui").stdout
|
||||
self.assertNotIn("Floor:", out)
|
||||
|
||||
def test_for_lang_and_kind_filters(self):
|
||||
self.seed()
|
||||
out = self.sisi("verifiers", "for", "random inputs parsing", "--lang", "rust").stdout
|
||||
|
||||
@@ -45,13 +45,6 @@ class VerifyTests(SisiCase):
|
||||
r = self.run_verify(contract([check("pwd", "pwd", stdout_contains=self.proj)]))
|
||||
self.assertEqual(r.returncode, 0, r.stdout)
|
||||
|
||||
def test_floor_fails(self):
|
||||
r = self.run_verify(contract([check("m", "true", rung=3, kind="money")]))
|
||||
self.assertEqual(r.returncode, 1)
|
||||
self.assertIn("floor", r.stdout)
|
||||
r = self.run_verify(contract([check("m", "true", rung=2, kind="money")]))
|
||||
self.assertEqual(r.returncode, 0)
|
||||
|
||||
def test_no_contract_exit_2(self):
|
||||
self.assertEqual(self.sisi("verify").returncode, 2)
|
||||
|
||||
|
||||
Reference in new issue
Block a user