mirror of
https://github.com/garrytan/gstack.git
synced 2026-11-07 01:15:47 +01:00
* fix(flaky): repair the five paid gate detectors and the judged review/plan-review prose (GSTA-128)
Daily flaky pass over the 2026-10-27 Open ledger entries, paid cases first.
- ship-docsync-store (40458489644, 40477638211): docsync-observer admitted only
`git branch --show-current`; both captured parents' fourth call was a read ending
in `git branch -a`. Operand-free branch listings are now part of the read grammar.
- ship-docsync-completion (40465691803): the parent ran two /document-release
dispatches and wrote the accepted second section into the report while the case
compared the first. The contract now follows the last foreground dispatch.
- ship-local-hook-preservation (40467320097): the red reply delegated the guard to
the repo owner ("have someone wire the guard in by hand"); toUser now reads a
determiner-led phrasal object and owner/maintainer/someone + themselves.
- plan-design-finding-floor (x2): the pending menu asked to cover all 7 dimensions
without the word "focus"; the picker now reads that question shape.
- Judge cases: plan-review headers no longer offer a "(or unverified)" branch the
four-mode preflight can never print; /review's Scope Check is emitted in Step 3
after the full diff read; the small-diff rule and the specialists record agree on
State Machines; Step 5.8.2 names which post-fix rerun rule governs. Nearby prose
tightened so review, ship and plan-eng-review stay at their parity caps; shrunk
size pins lowered per the guard's own instruction.
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
* test(plan-review): expect the renamed routing row ('Any other mode') in the Eng provider case
The GSTA-128 prose repair renamed the plan-review routing row from 'other preflight mode, including harness mismatch' to 'Any other mode (not_installed, under_current_harness)'; test/plan-review-cases.test.ts:657 still asserted the old text and failed quick-bun-default on #3516 (run 40524518937).
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
* test(eval-select): register the three new free fixtures in FREE_FIXTURES
eval: select reported docsync-branch-listing-public.json, docsync-two-attempts-public.json and design-floor-focus-cover-all.json as unknown dependencies (needs touchfile entry) and fell back to the full gate on that alone. Each is read only by a free test, so they belong in FREE_FIXTURES beside their siblings.
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
* fix(review): pre-landing review fixes for the paid flaky-case repairs
Pass 1 of /ship's review loop on #3516 (core, four specialists, native and
outside adversarial, Red Team). Fixed in the diff:
- test/skill-e2e-ship-docsync.test.ts: the two-attempt retained-edit filter
dropped a path from changedPaths even when the accepted contract's
files_updated claimed it, so an honest re-audit that re-edits the same
document read as 'unreported edits'. acceptedChangedPaths() in
test/helpers/docsync-contract.ts keeps a retained path the accepted
contract claims; the free replay proves the old filter red on that shape.
- test/helpers/ship-hook-actor.ts: the owner+reflexive manual-integration arm
credited a denial ('so the owner does not have to do it themselves') or a
first-person claim. ownersOwnHand() requires a hook noun, rejects a
negation before the reflexive and a first-person subject; probes added.
- scripts/resolvers/plan-gates.ts + review/sections/manifest.json: the
no-plan path still said 'Emit Step 1.5's Scope Check once' and the STOP
trigger 'finishing Step 1.5's Scope Check', the circular prerequisite gate
40454750574 flagged, on the path most reviews take. Both now point at
Step 3 ('Step 3 emits the Scope Check once without plan fields';
'Before leaving Step 1.5').
- review/SKILL.md.tmpl: Step 3 item 5 emits the Scope Check on the first
pass only (a fix-range repeat pass reads a partial diff by construction);
two prose tightenings keep the review skeleton under its pins, which are
lowered by 3 on the eight pinned hosts.
- test/helpers/docsync-interface.ts: the declared branch-listing class now
enumerates the exact flag set DOCS_BRANCH_LIST_FLAGS accepts.
Coverage audit (Step 7) tests: plan-review and doc-review run headers admit
only the CODEX_MODE values their preflight prints
(test/outside-voice-preflight.test.ts); the final Scope Check is emitted
once in Step 3 and every owner names that point, no-plan path and STOP
trigger included (test/review-workflow-clarity.test.ts).
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
* fix(ship-hook-actor): read the owner's denial in the owner's own clause
Review pass 2 on #3516 (State Machines, with the same site flagged by every
other reviewer): the pass-1 negation guard in ownersOwnHand() scanned the
whole sentence prefix before the reflexive, so an honest request after a
negated subordinate clause ("Since the installer did not run, the repo owner
needs to add the guard to the existing hooks themselves") was refused, a
recall regression against ee73419 that would red the paid
ship-local-hook-preservation case. The guard now reads the clause from the
last owner noun to the reflexive, and its contraction alternative matches
"doesn't"/"won't" (the pass-1 form sat behind a word boundary and never
matched). Three credited and two refused probes added; the credited ones
fail on the pass-1 helper.
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
* docs(changelog): [Unreleased] entry for the GSTA-128 paid flaky-case repairs
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
* docs(changelog): count the four repaired gate detectors, not five
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
* test(parity): re-pin ship maxSizeRatio 1.7524 -> 1.7525 on the main-merged tree
The review-army small-diff clause (+5 union bytes) lands on a main that
sat 4 bytes under the ship cap after #3515 and #3517: 328,932 -> 328,937
/ 187,706 = 1.7524 both ways at four places, so the pin moves one in the
last place. GStack Minder's rule 19 grant for #3516 after train 26 free
run 40556676971 failed test/parity-suite.test.ts. Before/after and the
reason are in the CHANGELOG entry.
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
* RESTAMP: 1.91.280.0 -> 1.91.281.0 (stamped; queue_mode=stamp-at-merge base=origin/main@703b0049ebbe policy=base origin/main@703b0049ebbe:.gstack/ship-policy.json)
ship, next in queue at 1.91.281.0
STAMP_VERSION: 1.91.281.0
claims: ignored (stamp-at-merge)
stage version: done (wrote 1.91.281.0)
stage release_tool: done (bun scripts/gen-agents-digest.ts)
stage changelog: done (Unreleased -> 1.91.281.0)
stage stamp_paths: skipped (no tentative mention newer than the fork version 1.91.276.0 and none of base 1.91.280.0 on a line this branch added)
stage mirror: skipped (no mirror in policy)
stage apply: done (4 file(s))
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 5d8184d56..4363f3d7b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,6 +1,6 @@
# Changelog
-## [Unreleased]
+## [1.91.281.0] - 2026-10-27
**Four paid gate detectors stop judging honest transcripts red, and /review's Scope Check has one emission point.** The 2026-10-27 flaky pass (GSTA-128) read each red transcript and repaired the detector or the prose it judged, never the threshold.
diff --git a/VERSION b/VERSION
index 3d95d3946..12d5f1cc7 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-1.91.280.0
+1.91.281.0
diff --git a/agents-digest/gstack-AGENTS.md b/agents-digest/gstack-AGENTS.md
index 15ac5e105..2b8121978 100644
--- a/agents-digest/gstack-AGENTS.md
+++ b/agents-digest/gstack-AGENTS.md
@@ -1,4 +1,4 @@
-# gstack digest v1.91.280.0 — regenerate/re-copy after upgrading gstack
+# gstack digest v1.91.281.0 — regenerate/re-copy after upgrading gstack
Behavioral rules from gstack (https://github.com/garrytan/gstack), compressed
for agent hosts without a full skill install. The full skills add workflows,
diff --git a/node_modules b/node_modules
new file mode 120000
index 000000000..858ae29ce
--- /dev/null
+++ b/node_modules
@@ -0,0 +1 @@
+/workspace/gstack/node_modules
\ No newline at end of file
diff --git a/package.json b/package.json
index d0c1012d7..4a7a5d6cb 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "gstack",
- "version": "1.91.280",
+ "version": "1.91.281",
"description": "Garry's Stack — Claude Code skills + fast headless browser. One repo, one install, entire AI engineering workflow.",
"license": "MIT",
"type": "module",
FILES: CHANGELOG.md VERSION agents-digest/gstack-AGENTS.md package.json
MERGE_CONDITION: sha=d0ed2d938ef4c98352a53ea27ce3596824068568
next: NEW_VERSION=1.91.281.0; commit and push only the stamp diff above (FILES), with no edit of your own: the train's verify accepts the CHANGELOG only as the base's plus this PR's entry re-headed; merge with the expected head d0ed2d938e and recompute on a stale queue.
GSTACK_RESULT: skill=restamp status=complete run=/workspace/gstack/.gstack/tmp/restamp-journal.json
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
---------
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
349 lines
21 KiB
TypeScript
349 lines
21 KiB
TypeScript
/**
|
||
* Review Army resolver — parallel specialist reviewers for /review
|
||
*
|
||
* Generates template prose that instructs Claude to:
|
||
* 1. Detect stack and scope (via gstack-diff-scope)
|
||
* 2. Select and dispatch specialist subagents in parallel
|
||
* 3. Collect, parse, merge, and deduplicate JSON findings
|
||
* 4. Feed merged findings into the existing Fix-First pipeline
|
||
*
|
||
* Shipped as Release 2 of the self-learning roadmap (SELF_LEARNING_V0.md).
|
||
*/
|
||
import type { TemplateContext } from './types';
|
||
import { CC_BACKGROUND_DEFAULT_SINCE, FOREGROUND_IF_AVAILABLE, BACKGROUND_RECOVERY } from './constants';
|
||
import { learningsCapture, LEARNINGS_VERDICT } from './learnings';
|
||
import { DEFENSIVE_REVIEW_FRAMING, FIXTURE_SUMMARY_MODE } from './defensive-review';
|
||
|
||
function generateSpecialistSelection(ctx: TemplateContext): string {
|
||
const isShip = ctx.skillName === 'ship';
|
||
const stepSel = isShip ? '9.1' : '4.5';
|
||
const stepMerge = isShip ? '9.2' : '4.6';
|
||
const nextStep = isShip ? 'Step 9.3 (cross-review dedup)' : 'Step 4.8 (adversarial review), then Step 5';
|
||
return `## Step ${stepSel}: Review Army — Specialist Dispatch
|
||
|
||
### Detect stack and scope
|
||
|
||
\`\`\`bash
|
||
_SM=$(${ctx.paths.binDir}/gstack-state-matrix detect --base <base>) || _SM=SCOPE_STATE_MACHINE=unknown; source <(echo "$_SM")
|
||
source <(${ctx.paths.binDir}/gstack-diff-scope <base> 2>/dev/null) || true
|
||
set | grep '^SCOPE_'
|
||
STACK=""
|
||
[ -f Gemfile ] && STACK="\${STACK}ruby "
|
||
[ -f package.json ] && STACK="\${STACK}node "
|
||
[ -f requirements.txt ] || [ -f pyproject.toml ] && STACK="\${STACK}python "
|
||
[ -f go.mod ] && STACK="\${STACK}go "
|
||
[ -f Cargo.toml ] && STACK="\${STACK}rust "
|
||
[ -f pubspec.yaml ] && STACK="\${STACK}dart "
|
||
echo "STACK: \${STACK:-unknown}"
|
||
DIFF_BASE=$(git merge-base origin/<base> HEAD)
|
||
DIFF_LINES=$(git diff "$DIFF_BASE" --numstat | awk '{n+=$1+$2} END {print n+0}')
|
||
echo "DIFF_LINES: $DIFF_LINES"
|
||
# Detect test framework
|
||
TEST_FW=""
|
||
{ [ -f jest.config.ts ] || [ -f jest.config.js ]; } && TEST_FW="jest"
|
||
[ -f vitest.config.ts ] && TEST_FW="vitest"
|
||
{ [ -f spec/spec_helper.rb ] || [ -f .rspec ]; } && TEST_FW="rspec"
|
||
{ [ -f pytest.ini ] || [ -f conftest.py ]; } && TEST_FW="pytest"
|
||
[ -f go.mod ] && TEST_FW="go-test"
|
||
[ -f pubspec.yaml ] && TEST_FW="dart-test" && grep -qsE '^ +sdk: *.?flutter' pubspec.yaml && TEST_FW="flutter-test"
|
||
echo "TEST_FW: \${TEST_FW:-unknown}"
|
||
\`\`\`
|
||
|
||
### Read specialist hit rates (adaptive gating)
|
||
|
||
\`\`\`bash
|
||
${ctx.paths.binDir}/gstack-specialist-stats 2>/dev/null || true
|
||
\`\`\`
|
||
|
||
### Select specialists
|
||
|
||
Select specialists from the scope signals above.
|
||
|
||
**Always-on (every review with 50+ changed lines):**
|
||
1. **Testing** — read \`${ctx.paths.skillRoot}/review/specialists/testing.md\`
|
||
2. **Maintainability** — read \`${ctx.paths.skillRoot}/review/specialists/maintainability.md\`
|
||
|
||
**If DIFF_LINES < 50:** Skip all specialists except State Machines (item 9 decides it). Print: "Small diff ($DIFF_LINES lines) — specialists skipped." Continue to Step ${stepMerge} with the ${isShip ? 'core/design-lite' : 'core'} findings and an empty or State Machines-only specialist list, then the parent's Exploratory QA step and ${nextStep}. Small diffs skip fan-out, never the parent-owned smoke probes or core shared-code checks.
|
||
|
||
**Conditional (dispatch when its scope signal is true):**
|
||
3. **Security** — if SCOPE_AUTH=true, OR if SCOPE_BACKEND=true AND DIFF_LINES > 100. Read \`${ctx.paths.skillRoot}/review/specialists/security.md\`
|
||
4. **Performance** — if SCOPE_BACKEND=true OR SCOPE_FRONTEND=true. Read \`${ctx.paths.skillRoot}/review/specialists/performance.md\`
|
||
5. **Data Migration** — if SCOPE_MIGRATIONS=true. Read \`${ctx.paths.skillRoot}/review/specialists/data-migration.md\`
|
||
6. **API Contract** — if SCOPE_API=true. Read \`${ctx.paths.skillRoot}/review/specialists/api-contract.md\`
|
||
7. **Design** — if SCOPE_FRONTEND=true. Use the existing design review checklist at \`${ctx.paths.skillRoot}/review/design-checklist.md\` and run the mechanical pass at the top of that checklist (the user-installed design detector, when present) before the LLM items
|
||
8. **Simplification** — if DIFF_LINES > 100. Read \`${ctx.paths.skillRoot}/review/specialists/simplification.md\`. Advisory-only lens: hunts unrequested structure (hand-rolled stdlib, one-implementation abstractions, dependencies duplicating platform features), never coverage.
|
||
9. **State Machines** — if SCOPE_STATE_MACHINE is true or unknown: read \`${ctx.paths.skillRoot}/review/specialists/state-machines.md\`, run \`${ctx.paths.binDir}/gstack-state-matrix outfile\`, Read the file it prints, write the full output there, then run \`${ctx.paths.binDir}/gstack-state-matrix check <file>\` on it.
|
||
|
||
### Adaptive gating
|
||
|
||
After scope-based selection, apply adaptive gating based on specialist hit rates:
|
||
|
||
For each conditional specialist that passed scope gating, read the \`gstack-specialist-stats\` output:
|
||
- If tagged \`[GATE_CANDIDATE]\` (0 findings in 10+ dispatches): skip it. Print: "[specialist] auto-gated (0 findings in N reviews)."
|
||
- If tagged \`[NEVER_GATE]\`: always dispatch regardless of hit rate.
|
||
|
||
**Force flags:** \`--<specialist>\` (e.g. \`--simplification\`) or \`--all-specialists\` in the prompt force-includes it.
|
||
|
||
Print the selection:
|
||
"Dispatching N specialists: [names]. Skipped: [names] (scope not detected). Gated: [names] (0 findings in N+ reviews)."`;
|
||
}
|
||
|
||
/**
|
||
* The diff command every dispatched reviewer runs. In /ship the parent writes the
|
||
* base sha into the prompt (the merge base on pass 1, RANGE_BASE from pass 2 on):
|
||
* a reviewer is its own process and never sees the parent's shell variables, so a
|
||
* `$RANGE_BASE` reference there would silently fall back to the whole branch.
|
||
*/
|
||
function diffBase(ctx: TemplateContext): string {
|
||
return ctx.skillName === 'ship' ? 'DIFF_BASE=<diff-base>' : 'DIFF_BASE=$(git merge-base origin/<base> HEAD)';
|
||
}
|
||
|
||
function generateSpecialistDispatch(ctx: TemplateContext): string {
|
||
return `### Dispatch specialists in parallel
|
||
|
||
For each selected specialist, launch an independent subagent via the Agent tool.
|
||
**Launch ALL selected specialists in a single message** (multiple Agent tool calls)
|
||
so they run in parallel. Each subagent has fresh context — no prior review bias.
|
||
${ctx.skillName === 'ship' ? `
|
||
**Fan-out (\`--review-fanout auto|serial|parallel\` in the prompt; default \`auto\`).**
|
||
Under \`auto\`, when the host reports fewer free subagent slots than selected
|
||
specialists (Capy caps a thread at 8 running subagents, and waiting or idle ones hold
|
||
a slot), dispatch in batches of the free-slot count, at least one per batch, each
|
||
batch in one message, and start the next batch only after every reader of the
|
||
previous one has finished or is confirmed stopped; print \`Fan-out: N specialists in
|
||
M batches of K\`. A host that reports no slot count runs one parallel batch.
|
||
\`serial\` is batches of one; \`parallel\` is one batch regardless of slots (a refused
|
||
launch is a failed reader, never silently dropped coverage). Batching changes the
|
||
order, never the set: every selected specialist still runs before Step 9.2 merges.
|
||
` : ''}
|
||
**Each specialist subagent prompt:**
|
||
|
||
Each specialist prompt includes:
|
||
|
||
1. The specialist's checklist path from the selection above (the subagent reads it; never paste its content)
|
||
2. Stack context: "This is a {STACK} project."
|
||
3. Past learnings for this domain (if any exist):
|
||
|
||
\`\`\`bash
|
||
${learningsCapture(`${ctx.paths.binDir}/gstack-learnings-search --type pitfall --query "{specialist domain}" --limit 5`)}
|
||
${LEARNINGS_VERDICT}
|
||
\`\`\`
|
||
|
||
If learnings are found, include them: "Past learnings for this domain: {learnings}"
|
||
|
||
4. **Defensive framing (Security specialist and the Red Team below only).** Begin the prompt with:
|
||
"${DEFENSIVE_REVIEW_FRAMING}"
|
||
and replace its full-diff command with: "${FIXTURE_SUMMARY_MODE}"
|
||
Every other specialist, including Testing, reads the full diff with fixtures.
|
||
|
||
5. Instructions:
|
||
|
||
"You are a specialist code reviewer. Read the checklist at {checklist path}, then run
|
||
\`${diffBase(ctx)} && git diff "$DIFF_BASE"\` to get the ${ctx.skillName === 'ship' ? 'diff (`<diff-base>`: write the sha in before dispatch, the merge base on pass 1 and `RANGE_BASE` from pass 2 on; never a shell variable)' : 'full diff'}. Apply the checklist against the diff.
|
||
|
||
\`NO FINDINGS\` alone is the expected, complete result for a clean diff; never invent an item to show work. Otherwise output one JSON object per finding, on its own line:
|
||
{\\"severity\\":\\"CRITICAL|INFORMATIONAL\\",\\"confidence\\":N,\\"path\\":\\"file\\",\\"line\\":N,\\"category\\":\\"category\\",\\"summary\\":\\"description\\",\\"fix\\":\\"recommended fix\\",\\"fingerprint\\":\\"path:line:category\\",\\"specialist\\":\\"name\\"}
|
||
|
||
Required fields: severity, confidence, path, category, summary, specialist.
|
||
Optional: line, fix, fingerprint, evidence, test_stub, advisory, evidence_paths, helper_target, cause.
|
||
CRITICAL means a test that would fail, a production break, or a security or data-loss defect; everything else is INFORMATIONAL.
|
||
A defect the diff causes but that shows elsewhere (a caller broken by a changed signature, a consumer of a removed export) keeps the victim as \`path\` and names the changed line in \`cause\`: {\\"cause\\":{\\"path\\":\\"file\\",\\"line\\":N}}. Without it the finding reads as pre-existing code.
|
||
|
||
Leave extraction advice to the core shared-code check; report real defects in duplicated code independently, keep advisory metadata on structural advice, and never call a demonstrated defect advisory because a shared helper could fix it.
|
||
|
||
If you can write a test that would catch this issue, include it in the \`test_stub\` field.
|
||
Use the detected test framework ({TEST_FW}). Write a minimal skeleton — describe/it/test
|
||
blocks with clear intent. Skip test_stub for architectural or design-only findings.
|
||
|
||
Output nothing else: no preamble, no summary or commentary.
|
||
|
||
Stack context: {STACK}
|
||
Past learnings: {learnings or 'none'}"
|
||
|
||
**Subagent configuration:**
|
||
- Use \`subagent_type: "general-purpose"\`
|
||
- Pass ${FOREGROUND_IF_AVAILABLE} on every specialist Agent call — background is the default since ${CC_BACKGROUND_DEFAULT_SINCE}; omitting an available flag is not foreground. ${BACKGROUND_RECOVERY}
|
||
|
||
**Wait for readers before editing:**
|
||
- Confirm that each task has finished or is stopped. A timeout alone does not prove termination. If a reader or writer is still active, wait; if its state is unknown, inspect its task/process status. If you cannot confirm it stopped, use the parent's Fix-First stop path without edits.
|
||
- A failed task may be stopped without having completed its review. Record the failure and retain usable partial findings.
|
||
- Continue independent evidence collection after a terminal failure. Missing dispatched coverage remains incomplete, never completed or clean; successful peers cannot replace it.`;
|
||
}
|
||
|
||
function generateFindingsMerge(ctx: TemplateContext): string {
|
||
const isShip = ctx.skillName === 'ship';
|
||
const stepMerge = isShip ? '9.2' : '4.6';
|
||
const fixFirstRef = isShip ? 'Step 9.3 dedup, then Step 9.4 Fix-First' : 'Step 5 Fix-First';
|
||
const critPassRef = isShip ? 'the checklist pass (Step 9)' : 'the CRITICAL pass findings from Step 4';
|
||
const persistRef = isShip ? 'the review-log persist' : 'the review-log entry in Step 5.8';
|
||
return `### Step ${stepMerge}: Collect and merge findings
|
||
|
||
Follow these stages in order. Validate core and specialist findings alike, but keep
|
||
their source labels: specialist scoring is not the final review's defect count.
|
||
|
||
#### 1. Parse outputs
|
||
|
||
After specialist attempts settle, collect their outputs, tagged by actual source.
|
||
\`NO FINDINGS\` is a completed, clean result, never a failed reviewer. Otherwise parse
|
||
each JSON line and skip invalid lines. Missing or unusable output is incomplete
|
||
coverage, not an empty success. Keep each specialist's returned findings for activity stats.
|
||
|
||
#### 2. Validate severity
|
||
|
||
For core and specialist findings with \`"severity":"CRITICAL"\` and \`"advisory":true\`,
|
||
remove \`advisory\` and retain its \`CRITICAL\` severity. Treat these as defects before
|
||
identity, merging, counting, scoring or Fix-First. Never downgrade severity to make
|
||
advisory metadata consistent. Valid INFORMATIONAL advisories remain advisory in
|
||
every category, including simplification.
|
||
|
||
#### 3. Identify and merge
|
||
|
||
Partition defects and advisories BEFORE grouping by fingerprint. Never merge a
|
||
defect with advice, even on a supplied-hash collision. Neither higher-confidence
|
||
advice nor a prior skipped extraction may replace, downgrade or suppress a defect.
|
||
|
||
Compute identities for both core and specialist findings:
|
||
- Shared-code advice (category \`shared-libs\` or fingerprint prefix \`shared-libs:\`):
|
||
call installed \`sharedLibsFingerprint\` from \`${ctx.paths.skillRoot}/lib/review-evidence.ts\`
|
||
with \`evidence_paths\` and \`helper_target\` as literal JSON on stdin, as in the core pass;
|
||
never trust a supplied hash or generate one yourself. Missing/malformed metadata
|
||
cannot deduplicate or reuse a saved decision.
|
||
- Other findings: use supplied \`fingerprint\`, else \`{path}:{line}:{category}\`
|
||
or \`{path}:{category}\` when no line exists.
|
||
|
||
Within the specialist list, merge matching identities in the same partition: keep
|
||
the highest confidence and all source names. Confirmation by distinct specialists adds +1 (cap at 10) and \`MULTI-SPECIALIST CONFIRMED ({specialist1} + {specialist2})\`.
|
||
Core findings never earn a specialist confidence boost. Preserve \`advisory\`,
|
||
\`evidence_paths\` and \`helper_target\` through every merge.
|
||
|
||
#### 4. Lead judgment
|
||
|
||
Reviewers fill the space they are given. Before a merged finding counts, the
|
||
parent reads it and drops or downgrades it on these grounds, saying so:
|
||
- **Nit gravity.** A reviewer whose whole return is style, naming and preference
|
||
found nothing; say so and count no defect.
|
||
- **Hypothetical, not actual.** A defect names the call site or input that reaches
|
||
it; one that does not is a note until someone traces it.
|
||
- **Structure for a case that does not exist.** Advice to abstract, generalize or
|
||
guard a path nothing takes is advisory.
|
||
- **A different design is not a defect.** "I would have done it differently" with
|
||
no failing case is dropped.
|
||
- **Missing context.** A finding that assumes a rule the repository documents
|
||
otherwise is dropped with the pointer.
|
||
- **On record.** A class \`docs/review-policy.md\` rules below the floor is a note,
|
||
named by its ruling.
|
||
Independent agreement between reviewers is the strongest signal (the
|
||
\`MULTI-SPECIALIST CONFIRMED\` boost records it). A reviewer that
|
||
returned \`NO FINDINGS\` was right until a traced defect says otherwise.
|
||
|
||
#### 5. Apply specialist confidence gates
|
||
|
||
- Confidence 7+: show normally in the findings output
|
||
- Confidence 5-6: show with caveat "Medium confidence — verify this is actually an issue"
|
||
- Confidence 3-4: move to appendix (suppress from main findings)
|
||
- Confidence 1-2: suppress entirely
|
||
|
||
Core findings keep the core Confidence Calibration gates.
|
||
|
||
#### 6. Score and present specialists
|
||
|
||
Only specialist findings enter this header and \`quality_score\`; core findings do not.
|
||
Use the merged NON-advisory specialist findings for both counts and score;
|
||
the header's N is X + Y, so advisory findings never add to it:
|
||
\`quality_score = max(0, 10 - (critical_count * 2 + informational_count * 0.5))\`
|
||
Cap at 10 and retain for ${persistRef}. These are not final unresolved-defect totals.
|
||
Print only this block: the stage 7 activity object and \`test_stub\` bodies are log and Fix-First data.
|
||
Validated \`"advisory": true\` findings from any source are excluded from score,
|
||
header, unresolved-defect totals and clean-status blockers. Show them separately;
|
||
they remain ASK-only, never auto-applied. Real defects follow normal Fix-First.
|
||
|
||
\`\`\`
|
||
SPECIALIST REVIEW: N findings (X critical, Y informational) from Z specialists
|
||
|
||
[For each finding, in order: CRITICAL first, then INFORMATIONAL, sorted by confidence descending;
|
||
advisory findings last, each rendered with an [ADVISORY] label in place of the severity]
|
||
[SEVERITY] (confidence: N/10, specialist: name) path:line — summary
|
||
Fix: recommended fix
|
||
[If MULTI-SPECIALIST CONFIRMED: show confirmation note]
|
||
|
||
PR Quality Score: X/10
|
||
\`\`\`
|
||
|
||
**Simplification footer (after the score line):**
|
||
- If the simplification specialist was dispatched and returned findings, sum
|
||
their \`lines_removable\` values and print: \`net: -N lines possible\` (omit
|
||
findings without the field from the sum).
|
||
- If it was dispatched and returned NO FINDINGS, print:
|
||
\`Simplification: lean already — nothing to cut.\`
|
||
- If it was not dispatched, print neither line.
|
||
|
||
Core shared-code savings never enter this footer; explain any overlap once in the core proposal.
|
||
|
||
#### 7. Save specialist activity
|
||
|
||
Compile a \`specialists\` object for ${persistRef}.
|
||
${isShip ? 'For each specialist' : 'For DIFF_LINES < 50, keep `specialists: {}` (or `state-machines` alone when it dispatched); do not manufacture per-specialist scope records. Otherwise record each considered specialist'} (testing, maintainability, security, performance, data-migration, api-contract, design, simplification, state-machines, red-team):
|
||
- If dispatched: \`{"dispatched": true, "findings": N, "critical": N, "informational": N}\`
|
||
- If skipped by scope: \`{"dispatched": false, "reason": "scope"}\`
|
||
- If skipped by gating: \`{"dispatched": false, "reason": "gated"}\`
|
||
- If not applicable (e.g., red-team not activated): omit from the object
|
||
|
||
Count only findings that specialist actually returned, before deduplication.
|
||
Advisory findings COUNT in the stats \`findings\` field, not its defect counts.
|
||
Include Design despite its different checklist. Preserve dispatch/failure status:
|
||
zero returned findings from a failed attempt is not a clean review.
|
||
|
||
#### 8. Hand off to Fix-First
|
||
|
||
Send these findings to ${fixFirstRef} alongside ${critPassRef}.
|
||
Consolidate equivalent shared-code advice under the core proposal, retaining all
|
||
sources and counting overlapping savings once. Keep actual specialist stats;
|
||
core-only advice must not create a specialist dispatch or finding.
|
||
Normal AUTO-FIX/ASK rules apply, with advice ASK-only. Missing coverage still blocks
|
||
completion. Advice never permits edits while readers are active or replaces a required review.`;
|
||
}
|
||
|
||
function generateRedTeam(ctx: TemplateContext): string {
|
||
const isShip = ctx.skillName === 'ship';
|
||
const stepMerge = isShip ? '9.2' : '4.6';
|
||
const fixFirstRef = isShip ? 'Step 9.3 dedup, then Step 9.4 Fix-First' : 'Step 5 Fix-First';
|
||
return `### Red Team dispatch (conditional)
|
||
|
||
**Activation:** Only if DIFF_LINES > 200 OR any specialist produced a CRITICAL finding.
|
||
|
||
If activated, dispatch one more subagent via the Agent tool (pass ${FOREGROUND_IF_AVAILABLE} — foreground; subagents default to background since ${CC_BACKGROUND_DEFAULT_SINCE}; ${BACKGROUND_RECOVERY})
|
||
|
||
The Red Team subagent receives:
|
||
1. The red-team checklist path \`${ctx.paths.skillRoot}/review/specialists/red-team.md\` (it reads the file)
|
||
2. The merged specialist findings from Step ${stepMerge}, one line each (so it knows what was already caught)
|
||
3. The git diff command
|
||
|
||
Prompt, after the defensive framing and fixture handling from item 4 of the specialist dispatch: "You are a red team reviewer. The code has already been reviewed by N specialists
|
||
who found the following issues: {merged findings summary}. Your job is to find what they
|
||
MISSED. Read the checklist at {red-team checklist path}, list changed files with \`${diffBase(ctx)} && git diff --name-status "$DIFF_BASE"\`, read them as that fixture handling says, and look for gaps.
|
||
Output findings as JSON objects (same schema as the specialists), or \`NO FINDINGS\` alone, the expected result when they missed nothing. Focus on cross-cutting
|
||
concerns, integration boundary issues, and failure modes that specialist checklists
|
||
don't cover."
|
||
|
||
Tag Red Team findings \`"specialist":"red-team"\`.
|
||
Add them to the original specialist outputs and rerun stages 1–8 of Step ${stepMerge}
|
||
before ${fixFirstRef}; do not boost or count the earlier findings twice.
|
||
|
||
If the Red Team returns NO FINDINGS, note: "Red Team review: no additional issues found."
|
||
If the Red Team fails or times out, confirm it stopped and record its review as incomplete, just as for other specialists. ${isShip ? "Return to the parent's Exploratory QA step, then dedup and persistence; Step 9.4 cannot certify missing dispatched coverage as completed or clean." : 'Continue independent Step 4.7 QA and Step 4.8 adversarial review; Step 5.8 cannot certify missing dispatched coverage as completed or clean.'}`;
|
||
}
|
||
|
||
export function generateReviewArmy(ctx: TemplateContext): string {
|
||
// Codex host: strip entirely — Codex should not run Review Army
|
||
if (ctx.host === 'codex') return '';
|
||
|
||
const sections = [
|
||
generateSpecialistSelection(ctx),
|
||
generateSpecialistDispatch(ctx),
|
||
generateFindingsMerge(ctx),
|
||
generateRedTeam(ctx),
|
||
];
|
||
|
||
return sections.join('\n\n---\n\n');
|
||
}
|