Files
msd-core/tests/effort-surface-axis.test.cjs
Tom Boucher 3f6b063fbb chore(#2799): invoke_reviewers and write_reviews iterate declared lanes (#2861)
* chore(#2799): resolve reviewer lanes into executable invocation plans

Phase 5b of ADR-2782. Adds the resolver and runner that let invoke_reviewers
iterate declared lanes instead of hand-authored per-CLI bash.

Five additive descriptor amendments, each forced by a lane that ships today:
- LaneHandler gains 'opencode' — the lane rebuilds its review from assistant
  text parts of a --format json stream; a plain stdout copy re-breaks #1936.
- modelConfigKey — antigravity's key is review.models.agy, not .antigravity,
  so resolving by slug silently dropped a configured model.
- defaultHost/fallbackModel — Phase 4 federated every *_host with a default of
  empty string; the real fallback only existed in the bash.
- args becomes an argv template with a closed four-placeholder vocabulary.
  Positional splicing produced 'codex --model M -o F exec --ephemeral', which
  is not a valid invocation: codex injects in the middle, twice.
- kimi-code lane, with the bounded command-capability probe (needle
  --output-format) that tells Kimi Code from the legacy python kimi-cli.

Parity gate re-pointed: the workflow-text families it scanned are the text this
phase deletes, so they are replaced by descriptor-to-registry parity plus an
anti-parity check that no bespoke leg returns.

jq, curl and external timeout/gtimeout all drop out of the review path.

Refs #2782

* chore(#2799): add review-lane query surface and widen the manifest vocabulary

Adds the gsd-tools 'review-lane' route (plan/invoke/sections) the workflow
loops over, projects all twelve lanes into their capability manifests, and
widens capability-validator for the amendments.

opencode admitted to VALID_LANE_HANDLERS under the second arm of the enum's
own admission rule: one lane, justified by a documented upstream defect data
cannot express (#1936 — the agent can end its turn with zero output tokens and
--format default then drops the assistant text entirely).

Two bugs caught by an end-to-end stub run and fixed here:
- loadConfigResolved returns a provenance wrapper, not the config; using it
  directly resolved every key to undefined, which reads as 'nothing
  configured' and silently dropped every model override.
- hasBinary used shell:true with an args array (Node 26 DEP0190). Replaced
  with a PATH scan that spawns nothing at all.

Refs #2782

* chore(#2799): iterate declared lanes in invoke_reviewers and write_reviews

Replaces the eleven hand-authored per-CLI bash legs with a loop over resolved
lanes, and renders REVIEWS.md sections from each lane's declared
reviewsSection instead of thirteen hardcoded headings. review.md drops from
1104 lines to 507 (61KB to 28.7KB).

Parity gate re-pointed, as agreed: the leg-marker and section-heading families
scanned exactly the text this phase deletes, so they are replaced by
descriptor-to-registry parity in both directions, plus an anti-parity check
that fires if a bespoke leg is ever re-added. Enum, emitting sites and the
Object.keys lock moved together.

The budget-trim helper is hoisted out of the Ollama leg: it was always
lane-agnostic, and any lane may now declare a promptBudgetKey.

Refs #2782

* feat(#2799): bind the consented egress host and re-verify it at invocation

Completes ADR-2782 D5. Rule 1 was recorded in the ADR as delivered by Phase 3
but was not implemented: ConsentRecord had no host field and nothing in the
tree bound one, so this phase's rule-4 comparison had no baseline.

ConsentRecord gains an OPTIONAL reviewerHost. Optional is the whole design:
isValidConsentRecord does not require it, so every record already on disk
stays valid and no re-consent storm fires (D4 rule 5). It is deliberately
excluded from disclosureSignature — the loader has no config resolver, so
folding a config-derived value in would make loader and lifecycle compute
different signatures for the same manifest and re-prompt forever.

Install resolves hostConfigKey (falling back to the lane's declared
defaultHost, which is what the invocation path uses) and records it.
Invocation re-resolves and blocks on mismatch rather than silently
redirecting. Absence allows: no record, or a record predating the field,
means nothing to compare — denying there would break every existing
local-model user on upgrade.

Refs #2782

* test(#2799): cover the resolver, runner and handlers; retarget the parity suites

Adds the golden invocation-plan table (one row per shipped lane, derived from
the bash legs rather than the descriptor types) plus runner coverage for the
probe, empty-output policy, the three handlers and the egress check.

Retargets the existing suites onto the new contract: descriptor-to-registry
parity, the anti-parity check, the opencode handler, and the twelfth lane.

Two corrections found by running them:
- modelConfigKey was required; that breaks D4 rule 2, since a reviewer
  manifest authored before this phase would fail validation on upgrade. It is
  optional, read as null when absent.
- the antigravity non-zero-exit test pre-seeded the transcript, which asserted
  that a STALE entry leaks through — the exact bug the watermark prevents. The
  spawn now appends, as the real tool does.

Refs #2782

* fix(#2799): restore agy --add-dir and the self-report prompt in the handler

Retargeting the three legacy reviewer suites off the deleted bash surfaced two
real regressions in the port, both #2176:

- --add-dir was dropped. Without it agy's permission context never receives the
  cwd repo, so the agent anchors on its own scratch dir and reviews the plan
  text in isolation — the exact failure the Review Instructions forbid. It is
  capability-probed, because an older agy rejects the unknown flag outright and
  a lane that fails to start is worse than one running on the prompt anchor.
- the prompt lost the clause mandating a REVIEWED-WITHOUT-REPO-ACCESS
  self-report, which is what makes a blind review distinguishable from a
  grounded one. antigravity now builds its own prompt variant.

Also ports the #2073 mode-2 cli.log diagnostic, which was dropped: a pinned
model that 404s exits 0 with empty stdout AND an empty transcript, so agy's own
log is the only evidence that anything failed.

The three suites now assert against the plan and the handler instead of
matching fence text, so they no longer need allow-test-rule exemptions.

Refs #2782

* docs(#2799): document the declared lanes, the new flag, and dropped prerequisites

COMMANDS.md gains --kimi-code and replaces the jq-prerequisite paragraph,
which is now false: no lane requires jq, curl or an external timeout. Adds the
changed-egress-destination behavior, since a blocked lane is something a user
can hit.

CONFIGURATION.md records that the model config key is declared per lane rather
than derived from the flag — antigravity's is review.models.agy — and adds
review.models.kimi-code.

reviewer-instances.md now routes an instance through its lane's single
invocation seam instead of a copied per-adapter bash block, which is what lets
a cross-cutting fix reach instances for free. That required implementing the
--model/--agent/--as flags it documents; --model re-resolves through the lane's
argv template rather than splicing, so the flag lands where the lane declares
it rather than ahead of a subcommand.

CONTEXT.md glossary gains both new modules.

Refs #2782

* chore(#2799): drop the stale emitted-drift acknowledgment

The only entry was #2797's, acknowledging COMMENT-ONLY GROWTH in review.md.
That file now shrinks by ~32KB and every emitted hash that moved is
attributable to this diff, so the ack no longer explains anything. Removing
the last entry means removing the file: its presence is the alarm, and an
empty one signals nothing.

Verified by deleting it and re-running the attribution and provenance gates
plus lint:ci — all green without it.

Refs #2782

* docs(#2799): record the Phase 5b vocabulary widenings in ADR-2782

Five additive amendments, each forced by a lane that ships today, plus two
corrections the phase had to make rather than work around:

- D5 rule 1 was recorded as delivered by Phase 3 and was not implemented, so
  this phase's rule-4 comparison had no baseline. Recorded because an ADR
  asserting a rule was delivered is exactly what stops a later phase checking.
- The DEFECT.GENERATIVE-FIX gate is re-pointed: its workflow-text families
  scanned the text this phase deletes.

Also records that D7's 'skip the probe where no bounding mechanism exists'
carve-out is obsolete — in practice it meant the Antigravity lane ran unbounded
on every stock macOS host, which ships neither timeout nor gtimeout.

Refs #2782

* fix(#2799): close four defects found by adversarial review

Two confirmed bugs, both reproduced before fixing:

- resolveLanePlan was not total. An openai-http lane with a missing or
  non-object invoke dereferenced inv.hostConfigKey and threw, contradicting
  the module's own documented contract; the spawn branch guarded correctly and
  the http branch did not. The CLI seam resolves every selected lane in one
  map, so one malformed overlay manifest would have aborted the whole review
  rather than dropping its own lane. Guarded, plus a per-lane try/catch at the
  seam so a throw can never take down siblings.
- A reviewer-instance model was silently dropped for any lane declaring
  modelConfigKey null (cursor, qwen, coderabbit). reviewer_instances validates
  that cli is a known slug but never that the slug accepts a model, so a user
  could configure one, get a clean run, and never learn a different model
  reviewed their plan. Now warns explicitly.

Two hardening fixes:

- The slug is concatenated into artifact paths, so LANE_SLUG_RE is enforced in
  the resolver rather than inherited from a validator that does not run on this
  path — the module documents itself as the overlay-manifest trust boundary, so
  it should not depend on someone else having checked.
- normalizeHost mangled a scheme-less value: new URL('localhost:11434') parses
  with an empty hostname, so it became 'localhost://11434' and was compared and
  requested as if real. An empty hostname now means not-a-URL.

Also documents the one gap that cannot be closed here: the antigravity
watermark is keyed by workspace, so two concurrent reviews of the same repo
share a transcript. agy exposes no per-invocation id to filter on, so the
handler now states which half of its never-stale guarantee actually holds.

Refs #2782

* test(#2799): retarget the remaining eight review.md-asserting suites

The remote runner found 37 failures the local sweep missed (it hit the shell's
two-minute cap before reaching these). All eight extract per-CLI bash from
review.md that this phase deletes; each protects a real invariant, so each is
retargeted onto the plan, the runner or the handler rather than removed.

Three real defects surfaced by doing so:

- effort args never reached ANY lane. model-resolver.cjs exports no
  resolveExecution, so effortFor silently returned [] every time. Restored by
  calling the same bounded resolve-execution query the bash legs used — and
  NOT with --raw, which prints the resolved effort rather than the picked
  field, so claude got 'low' instead of '--effort low'.
- the timeout guidance lost 'a silent empty output is a timeout kill, not a
  crash' — the operator note that exists because of the Codex 0xc0000142
  misdiagnosis. Restored.
- the opencode handler dropped EMPTY assistant text parts. The shipped jq was
  , and  only substitutes for false/null — an empty
  string is truthy in jq and contributed a blank line. Found by a property
  test shrinking to ['', ''].

The opencode property suite no longer spawns jq at all, which deletes the
#2099 hang mechanism it was architected around rather than mitigating it.

Refs #2782

* fix(#2799): register the two new generated modules, and untrack them

The remote runner caught build output committed to git. Both new modules
compile from src/*.cts into gsd-core/bin/lib/*.cjs, and every sibling generated
that way is gitignored and eslint-ignored (ADR-457) - including Phase 1's own
review-lane-descriptor.cjs. Mine were neither, so repo-invariants' "each
bin/lib/*.cjs is linted xor ignored according to migration state" failed.

Registered both in .gitignore and eslint.config.mjs alongside the Phase 1
module, and dropped them from the index. Nothing about the shipped behaviour
changes; the artifacts are rebuilt by build:lib.

This is the new-.cts-module registration ripple, and it is the one part of it I
had not completed - the CONTEXT.md glossary and the inventory manifest were
already done.

Refs #2782

* chore(#2799): backfill changeset pr number to 2861

* chore(#2799): backfill changeset pr number to 2861

---------

Co-authored-by: Test <test@example.com>
2026-07-30 12:48:06 -04:00

435 lines
18 KiB
JavaScript

// allow-test-rule: source-text-is-the-product (see #2481)
// The final describe block asserts on gsd-core/workflows/review.md's text. A
// workflow .md IS what the runtime loads — its literal command lines are the
// deployed contract, and there is no runtime seam that executes review.md here.
// Every other block in this file is behavioral (CLI + module surface).
/**
* #2481 — ADR-1239 `effortSurface` axis + ADR-443 path (a).
*
* Before this change effort reached a runtime only through install-time channels
* (EFFORT_RENDERING's `frontmatter`/`api`), so a reviewer CLI spawned as a
* subprocess silently inherited whatever effort sat in the user's own global CLI
* config. These tests pin the invocation-time channel: the negotiated axis that
* decides WHETHER effort is deliverable, the renderer that knows the syntax, and
* the live orchestration path that carries it.
*/
const { describe, test } = require('node:test');
const assert = require('node:assert/strict');
const fs = require('node:fs');
const path = require('node:path');
const fc = require('fast-check');
const { runGsdTools, createTempProject, cleanup } = require('./helpers.cjs');
const REPO_ROOT = path.resolve(__dirname, '..');
const {
renderEffortArgv,
EFFORT_ARGV,
} = require(path.join(REPO_ROOT, 'gsd-core', 'bin', 'lib', 'model-catalog.cjs'));
const {
HOST_INTEGRATION_AXES,
negotiateHostCapabilities,
degradationFor,
} = require(path.join(REPO_ROOT, 'gsd-core', 'bin', 'lib', 'host-integration.cjs'));
const {
_HOST_INTEGRATION_VOCAB,
validateRuntimeBody,
} = require(path.join(REPO_ROOT, 'gsd-core', 'bin', 'lib', 'capability-validator.cjs'));
/**
* A real shipped descriptor with one hostIntegration axis stripped.
*
* Deriving the fixture from a descriptor this gate did not author satisfies the
* fixture-provenance rule (#2371) — a hand-built body would only ever encode the
* author's mental model of a valid descriptor, which is how the required-axis
* defect reached the runner in the first place.
*/
function shippedDescriptorWithout(axis) {
const cap = JSON.parse(
fs.readFileSync(path.join(REPO_ROOT, 'capabilities', 'vscode', 'capability.json'), 'utf8'),
);
delete cap.runtime.hostIntegration[axis];
return cap;
}
/** Write a project whose effort cascade resolves to a known universal value. */
function projectWithEffort(effort) {
const dir = createTempProject();
fs.writeFileSync(
path.join(dir, '.planning', 'config.json'),
JSON.stringify({ effort: { default: effort } }, null, 2),
);
return dir;
}
describe('#2481 effortSurface — closed vocabulary', () => {
test('is exactly argv|none — no config-file member', () => {
// Gemini CLI was the only host with a config-file effort surface and was
// removed as a sunset runtime (8f2ebbe9b / #1928 / PR #1996). A member no
// supported host can claim would invite guessed descriptor values.
assert.deepEqual([...HOST_INTEGRATION_AXES.effortSurface], ['argv', 'none']);
});
test('engine vocabulary and validator mirror agree (parity guard)', () => {
assert.deepEqual(
[...HOST_INTEGRATION_AXES.effortSurface],
[..._HOST_INTEGRATION_VOCAB.effortSurface],
);
});
test('undocumented is NOT a vocabulary member — it is the corpus sentinel', () => {
assert.ok(!HOST_INTEGRATION_AXES.effortSurface.includes('undocumented'));
});
});
describe('#2481 effortSurface — negotiation fails closed', () => {
const cases = [
['argv declared', 'argv', 'argv'],
['undocumented sentinel', 'undocumented', 'none'],
['retired value (config-file)', 'config-file', 'none'],
['unknown/future value', 'quantum-telepathy', 'none'],
['empty string', '', 'none'],
['none declared', 'none', 'none'],
];
for (const [label, declared, expected] of cases) {
test(`${label} -> ${expected}`, () => {
const r = negotiateHostCapabilities({ protocolVersion: 1, modelMode: 'active', effortSurface: declared });
assert.equal(r.effective.effortSurface, expected);
});
}
test('axis omitted entirely -> safe floor, and the omission is warned', () => {
const r = negotiateHostCapabilities({ protocolVersion: 1, modelMode: 'active' });
assert.equal(r.effective.effortSurface, 'none');
assert.ok(r.warnings.some((w) => String(w).includes('effortSurface')));
});
test('a descriptor that omits the axis entirely still validates clean', () => {
// The axis was added after descriptors existed. Requiring it would invalidate
// every pre-existing descriptor — including third-party ones — and break the
// "purely additive" property ADR-1239 promises for external descriptors.
// Regression guard: 48 suites failed across both node lanes when it was required.
const cap = shippedDescriptorWithout('effortSurface');
const errors = validateRuntimeBody(cap);
assert.deepEqual(
errors, [],
`a descriptor without effortSurface must validate clean, got: ${JSON.stringify(errors)}`,
);
});
test('optional does not mean unvalidated — a present bad value is still rejected', () => {
const cap = shippedDescriptorWithout('effortSurface');
cap.runtime.hostIntegration.effortSurface = 'config-file'; // retired value
const errors = validateRuntimeBody(cap);
assert.ok(
errors.some((e) => String(e).includes('effortSurface')),
`a present invalid value must error, got: ${JSON.stringify(errors)}`,
);
});
test('an undeclared axis is never invented from a profile baseline', () => {
// Regression guard for the failure this axis was designed against: a
// programmatic-cli host must not inherit `argv` merely by being programmatic.
const r = negotiateHostCapabilities({
protocolVersion: 1,
embeddingMode: 'imperative',
commandSurface: 'slash-file',
modelMode: 'active',
});
assert.equal(r.effective.effortSurface, 'none');
});
});
describe('#2481 effortSurface — is its own axis, not folded into the model point', () => {
test('the model interface point still grades on modelMode alone', () => {
// Deliberate: modelMode has graded interface point 3 since Phase A. Widening
// it to also mean "delivers effort" would silently redefine that contract for
// every existing consumer. Effort is read from effective.effortSurface.
assert.equal(degradationFor('model', { modelMode: 'active' }).level, 'full');
assert.equal(degradationFor('model', { modelMode: 'passive' }).level, 'degraded');
});
test('declaring an effort surface does not change the model point', () => {
for (const es of ['argv', 'none', 'undocumented', undefined]) {
assert.equal(degradationFor('model', { modelMode: 'active', effortSurface: es }).level, 'full');
}
});
test('degradationFor never throws on a malformed axes object', () => {
for (const axes of [{}, { modelMode: null }, { effortSurface: 42 }, { modelMode: 'active', effortSurface: [] }]) {
assert.ok(['full', 'degraded', 'absent'].includes(degradationFor('model', axes).level));
}
});
});
describe('#2481 renderEffortArgv — per-host syntax and clamping', () => {
test('claude renders --effort', () => {
assert.deepEqual(renderEffortArgv('claude', 'xhigh', 'argv').argv, ['--effort', 'xhigh']);
});
test('opencode renders --variant', () => {
assert.deepEqual(renderEffortArgv('opencode', 'high', 'argv').argv, ['--variant', 'high']);
});
test('codex renders the generic -c config override, not a dedicated flag', () => {
// codex-rs/exec/src/cli.rs: model_reasoning_effort is NOT a CLI flag
// (config.toml key only), so -c key=value is the only argv route.
assert.deepEqual(
renderEffortArgv('codex', 'high', 'argv').argv,
['-c', 'model_reasoning_effort=high'],
);
});
test('clamps the provider-unique tail levels', () => {
// claude has no `minimal`; codex has no `max`.
assert.deepEqual(renderEffortArgv('claude', 'minimal', 'argv').argv, ['--effort', 'low']);
assert.deepEqual(renderEffortArgv('codex', 'max', 'argv').argv, ['-c', 'model_reasoning_effort=xhigh']);
});
test('emits nothing when the surface is not argv', () => {
for (const surface of ['none', 'undocumented', 'config-file', '', null, undefined]) {
assert.deepEqual(renderEffortArgv('claude', 'xhigh', surface).argv, []);
}
});
test('emits nothing for a host with no known syntax', () => {
for (const host of ['gemini', 'cursor', 'zcode', '']) {
assert.deepEqual(renderEffortArgv(host, 'high', 'argv').argv, []);
}
});
test('inherited Object members are not mistaken for host specs', () => {
// Regression guard: a bare EFFORT_ARGV[host] lookup resolves these to
// inherited members — truthy, but with no clamp/render — so a hostile host
// id from an untrusted descriptor threw instead of degrading.
for (const host of ['__proto__', 'constructor', 'toString', 'hasOwnProperty', 'valueOf']) {
assert.deepEqual(
renderEffortArgv(host, 'high', 'argv').argv, [],
`${host} must degrade to no argument, not throw`,
);
}
});
test('emits nothing for a missing or unrecognised effort level', () => {
for (const level of ['', 'bogus', 'HIGH', ' high', null, undefined, 42]) {
assert.deepEqual(renderEffortArgv('claude', level, 'argv').argv, []);
}
});
test('property: a rendered level is always inside that host\'s supported set', () => {
const hosts = Object.keys(EFFORT_ARGV);
const levels = ['minimal', 'low', 'medium', 'high', 'xhigh', 'max'];
fc.assert(
fc.property(fc.constantFrom(...hosts), fc.constantFrom(...levels), (host, level) => {
const r = renderEffortArgv(host, level, 'argv');
if (r.argv.length === 0) return true;
return EFFORT_ARGV[host].supported.has(r.value);
}),
{ numRuns: 200, seed: 2481 },
);
});
});
describe('#2481 live path — resolve-execution carries invocation-time effort', () => {
test('--host renders the argument for an argv host', (t) => {
const dir = projectWithEffort('xhigh');
t.after(() => cleanup(dir));
const r = runGsdTools('query resolve-execution gsd-planner --host claude', dir);
assert.ok(r.success, `resolve-execution failed: ${r.error}`);
const out = JSON.parse(r.output);
assert.equal(out.effort, 'xhigh');
assert.equal(out.effort_surface, 'argv');
assert.deepEqual(out.effort_argv, ['--effort', 'xhigh']);
assert.equal(out.effort_argv_string, '--effort xhigh');
});
test('--host on a host without a documented surface renders nothing', (t) => {
const dir = projectWithEffort('xhigh');
t.after(() => cleanup(dir));
const out = JSON.parse(runGsdTools('query resolve-execution gsd-planner --host cursor', dir).output);
assert.equal(out.effort_surface, 'none');
assert.deepEqual(out.effort_argv, []);
assert.equal(out.effort_argv_string, '');
});
test('an unknown host degrades closed rather than erroring', (t) => {
const dir = projectWithEffort('high');
t.after(() => cleanup(dir));
const r = runGsdTools('query resolve-execution gsd-planner --host not-a-real-host', dir);
assert.ok(r.success, 'an unknown host must degrade, not fail');
const out = JSON.parse(r.output);
assert.equal(out.effort_surface, 'none');
assert.deepEqual(out.effort_argv, []);
});
test('omitting --host leaves the JSON contract untouched', (t) => {
const dir = projectWithEffort('high');
t.after(() => cleanup(dir));
const out = JSON.parse(runGsdTools('query resolve-execution gsd-planner', dir).output);
for (const k of ['host', 'effort_surface', 'effort_argv', 'effort_argv_string', 'effort_argv_value']) {
assert.ok(!(k in out), `--host absent must not add "${k}" to the contract`);
}
});
test('--host requires a value', (t) => {
const dir = projectWithEffort('high');
t.after(() => cleanup(dir));
const r = runGsdTools('query resolve-execution gsd-planner --host', dir);
assert.ok(!r.success, 'a valueless --host must be a usage error');
});
test('a shell-metacharacter host is not interpolated, just unmatched', (t) => {
const dir = projectWithEffort('high');
t.after(() => cleanup(dir));
const r = runGsdTools('query resolve-execution gsd-planner --host "claude; touch pwned"', dir);
assert.ok(r.success);
assert.deepEqual(JSON.parse(r.output).effort_argv, []);
assert.ok(!fs.existsSync(path.join(dir, 'pwned')), 'no shell interpolation of the host value');
});
});
describe('#2481 — the escalation surface renders argv (CLI-level, not a workflow claim)', () => {
// NAMING IS DELIBERATE. This exercises `resolve-execution --attempt` directly,
// which is the CLI surface ADR-443's blocker explicitly EXCLUDES when it asks
// for "a real caller outside src/commands.cts's CLI surface and tests". It
// proves the escalation ladder still renders a host argument; it does NOT
// prove any workflow escalates. The live workflow caller for Decision item 6
// is #2296's gsd-core/references/execute-phase-quota-recovery.md, asserted
// separately below.
test('--attempt walks the effort ladder above the configured default', (t) => {
const dir = createTempProject();
t.after(() => cleanup(dir));
fs.writeFileSync(
path.join(dir, '.planning', 'config.json'),
JSON.stringify({
effort: { default: 'low' },
dynamic_routing: { enabled: true, escalate_on_failure: true, max_escalations: 3 },
}, null, 2),
);
const at = (n) => JSON.parse(
runGsdTools(`query resolve-execution gsd-planner --host claude --attempt ${n}`, dir).output,
);
// attempt 0 is the un-escalated baseline; a later attempt must not be lower.
const base = at(0);
const later = at(2);
const RANK = { minimal: 0, low: 1, medium: 2, high: 3, xhigh: 4, max: 5 };
assert.equal(base.effort, 'low');
assert.ok(
RANK[later.effort] >= RANK[base.effort],
`escalation must not lower effort: attempt0=${base.effort} attempt2=${later.effort}`,
);
// Whatever the ladder resolved, it must still reach the host as an argument.
assert.equal(later.effort_surface, 'argv');
assert.deepEqual(later.effort_argv, ['--effort', later.effort]);
});
test('a negative --attempt is rejected', (t) => {
const dir = projectWithEffort('high');
t.after(() => cleanup(dir));
assert.ok(!runGsdTools('query resolve-execution gsd-planner --attempt -1', dir).success);
});
});
describe('#2481 — ADR-443 mechanism callers, as they actually exist', () => {
const quotaRecovery = fs.readFileSync(
path.join(REPO_ROOT, 'gsd-core', 'references', 'execute-phase-quota-recovery.md'),
'utf8',
);
const executePhase = fs.readFileSync(
path.join(REPO_ROOT, 'gsd-core', 'workflows', 'execute-phase.md'),
'utf8',
);
test('Decision item 6 (escalation) has its live caller — from #2296, not this change', () => {
assert.match(
quotaRecovery, /resolve-execution\s+gsd-executor\s+--attempt/,
'execute-phase-quota-recovery.md must invoke resolve-execution with --attempt (#2296)',
);
assert.ok(
executePhase.includes('references/execute-phase-quota-recovery.md'),
'that reference must be @-included into execute-phase.md, or it is not a live caller',
);
});
test('Decision item 1 (invocation override) still has NO live caller', () => {
// Guards the corrected ADR-443 claim. If someone later wires --effort into a
// workflow, this fails and the ADR status text must be revisited — that is
// the point: the ADR must not silently drift back to being wrong.
const dirs = ['gsd-core/workflows', 'gsd-core/references', 'agents', 'commands'];
const hits = [];
const walk = (d) => {
const abs = path.join(REPO_ROOT, d);
if (!fs.existsSync(abs)) return;
for (const e of fs.readdirSync(abs, { withFileTypes: true })) {
const full = path.join(abs, e.name);
if (e.isDirectory()) walk(path.relative(REPO_ROOT, full));
else if (e.name.endsWith('.md') && /resolve-execution[^\r\n]*--effort\s/.test(fs.readFileSync(full, 'utf8'))) {
hits.push(path.relative(REPO_ROOT, full));
}
}
};
dirs.forEach(walk);
assert.deepEqual(
hits, [],
`ADR-443 records Decision item 1 as having no live caller; found: ${JSON.stringify(hits)}. ` +
'Update the ADR-443 amendment before adding one.',
);
});
});
describe('#2481 review workflow resolves effort per reviewer', () => {
const reviewMd = fs.readFileSync(
path.join(REPO_ROOT, 'gsd-core', 'workflows', 'review.md'),
'utf8',
);
test('shipped orchestration invokes resolve-execution — the grep ADR-443 said returned zero hits', () => {
// Phase 5b (#2799) moved the call out of review.md's per-lane bash and into the review-lane
// route, which resolves effort once per selected lane through the SAME surface. ADR-443's
// invariant is about shipped orchestration calling resolve-execution at all, not about which
// file it lives in — so the assertion follows the call rather than pinning the old location.
const toolsSrc = fs.readFileSync(
path.join(__dirname, '..', 'gsd-core', 'bin', 'gsd-tools.cjs'), 'utf-8',
);
assert.ok(
toolsSrc.includes('resolve-execution'),
'ADR-443 blocks on no shipped orchestration calling resolve-execution',
);
});
test('each argv-effort reviewer places effort in its resolved command line', () => {
// Stronger than the old shell-variable check: this asserts the effort actually lands in the
// argv AT THE POSITION the lane declares, which a `$VAR` substring never proved. Lanes whose
// effortChannel is not `argv` must receive nothing.
const { REVIEWER_LANES } = require('../gsd-core/bin/lib/review-lane-descriptor.cjs');
const { resolveLanePlan } = require('../gsd-core/bin/lib/review-lane-invocation.cjs');
const EFFORT = ['--effort', 'high'];
for (const lane of REVIEWER_LANES.filter((l) => l.transport === 'spawn')) {
const r = resolveLanePlan({
lane, configGet: () => undefined, runDir: '/run', repoRoot: '/repo', effortArgs: EFFORT,
});
assert.equal(r.ok, true, `${lane.slug} failed to resolve`);
const carries = r.plan.argv.includes('--effort');
assert.equal(
carries, lane.invoke.effortChannel === 'argv',
`${lane.slug}: effortChannel=${lane.invoke.effortChannel} but argv ${carries ? 'carries' : 'omits'} effort`,
);
}
// The three lanes ADR-1239 #2481 named must still be the argv-effort set.
const argvEffort = REVIEWER_LANES
.filter((l) => l.transport === 'spawn' && l.invoke.effortChannel === 'argv')
.map((l) => l.slug).sort();
assert.deepStrictEqual(argvEffort, ['claude', 'codex', 'opencode']);
});
});