Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
afa3b4d
docs: add legacy code audit (/audit) design doc
wenshao Aug 2, 2026
522e23c
docs: revise legacy audit design with round-2 replication evidence
wenshao Aug 2, 2026
509e79a
docs: note cross-file tracer cost and budget rule in legacy audit design
wenshao Aug 2, 2026
7fd87c6
feat(audit): add legacy code audit workflow
wenshao Aug 2, 2026
2992d53
Merge remote-tracking branch 'origin/main' into feat/legacy-code-audit
wenshao Aug 6, 2026
2b9cf83
feat(audit): align the audit workflow with the merged design doc
wenshao Aug 6, 2026
e4386ea
Merge remote-tracking branch 'origin/main' into feat/legacy-code-audit
wenshao Aug 6, 2026
0ad3dd9
fix(audit): lift tokenizeArgs and anchor the guard probes at the invo…
wenshao Aug 6, 2026
ff9c53b
fix(audit): make check-anchors --callers conditional in the skill
wenshao Aug 6, 2026
94b0b95
Merge branch 'main' into feat/legacy-code-audit
qwen-code-dev-bot Aug 6, 2026
6d633b9
fix(audit): name-record unreadable sidecar callers
qwen-code-dev-bot Aug 6, 2026
03c1519
Merge remote-tracking branch 'origin/main' into feat/legacy-code-audit
qwen-code-dev-bot Aug 7, 2026
5eb156e
fix(audit): close fail-open gates found in review across the pipeline
qwen-code-dev-bot Aug 7, 2026
0642802
Merge branch 'main' into feat/legacy-code-audit
qwen-code-dev-bot Aug 7, 2026
d883ddc
fix(cli): harden audit helpers per review feedback (#8403)
qwen-code-dev-bot Aug 7, 2026
e1e6fcf
fix(cli): address second review round for audit helpers (#8403)
qwen-code-dev-bot Aug 11, 2026
67b1320
fix(external-context): read the response body with a reader, not for-…
wenshao Aug 9, 2026
7c33b0b
fix(audit): make fallback relocation paths explicit in the skill comm…
qwen-code-dev-bot Aug 12, 2026
8209913
Merge branch 'main' into feat/legacy-code-audit
qwen-code-dev-bot Aug 12, 2026
319c0cf
fix(cli): apply review-round fixes to audit anchors, walk, and exit f…
qwen-code-dev-bot Aug 12, 2026
72a4d89
Merge branch 'main' into feat/legacy-code-audit
qwen-code-dev-bot Aug 12, 2026
029231e
Merge branch 'main' into feat/legacy-code-audit
qwen-code-dev-bot Aug 13, 2026
2dc868d
Merge branch 'main' into feat/legacy-code-audit
qwen-code-dev-bot Aug 13, 2026
5df644a
Merge remote-tracking branch 'origin/main' into feat/legacy-code-audit
qwen-code-ci-bot Aug 13, 2026
2581412
fix(audit): address round-3 review findings for the audit module (#8403)
qwen-code-ci-bot Aug 13, 2026
54c5cbe
Merge branch 'main' into feat/legacy-code-audit
qwen-code-dev-bot Aug 13, 2026
722b06d
Merge branch 'main' into feat/legacy-code-audit
qwen-code-dev-bot Aug 13, 2026
c714b90
Merge remote-tracking branch 'origin/main' into feat/legacy-code-audit
qwen-code-dev-bot Aug 14, 2026
216937d
fix(cli): apply round-4 review fixes to audit guard, anchors, and sid…
qwen-code-dev-bot Aug 14, 2026
538905d
fix(cli): apply round-6 review fixes to audit guard, anchors, and sid…
qwen-code-dev-bot Aug 14, 2026
d5c48e3
Merge branch 'main' into feat/legacy-code-audit
wenshao Aug 14, 2026
e528918
fix(cli): close round-6 audit guard, anchor, and hash holes (#8403)
qwen-code-dev-bot Aug 14, 2026
789b6e4
fix(cli): close round-8 audit anchor and guard criticals (#8403)
qwen-code-dev-bot Aug 15, 2026
25da0ff
Merge branch 'main' into feat/legacy-code-audit
qwen-code-dev-bot Aug 15, 2026
cd1276a
Merge branch 'main' into feat/legacy-code-audit
qwen-code-dev-bot Aug 15, 2026
92642bd
Merge branch 'main' into feat/legacy-code-audit
qwen-code-dev-bot Aug 15, 2026
2afc1fb
Merge branch 'main' into feat/legacy-code-audit
qwen-code-dev-bot Aug 16, 2026
5aabe7c
Merge branch 'main' into feat/legacy-code-audit
qwen-code-dev-bot Aug 16, 2026
aed1ab5
Merge remote-tracking branch 'origin/main' into feat/legacy-code-audit
qwen-code-dev-bot Aug 16, 2026
afa923a
Merge branch 'main' into feat/legacy-code-audit
qwen-code-dev-bot Aug 16, 2026
5af49e9
Merge remote-tracking branch 'origin/main' into feat/legacy-code-audit
qwen-code-dev-bot Aug 17, 2026
926aef8
Merge branch 'main' into feat/legacy-code-audit
qwen-code-dev-bot Aug 17, 2026
1deabe8
Merge branch 'main' into feat/legacy-code-audit
qwen-code-dev-bot Aug 17, 2026
580b439
Merge branch 'main' into feat/legacy-code-audit
qwen-code-dev-bot Aug 18, 2026
a2638ea
Merge branch 'main' into feat/legacy-code-audit
qwen-code-dev-bot Aug 18, 2026
a0ee238
Merge branch 'main' into feat/legacy-code-audit
qwen-code-dev-bot Aug 18, 2026
caadc0c
Merge remote-tracking branch 'origin/main' into feat/legacy-code-audit
wenshao Aug 19, 2026
1897bd4
fix(core): stabilize the audit fallback root across symlink path spel…
wenshao Aug 19, 2026
daa8f6e
Merge remote-tracking branch 'origin/feat/legacy-code-audit' into fea…
wenshao Aug 19, 2026
1f97f93
Merge branch 'main' into feat/legacy-code-audit
qwen-code-dev-bot Aug 20, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/users/features/_meta.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export default {
commands: 'Commands',
'code-review': 'Code Review',
'legacy-audit': 'Legacy Code Audit',
'followup-suggestions': 'Followup Suggestions',
'tool-use-summaries': 'Tool-Use Summaries',
'markdown-rendering': 'Markdown Rendering',
Expand Down
67 changes: 67 additions & 0 deletions docs/users/features/legacy-audit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# Legacy Code Audit

> Audit a module or directory of **existing, merged code** — no diff, no PR — using `/audit`.

`/review` is built for increments; `/audit` points the same machinery at code that is already merged: pre-refactor assessments, taking over an unfamiliar module, security review of a sensitive subsystem. The product is a verified, deduplicated, theme-clustered findings report.

## Quick Start

```bash
# Audit a module (default effort: medium)
/audit packages/core/src/permissions

# Quick unverified triage, one reader sub-agent
/audit packages/core/src/hooks --effort low

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deferred to a follow-up round (not dropped). Pointing the Quick Start low example at a module under the 2,000-line low gate requires measuring candidate modules against the live plan-files gate; that measurement and the doc fix land next round.

中文说明

推迟到后续轮次(并非丢弃)。把 Quick Start 的 low 示例指向低于 2,000 行 low 门限的模块,需要先对候选模块用真实 plan-files 门限测量;该测量与文档修复下一轮落地。


# Full pipeline plus reverse-audit rounds
/audit packages/core/src/permissions --effort high
```

Single files are not audited — `/review <file-path>` already covers that case, and `/audit` says so and stops.

## Effort Levels

`--effort low|medium|high` trades depth for cost. **The word means the opposite of what it does in `/review`**: `/review`'s medium _drops_ the adversarial personas while `/audit`'s medium _adds_ one (6a) — and both skills select the tier with the same `--effort` flag. If you run both, reset your expectation at the boundary.

| Level | What runs | Findings | Cost |
| -------- | --------------------------------------------------------------------------------------------------------- | --------------------------- | ---------------- |
| `low` | One reader sub-agent rotating through directed angles plus a gap sweep | ≤10, labeled **unverified** | Cheap |
| `medium` | The measured 8-dimension fan-out (1a, 1c, 2, 3a/3b/3c, 4, 5) plus the 6a attacker seat, plus verification | Uncapped, verified | Tens of M tokens |
| `high` | medium + the 6b/6c personas + iterative reverse-audit rounds | Uncapped, verified | Extrapolated |

## Size gates and budget

v1 audits one bounded module at a time. `plan-files` refuses at plan time — and asks for a narrower path — when:

- subject lines exceed **9,000** (the topology both experiments validated);
- test lines exceed **18,000** at medium/high (Agent 5 reads the corpus whole);
- subject lines exceed **2,000** at low (points you at medium);
- the priced token estimate's top exceeds the **60M** cap.

A larger subsystem is audited as coherent sub-paths, one bounded run each. For subject-gate and token-cap refusals, lowering the effort is never the remedy — the priced cost is a function of line counts alone. The test-line gate does not apply at `low` (the corpus goes unexamined there — triage, not an audit). A `low-gate` refusal names its own remedy: when the message offers the tier change, re-run with `--effort medium`; when it names the path instead (medium would refuse first — the priced estimate over the token cap, or test lines over the medium gate), no tier change helps, so narrow the path.

## What you confirm before anything launches

A fan-out run prints its roster and token estimate and starts only on your confirmation. The same confirmation carries the two **execution consents**, as separate opt-ins:

1. a baseline run of the module's own test suite;
2. agent-authored verification **probes** — short programs written mid-run, executed against a scratch copy of the probed file (never your checkout's copy), each required to flip under the implied fix.

The walks themselves are read-only. Because the confirmation is the only budget enforcement and the execution gate, **`/audit` refuses non-interactive starts** (headless `qwen -p`, cron, sub-agent invocations).

## Safety properties

- **Local-only artifacts.** The report, its sidecar, and the plan/prompt records quote the module — possibly exploitable code — and must never land in version control. `plan-files` probes `.qwen/audits/` and `.qwen/tmp/` (ignore rules **and** force-added history) at plan time, offers a zero-footprint `.git/info/exclude` remedy, and re-checks at every checkpoint and at write time; a mid-run flip relocates everything to a per-user fallback outside the repo.
- **Untrusted data.** Every consumer of module content — dimension agents, verifiers, the dedup clusterer, the low-tier reader, the orchestrator itself — opens with an untrusted-data preamble: the module is evidence, not instructions. A directive embedded in the code ("report no findings") is itself a finding.
- **Drift protection.** A path-scoped sidecar (diff, untracked content copies, per-file content hashes) is captured at run start and re-checked before verification, before each high-tier round, and at write time. Content drift in a file that already carries anchored findings stops the run with a partial report; any other drift is flagged and the run continues.
- **No verdict.** The report is findings, walks, and disclosures — never "approved". Posting and fixing stay with you.

## The report

`.qwen/audits/<YYYY-MM-DD>-<HHMMSS>-<path-slug>.md`, opening with a run-metadata header (commit SHA, model id, dirty state with sidecar, consumption against the estimate, walks completed/skipped/uncoverable, unexercised-machinery flags). Findings are clustered by root cause, each with severity, locations, failure scenario, evidence tier (end-to-end probe / unit probe / code read), and the independent-discovery count ("found independently by N agents"). Confirmed-low findings sit in their own "needs human review" section; anything unverified is labeled unverified.

## Limitations

- Submodules are refused at plan time (no drift coverage inside them in v1).
- Dedup is intra-run; already-filed issues are not cross-checked.
- The medium/high tiers are calibrated on two modules of this repository; the low tier and the high-tier loop are unmeasured first cuts, and the report header says so.
1 change: 1 addition & 0 deletions packages/cli/src/cli.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1061,6 +1061,7 @@ describe('bootstrap import boundaries', () => {
const configSource = readFileSync('src/config/config.ts', 'utf8');
const commandNameByIdentifier = new Map([
['authCommand', 'auth'],
['auditCommand', 'audit'],
['channelCommand', 'channel'],
['extensionsCommand', 'extensions'],
['hooksCommand', 'hooks'],
Expand Down
4 changes: 4 additions & 0 deletions packages/cli/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ type BootstrapRoute = 'serve' | 'mcp' | 'help' | 'version' | 'default';

export const TOP_LEVEL_COMMANDS = [
['auth', 'Configure authentication (removed)'],
[
'audit <command>',
'Helpers used by the /audit skill (argument parsing, audit planning, brief printing, run-state captures)',
],
['channel <command>', 'Manage messaging channels (Telegram, Discord, etc.)'],
['extensions <command>', 'Manage Qwen Code extensions.'],
['hooks', 'Manage Qwen Code hooks (use /hooks in interactive mode).'],
Expand Down
52 changes: 52 additions & 0 deletions packages/cli/src/commands/audit.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/**
* @license
* Copyright 2026 Qwen Team
* SPDX-License-Identifier: Apache-2.0
*/

import { describe, it, expect } from 'vitest';
import { readFileSync } from 'node:fs';
import { auditCommand } from './audit.js';

describe('auditCommand', () => {
it('registers exactly the expected subcommands', () => {
const source = readFileSync('src/commands/audit.ts', 'utf8');
const subcommands = [...source.matchAll(/\.command\((\w+Command)\)/g)].map(
(m) => m[1],
);
expect(subcommands).toEqual([
'parseArgsCommand',
'planFilesCommand',
'agentPromptCommand',
'snapshotCommand',
'driftCheckCommand',
'guardCheckCommand',
'checkAnchorsCommand',
]);
});

it('demandCommand text names each subcommand', () => {
const source = readFileSync('src/commands/audit.ts', 'utf8');
// Assert against the demandCommand MESSAGE, not the whole file: the
// import lines also contain the subcommand module names.
const message = /\.demandCommand\(\s*1,\s*'([^']+)'/.exec(source)?.[1];
expect(message).toBeDefined();
for (const name of [
'parse-args',
'plan-files',
'agent-prompt',
'snapshot',
'drift-check',
'guard-check',
'check-anchors',
]) {
expect(message).toContain(name);
}
});

it('is a CommandModule with an empty dispatch handler', () => {
expect(auditCommand.command).toBe('audit');
expect(typeof auditCommand.builder).toBe('function');
expect(typeof auditCommand.handler).toBe('function');
});
});
41 changes: 41 additions & 0 deletions packages/cli/src/commands/audit.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/**
* @license
* Copyright 2026 Qwen Team
* SPDX-License-Identifier: Apache-2.0
*/

// `qwen audit`: the non-interactive helpers used by the bundled /audit skill
// for auditing existing code (no diff, no PR). The skill orchestrates via
// shell calls to these subcommands; see
// packages/core/src/skills/bundled/audit/SKILL.md.

import type { CommandModule } from 'yargs';
import { parseArgsCommand } from './audit/parse-args.js';
import { planFilesCommand } from './audit/plan-files.js';
import { agentPromptCommand } from './audit/agent-prompt.js';
import { checkAnchorsCommand } from './audit/check-anchors.js';
import { guardCheckCommand } from './audit/guard-check.js';
import { driftCheckCommand, snapshotCommand } from './audit/snapshot.js';

export const auditCommand: CommandModule = {
command: 'audit',
describe:
'Helpers used by the /audit skill (argument parsing, audit planning, brief printing, run-state captures)',
builder: (yargs) =>
yargs
.command(parseArgsCommand)
.command(planFilesCommand)
.command(agentPromptCommand)
.command(snapshotCommand)
.command(driftCheckCommand)
.command(guardCheckCommand)
.command(checkAnchorsCommand)
.demandCommand(
1,
'audit needs a subcommand: parse-args, plan-files, agent-prompt, snapshot, drift-check, guard-check, check-anchors',
)
.version(false),
handler: () => {
// Dispatch is per-subcommand.
},
};
111 changes: 111 additions & 0 deletions packages/cli/src/commands/audit/agent-prompt.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
/**
* @license
* Copyright 2026 Qwen Team
* SPDX-License-Identifier: Apache-2.0
*/

import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
import {
mkdirSync,
mkdtempSync,
readFileSync,
rmSync,
writeFileSync,
} from 'node:fs';
import { join } from 'node:path';
import { tmpdir } from 'node:os';
import { agentPromptCommand } from './agent-prompt.js';
import { writeStdoutLine } from '../../utils/stdioHelpers.js';
import { buildFilesPlan, collectAuditFiles } from './lib/files-plan.js';

vi.mock('../../utils/stdioHelpers.js', () => ({
writeStdoutLine: vi.fn(),
}));

let dir: string;

beforeEach(() => {
dir = mkdtempSync(join(tmpdir(), 'audit-agent-prompt-'));
mkdirSync(join(dir, 'mod'), { recursive: true });
writeFileSync(join(dir, 'mod', 'a.ts'), 'const a = 1;\n');
vi.mocked(writeStdoutLine).mockClear();
});

afterEach(() => {
rmSync(dir, { recursive: true, force: true });
});

function writePlan(effort: 'low' | 'medium' | 'high'): string {
const plan = buildFilesPlan(
join(dir, 'mod'),
join(dir, 'mod'),
effort,
collectAuditFiles(join(dir, 'mod')),
);
const planPath = join(dir, `plan-${effort}.json`);
writeFileSync(planPath, JSON.stringify(plan));
return planPath;
}

const run = (argv: Record<string, unknown>) =>
(agentPromptCommand.handler as (a: unknown) => void)({
_: ['audit', 'agent-prompt'],
...argv,
});

describe('agentPromptCommand handler', () => {
it('prints a role brief for a role in the roster', () => {
run({ plan: writePlan('medium'), role: '1a', probes: 'declined' });
const printed = vi.mocked(writeStdoutLine).mock.calls[0][0];
expect(printed).toContain('You are Agent 1a');
// Declined probe opt-in strips the execution instructions.
expect(printed).toContain('Execution is NOT opted in');
});

it('maps the opted-in probe flag to the probe discipline', () => {
// The 'opted-in' → probesConsented === true mapping is load-bearing:
// without it every opted-in run prints the declined brief and the
// verifier tier silently caps at code reads.
run({ plan: writePlan('medium'), role: '1a', probes: 'opted-in' });
const printed = vi.mocked(writeStdoutLine).mock.calls[0][0];
expect(printed).toContain('A probe runs only against a scratch copy');
expect(printed).not.toContain('Execution is NOT opted in');
});

it('refuses the low reader at medium and a roster role at low', () => {
expect(() =>
run({
plan: writePlan('medium'),
role: 'low-reader',
probes: 'declined',
}),
).toThrow(/only valid for a low-tier plan/);
// Low plans carry an empty roster: every dimension role is refused.
expect(() =>
run({ plan: writePlan('low'), role: '1a', probes: 'declined' }),
).toThrow(/not in this plan's roster/);
});

it('refuses a stale-plan role that is not in the roster', () => {
// 'toString' rides the prototype-membership hole a raw .includes()
// call would leave open: it is an Object.prototype member, not a role.
expect(() =>
run({ plan: writePlan('medium'), role: 'toString', probes: 'declined' }),
).toThrow(/must be one of/);
});

it('fails closed when the plan carries a non-array roster', () => {
const planPath = writePlan('medium');
const parsed = JSON.parse(readFileSync(planPath, 'utf8')) as Record<
string,
unknown
>;
// A string roster ('1a' .includes('1a') === true, '12' admits '2')
// must fail closed, not reach substring membership.
parsed['roster'] = '12';
writeFileSync(planPath, JSON.stringify(parsed));
expect(() =>
run({ plan: planPath, role: '2', probes: 'declined' }),
).toThrow(/not in this plan's roster/);
});
});
94 changes: 94 additions & 0 deletions packages/cli/src/commands/audit/agent-prompt.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
/**
* @license
* Copyright 2026 Qwen Team
* SPDX-License-Identifier: Apache-2.0
*/

// `qwen audit agent-prompt`: print the brief for one audit role — or the
// low tier's reader — with the plan's context assembled in. The /audit skill
// launches its agents with exactly these prompts (one call per roster role),
// so what every agent is told is fixed by code, not improvised by the
// orchestrator.

import type { CommandModule } from 'yargs';
import { writeStdoutLine } from '../../utils/stdioHelpers.js';
import { readPlanFile } from './lib/read-json.js';
import {
AUDIT_BRIEFS,
buildAuditPrompt,
buildLowReaderPrompt,
type AuditBriefRole,
} from './lib/audit-agent-briefs.js';

interface AgentPromptArgs {
plan: string;
role?: string;
probes?: 'opted-in' | 'declined';
}

function runAgentPrompt(args: AgentPromptArgs): void {
const plan = readPlanFile(args.plan, 'agent-prompt');
const probesConsented = args.probes === 'opted-in';
// A stale plan JSON can carry anything in its roster — a non-array must
// fail closed (empty roster, every role refused), never reach .includes.
const roles = Array.isArray(plan.roster) ? (plan.roster as string[]) : [];
if (args.role === 'low-reader') {
if (plan.effort !== 'low') {
throw new Error(
`agent-prompt: low-reader is only valid for a low-tier plan (this plan is ${plan.effort}).`,
);
}
writeStdoutLine(buildLowReaderPrompt(plan));
return;
}
const role = args.role as Exclude<AuditBriefRole, 'low-reader'> | undefined;
// Object.hasOwn, not `in`: a stale-plan role like "toString" matches
// inherited Object.prototype keys and would emit an undefined brief.
if (!role || !Object.hasOwn(AUDIT_BRIEFS, role)) {
throw new Error(
`agent-prompt: --role must be one of ${[...Object.keys(AUDIT_BRIEFS), 'low-reader'].join(', ')}.`,
);
}
if (!roles.includes(role)) {
throw new Error(

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Suggestion] agent-prompt's roster-membership/tier/prototype guards (Object.hasOwn, roles.includes, low-reader only at low) are untested — the design invariant "roster is computed by code and cannot be shrunk" is enforced only here. — Failure scenario: deleting the roles.includes check ships green; agent-prompt --role 6b --plan <medium-plan> then emits a 6b brief for a tier whose plan never disclosed or priced 6b; the stale-plan toString guard is equally unprotected. Suggested fix: an agent-prompt.test.ts exercising medium-plan+low-reader, low-plan+1a, and stale-plan 'toString' roster cases.

中文说明

问题:agent-prompt 的 roster 成员/档位/原型守卫(Object.hasOwn、roles.includes、low-reader 仅限 low)没有任何测试——"roster 由代码计算、不可缩减"的设计不变量只在这里强制。失败场景:删掉 roles.includes 检查套件全绿;agent-prompt --role 6b --plan <medium计划> 会为计划从未披露/定价 6b 的档位输出 6b brief;过期计划的 toString 守卫同样无保护。修复建议:新增 agent-prompt.test.ts 覆盖 medium 计划+low-reader、low 计划+1a、过期计划 'toString' roster 等用例。

— DeepSeek/deepseek-v4-flash via Qwen Code /review (v0.21.8)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Suggestion] agent-prompt's roster-membership/tier/prototype guards (Object.hasOwn, roles.includes, low-reader only at low) are untested — the design invariant "roster is computed by code and cannot be shrunk" is enforced only here. — Failure scenario: deleting the roles.includes check ships green; agent-prompt --role 6b --plan <medium-plan> then emits a 6b brief for a tier whose plan never disclosed or priced 6b; the stale-plan toString guard is equally unprotected. Suggested fix: an agent-prompt.test.ts exercising medium-plan+low-reader, low-plan+1a, and stale-plan 'toString' roster cases.

中文说明

问题:agent-prompt 的 roster 成员/档位/原型守卫(Object.hasOwn、roles.includes、low-reader 仅限 low)没有任何测试——"roster 由代码计算、不可缩减"的设计不变量只在这里强制。失败场景:删掉 roles.includes 检查套件全绿;agent-prompt --role 6b --plan <medium计划> 会为计划从未披露/定价 6b 的档位输出 6b brief;过期计划的 toString 守卫同样无保护。修复建议:新增 agent-prompt.test.ts 覆盖 medium 计划+low-reader、low 计划+1a、过期计划 'toString' roster 等用例。

— DeepSeek/deepseek-v4-flash via Qwen Code /review (v0.21.8)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Suggestion] agent-prompt's roster-membership/tier/prototype guards (Object.hasOwn, roles.includes, low-reader only at low) are untested — the design invariant "roster is computed by code and cannot be shrunk" is enforced only here. — Failure scenario: deleting the roles.includes check ships green; agent-prompt --role 6b --plan <medium-plan> then emits a 6b brief for a tier whose plan never disclosed or priced 6b; the stale-plan toString guard is equally unprotected. Suggested fix: an agent-prompt.test.ts exercising medium-plan+low-reader, low-plan+1a, and stale-plan 'toString' roster cases.

中文说明

问题:agent-prompt 的 roster 成员/档位/原型守卫(Object.hasOwn、roles.includes、low-reader 仅限 low)没有任何测试——"roster 由代码计算、不可缩减"的设计不变量只在这里强制。失败场景:删掉 roles.includes 检查套件全绿;agent-prompt --role 6b --plan <medium计划> 会为计划从未披露/定价 6b 的档位输出 6b brief;过期计划的 toString 守卫同样无保护。修复建议:新增 agent-prompt.test.ts 覆盖 medium 计划+low-reader、low 计划+1a、过期计划 'toString' roster 等用例。

— DeepSeek/deepseek-v4-flash via Qwen Code /review (v0.21.8)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Suggestion] agent-prompt's roster-membership/tier/prototype guards (Object.hasOwn, roles.includes, low-reader only at low) are untested — the design invariant "roster is computed by code and cannot be shrunk" is enforced only here. — Failure scenario: deleting the roles.includes check ships green; agent-prompt --role 6b --plan <medium-plan> then emits a 6b brief for a tier whose plan never disclosed or priced 6b; the stale-plan toString guard is equally unprotected. Suggested fix: an agent-prompt.test.ts exercising medium-plan+low-reader, low-plan+1a, and stale-plan 'toString' roster cases.

中文说明

问题:agent-prompt 的 roster 成员/档位/原型守卫(Object.hasOwn、roles.includes、low-reader 仅限 low)没有任何测试——"roster 由代码计算、不可缩减"的设计不变量只在这里强制。失败场景:删掉 roles.includes 检查套件全绿;agent-prompt --role 6b --plan <medium计划> 会为计划从未披露/定价 6b 的档位输出 6b brief;过期计划的 toString 守卫同样无保护。修复建议:新增 agent-prompt.test.ts 覆盖 medium 计划+low-reader、low 计划+1a、过期计划 'toString' roster 等用例。

— DeepSeek/deepseek-v4-flash via Qwen Code /review (v0.21.8)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Suggestion] agent-prompt's roster-membership/tier/prototype guards (Object.hasOwn, roles.includes, low-reader only at low) are untested — the design invariant "roster is computed by code and cannot be shrunk" is enforced only here. — Failure scenario: deleting the roles.includes check ships green; agent-prompt --role 6b --plan <medium-plan> then emits a 6b brief for a tier whose plan never disclosed or priced 6b; the stale-plan toString guard is equally unprotected. Suggested fix: an agent-prompt.test.ts exercising medium-plan+low-reader, low-plan+1a, and stale-plan 'toString' roster cases.

中文说明

问题:agent-prompt 的 roster 成员/档位/原型守卫(Object.hasOwn、roles.includes、low-reader 仅限 low)没有任何测试——"roster 由代码计算、不可缩减"的设计不变量只在这里强制。失败场景:删掉 roles.includes 检查套件全绿;agent-prompt --role 6b --plan <medium计划> 会为计划从未披露/定价 6b 的档位输出 6b brief;过期计划的 toString 守卫同样无保护。修复建议:新增 agent-prompt.test.ts 覆盖 medium 计划+low-reader、low 计划+1a、过期计划 'toString' roster 等用例。

— DeepSeek/deepseek-v4-flash via Qwen Code /review (v0.21.8)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Suggestion] agent-prompt's roster-membership/tier/prototype guards (Object.hasOwn, roles.includes, low-reader only at low) are untested — the design invariant "roster is computed by code and cannot be shrunk" is enforced only here. — Failure scenario: deleting the roles.includes check ships green; agent-prompt --role 6b --plan <medium-plan> then emits a 6b brief for a tier whose plan never disclosed or priced 6b; the stale-plan toString guard is equally unprotected. Suggested fix: an agent-prompt.test.ts exercising medium-plan+low-reader, low-plan+1a, and stale-plan 'toString' roster cases.

中文说明

问题:agent-prompt 的 roster 成员/档位/原型守卫(Object.hasOwn、roles.includes、low-reader 仅限 low)没有任何测试——"roster 由代码计算、不可缩减"的设计不变量只在这里强制。失败场景:删掉 roles.includes 检查套件全绿;agent-prompt --role 6b --plan <medium计划> 会为计划从未披露/定价 6b 的档位输出 6b brief;过期计划的 toString 守卫同样无保护。修复建议:新增 agent-prompt.test.ts 覆盖 medium 计划+low-reader、low 计划+1a、过期计划 'toString' roster 等用例。

— DeepSeek/deepseek-v4-flash via Qwen Code /review (v0.21.8)

`agent-prompt: role ${role} is not in this plan's roster (${roles.join(', ') || 'empty'}). The roster is computed from the plan's effort — regenerate the plan if you need a different tier.`,
);
}
writeStdoutLine(buildAuditPrompt(role, plan, probesConsented));
}
Comment on lines +57 to +58

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Escalated to a maintainer decision — not resolved in this round. The workflow's deterministic diff-growth brake has engaged: this PR has stayed over the growth budget for 14+ consecutive rounds, and the review findings themselves are driving the growth, so the autofix loop is no longer permitted to keep patching it. Under the not-converging rule this round made no code fixes; the only change merged was the required origin/main conflict resolution. This finding remains open and is carried in the maintainer handoff alongside the options (split the PR, narrow the v1 threat model, accept with the tail deferred, or redesign).

中文说明

已升级至维护者决策 — 本轮未在代码中解决。 工作流的确定性 diff 增长刹车已触发:本 PR 已连续 14 轮以上超出增长预算,且审查发现本身就是增长的来源,因此 autofix 循环不再被允许继续打补丁。按照"不收敛"规则,本轮没有做任何代码修复;唯一合并的改动是按要求完成的 origin/main 冲突解决。该发现保持开放,并已纳入维护者交接文档,与各个选项一并列出(拆分 PR、收窄 v1 威胁模型、接受现状并延后尾部问题、或重新设计)。


export const agentPromptCommand: CommandModule = {
command: 'agent-prompt',
describe:
'Print the brief for an audit role or the low-tier reader — with plan context assembled',
builder: (yargs) =>
yargs
.option('plan', {
type: 'string',
demandOption: true,
describe: 'Plan JSON written by `qwen audit plan-files`',
})
.option('role', {
type: 'string',
describe: 'Print one role brief (must be in the plan roster)',
})
.option('probes', {
choices: ['opted-in', 'declined'] as const,
describe:
'The Step-2 probe opt-in verdict; declined prompts carry no execution instructions (not required for --role low-reader — low runs no execution classes)',
})
.check((argv) => {
if (!argv.role) {
throw new Error('agent-prompt: pass --role <id>.');
}
if (argv.role !== 'low-reader' && !argv.probes) {
throw new Error(
'agent-prompt: pass --probes opted-in|declined (the Step-2 probe opt-in).',
Comment on lines +84 to +86

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Escalated to a maintainer decision — not resolved in this round. The workflow's deterministic diff-growth brake has engaged: this PR has stayed over the growth budget for 14+ consecutive rounds, and the review findings themselves are driving the growth, so the autofix loop is no longer permitted to keep patching it. Under the not-converging rule this round made no code fixes; the only change merged was the required origin/main conflict resolution. This finding remains open and is carried in the maintainer handoff alongside the options (split the PR, narrow the v1 threat model, accept with the tail deferred, or redesign).

中文说明

已升级至维护者决策 — 本轮未在代码中解决。 工作流的确定性 diff 增长刹车已触发:本 PR 已连续 14 轮以上超出增长预算,且审查发现本身就是增长的来源,因此 autofix 循环不再被允许继续打补丁。按照"不收敛"规则,本轮没有做任何代码修复;唯一合并的改动是按要求完成的 origin/main 冲突解决。该发现保持开放,并已纳入维护者交接文档,与各个选项一并列出(拆分 PR、收窄 v1 威胁模型、接受现状并延后尾部问题、或重新设计)。

);
}
return true;
}),
handler: (argv) => {
runAgentPrompt(argv as unknown as AgentPromptArgs);
},
};
Loading
Loading