mirror of
https://github.com/garrytan/gstack.git
synced 2026-11-03 07:18:03 +01:00
* fix(ship): base merges, adjacent base edits, test-only and audit-requested fixes no longer force a second review loop (GST-407, GST-384, GST-391) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * ship driver: trim two phrases for headroom with #3662 Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * ship driver: keep the Next steps heading phrase the handoff check reads; trim elsewhere Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * test: regenerate ship goldens Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix: pre-landing review fixes comparePath returns same only when every hunk sits where the base change puts it (patch-ids ignore positions) and treats a file-mode change as changed; the scoped-review packet says when a fence is truncated; --docs-result must be the posted audit's result; the --context-reviewed record goes beside the packet, outside the worktree. Negative controls for each. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix: pass-2 review fixes A test edit routes as tests= only when it adds lines with no gate tag; a removed or changed line or an unreadable test diff goes through the full loop. Diffs skip textconv. A hunkless patch (binary, empty, mode-only) is same when its patch-id matches. Without --reviewed-base test files route as before. finish's packet path and attempt's state directory have fallbacks. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix: Step 11 review fixes; a version-only stamp_files edit after review is release metadata (GBRA-251) gateEditedPaths reads removed lines only inside hunks; carry refuses when a path listing fails; docs freshness stops on a failed listing; attempt counts an unreadable state file. releasePaths includes stamp_files paths whose edit is a version swap under stamp_patterns. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix: no test edit skips review; guard packet writes; exclusive attempt state A test-only edit with no gate tag gets the scoped fix-check of its test hunks instead of a lanes-only rerun. Packet write failures print a STOP or RECEIPT_CARRY_REFUSED. attempt's allowance uses an exclusive create. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix: attempt prints gstack's install command; carry checks the product diff outside context paths The attempt STOP no longer echoes the audit child's fix text. A scoped-review carry now requires the product patch-id without the context paths to match at both heads. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix: oversized packets take the full loop; exact --docs-requested match; name-only test globs only in test dirs A scoped-review packet section over 200 lines sends that path to the full loop instead of a truncated packet. The docs-result path match is exact. test_*.py, *Test.java and similar count as test code only under a test directory. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * docs(unattended): carry's scoped-review refusal and what it keeps Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * docs: carry's scoped-review route in ship-policy, review-policy and troubleshooting (docs-a-1) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * test(windows): curate ship-rereview-triggers out of the Windows lane like ship-release (run 41193336209) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix(review-log): record a notes-only /ship pass clean; name the cause and repair when a pass's tree moved (GST-430) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix(receipt): carry and write handle PRs with thousands of files; tree receipt fails closed on a failed diff (GST-448) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix(ship): preflight routes RECEIPT_CARRY_SCOPED_REVIEW to the scoped review; carry --dry-run writes no packet (GST-442) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * docs(ship): Step 1.4 and Step 16 route the scoped-review refusal and the --docs-requested fix; trims keep the cap (GST-442, GST-444) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix: /ship review pass 1: notes-only floor, scoped carry order, named temp and diff refusals - A notes-only pass is recorded clean only when every finding is fixed, or noted or deferred below the blocking floor (never CRITICAL or blocking), by its logger-stamped action, and the findings account for the claimed issue and critical counts (GST-430). - The preflight scoped carry route commits and pushes the base-merge fix before writing the packet (GST-442). - patchId refuses by name on an unwritable TMPDIR; the tree receipt names why its diff failed (GST-448). - Step 16 stage 3 spells out --docs-requested with its --docs-result (GST-444). Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * test: pin the Step 16 --docs-requested route with its --docs-result Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix: a claimed clean review row with a logger-stamped open gate finding reads UNVERIFIED (red-team, pass 1) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix: Step 11 findings: gate rows from --findings are stamped, one open rule, stale patch-id dirs swept - deriveFromFindings stamps gate rows with the session kind before deriving status, so a findings file cannot dispose of a gate finding the unattended logger forces open (outside-voice#1). - reviewFreshness reads a claimed row's findings with isOpenByAction, the rule the notes-only rewrite uses; noted and deferred clear a finding only when it is marked blocking: false and is not CRITICAL. - patchId sweeps gstack-patch-id-* directories over an hour old that a killed carry left in TMPDIR. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix: Step 11 round 2: stamped-open gates win over status and disposition; resolved gate, skipped and below-floor actions stay CURRENT - isOpenFinding treats action 'open' (the logger's forced-open stamp) as open before a row's status or disposition. - reviewFreshness flags a claimed clean row only for an 'open' action or a CRITICAL or blocking deferral or note, so interactive kept and restored gates, skipped advisories and INFORMATIONAL deferrals read CURRENT as before. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix: carry dry run offers the scoped route last; patch-id diff under the git dir; changelog matches the review-log floor Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix: a claimed clean review row with any unresolved non-gate CRITICAL finding reads UNVERIFIED (pass 2 red-team) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * docs: carry dry-run scoped route, patch-id directory, tree-receipt refusal (docs-d-1 audit) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix(ship): Step 3 names merge conflicts in its STOP sentence again (ship-workflow-clarity pin) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix(tree-receipt): keep the gated-to-current diff at the file helper timeout (60 s); pregate literals check Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * test(carry): large-diff fixture sets core.longpaths so Git for Windows can add its long receipt paths (windows-free-shard 1, run 41210080055) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix(review): a stale local base branch yields to its origin twin in gate-diff and diff-scope (GST-462) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix(ship): Step 11 saves the targeted record and the receipt writes carry it; Step 9 clears it (GST-464) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * changelog: GST-464 and GST-462 Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix(review): pass 1: ahead and diverged labels, diff-scope needs shared history; preflight refreshes origin/<base> and stops on a diff far beyond the PR (GST-462, HARN-15) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix: pass-2 review fixes for base twin, prSized stop and targeted record Resolve the tracking twin by refs/remotes/<remote>/<ref> and only for a bare branch name, keep a local base that is ahead or diverged, quote the prSized stop's base and name the fork case, and have every Step 9 entry create, exclude and clear .gstack/tmp/targeted.json. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix: origin's tracking base wins whenever related; prSized lower bound The fix-check found that keeping a local base ahead of origin left unpushed base commits out of the gate scan while review-plan listed them. The tracking branch now wins whenever it shares history with HEAD, an explicit origin/main reads refs/remotes/origin/main, the preflight also stops when the diff lists fewer files than the PR, and the Step 9 exclude line survives a missing .git/info and an exclude file without a final newline. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * changelog: the tracking-ref claim holds while the tracking branch exists Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * test: repin the two ship section briefs under no-loss replay GST-464 GST-464 brief-identity check: every reviewer brief lib/review-brief.ts cuts from ship/sections/review-army.md and adversarial.md stays byte-identical to the bodies the L and GST-257 replays admitted; only lead instructions outside the cut spans changed. The check is a test CI runs. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * ship: keep Step 9's PASS_HEAD sentence whole; repin review-army under GST-464 The targeted-record line follows the PASS_HEAD/RANGE_BASE sentence instead of splitting it (test/review-fix-range.test.ts pins that sentence). The brief-body check still holds: every reviewer brief is byte-identical. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix: restore bin/gstack-ship-receipt after the main merge The merge commitb10e2dbwrote a truncated copy of the file. This is the three-way merge of both sides with the refused() union: main's codes plus RECEIPT_CARRY_SCOPED_REVIEW. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * review-collect: narrow the consumer scan and give it one 300 s deadline (GST-544) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * review-collect: keep the consumer scan deadline under the 180 s plan timeout (review fix) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * review-collect: plain paths under --literal-pathspecs; whole-millisecond timeout override (review fix) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * review-collect: whole-tree grep for non-UTF-8 names, no argument spread, name spawn errors (review fix) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * review-collect: cap the consumer grep output at 256 MB across calls; per-scan deadline wording (review fix, cycle 4) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * review-collect: read a missing spawn status as null (Bun 1.4.2 returns undefined on ENOENT) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * test: review-collect whole-tree helper reads a null status as -1 (typecheck:test ratchet) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * review-bots: /review and /ship triage every configured review bot, not only Greptile (#3122) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix: pre-landing review fixes (gh before 2.48 pages without --slurp; driver routes Step 10; tests for guards, review-bot fence, REMOTE_SLUG owner) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix: drop the review-bot fence test that could not fail (the tool-fence WARN degrade is unreachable: placeholder spans are skipped first) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix: Step 11 review fixes (record by comment id so a filename never reaches a shell; lookup failures are errors; tojson pages; longest bot prefix wins) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix: pass-2 review fixes (record refuses * paths, colliding ids and a missing fetch dir; parent requires id and dir; botOwning doc) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * review: classify the PR type and always check repo conventions (#356) The checklist now opens with a PR-type line (application, CI/infra, scripts/tooling, docs-only or mixed). Application and mixed diffs run every category; other types always run five categories, including the new Repo Conventions & Platform Fit, and report the rest as not applicable in one line instead of skipping silently. No-loss replay: GSTA-224 H1 preregistered no-loss run (run id gsta224-h1-20261031, Opus 5.5, 81 calls, $9.53) against main's checklist with a no-gstack arm; every preregistered bar passed. The review/checklist.md pin in test/review-packets-removed.test.ts moves to a32963ef with replay 'GSTA-224 H1'. Refs GSTA-224 Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * review-bots: allowlist the record placeholders and match Step 10's id rule in tests The record fence uses <comment-id>, <fix|fp|already-fixed> and <category>, each with an enum or numeric grammar; <greptile-dir> becomes <bot-dir>. review/greptile-triage.md also lists every REVIEW_BOTS skip reason. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * docs: review-bot triage covers every configured bot (#3122) README, CONTRIBUTING, the contributor reference and standalone-binaries name gstack-review-bots and the review-bot fence; TODOS drops the #3122 item; the changelog fragment covers record-by-id and lookup errors. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * test: the PR-type test also pins the compose, Terraform and README/CHANGELOG phrases Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * test: follow the review-bot rename in the remote free tier's three reds The cross-skill consistency judge describes review-bot-history.md and its record helper; the tracker-guard exemption for the removed raw Greptile fetch in review/greptile-triage.md is dropped (the fetch now lives in gstack-review-bots, whose bodies still reach context only through gstack-issue-guard); the Step 10 PR-check test expects 'Review bots: not run'. HARNESS_VERSION stays 6: skill-fixture.ts and llm-judge.ts are recorded non-behavioral for every other case. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * test: keep the cross-skill judge's rubric to one renamed bullet Name review-bot-history.md beside the older greptile-history.md so the calibration corpus still matches, and keep the REMOTE_SLUG bullet. One live 3-sample panel at this tree: consistent 3/3, scores 4/4/4. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * changelog: H1 fragment passes prose lint Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * changelog: name the H1 fragment after its branch; TODOS drops #356 Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * docs: /review's PR type step in docs/skills.md (#356) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * ship-policy: review_exclude_paths key and loadPolicyAt (GST-508) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * review: apply the base policy's review_exclude_paths and the reviewer diff ceiling (GST-508) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * receipt: bind review_exclude in write, carry and the queue (GST-508) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * docs, tests and changelog for review_exclude_paths (GST-508) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix: pre-landing review fixes (binary by bytes, links kept, untracked files out of the selection) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix: keep binary files at code paths under review_exclude_paths Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * docs: name the reasons that keep a binary file under review_exclude_paths Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix: keep every review_exclude_paths candidate when the gate scan is unknown; docs example names its version Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * test: keep the NUL fixture clear of the sync-spawn tripwire Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * changelog: split the ceiling sentence Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix: keep a live binary file whose bytes cannot be read; tests render outside voices from a clean checkout and read the ship fixture text Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * test(review-exclude): explicit +x for the census script; skip the chmod-000 read case on Windows and root Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * refactor: move loadPolicyAt to lib/ship-policy-at.ts so lib/ship-policy.ts stays under the 800-line module cap Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix: refuse a base that contains HEAD; skip a self-pointing origin/HEAD (GST-774) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * chore: regenerate gstack-doctor-components.sh for BASE_CONTAINS_HEAD Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix: land resumes a merged merge-only PR instead of refusing BASE_CONTAINS_HEAD (GST-774 review) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * docs: changelog fragment for GST-774 Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * docs: troubleshooting names diff-scope base_contains_head and the self-pointing no_base case (GST-774 docs audit) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * test: repin the reviewer briefs to GST-508's no-loss-tested bytes ship/sections/review-army.md, ship/sections/adversarial.md and lib/review-depth.ts now pin the bytes the GST-508 preregistered no-loss replay ran atef2760f(handoffs/GSTA-202/noloss-results.md in the GStack Minder drive): Arm V 33/41 vs R 33/41, delta 4, exact sign flip, p_NI 0.0279 (pass). The merge of main83ae96eleaves these three files byte-identical toef2760f, and an Arm P unit (3593) renders byte-identical briefs atef2760fand at the merge. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix: GST-774 review round 1 — merged resume depth, aliased and detached PR checkouts, develop/trunk defaults Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * ship: Step 20 says a metrics row, keeping DRIVER.md at 12 KB after the main merge Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * test: ship-parts resend case leaves room for the first phase-3 part after the Step 9 targeted-record sentence Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix: /ship delivers review/checklist.md in two parts so checklist v1 fits the 24576-byte part cap (#3670) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * changelog: drop the GST-407 and GST-430 fragments, already released on main (stacked history) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * wave review-53cfb5bfe011: lib/ship-policy.ts back to 800 lines (module-size ratchet after merging #3744 and #3795) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * wave review-53cfb5bfe011: /ship pass 1 fixes - lib/ship-receipt-depth.ts: a merged resume (land after a true merge) no longer recomputes the review_exclude digest over the emptied range, so it lands instead of RECEIPT_INVALID (failing-first land test with review_exclude_paths active). - bin/gstack-review-dispatch render: a standalone targeted render under an active review_exclude_paths refuses and points at the pass manifest voices stage, instead of writing a brief with no selection that leaves verify dirty (failing-first test). - test/default-base.test.ts: #3795 expectations follow main R51 depth (light for an 80-line code diff; runtime_lines=80 still proves the real base). - test/review-dispatch.test.ts: the GST-897 fingerprint test renders from the clean checkout, like its neighbor, because CI rebuilds the tracked lib/diagram-render/dist/diagram-render.html and the reviewer diff ceiling refused the ROOT render. * wave review-53cfb5bfe011: /ship pass 2 fixes - lib/review-exclude.ts: binaryContent reads each blob's first 8,000 bytes (git cat-file blob, 8 KB buffer) instead of one --batch read capped at 256 MB, so head mode (receipt, carry, queue) and the plan agree past 256 MB of blobs; an unreadable blob is kept, as in live mode. Failing-first test with two 270 MB blobs. - lib/review-bots.ts: a file-level bot review comment (subject_type file, no line position) is triaged instead of read as outdated. Failing-first test. - test/ship-queue-land.test.ts: the merged-resume exclusion test runs its gate scan under the fixture state root, not the real home (CI free-suite 6 home containment). * fix: merge follow-ups for main3d99c22: origin/* stays qualified in diff-scope's twin step, retro skeleton back under its cap, combined no-loss pin GST-508+R51+GST-911 * fix(review): receipt write gate-scans whenever the base declares review_exclude_paths; collectLive never re-qualifies origin/<base> (#3852 /ship red-team#1, outside-voice#1) * test: the docs-only receipt digest test keeps its gate scan out of the real home (free-suite shard 5 FREE_SUBSHARD_REJECTED) * fix(mergefc292e22f): tentative REVIEW_EXCLUDE_KEY_VERSION, classify targeted.json, render main's new outside-voice test from a clean checkout - lib/ship-policy.ts: REVIEW_EXCLUDE_KEY_VERSION 1.93.0.0 -> 1.94.0.0, the next-minor tentative form stamp_paths moves (docs/ship-policy.md, #3512); 1.93.0.0 is a released heading that never names the key. - test/gstack-clean-producers.test.ts (new from main): KEPT gains targeted.json, the wave's --review-targeted input. - test/review-dispatch.test.ts: main's wrong-tree test rendered the outside voice from ROOT; a CI build that dirties ROOT pushes that diff past the wave's REVIEW_DIFF_MAX_BYTES ceiling, so render refused and verify saw no brief (exit 3). It now runs in cleanCheckout like the wave's other outside-voice tests. * test(merge68410828f): GST-967's brief-body pin carries the wave's GST-508 placeholders The merged sectionTexts differ from main's by exactly the wave's GST-508 exclude-pathspec lines (merged minus main equals wave minusfc292e22f); the 1,440-case plan grid still hashes to main's MAIN_PLANS. Checks: GStack Minder drive handoffs/GSTA-202/merge-6841-checks.md. * fix(mergee85005482): targeted classes since the read accept an empty range; the wave's receipt tests pass main's targeted record - lib/ship-receipt-depth.ts targetedClassesSince (main, GST-986) reads the range from the commit the targeted reader read to HEAD through headInputs, which since #3795 runs gstack-diff-scope's BASE_CONTAINS_HEAD check. When the reader read HEAD itself the range is empty, diff-scope reported base_contains_head, and every write with --review-targeted was refused (the product patch matched). It now passes merged=true (--merged), which skips only that check; an ancestor check already guards the range. - test/review-exclude.test.ts and test/review-targeted.test.ts: since #3887 write refuses a money head with no targeted record and requires the record's head, so the wave's two writes that must succeed pass one, as main's own tests do (targetedAtHead in test/ship-receipt-depth.test.ts). * test(mergee85005482): drop the wave's duplicate targeted.json KEPT entry Main (#3887) classified .gstack/tmp/targeted.json in KEPT too; the auto-merge kept both keys, which typecheck:test rejects (TS1117). Main's entry stays. * test(mergee85005482): ship size ledger entry for the merged tree (-232 B) Main's ship size ledger plus the wave's entries summed to 345,334 B; the merged tree measures 345,102 B because DRIVER.md takes main's shorter Step 19 line. Recorded with scripts/size-ledger.ts record ship. --------- Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
589 lines
41 KiB
TypeScript
589 lines
41 KiB
TypeScript
/**
|
|
* review-depth — the one policy owner for how much review a /ship run dispatches
|
|
* (docs/review-policy.md#review-depth). A pure function from the changed paths and
|
|
* their line counts, gstack-diff-scope flags, the base registry's generated outputs,
|
|
* the gate scan and the pass history to a diff class, a review depth (light,
|
|
* standard, full), the next step of the loop and the reviewers that step
|
|
* dispatches, each with its effort tier and the pathspecs it leaves out. Git reads
|
|
* live in lib/review-collect.ts; bin/gstack-review-plan prints the plan; the
|
|
* review-army resolver and the skills read the same definitions.
|
|
*/
|
|
import { createHash } from 'node:crypto';
|
|
import * as fs from 'node:fs';
|
|
import * as path from 'node:path';
|
|
import type { ResultCodeName } from './result-codes';
|
|
import { matchesAny } from './ship-policy';
|
|
import { decodeCharRefs, matchRisk, RISK_RULES, SVG_PATH, svgActive, type RiskClass } from './review-risk';
|
|
|
|
export type DiffClass = 'docs' | 'tests' | 'code' | 'gate';
|
|
export type PathClass = 'docs' | 'tests' | 'code';
|
|
export type Depth = 'light' | 'standard' | 'full';
|
|
export type Effort = 'light' | 'medium' | 'full' | 'host';
|
|
export type Role = 'specialist' | 'red-team' | 'adversarial-native' | 'outside-voice' | 'fix-check' | 'targeted';
|
|
export type Step = 'full' | 'scoped' | 'fix-check' | 'voices' | 'done' | 'stop';
|
|
|
|
export const SPECIALISTS = ['testing', 'maintainability', 'security', 'performance', 'data-migration', 'api-contract', 'design', 'simplification', 'state-machines'] as const;
|
|
export type Specialist = (typeof SPECIALISTS)[number];
|
|
/** The review rounds one /ship invocation runs (R51): a full, scoped or fix-check step is a round. */
|
|
export const FULL_PASS_CAP = 2;
|
|
export const SMALL_DIFF_LINES = 50;
|
|
export const RED_TEAM_LINES = 200;
|
|
export const LARGE_DIFF_LINES = 100;
|
|
/** The largest fix range, in runtime lines, a pass 2 after a blocking fix reviews as a scoped pass (GSTA-152 D6); a starting value. */
|
|
export const SCOPED_RANGE_LINES = 150;
|
|
/** The checklists the batched specialist always reads on code and gate class, whatever the depth or scope (GSTA-167 part 2). */
|
|
export const LIGHT_FIXED: readonly Specialist[] = ['testing', 'security'];
|
|
/** The checklists the batched specialist adds when scope asks; maintainability, performance and simplification are read only when forced. */
|
|
export const BATCH_SCOPED: readonly Specialist[] = ['data-migration', 'api-contract', 'design', 'state-machines'];
|
|
/**
|
|
* Each blocking role's effort (GSTA-167 part 3, CREW 30c): specialists at medium, which is how the no-loss controls ran
|
|
* them; the Red Team, the native adversarial pass and the fix-check at full (the lane's reasoning); the outside voice at
|
|
* its own provider's. Light's batched specialist carries the Red Team prompt, so it stays full.
|
|
*/
|
|
export const ROLE_EFFORT = { specialist: 'medium', 'red-team': 'full', 'adversarial-native': 'full', 'fix-check': 'full', 'outside-voice': 'host', targeted: 'full' } as const satisfies Record<Role, Effort>;
|
|
/** Why light with runtime above 0 keeps the native adversarial pass as its own dispatch. */
|
|
export const LIGHT_ADVERSARIAL_REASON = 'backtest inconclusive (GSTA-147 D5)';
|
|
const CLASS_RANK: Record<DiffClass, number> = { docs: 0, tests: 1, code: 2, gate: 3 };
|
|
const DEPTH_RANK: Record<Depth, number> = { light: 0, standard: 1, full: 2 };
|
|
|
|
const AGENT_PROSE = [/(^|\/)SKILL\.md(\.tmpl)?$/, /(^|\/)sections\//, /^scripts\/resolvers\//, /^docs\/[^/]*-policy\.md$/, /^docs\/(captain|unattended|pregate)\.md$/, /(^|\/)DRIVER\.md(\.tmpl)?$/, /(^|\/)templates\//, /(^|\/)(AGENTS|CLAUDE|ETHOS)\.md$/, /(^|\/)specialists\//, /(^|\/)checklist\.md$/, /^\.gstack\//];
|
|
/** gstack-diff-scope's TEST_PATH_RE (the test-bootstrap rule), plus fixture directories. */
|
|
const TEST_PATH = [/(^|\/)(tests?|spec|__tests__)\/|(^|\/)tests?\.py$|(^|\/)test_[^/]+\.py$|_test\.(go|py|rb|ts|js|exs|dart)$|\.(test|spec)\.[jt]sx?$|_spec\.rb$|Test\.(java|kt)$/, /(^|\/)fixtures?\//];
|
|
const DOC_PATH = /\.(md|mdx|markdown|rst|txt|adoc)$/i;
|
|
/** Release metadata a version stamp writes: never a reason for review depth on its own. */
|
|
const RELEASE_METADATA = [/^CHANGELOG\.md$/, /^VERSION$/, /^agents-digest\//];
|
|
/** Gate paths, the review-depth machinery included: an edit to how much review runs gets the most review. */
|
|
const GATE_PATH = [
|
|
/(^|\/)\.github\/workflows\//, /(^|\/)(secrets?|credentials?|keychain|token[s]?)([._/-]|$)/i, /state-root/, /(^|\/)(pregate|gate|ship-receipt|ship-policy)[^/]*\.(ts|sh|json)$/, /(^|\/)bin\/gstack-(pregate|gate|ship-receipt|verify-gate|ci-gate)$/,
|
|
/^lib\/review-(depth|collect|scope|targeted|risk)\.ts$/, /^review\/specialists\/targeted\.md$/, /^bin\/gstack-review-plan$/, /^lib\/ship-queue[^/]*\.ts$/, /^lib\/regen\.ts$/, /^\.gstack\/generated\.json$/, /^ship\/sections\/(review-army|adversarial)\.md\.tmpl$/, /^scripts\/resolvers\/review-army\.ts$/,
|
|
];
|
|
|
|
/** The path rules lib/review-exclude.ts keeps a matched file for: a gate path, agent prose, or a data-shaped config file. */
|
|
export const isGatePath = (p: string) => GATE_PATH.some(r => r.test(p));
|
|
export const isAgentProse = (p: string) => AGENT_PROSE.some(r => r.test(p));
|
|
export const isDataConfig = (p: string) => DATA_CONFIG.some(r => r.test(p));
|
|
|
|
/** Data files: JSON, CSV, TSV and raster images. YAML and TOML are never data here: deploy configs and API specs stay code. An SVG is data only as a drawing (svgDrawing); executable SVG stays code. */
|
|
export const DATA_PATH = /\.(json|jsonl|ndjson|csv|tsv|png|jpe?g|gif|webp|bmp|ico|avif)$/i;
|
|
/** Data-shaped files tools read by convention, with no code naming them: always code. */
|
|
const DATA_CONFIG = [
|
|
/(^|\/)\.github\//, /(^|\/)config\//, /(^|\/)\.[^/]+$/, /(^|\/)[^/]+\.config\.[^/]+$/,
|
|
/(^|\/)(package|package-lock|npm-shrinkwrap|composer|deno|jsr|tsconfig[^/]*|jsconfig[^/]*|manifest|app|vercel|netlify|firebase|renovate|turbo|nx|lerna|biome|angular|nest-cli|lint-staged|components|pyrightconfig|cdk|serverless|appsettings[^/]*)\.json$/i,
|
|
];
|
|
|
|
/**
|
|
* The SVG elements a chart is drawn with, lowercased, under any namespace prefix: shapes, text, paint servers, clip paths,
|
|
* filters (feImage loads a document, so it is left out), CSS, and the RDF metadata plotting libraries write. No script,
|
|
* foreignObject, link, animation or embedded document.
|
|
*/
|
|
const SVG_ELEMENTS = new Set([
|
|
'svg', 'g', 'defs', 'symbol', 'use', 'path', 'rect', 'circle', 'ellipse', 'line', 'polyline', 'polygon', 'text', 'tspan', 'textpath', 'title', 'desc',
|
|
'metadata', 'clippath', 'mask', 'pattern', 'marker', 'lineargradient', 'radialgradient', 'stop', 'style', 'image', 'filter',
|
|
'feblend', 'fecolormatrix', 'fecomponenttransfer', 'fecomposite', 'feconvolvematrix', 'fediffuselighting', 'fedisplacementmap', 'fedistantlight',
|
|
'fedropshadow', 'feflood', 'fefunca', 'fefuncb', 'fefuncg', 'fefuncr', 'fegaussianblur', 'femerge', 'femergenode', 'femorphology', 'feoffset',
|
|
'fepointlight', 'fespecularlighting', 'fespotlight', 'fetile', 'feturbulence',
|
|
'rdf', 'work', 'agent', 'type', 'date', 'format', 'creator', 'description', 'license',
|
|
]);
|
|
/** Markup a drawing may hold besides elements: comments, CDATA, the XML declaration, and a DOCTYPE that names no document but W3C's SVG DTD. */
|
|
const SVG_MARKUP = /^<(?:!--|!\[CDATA\[|\?xml\s|!DOCTYPE\s+svg(?:\s+PUBLIC\s+(["'])-\/\/W3C\/\/DTD SVG [\w .]+\/\/EN\1\s+(["'])https?:\/\/www\.w3\.org\/[\w.\/-]+\.dtd\2)?\s*>)/i;
|
|
/**
|
|
* What a drawing never holds: a named entity beyond the five XML ones, a backslash (a CSS escape such as @\69mport), a CSS
|
|
* import, a url() to another document, a CSS expression or binding.
|
|
*/
|
|
export const SVG_REFUSED = [/&(?!(?:amp|lt|gt|quot|apos);)/, /\\/, /@import/i, /url\((?!\s*#|['"]\s*#)/i, /expression\s*\(/i, /-moz-binding|\bbehavior\s*:/i];
|
|
/** A drawing's CSS, a style element's text or a style attribute's value, holds declarations only: no @ rule and no function but url(#id). */
|
|
const SVG_STYLE_OPEN = /<(?:[A-Za-z_][\w.-]*:)?style\b/gi;
|
|
const SVG_STYLE_CLOSE = /^<\/(?:[A-Za-z_][\w.-]*:)?style\s*>/i;
|
|
const SVG_CSS_REF = /url\(\s*(['"]?)#[\w.:-]*\1\s*\)/gi;
|
|
const SVG_CSS_REFUSED = /[@(]/;
|
|
/** An href or src value a drawing may hold: a same-document reference, or a raster image inline. */
|
|
const SVG_HREF = /^\s*(?:#|data:image\/(?:png|jpe?g|gif|webp);base64,[A-Za-z0-9+/=\s]*$)/i;
|
|
|
|
/**
|
|
* Whether an SVG's whole text is a drawing (GST-911): every element in SVG_ELEMENTS, no event handler, every href or src a
|
|
* same-document reference or an inline raster image, CSS of declarations only, and nothing SVG_REFUSED names, read after character references are
|
|
* decoded. Every name= in the text is read, so a stray quote cannot hide a later attribute inside its value; an unquoted value
|
|
* stops at the next =, which keeps the scan linear. A style element's CSS is walked with indexOf to its closing tag, dropping
|
|
* comments and reading CDATA as CSS, so neither can hide a closing tag; any other markup inside it, or a style element that never
|
|
* closes, refuses. Anything else, an SVG that can run code included, stays code.
|
|
*/
|
|
export function svgDrawing(text: string): boolean {
|
|
const t = decodeCharRefs(text);
|
|
if (SVG_REFUSED.some(r => r.test(t)) || svgActive(t)) return false;
|
|
const cssDrawing = (css: string) => !SVG_CSS_REFUSED.test(css.replace(SVG_CSS_REF, ''));
|
|
for (let at = 0; ;) {
|
|
SVG_STYLE_OPEN.lastIndex = at;
|
|
const open = SVG_STYLE_OPEN.exec(t);
|
|
if (!open) break;
|
|
let i = t.indexOf('>', open.index) + 1;
|
|
if (!i) return false;
|
|
let css = '';
|
|
for (;;) {
|
|
const lt = t.indexOf('<', i);
|
|
if (lt === -1) return false;
|
|
css += t.slice(i, lt);
|
|
if (t.startsWith('<!--', lt)) {
|
|
i = t.indexOf('-->', lt + 4) + 3;
|
|
if (i === 2) return false;
|
|
} else if (t.startsWith('<![CDATA[', lt)) {
|
|
const end = t.indexOf(']]>', lt + 9);
|
|
if (end === -1) return false;
|
|
css += t.slice(lt + 9, end);
|
|
i = end + 3;
|
|
} else if (SVG_STYLE_CLOSE.test(t.slice(lt, lt + 256))) {
|
|
at = lt + 1;
|
|
break;
|
|
} else return false;
|
|
}
|
|
if (!cssDrawing(css)) return false;
|
|
}
|
|
for (let at = t.indexOf('<'); at !== -1; at = t.indexOf('<', at + 1)) {
|
|
if (SVG_MARKUP.test(t.slice(at, at + 512))) continue;
|
|
const tag = /^<\/?(?:[A-Za-z_][\w.-]*:)?([A-Za-z_][\w.-]*)/.exec(t.slice(at, at + 256));
|
|
if (!tag || !SVG_ELEMENTS.has(tag[1]!.toLowerCase())) return false;
|
|
}
|
|
for (const m of t.matchAll(/(?<![\w.:-])([A-Za-z_][\w.:-]*)\s*=\s*(?=(?:"([^"]*)"|'([^']*)'|([^\s"'<>=]+)))/g)) {
|
|
const local = m[1]!.slice(m[1]!.lastIndexOf(':') + 1).toLowerCase();
|
|
const value = m[2] ?? m[3] ?? m[4] ?? '';
|
|
if (local.startsWith('on') || ((local === 'href' || local === 'src') && !SVG_HREF.test(value)) || (local === 'style' && !cssDrawing(value))) return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
/** A hash of the constants and patterns that decide a depth, not of this file's bytes: a comment edit keeps it, a threshold edit changes it. */
|
|
export const DEPTH_RULES = createHash('sha256').update(JSON.stringify({
|
|
RISK_RULES, SMALL_DIFF_LINES, RED_TEAM_LINES, LARGE_DIFF_LINES, FULL_PASS_CAP, LIGHT_FIXED, BATCH_SCOPED, SCOPED_RANGE_LINES, ROLE_EFFORT, SVG_ELEMENTS: [...SVG_ELEMENTS],
|
|
patterns: Object.entries({ GATE_PATH, AGENT_PROSE, TEST_PATH, RELEASE_METADATA, DOC_PATH: [DOC_PATH], DATA_PATH: [DATA_PATH], DATA_CONFIG, SVG_MARKUP: [SVG_MARKUP], SVG_REFUSED, SVG_HREF: [SVG_HREF], SVG_STYLE_OPEN: [SVG_STYLE_OPEN], SVG_STYLE_CLOSE: [SVG_STYLE_CLOSE], SVG_CSS_REF: [SVG_CSS_REF], SVG_CSS_REFUSED: [SVG_CSS_REFUSED] }).map(([k, v]) => [k, v.map(r => `/${r.source}/${r.flags}`)]),
|
|
})).digest('hex').slice(0, 16);
|
|
|
|
/**
|
|
* One changed path's class. Markdown an agent or a gate reads (skills, sections, resolvers, policy and rule docs,
|
|
* templates, any markdown in a skill directory) is code: it is gstack's product. `root` is the repository root
|
|
* (skill directories probed on disk) or the top-level skill directory names read from a commit.
|
|
*/
|
|
export function classifyPath(p: string, root?: string | readonly string[]): PathClass {
|
|
if (RELEASE_METADATA.some(r => r.test(p))) return 'docs';
|
|
if (AGENT_PROSE.some(r => r.test(p))) return 'code';
|
|
if (TEST_PATH.some(r => r.test(p))) return 'tests';
|
|
if (!DOC_PATH.test(p)) return 'code';
|
|
const top = p.includes('/') ? p.split('/')[0]! : '';
|
|
if (!top || !root) return 'docs';
|
|
if (typeof root === 'string') return ['SKILL.md', 'SKILL.md.tmpl'].some(f => fs.existsSync(path.join(root, top, f))) ? 'code' : 'docs';
|
|
return root.includes(top) ? 'code' : 'docs';
|
|
}
|
|
|
|
/**
|
|
* A code-class path the data rule may move to docs: a data extension, and not agent prose, a gate path or a config file.
|
|
* Only classifyDiff applies the rule, and only to a candidate its collector found no consumer for (ClassInput.consumed);
|
|
* classifyPath and every path-only caller keep data files code.
|
|
*/
|
|
export function dataCandidate(p: string, root?: string | readonly string[]): boolean {
|
|
return DATA_PATH.test(p) && classifyPath(p, root) === 'code' && ![...AGENT_PROSE, ...GATE_PATH, ...DATA_CONFIG].some(r => r.test(p));
|
|
}
|
|
|
|
/** An SVG the data rule may move to docs once the collector reads its whole text as a drawing (ClassInput.drawings); never a data file another file is named through. */
|
|
export function svgCandidate(p: string, root?: string | readonly string[]): boolean {
|
|
return SVG_PATH.test(p) && classifyPath(p, root) === 'code' && ![...AGENT_PROSE, ...GATE_PATH, ...DATA_CONFIG].some(r => r.test(p));
|
|
}
|
|
|
|
/** Whether a range needs the gate scan: any path that is not docs by the path-only rule. The data rule never skips it. */
|
|
export function gateScanNeeded(paths: readonly string[], root?: string | readonly string[]): boolean {
|
|
return paths.some(p => classifyPath(p, root) !== 'docs');
|
|
}
|
|
|
|
export type DepthErrorCode = 'scope_error' | 'gate_scan_unavailable' | 'registry_unavailable' | 'registry_invalid' | 'numstat_failed' | 'binary_code_path' | 'consumer_scan_failed';
|
|
/** Why a depth failed closed to full: the input it could not read, a sanitized cause and the repair; `result` is the result code behind it when one exists. */
|
|
export interface DepthError { code: DepthErrorCode; detail: string; input: string; repair: string; result?: ResultCodeName }
|
|
export interface PathLines { path: string; lines: number; binary: boolean }
|
|
/** The base commit's `.gstack/generated.json`: outputs of entries with a command only; `error` when it could not be read or validated. */
|
|
export interface RegistryInfo { sha: string | null; outputs: readonly string[]; error?: DepthError }
|
|
|
|
export interface ClassInput {
|
|
paths: readonly string[];
|
|
/** gstack-diff-scope output (SCOPE_* keys). */
|
|
scope?: Record<string, string>;
|
|
/** Gate hunks the gate scan tagged (an RH rule: a relaxed threshold, a skipped test, a loosened check); null when the scan did not run or failed. Plain test edits are listed, never tagged, and do not count. */
|
|
gateTagged: number | null;
|
|
/** Paths the diff deletes or renames away. */
|
|
deleted?: readonly string[];
|
|
/** Paths whose whole change is a version stamp (package.json's version key): classified as docs. */
|
|
stampOnly?: readonly string[];
|
|
/** The repository root, or the skill directory names at the reviewed commit: markdown inside a skill directory is code. */
|
|
root?: string | readonly string[];
|
|
/** Changed lines per path; without it a code diff counts every line as runtime. */
|
|
perPath?: readonly PathLines[];
|
|
registry?: RegistryInfo;
|
|
/** Collector failures (a diff git could not list): each fails the depth closed. */
|
|
errors?: readonly DepthError[];
|
|
/**
|
|
* The data candidates (dataCandidate) a non-docs file names at the head, the merge base or in the working tree
|
|
* (lib/review-collect.ts). A candidate not listed counts as docs; 'all' or no scan keeps every data file code.
|
|
*/
|
|
consumed?: readonly string[] | 'all';
|
|
/** Paths the diff creates (untracked files included): their added lines are the whole file. */
|
|
created?: readonly string[];
|
|
/** The SVG candidates (svgCandidate) whose whole text the collector read as a drawing (svgDrawing); any other SVG stays code. */
|
|
drawings?: readonly string[];
|
|
/** Added and deleted lines per path (lib/review-collect.ts): the risk classes read them; without them no line signal applies. */
|
|
added?: Record<string, readonly string[]>;
|
|
removed?: Record<string, readonly string[]>;
|
|
/** Paths the base policy's review_exclude_paths leave out of every reader's diff (lib/review-exclude.ts): classified as docs. */
|
|
excluded?: ReadonlySet<string>;
|
|
}
|
|
export interface ClassResult { class: DiffClass; reasons: string[]; errors: DepthError[]; runtimeLines: number | null; risk: RiskClass[] }
|
|
|
|
const sanitize = (s: string) => s.replace(/[\0-\x1f]+/g, ' ').slice(0, 200);
|
|
const isOutput = (i: ClassInput, p: string) => !!i.registry?.outputs.length && matchesAny(i.registry.outputs, p);
|
|
const unconsumedData = (i: ClassInput, p: string) => Array.isArray(i.consumed) && !i.consumed.includes(p) && (dataCandidate(p, i.root) || (!!i.drawings?.includes(p) && svgCandidate(p, i.root)));
|
|
const pathClass = (i: ClassInput, p: string): PathClass => (i.excluded?.has(p) || (i.stampOnly ?? []).includes(p) || unconsumedData(i, p) ? 'docs' : classifyPath(p, i.root));
|
|
|
|
/** The diff's class, raised to gate by any gate signal; `errors` lists every input that fails the depth closed; `runtimeLines` counts code-class lines outside the base registry's outputs. */
|
|
export function classifyDiff(i: ClassInput): ClassResult {
|
|
const reasons: string[] = [];
|
|
const errors: DepthError[] = [...(i.errors ?? [])];
|
|
let cls: DiffClass = 'docs';
|
|
const raise = (c: DiffClass, why: string) => { if (CLASS_RANK[c] > CLASS_RANK[cls]) cls = c; reasons.push(why); };
|
|
if (!i.paths.length) raise('docs', 'no changed paths');
|
|
for (const p of i.paths) { const c = pathClass(i, p); if (CLASS_RANK[c] > CLASS_RANK[cls]) raise(c, `${c}: ${p}`); }
|
|
const data = i.paths.filter(p => unconsumedData(i, p));
|
|
if (data.length) reasons.push(`docs: ${data.length} data path(s) no code names`);
|
|
const s = i.scope ?? {};
|
|
if (s.SCOPE_ERROR) {
|
|
raise('code', `scope error: ${s.SCOPE_ERROR}`);
|
|
errors.push({ code: 'scope_error', detail: sanitize(s.SCOPE_ERROR), input: 'gstack-diff-scope <base>', repair: 'run gstack-diff-scope <base> by hand and fix what it reports' });
|
|
}
|
|
if (CLASS_RANK[cls] >= CLASS_RANK.tests) {
|
|
if (i.gateTagged === null) {
|
|
raise('gate', 'gate scan unavailable');
|
|
errors.push({ code: 'gate_scan_unavailable', detail: 'gstack-gate-diff reported no GATE_SUMMARY', input: 'gstack-gate-diff <base>', repair: 'run gstack-gate-diff <base> and read its GATE_ERROR line, or pass the recorded scan as --gate-tagged <n>' });
|
|
} else if (i.gateTagged > 0) raise('gate', `gate scan tagged ${i.gateTagged} hunk(s)`);
|
|
const deletedGuarded = (i.deleted ?? []).filter(p => !i.excluded?.has(p) && classifyPath(p, i.root) !== 'docs');
|
|
if (deletedGuarded.length) raise('gate', `deletes ${deletedGuarded.length} code or test path(s)`);
|
|
}
|
|
if (CLASS_RANK[cls] >= CLASS_RANK.code) {
|
|
if (s.SCOPE_AUTH === 'true') raise('gate', 'auth paths');
|
|
if (s.SCOPE_MIGRATIONS === 'true') raise('gate', 'migrations');
|
|
for (const p of i.paths) if (GATE_PATH.some(r => r.test(p))) { raise('gate', `gate path: ${p}`); break; }
|
|
if (i.registry?.error) errors.push(i.registry.error);
|
|
}
|
|
const riskHits = CLASS_RANK[cls] >= CLASS_RANK.code ? matchRisk({ codePaths: i.paths.filter(p => pathClass(i, p) === 'code'), added: i.added, removed: i.removed, scopeAuth: s.SCOPE_AUTH === 'true' }) : new Map<RiskClass, string>();
|
|
const risk = [...riskHits.keys()];
|
|
reasons.push(...[...riskHits.values()].map(r => `risk: ${r}`));
|
|
if (!i.perPath) return { class: cls, reasons, errors, runtimeLines: null, risk };
|
|
let runtimeLines = 0;
|
|
for (const e of i.perPath) {
|
|
if (pathClass(i, e.path) !== 'code' || isOutput(i, e.path)) continue;
|
|
if (e.binary) errors.push({ code: 'binary_code_path', detail: 'git reports a binary change, so its lines cannot be counted', input: e.path, repair: "register it as an output of an entry with a command in the base branch's .gstack/generated.json, or accept the full review" });
|
|
else runtimeLines += e.lines;
|
|
}
|
|
return { class: cls, reasons, errors, runtimeLines, risk };
|
|
}
|
|
|
|
/** Risk, not size (R51): any classifier error, gate class or risk class is full; everything else is light. A floor only raises; a fixed blocker or a CRITICAL raises light to standard for the next step (planReview). */
|
|
export function depthFor(o: { cls: DiffClass; runtimeLines: number; errors: readonly DepthError[]; risk?: readonly RiskClass[]; floor?: Depth }): Depth {
|
|
const d: Depth = o.errors.length || o.cls === 'gate' || o.risk?.length ? 'full' : 'light';
|
|
return o.floor && DEPTH_RANK[o.floor] > DEPTH_RANK[d] ? o.floor : d;
|
|
}
|
|
|
|
export interface DepthResult { depth: Depth; class: DiffClass; runtimeLines: number; reasons: string[]; errors: DepthError[]; codes: ResultCodeName[]; rules: string; risk: RiskClass[] }
|
|
|
|
function decideDepth(c: ClassResult, runtimeLines: number, floor?: Depth): DepthResult {
|
|
const unfloored = depthFor({ cls: c.class, runtimeLines, errors: c.errors, risk: c.risk });
|
|
const reasons = [...c.errors.map(e => `error:${e.code}`), ...(c.class === 'gate' ? ['gate-class'] : []), ...c.risk.map(r => `risk:${r}`), `runtime=${runtimeLines}`];
|
|
if (floor && DEPTH_RANK[floor] > DEPTH_RANK[unfloored]) reasons.push(`floor:${floor}`);
|
|
const codes = [...new Set(c.errors.flatMap(e => (e.result ? [e.result] : [])))];
|
|
return { depth: depthFor({ cls: c.class, runtimeLines, errors: c.errors, risk: c.risk, floor }), class: c.class, runtimeLines, reasons, errors: c.errors, codes, rules: DEPTH_RULES, risk: c.risk };
|
|
}
|
|
|
|
/** The depth of a collected range (lib/review-collect.ts) plus a recorded gate-scan result: what the queue recomputes at a head. */
|
|
export function depthOfCommitInput(input: ClassInput & { floor?: Depth }): DepthResult {
|
|
const c = classifyDiff(input);
|
|
return decideDepth(c, c.runtimeLines ?? 0, input.floor);
|
|
}
|
|
|
|
// ---------------------------------------------------------------------------
|
|
// numeric claims: the outside voice's trigger on docs and tests diffs
|
|
// ---------------------------------------------------------------------------
|
|
const CLAIM = new RegExp([
|
|
String.raw`\d+(?:\.\d+)?\s?%`, String.raw`[$€£]\s?\d`, String.raw`\b\d+(?:\.\d+)?\s?x\b`,
|
|
String.raw`\b\d+(?:\.\d+)?\s?(?:ms|s|seconds?|minutes?|hours?|tokens?|credits?|[kKmM]tok)\b`,
|
|
String.raw`(?<![\d.])\d+\.\d+(?![\d.])`,
|
|
String.raw`[=≈<>≤≥]\s*-?\d`, String.raw`\b\d+\s*/\s*\d+\b`, String.raw`\b\d+(?:\.\d+)?e-?\d+\b`,
|
|
String.raw`\b(?:p|n|median|mean|average|rate|score|accuracy|recall|precision|speedup|faster|slower|cheaper|cost|hits?|misses)\b[^\n]{0,40}\d`,
|
|
].join('|'), 'i');
|
|
/** Not claims: dates, versions, issue numbers, step numbers. Stripped before the scan. */
|
|
const NOT_CLAIM = /\b\d{4}-\d{2}-\d{2}\b|\bv?\d+(?:\.\d+){2,}\b|#\d+\b|\b(?:step|phase|pass|rule|item|round)\s+\d+(?:\.\d+)?\b/gi;
|
|
export interface NumbersResult { publishes: boolean; claims: number; fingerprint: string }
|
|
|
|
/** Where a number is published: prose and data files. Code and test source are not publications. */
|
|
const PUBLISHED = /\.(md|mdx|markdown|rst|txt|adoc|json|csv|tsv)$/i;
|
|
|
|
/** Added lines (path → lines) → whether the diff publishes numeric claims in prose or data files, and a fingerprint of those claims and their files. */
|
|
export function scanNumbers(added: Record<string, readonly string[]>): NumbersResult {
|
|
const hits: string[] = [];
|
|
for (const p of Object.keys(added).filter(f => PUBLISHED.test(f)).sort()) for (const line of added[p] ?? []) if (CLAIM.test(line.replace(NOT_CLAIM, ' '))) hits.push(`${p}\t${line.trim()}`);
|
|
const fingerprint = hits.length ? createHash('sha256').update(hits.join('\n')).digest('hex').slice(0, 16) : 'none';
|
|
return { publishes: hits.length > 0, claims: hits.length, fingerprint };
|
|
}
|
|
|
|
// ---------------------------------------------------------------------------
|
|
// the loop: which step comes next
|
|
// ---------------------------------------------------------------------------
|
|
export interface History {
|
|
/** Full review passes already run in this invocation (0 before pass 1). */
|
|
fullPasses: number;
|
|
/** The step that just finished; none before pass 1. */
|
|
last: 'none' | 'full' | 'fix-check';
|
|
/** The finished step fixed at least one blocking finding. */
|
|
fixedBlocking?: boolean;
|
|
/** The finished step fixed findings below the floor (pass 1 only fixes those). */
|
|
fixedBelow?: boolean;
|
|
/** A blocking finding is still open in fix scope (unfixed). */
|
|
blockingOpen?: boolean;
|
|
/** A fix in the finished step touched a gate-class path. */
|
|
touchedGate?: boolean;
|
|
/** Runtime lines of the fix range (RANGE_BASE..HEAD) as classifyDiff counts them, 0 when it touches none; undefined or null when the range was not read. */
|
|
rangeRuntimeLines?: number | null;
|
|
pass1Depth?: Depth;
|
|
/** The diff is gate class (planReview sets it): Step 11's voices run before any stop. */
|
|
gate?: boolean;
|
|
/** Step 11's native adversarial pass already ran (planReview sets it from PlanInput.adversarialRan). */
|
|
adversarialRan?: boolean;
|
|
/** The approval id of the owner's recorded grant of one scoped fix-check after round 2 (review_loop_exception). */
|
|
granted?: string;
|
|
}
|
|
export interface NextStep { step: Step; reason: string }
|
|
|
|
/**
|
|
* The transition table (docs/review-policy.md#transitions). Pass 1 is full. A fixed
|
|
* blocking finding earns a second full pass on the range, scoped when `depth` (known
|
|
* only to planReview) is below full and the fix range has at most SCOPED_RANGE_LINES
|
|
* runtime lines; any other fix earns one fix-check, except a light pass whose fix range
|
|
* changes no runtime lines; two rounds is the cap (R51: a scoped pass or a fix-check is
|
|
* one): after round 2, below-floor fixes finish with notes, and a blocker open or fixed
|
|
* there, or a gate-class edit there, stops for the owner, whose grant may add one scoped fix-check.
|
|
* The cap limits fix rounds, not Step 11's voices: on gate class any stop waits for them (GST-967),
|
|
* and the owner's recorded grant (`granted`) turns the stop after a round-2 full pass with a fixed finding into its
|
|
* one fix-check; a fix-check never earns another, so the grant cannot repeat.
|
|
*/
|
|
export function nextStep(h: History, depth?: Depth): NextStep {
|
|
const n = loopStep(h, depth);
|
|
if (n.step !== 'stop') return n;
|
|
if (h.gate && !h.adversarialRan) return { step: 'voices', reason: `gate class: Step 11's voices (adversarial, outside, targeted) run before the owner's exit, then ask again with --adversarial-ran (${n.reason})` };
|
|
if (h.granted && !h.blockingOpen && h.last === 'full' && h.fullPasses === FULL_PASS_CAP) return { step: 'fix-check', reason: `the owner's grant ${h.granted} adds one scoped fix-check after round ${FULL_PASS_CAP} (review_loop_exception), never a fourth round` };
|
|
return n;
|
|
}
|
|
|
|
function loopStep(h: History, depth?: Depth): NextStep {
|
|
if (h.last === 'none') return { step: 'full', reason: 'pass 1 reviews the whole diff' };
|
|
const fixed = !!(h.fixedBlocking || h.fixedBelow);
|
|
if (h.last === 'fix-check') return h.blockingOpen || h.fixedBlocking || h.touchedGate ? { step: 'stop', reason: `the fix-check ${h.touchedGate && !h.blockingOpen && !h.fixedBlocking ? 'edited a gate-class path' : 'found a blocking finding'}: name it for the owner, whose grant may add one scoped fix-check, never a third round` } : { step: 'done', reason: fixed ? 'round cap 2 reached: the below-floor fixes ship as notes in the PR body and receipt' : 'the fix-check found nothing blocking' };
|
|
if (h.blockingOpen && h.fullPasses >= FULL_PASS_CAP) return { step: 'stop', reason: `a blocking finding is open after ${FULL_PASS_CAP} rounds: name it for the owner` };
|
|
if (h.blockingOpen) return { step: 'stop', reason: 'a blocking finding is still open in fix scope: name it for the owner' };
|
|
if (!fixed) return { step: 'done', reason: 'the step applied no edits' };
|
|
if (h.fullPasses >= FULL_PASS_CAP) return h.fixedBlocking || h.touchedGate
|
|
? { step: 'stop', reason: `${h.fixedBlocking ? 'a blocking finding was fixed' : 'a fix edited a gate-class path'} in round ${FULL_PASS_CAP}, the cap: name it for the owner, whose grant may add one scoped fix-check (review_loop_exception)` }
|
|
: { step: 'done', reason: `round cap ${FULL_PASS_CAP} reached: the below-floor fixes ship as notes in the PR body and receipt` };
|
|
if (!h.fixedBlocking && !h.touchedGate && depth === 'light' && h.rangeRuntimeLines === 0) return { step: 'done', reason: 'light depth: the below-floor fixes change no runtime lines, so they ship as notes without a fix-check' };
|
|
if (h.fixedBlocking || h.touchedGate) {
|
|
if (!h.fixedBlocking) return { step: 'full', reason: 'a fix touched a gate-class path: full pass on the range' };
|
|
const n = h.rangeRuntimeLines;
|
|
const keep = h.touchedGate ? 'a fix touched a gate-class path' : depth === undefined ? 'the depth is unknown' : h.pass1Depth === 'full' ? 'pass 1 ran at full depth' : depth === 'full' ? 'the diff is at full depth'
|
|
: typeof n !== 'number' || !Number.isFinite(n) || n < 0 ? 'the fix range was not read' : n > SCOPED_RANGE_LINES ? `the fix range has ${n} runtime lines (> ${SCOPED_RANGE_LINES})` : null;
|
|
if (keep) return { step: 'full', reason: `a blocking finding was fixed and ${keep}: full pass on the range` };
|
|
return { step: 'scoped', reason: `a blocking finding was fixed on a ${depth} diff with ${n} runtime lines in the fix range (<= ${SCOPED_RANGE_LINES}): scoped pass on the range` };
|
|
}
|
|
return { step: 'fix-check', reason: 'only below-floor fixes: one fix-check reads the touched hunks (round 2)' };
|
|
}
|
|
|
|
// ---------------------------------------------------------------------------
|
|
// the dispatch plan of one step
|
|
// ---------------------------------------------------------------------------
|
|
export interface PlanInput extends ClassInput {
|
|
diffLines: number;
|
|
history: History;
|
|
numbers: NumbersResult;
|
|
/** Specialists force-included by prompt flags; 'all' for --all-specialists. */
|
|
force?: readonly string[] | 'all';
|
|
/** Specialists the hit-rate stats tag GATE_CANDIDATE. */
|
|
gated?: readonly string[];
|
|
/** A specialist produced a CRITICAL finding (Red Team activation on code class; raises light to standard). */
|
|
criticalFound?: boolean;
|
|
/** Step 11's native adversarial pass already ran in this invocation. */
|
|
adversarialRan?: boolean;
|
|
/** The numeric-claim fingerprint the outside voice last reviewed; a change reruns it. */
|
|
reviewedNumbers?: string;
|
|
/** --depth-floor: raises the depth, never lowers it. */
|
|
floor?: Depth;
|
|
/** false under --no-tiers or review_effort_tiers off: specialists run at the host's default effort. */
|
|
tiers?: boolean;
|
|
/** The targeted classes (lib/review-targeted.ts) and whether the targeted reader already read this product patch. */
|
|
targeted?: { classes: readonly string[]; ran?: boolean };
|
|
/** The base policy's exclusion: one `:(top,exclude,glob)` pathspec per applied pattern, added to every reader, and the kept files under them as `:(top,literal)` pathspecs. */
|
|
exclusion?: { specs: readonly string[]; keep: readonly string[] };
|
|
}
|
|
/** One reviewer. `exclude` holds git pathspec argv items the reviewer's diff leaves out; `checklists` names what the batched specialist reads. */
|
|
export interface Dispatch { role: Role; name: string; effort: Effort; exclude: string[]; checklists?: string[]; reason?: string; keep?: string[] }
|
|
export interface ReviewPlan extends DepthResult {
|
|
/** The depth this step runs at: light raised to standard by a fixed blocker, a CRITICAL or an open blocker. */
|
|
stepDepth: Depth;
|
|
depthReasons: string[];
|
|
next: NextStep; numbers: NumbersResult; dispatches: Dispatch[]; skipped: string[];
|
|
}
|
|
|
|
const scopeWants: Partial<Record<Specialist, (s: Record<string, string>) => boolean>> = {
|
|
performance: s => s.SCOPE_BACKEND === 'true' || s.SCOPE_FRONTEND === 'true',
|
|
'data-migration': s => s.SCOPE_MIGRATIONS === 'true',
|
|
'api-contract': s => s.SCOPE_API === 'true',
|
|
design: s => s.SCOPE_FRONTEND === 'true',
|
|
'state-machines': s => s.SCOPE_STATE_MACHINE === 'true' || s.SCOPE_STATE_MACHINE === 'unknown' || s.SCOPE_STATE_MACHINE === undefined,
|
|
};
|
|
const forcedBy = (i: PlanInput) => (n: string) => i.force === 'all' || (Array.isArray(i.force) && i.force.includes(n));
|
|
|
|
/** The specialists a full pass selects for a class: class sets the eligible set, hit-rate gating applies inside it, gate class ignores gating. */
|
|
export function specialistsFor(cls: DiffClass, i: PlanInput, skipped: string[] = []): Specialist[] {
|
|
const s = i.scope ?? {};
|
|
const forced = forcedBy(i);
|
|
if (cls === 'docs') { skipped.push('specialists (docs class)'); return SPECIALISTS.filter(forced); }
|
|
if (cls === 'tests') { skipped.push('specialists except testing (tests class)'); return SPECIALISTS.filter(n => n === 'testing' || forced(n)); }
|
|
const want = (n: Specialist): boolean => {
|
|
if (forced(n)) return true;
|
|
if (n === 'state-machines') return scopeWants[n]!(s);
|
|
if (i.diffLines < SMALL_DIFF_LINES) return false;
|
|
switch (n) {
|
|
case 'testing': case 'maintainability': return true;
|
|
case 'security': return s.SCOPE_AUTH === 'true' || (s.SCOPE_BACKEND === 'true' && i.diffLines > LARGE_DIFF_LINES);
|
|
case 'simplification': return i.diffLines > LARGE_DIFF_LINES;
|
|
default: return scopeWants[n]!(s);
|
|
}
|
|
};
|
|
return SPECIALISTS.filter(n => {
|
|
if (!want(n)) return false;
|
|
if (cls !== 'gate' && !forced(n) && (i.gated ?? []).includes(n)) { skipped.push(`${n} (gated by hit rate)`); return false; }
|
|
return true;
|
|
});
|
|
}
|
|
|
|
/**
|
|
* The checklists the one batched specialist reads (the lean ensemble, GSTA-167 part 2): the class sets the base (none for docs,
|
|
* testing for tests, LIGHT_FIXED for code and gate), BATCH_SCOPED joins when scope asks and hit-rate gating allows (gate class
|
|
* ignores gating), and a forced checklist always joins.
|
|
*/
|
|
export function batchChecklists(cls: DiffClass, i: PlanInput, skipped: string[] = []): Specialist[] {
|
|
const forced = forcedBy(i);
|
|
const codeLike = cls === 'code' || cls === 'gate';
|
|
const base: readonly Specialist[] = codeLike ? LIGHT_FIXED : cls === 'tests' ? ['testing'] : [];
|
|
if (cls === 'docs') skipped.push('specialists (docs class)');
|
|
if (cls === 'tests') skipped.push('specialists except testing (tests class)');
|
|
const extra = SPECIALISTS.filter(n => {
|
|
if (base.includes(n)) return false;
|
|
if (forced(n)) return true;
|
|
if (!codeLike || !BATCH_SCOPED.includes(n) || !scopeWants[n]!(i.scope ?? {})) return false;
|
|
if (cls !== 'gate' && (i.gated ?? []).includes(n)) { skipped.push(`${n} (gated by hit rate)`); return false; }
|
|
return true;
|
|
});
|
|
const dropped = SPECIALISTS.filter(n => codeLike && !BATCH_SCOPED.includes(n) && !base.includes(n) && !extra.includes(n));
|
|
if (dropped.length) skipped.push(`${dropped.join(', ')} (lean ensemble: read only when forced)`);
|
|
return [...base, ...extra];
|
|
}
|
|
|
|
/** A path as one git exclude pathspec; a glob character or a leading colon makes it literal. */
|
|
const excludeSpec = (p: string) => `:(exclude${/[*?[\]\\]/.test(p) || p.startsWith(':') ? ',literal' : ''})${p}`;
|
|
const shellQuote = (s: string) => `'${s.replace(/'/g, "'\\''")}'`;
|
|
|
|
/** The diff command a dispatched reviewer runs; `<diff-base>` is the literal sha the parent writes in. */
|
|
export function diffCommand(d: Dispatch): string {
|
|
return d.exclude.length ? `git diff <diff-base> -- . ${d.exclude.map(shellQuote).join(' ')}` : 'git diff <diff-base>';
|
|
}
|
|
|
|
/** The second command a reader runs when the base policy's exclusion keeps files its patterns match (a git exclude beats any positive pathspec); null otherwise. */
|
|
export function keepCommand(d: Dispatch): string | null {
|
|
return d.keep?.length ? `git diff <diff-base> -- ${d.keep.map(shellQuote).join(' ')}` : null;
|
|
}
|
|
|
|
/** The reviewers the next step dispatches at its depth, with each role's effort tier and excluded pathspecs. */
|
|
export function planReview(i: PlanInput): ReviewPlan {
|
|
const c = classifyDiff(i);
|
|
const depth = decideDepth(c, c.runtimeLines ?? (CLASS_RANK[c.class] >= CLASS_RANK.code ? i.diffLines : 0), i.floor);
|
|
const { class: cls, runtimeLines } = depth;
|
|
const next = nextStep({ ...i.history, gate: cls === 'gate', adversarialRan: !!i.adversarialRan }, depth.depth);
|
|
const h = i.history;
|
|
const raise = depth.depth === 'light' && (h.fixedBlocking || h.blockingOpen || i.criticalFound);
|
|
const stepDepth: Depth = raise ? 'standard' : depth.depth;
|
|
const depthReasons = [...depth.reasons, ...(raise ? [`history:${h.fixedBlocking ? 'fixed-blocking' : h.blockingOpen ? 'blocking-open' : 'critical-found'}`] : [])];
|
|
const skipped: string[] = [];
|
|
const dispatches: Dispatch[] = [];
|
|
const x = i.exclusion;
|
|
const add = (role: Role, name: string, effort: Effort, exclude: string[] = [], extra: Partial<Dispatch> = {}) =>
|
|
dispatches.push({ role, name, effort, exclude: x ? [...exclude, ...x.specs] : exclude, ...extra, ...(x?.keep.length ? { keep: [...x.keep] } : {}) });
|
|
const docsAndOutputs = i.paths.filter(p => !i.excluded?.has(p) && ((pathClass(i, p) === 'docs' && !(i.numbers.publishes && DOC_PATH.test(p))) || isOutput(i, p))).map(excludeSpec);
|
|
const numbersChanged = i.numbers.publishes && i.reviewedNumbers !== undefined && i.reviewedNumbers !== i.numbers.fingerprint;
|
|
const firstVoices = h.fullPasses === 0 || !i.adversarialRan;
|
|
const specialist: Effort = i.tiers === false ? 'host' : ROLE_EFFORT.specialist;
|
|
if (next.step === 'full' && stepDepth === 'light') {
|
|
const forced = forcedBy(i);
|
|
if (runtimeLines > 0) {
|
|
add('specialist', 'batched', ROLE_EFFORT['red-team'], docsAndOutputs, { checklists: [...batchChecklists('code', i, skipped), 'red-team'] });
|
|
skipped.push('red-team (light depth: the batched specialist carries the Red Team prompt)');
|
|
if (firstVoices) add('adversarial-native', 'adversarial', 'full', [], { reason: LIGHT_ADVERSARIAL_REASON });
|
|
} else {
|
|
for (const n of SPECIALISTS.filter(forced)) add('specialist', n, specialist);
|
|
skipped.push('specialists, red-team and adversarial-native (light depth, runtime 0)');
|
|
}
|
|
if (h.fullPasses === 0 && i.numbers.publishes) add('outside-voice', 'outside-voice', 'host');
|
|
else if (numbersChanged) add('outside-voice', 'outside-voice (numbers changed)', 'host');
|
|
else skipped.push(`outside-voice (${cls} class, no numeric claims)`);
|
|
} else if (next.step === 'full') {
|
|
const full = stepDepth === 'full';
|
|
const dcls: DiffClass = full ? 'gate' : cls;
|
|
const raised = !full && (raise || runtimeLines <= SMALL_DIFF_LINES);
|
|
const lines = full ? i.diffLines : Math.max(runtimeLines, raised ? SMALL_DIFF_LINES : 0);
|
|
const checklists = batchChecklists(dcls, i, skipped);
|
|
if (checklists.length) add('specialist', 'batched', specialist, full ? [] : docsAndOutputs, { checklists });
|
|
const redTeam = dcls === 'gate' || (dcls === 'code' && (lines > RED_TEAM_LINES || !!i.criticalFound || raised));
|
|
if (redTeam) add('red-team', 'red-team', 'full');
|
|
else skipped.push(`red-team (${dcls} class${dcls === 'code' ? `, ${lines} runtime lines, no critical` : ''})`);
|
|
const codeLike = dcls === 'code' || dcls === 'gate';
|
|
if (h.fullPasses === 0 || (!i.adversarialRan && codeLike)) {
|
|
if (codeLike) add('adversarial-native', 'adversarial', 'full');
|
|
else skipped.push(`adversarial-native (${dcls} class)`);
|
|
if (codeLike || i.numbers.publishes) add('outside-voice', 'outside-voice', 'host');
|
|
else skipped.push(`outside-voice (${dcls} class, no numeric claims)`);
|
|
} else {
|
|
skipped.push('adversarial-native and outside-voice (run once per invocation)');
|
|
if (numbersChanged) add('outside-voice', 'outside-voice (numbers changed)', 'host');
|
|
}
|
|
} else if (next.step === 'scoped') {
|
|
add('fix-check', 'fix-check', 'full');
|
|
const forced = SPECIALISTS.filter(forcedBy(i));
|
|
for (const n of forced) add('specialist', n, specialist);
|
|
skipped.push(forced.length ? 'specialists (scoped pass; forced ones dispatched)' : 'specialists (scoped pass)');
|
|
add('red-team', 'red-team', 'full');
|
|
const stepElevenPending = !i.adversarialRan && cls === 'code';
|
|
if ((h.rangeRuntimeLines ?? 0) > 0 || stepElevenPending) add('adversarial-native', 'adversarial', 'full');
|
|
else skipped.push('adversarial-native (scoped pass: the fix range changes no runtime lines)');
|
|
if (stepElevenPending) add('outside-voice', 'outside-voice', 'host');
|
|
else if (numbersChanged) add('outside-voice', 'outside-voice (numbers changed)', 'host');
|
|
else skipped.push('outside-voice (scoped pass)');
|
|
} else if (next.step === 'fix-check') {
|
|
add('fix-check', 'fix-check', 'full');
|
|
if (numbersChanged) add('outside-voice', 'outside-voice (numbers changed)', 'host');
|
|
} else if (next.step === 'voices') {
|
|
add('adversarial-native', 'adversarial', 'full');
|
|
add('outside-voice', 'outside-voice', 'host');
|
|
}
|
|
if (i.targeted?.classes.length && ['full', 'scoped', 'fix-check', 'voices'].includes(next.step)) {
|
|
if (i.targeted.ran) skipped.push('targeted (already read this product patch)');
|
|
else add('targeted', 'targeted', ROLE_EFFORT.targeted);
|
|
}
|
|
return { ...depth, stepDepth, depthReasons, reasons: c.reasons, next, numbers: i.numbers, dispatches, skipped };
|
|
}
|
|
|
|
export function reviewPlanLine(p: ReviewPlan, pass: number): string {
|
|
return `REVIEW_PLAN: class=${p.class} pass=${pass} next=${p.next.step} dispatches=${p.dispatches.length} numbers=${p.numbers.publishes ? `yes(${p.numbers.claims})` : 'no'} fingerprint=${p.numbers.fingerprint} reason=${JSON.stringify(p.next.reason)}`;
|
|
}
|
|
|
|
export function reviewDepthLine(p: ReviewPlan): string {
|
|
return `REVIEW_DEPTH: ${p.depth} runtime_lines=${p.runtimeLines} rules=${p.rules} reasons=${p.depthReasons.join(',')} codes=${p.codes.join(',') || 'none'}${p.stepDepth !== p.depth ? ` step=${p.stepDepth}` : ''}`;
|
|
}
|