Skip to content

chore(repo): replace agent instruction prose with checks - #7954

Open
kanadgupta wants to merge 18 commits into
developfrom
kanad-claude/audit-agent-text-pruning-21ec83
Open

kanadgupta wants to merge 18 commits into
developfrom
kanad-claude/audit-agent-text-pruning-21ec83

Conversation

@kanadgupta

@kanadgupta kanadgupta commented Dec 4, 2026 •

Copy link
Copy Markdown
Member

Summary

Most of the agent-facing instruction text either restated code or described rules a check could enforce. This PR moves the enforceable rules into a check, deletes the prose, and keeps only a short root AGENTS.md.

  • Add tools/repo-policy.ts and run it from check:all. It verifies test tier names against each workspace's Vitest config, commit scope lists, script runners, lint-disable reasons, vendor/effect imports, CLAUDE.md links, instruction links and a byte budget for the root instructions.
  • Record existing violations per rule and file in tools/repo-policy.baseline.json. A file over its baseline fails; a file under it fails until pnpm policy:baseline lowers the entry, so the baseline only goes down.
  • Move the CLI contracts no check covers (command removal, telemetry, overlays, config loading, I/O spans) to apps/cli/docs/contracts.md, linked from the root AGENTS.md and the sync prompts.
  • Fail a second loadResolvedConfigContext call in one file.
  • Shrink the root AGENTS.md to the commands and constraints no check covers.
  • Remove the apps/cli, apps/cli-e2e and packages/config agent guides and the effect and test-audit skills. The cli-reference skill stays because the CI review prompts read it.
  • Move the config build and release runbook to packages/config/docs/build-and-release.md and the e2e replay-server guide to apps/cli-e2e/README.md.

Why the guides and skills are removed

A blinded ablation ran two real CLI changes three times each under three instruction sets: everything, workspace guides only, and the minimal root file only. All runs passed the hidden behaviour tests and repository checks, and the larger instruction sets did not score higher than the minimal one. The evaluation could not exercise every rule in the removed guides, so this shows no measured benefit rather than proof of none.

Reviewer notes

  • The removed guides held some policy the evaluation did not cover: tombstones for removed commands, the config-v* tag rules and telemetry event stability. The overlay authorization rule now lives in .github/ai-review/README.md.
  • ADR 0020 says the config naming vocabulary lives in the root AGENTS.md, which no longer carries it.
  • The comment rules use a line-based check that also counts some comment-like lines inside template strings.

Fixes CLI-3390

🤖 Generated with Claude Code

kanadgupta and others added 6 commits December 3, 2026 16:13
Add tools/repo-policy.ts and run it from check:all. It verifies test tier
names, commit scope lists, script runners, lint-disable reasons, vendor
imports, agent instruction symlinks, links and byte budgets, and the
comment rules. Rules with existing violations hold at their current count.

Generated with AI

Co-Authored-By: Claude <noreply@anthropic.com>
Generated with AI

Co-Authored-By: Claude <noreply@anthropic.com>
Drop instruction prose that restates code or that a lint, type check or
guard test already enforces. Move the config build and release runbook
and the e2e replay-server guide into docs, where people look for them.

Generated with AI

Co-Authored-By: Claude <noreply@anthropic.com>
Every eval submission for the stack start bucket check reloaded the
resolved config instead of reusing the one the handler already held.

Generated with AI

Co-Authored-By: Claude <noreply@anthropic.com>
…tructions

In a blinded ablation over two real CLI tasks, sessions given the skills
and the longer root instructions did not score higher than sessions given
the minimal root file alone.

Generated with AI

Co-Authored-By: Claude <noreply@anthropic.com>
The same ablation found no gain from the apps/cli, apps/cli-e2e and
packages/config guides. Repoint references to the docs that hold the
content people still need.

Generated with AI

Co-Authored-By: Claude <noreply@anthropic.com>
@kanadgupta kanadgupta added the run-ci Run full develop CI (tests) on drafts and non-develop PRs. label Dec 4, 2026
Add a root types:check script so turbo's types:check task covers tools/,
and fix the errors it found in the repo policy check and the local
release script.

Generated with AI

Co-Authored-By: Claude <noreply@anthropic.com>
@kanadgupta
kanadgupta marked this pull request as ready for review December 4, 2026 02:10
@kanadgupta
kanadgupta requested review from a team and supabase-oss as code owners December 4, 2026 02:10
@github-actions

github-actions Bot commented Dec 4, 2026

Copy link
Copy Markdown
Contributor

CLI benchmark (Lightweight Commands): no changes found

Commit 8515703 against develop at 8329f43 · 10 runs each · report only, never blocks merging

Command Workload Before After Change
supabase --version version 118 ms 113 ms no real change
supabase --help help 119 ms 124 ms no real change
supabase init init 120 ms 121 ms no real change
supabase migration new bench migration-new 132 ms 131 ms no real change
supabase config convert config-convert 135 ms 127 ms no real change (-5%, within normal variation)
supabase config validate config-validate 140 ms 148 ms no real change (+6%, within normal variation)
supabase gen types --lang typescript --project-id replayfixtureprojref gen-types 156 ms 156 ms no real change
supabase projects list projects-list 140 ms 140 ms no real change
supabase functions list --project-ref replayfixtureprojref functions-list 142 ms 151 ms no real change (+6%, within normal variation)

API calls: unchanged for all 9 commands.

Binary size: 134.1 MB, unchanged.

Details: timing ranges, API calls per command, slowest phases

Timing ranges

Command Workload Before range After range Change Verdict
supabase --version version 108-128 ms 106-125 ms -5 ms (-4%) within noise
supabase --help help 111-152 ms 110-162 ms +5 ms (+4%) within noise
supabase init init 106-145 ms 111-135 ms +1 ms (+1%) within noise
supabase migration new bench migration-new 120-159 ms 115-182 ms -1 ms (-1%) within noise
supabase config convert config-convert 112-234 ms 109-227 ms -7 ms (-5%) within noise
supabase config validate config-validate 131-154 ms 136-170 ms +9 ms (+6%) within noise
supabase gen types --lang typescript --project-id replayfixtureprojref gen-types 141-167 ms 142-166 ms +1 ms (+0%) within noise
supabase projects list projects-list 125-159 ms 125-149 ms +0 ms (+0%) within noise
supabase functions list --project-ref replayfixtureprojref functions-list 136-158 ms 138-160 ms +9 ms (+6%) within noise

API calls per command

Command Workload Before After Endpoint changes
supabase --version version 0 0
supabase --help help 0 0
supabase init init 0 0
supabase migration new bench migration-new 0 0
supabase config convert config-convert 0 0
supabase config validate config-validate 0 0
supabase gen types --lang typescript --project-id replayfixtureprojref gen-types 2 2
supabase projects list projects-list 1 1
supabase functions list --project-ref replayfixtureprojref functions-list 2 2

Slowest phases

No command moved beyond noise, so there are no phase deltas.

Workflow run

Comment /bench to run the lightweight benchmark (this comment) again on the latest commit, or /bench full to also run the integration-heavy benchmark, which posts in its own comment.

@github-actions github-actions Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Superseded by a newer AI review

🤖 AI Review

CLI reference prose guidance: not applicable (no reference sources changed).

Both independent reviews were available. The PR removes contributor guidance and adds a repository policy checker. The checker can reject valid source and commands, miss violations, and let new comment violations replace existing ones. A read-only scan reproduced the checkout’s comment baselines and verified that pending next work drops the comment-ratio count below the required total. Turbo 2.11.13 and the workspace dependencies were unavailable, so scheduling of the two new root checks remains unverified. The diff changes no CLI behavior or reference prose. The CLI reference style snapshot was marked not applicable.

Findings

Severity Location Category Sources Claim
🟠 MAJOR turbo.json:26 task-wiring codex pnpm check:all may omit the new root policy check and the tools type check.
🟡 MINOR AGENTS.md:6 documentation claude The PR removes the session-start guidance on what internal information to omit from public PRs, issues, and comments, along with the CLI guide’s consolidated compatibility guidance.
🟡 MINOR .github/ai-review/README.md:117 agent-guidance codex The rule requiring explicit authorization to edit CLI overlays disappears from the guidance loaded for CLI implementation work.
🟡 MINOR tools/repo-policy.ts:121 config-validation codex The config reload guard misses repeated calls through CliConfigValues.load and can flag a single helper call that is also mentioned in a comment.
🟡 MINOR tools/repo-policy.ts:432 policy-baseline codex A new comment violation passes when an unrelated existing violation of the same rule is removed.
🟡 MINOR tools/repo-policy.ts:120 command-parsing codex The runner check rejects quoted Bun file paths and misses some package-script invocations.
🟡 MINOR tools/repo-policy.ts:143 import-validation codex The vendor import check misses multiline imports and can flag import text inside strings.
🟡 MINOR tools/repo-policy.ts:151 lint-directives codex The lint-disable check can flag string literals and accepts directives with an empty reason.
🟡 MINOR tools/repo-policy.ts:107 comment-parsing codex The comment checks can count executable code and template-literal contents as comments.
🟡 MINOR tools/repo-policy.ts:309 symlink-validation codex The agent link check accepts dangling symlinks when their stored target path is correct.
🟡 MINOR tools/repo-policy.ts:370 link-validation codex The instruction link checker silently accepts links to deleted Markdown headings.
🟡 MINOR tools/repo-policy.ts:401 worktree-handling codex During local checks, untracked additions are skipped and an unstaged deletion of a scanned file aborts the scan.
🟡 MINOR tools/repo-policy.ts:282 workflow-validation codex An unrelated workflow step can mask a missing scope on the PR-title validator.
🟡 MINOR apps/cli/src/command-internal/management-api-runtime.layer.ts:75 documentation claude Deleting the CLI agent guide leaves source comments pointing to missing numbered layer invariants.
🟡 MINOR docs/adr/0020-config-naming-vocabulary.md:54 documentation claude ADR 0020 still directs readers to the root AGENTS.md for a config naming section that the PR removes.
⚪ NIT AGENTS.md:4 documentation claude The root guide’s blanket wording about bun run conflicts with the new checker’s allowance for direct file invocations.

Findings outside the diff

  • 🟡 MINOR apps/cli/src/command-internal/management-api-runtime.layer.ts:75 — Deleting the CLI agent guide leaves source comments pointing to missing numbered layer invariants.
  • 🟡 MINOR docs/adr/0020-config-naming-vocabulary.md:54 — ADR 0020 still directs readers to the root AGENTS.md for a config naming section that the PR removes.

Next impact (advisory)

Possible conflicts with work on the next branch. Informational only; this does not affect merging.

  • 🟡 MINOR tools/repo-policy.ts:439 — The comment-ratio check rejects a tree that combines this PR with the pending typed functions serve errors on next.

Stats

Claude findings: 4 · Codex findings: 12 · Confirmed: 16 · Refuted: 0 · Uncertain: 1


Models: claude-opus-5-5 + gpt-6.2-sol · Trigger: auto · Workflow run

This review runs once per PR. A maintainer can request another with a /ai-review comment.

Comment thread turbo.json Resolved
Comment thread AGENTS.md Resolved
Comment thread AGENTS.md Resolved
Comment thread .github/ai-review/README.md Resolved
Comment thread tools/repo-policy.ts Resolved
Comment thread tools/repo-policy.ts Resolved
Comment thread tools/repo-policy.ts Resolved
Comment thread tools/repo-policy.ts Resolved
Comment thread tools/repo-policy.ts Resolved
Comment thread tools/repo-policy.ts Resolved
kanadgupta and others added 3 commits December 3, 2026 18:35
Comments cited invariants from the deleted apps/cli/CLAUDE.md and the removed
Go porting status doc. They now state the reason inline. ADR 0020 notes that
the root AGENTS.md section it lists was removed.

Generated with AI

Co-Authored-By: Claude <noreply@anthropic.com>
Also scope the runner rule to package scripts, since `bun run file.ts` is
allowed.

Generated with AI

Co-Authored-By: Claude <noreply@anthropic.com>
- Fail comments that name a Markdown path that does not exist.
- Require reason text after ` -- ` in lint-disable comments and ignore
  directive text outside comments.
- Match vendor/effect imports split across lines and skip comments.
- Count resolved-config loads in code only, not comments.
- Read scopes only from the PR-title validator step and report it missing.
- Scan untracked files and skip deleted ones during local runs.

Generated with AI

Co-Authored-By: Claude <noreply@anthropic.com>
@kanadgupta

Copy link
Copy Markdown
Member Author

Follow-up on the AI review findings outside the diff:

  • Layer comments pointing to removed guide invariants: fixed in 822f0ec. The comments now state the reason inline. A new doc-reference check fails any source comment that names a missing .md file.
  • ADR 0020 pointing to the removed root section: fixed in 822f0ec with a "since removed" note.
  • next impact on comment-ratio: expected. The count is a ratchet, so whichever branch lands second updates the ALLOWED entry to the new total.

@kanadgupta

Copy link
Copy Markdown
Member Author

/ai-review

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🤖 AI Review

CLI reference prose guidance: snapshot supabase/supabase@6d14282 supplied to reviewers (advisory, not a style pass).

The new repository policy check and root tools type-check lack Turborepo root-task registration. The policy checker also has false positives, enforcement gaps, and two checkout-dependent failures. This PR changes no shipped CLI behavior or CLI reference prose, and the supplied next context shows no fundamental conflict. Validation included code inspection and isolated checks of the policy rules. Turbo was unavailable for a task-graph dry run.

Findings

Severity Location Category Sources Claim
🟠 MAJOR turbo.json:26 ci codex pnpm check:all does not schedule the new root policy check or the root tools type-check.
🟡 MINOR tools/repo-policy.ts:527 ci-reliability claude The exact-count ratchet rejects unrelated cleanups and can fail a combined merge candidate even when each PR passes separately.
🟡 MINOR tools/repo-policy.ts:437 correctness codex A CRLF checkout of the current AGENTS.md fails the new instruction budget.
🟡 MINOR tools/repo-policy.ts:387 correctness codex The policy check rejects an unchanged CLAUDE.md in a checkout using core.symlinks=false.
🟡 MINOR tools/repo-policy.ts:110 correctness codex The source checker treats some TypeScript string contents as comments and can reject valid source.
🟡 MINOR tools/repo-policy.ts:124 correctness codex The package-runner rule rejects quoted Bun script paths and accepts dotted package script names.
🟡 MINOR tools/repo-policy.ts:163 correctness codex The config reload guard can miss repeated loads within a command and flag separate entrypoints in the same file.
🟡 MINOR tools/repo-policy.ts:520 correctness codex Fixing one grandfathered violation can conceal a new violation of the same rule elsewhere.
🟡 MINOR tools/repo-policy.ts:312 correctness codex Deleting an instruction symlink and its target can fail the local policy check until the deletion is staged.
🟡 MINOR tools/repo-policy.ts:387 correctness codex The agent-link guard accepts dangling instruction and skill symlinks when their target text matches.
🟡 MINOR tools/repo-policy.ts:85 ci codex Adding an unrelated reusable-workflow job to the PR lint workflow would break the commit-scope check.
🟡 MINOR AGENTS.md:6 docs-consistency claude The review prompts still direct reviewers to package-level CLAUDE.md files after this PR deletes the CLI copy and its convention guide.
🟡 MINOR .github/ai-review/README.md:117 agent-instructions codex The overlay authorization rule disappears from the instructions loaded by CLI authors.
⚪ NIT docs/adr/0020-config-naming-vocabulary.md:54 docs-consistency claude+codex The naming ADR still describes three current sources even though the PR removes the root AGENTS.md copy.
⚪ NIT tools/repo-policy.ts:289 error-handling claude A failed git ls-files loses the diagnostic Git writes to stderr.

Stats

Claude findings: 4 · Codex findings: 10 · Confirmed: 15 · Refuted: 0 · Uncertain: 0


Models: claude-opus-5-5 + gpt-6.2-sol · Trigger: manual · Workflow run

This review runs once per PR. A maintainer can request another with a /ai-review comment.

Comment thread turbo.json
Comment on lines +26 to +28
"policy:check": {
"cache": false
},

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟠 MAJOR · ci · source: codex

pnpm check:all does not schedule the new root policy check or the root tools type-check.

Evidence: package.json:17 invokes turbo run. Lines 19 and 30 define the new root scripts. turbo.json:10–13 and :26–28 use bare task keys and omit //#types:check and //#policy:check. The repository previously used //#test:e2e:run for a root task in commit aa3bb6b.

Suggested fix: Register //#policy:check with caching disabled and add //#types:check alongside the workspace type-check task. Verify both root task IDs appear in the dry-run graph.

Comment thread tools/repo-policy.ts Outdated
Comment on lines +527 to +531
if (found.length === allowed) continue;
if (found.length < allowed) {
failures.push(`${rule}: ${found.length} left; lower its ALLOWED entry from ${allowed}.`);
continue;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 MINOR · ci-reliability · source: claude

The exact-count ratchet rejects unrelated cleanups and can fail a combined merge candidate even when each PR passes separately.

Evidence: tools/repo-policy.ts:43–46 stores exact totals, and :527–531 fails when a count drops below its total. Two PRs can each remove a different counted comment and make the same baseline edit from 176 to 175. The combined tree contains 174. .github/workflows/test.yml:24–29 and :60–78 configure the quality job to run on merge groups.

Suggested fix: Keep counts above the baseline as failures and report decreases as advisory baseline updates.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in 3f0ed91: a count below its allowance now prints a note to lower it instead of failing.

🤖 Addressed by Claude Code

Comment thread tools/repo-policy.ts
Comment on lines +437 to +445
const budget = file.endsWith("AGENTS.md")
? (INSTRUCTION_BUDGET[file] ?? DEFAULT_INSTRUCTION_BUDGET)
: undefined;
const bytes = new TextEncoder().encode(text).length;
if (budget !== undefined && bytes > budget) {
violations.push({
rule: "instruction-budget",
file,
message: `${bytes} bytes exceeds the ${budget}-byte budget; replace prose with a check or a link before adding more.`,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 MINOR · correctness · source: codex

A CRLF checkout of the current AGENTS.md fails the new instruction budget.

Evidence: tools/repo-policy.ts:50–52 sets a 1,000-byte limit, and :437–445 measures the raw working-tree text. Git's checkout filters produce 985 bytes with LF and 1,002 with core.autocrlf=true. git check-attr reports no line-ending override for AGENTS.md.

Suggested fix: Normalize CRLF to LF before measuring the instruction budget.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in 3f0ed91: the instruction budget is measured after normalizing CRLF to LF.

🤖 Addressed by Claude Code

Comment thread tools/repo-policy.ts
Comment on lines +387 to +399
const expectLink = Effect.fnUntraced(function* (file: TrackedFile, target: string) {
const actual = file.symlink
? yield* fs.readLink(path.join(repoRoot, file.path)).pipe(Effect.orElseSucceed(() => ""))
: "";
return actual === target
? []
: [
{
rule: "agent-file-link" as const,
file: file.path,
message: `Must be a symlink to \`${target}\` so every agent reads one source.`,
},
];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 MINOR · correctness · source: codex

The policy check rejects an unchanged CLAUDE.md in a checkout using core.symlinks=false.

Evidence: The root CLAUDE.md has index mode 120000 and blob content AGENTS.md. Git preserves that index mode with core.symlinks=false and materializes the blob as a regular file. tools/repo-policy.ts:312–315 marks it as a symlink from the index, then :387–399 treats the failed working-tree readLink as a violation.

Suggested fix: When Git's symlink emulation is enabled, validate the tracked link mode and target against the index and verify that the working-tree file contains that same target.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in 3f0ed91: when the link is checked out as a plain file, its content is compared with the expected target.

🤖 Addressed by Claude Code

Comment thread tools/repo-policy.ts
Comment on lines +110 to +114
const commentText = (line: string) => {
const trimmed = line.trimStart();
return trimmed.startsWith("//") || trimmed.startsWith("/*") || trimmed.startsWith("*")
? trimmed
: undefined;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 MINOR · correctness · source: codex

The source checker treats some TypeScript string contents as comments and can reject valid source.

Evidence: tools/repo-policy.ts:110–114 classifies lines by their first characters. Lines 185–201 search raw lines for lint directives and count comment-like lines. An isolated run of the source predicate emitted lint-disable-reason for a literal // eslint-disable-next-line inside a template string.

Suggested fix: Use TypeScript lexical comment ranges for comment counts and lint directives.

Comment thread tools/repo-policy.ts
Comment on lines +85 to +96
const PullRequestLintWorkflow = Schema.Struct({
jobs: Schema.Record(
Schema.String,
Schema.Struct({
steps: Schema.Array(
Schema.Struct({
uses: Schema.optional(Schema.String),
with: Schema.optional(Schema.Struct({ scopes: Schema.optional(Schema.String) })),
}),
),
}),
),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 MINOR · ci · source: codex

Adding an unrelated reusable-workflow job to the PR lint workflow would break the commit-scope check.

Evidence: tools/repo-policy.ts:85–96 requires a steps array for every job. Lines 340–351 decode the whole PR lint workflow before looking for the validator. The current validator is at .github/workflows/lint-pull-request.yml:43–50. Reusable-workflow callers use job-level uses and have no steps array.

Suggested fix: Allow reusable-workflow jobs in the schema and search the step-based jobs for the validator.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in 3f0ed91: jobs without steps (reusable-workflow callers) are allowed, and only step-based jobs are searched for the validator.

🤖 Addressed by Claude Code

Comment thread AGENTS.md Outdated
Comment on lines +6 to +8
`pnpm check:all` (lint, format, knip, types, workflows, `tools/repo-policy.ts`) and the guard tests
own the mechanical rules; when one fails, its message is the rule. Run the type, lint, and format
checks plus the affected `*.unit.test.ts` and `*.integration.test.ts` files for what you changed

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 MINOR · docs-consistency · source: claude

The review prompts still direct reviewers to package-level CLAUDE.md files after this PR deletes the CLI copy and its convention guide.

Evidence: .github/ai-review/claude-review-prompt.md:11–13, .github/ai-review/codex-review-prompt.md:11–13, and .github/ai-review/adjudicate-prompt.md:20–23 retain the package-level directions. The PR removes apps/cli/AGENTS.md and its CLAUDE.md symlink. The trusted CLI guide at lines 82–110 documented sibling layer provisioning, output flag precedence, and command tombstones.

Suggested fix: Point reviewers to the maintained ADRs and guard tests, and preserve the CLI conventions those sources do not cover in a durable reference.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in 32a1455: the three review prompts now point to the root CLAUDE.md, docs/adr/, and the checks under tools/.

🤖 Addressed by Claude Code

Comment on lines +117 to 121
completeness, and does not edit overlays or propose replacement prose. Overlays under
`apps/cli/docs/supabase/` are human-authored: adding, rewriting, or removing one requires explicit
human authorization, and a command implementation request does not grant it.
Reviewers do not infer authorship or authorization from writing style or absent PR metadata.
This is an AI review instruction, not a deterministic guarantee that every contradiction will be found.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 MINOR · agent-instructions · source: codex

The overlay authorization rule disappears from the instructions loaded by CLI authors.

Evidence: The deleted CLI guide stated the authorization rule at lines 112–117. .github/ai-review/README.md:117–121 preserves it in reviewer guidance. The replacement root AGENTS.md:1–17 omits the rule and a link to it.

Suggested fix: Keep the rule in scoped author instructions or link to the existing rule from the root AGENTS.md.

Comment on lines +54 to +55
- repo-root `AGENTS.md`, in a "Config Naming Vocabulary" section (since removed; the two places
below still carry it)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚪ NIT · docs-consistency · source: claude+codex

The naming ADR still describes three current sources even though the PR removes the root AGENTS.md copy.

Evidence: docs/adr/0020-config-naming-vocabulary.md:51 says the convention is documented in three places. Lines 54–55 mark one of them removed, and :72–74 and :82–84 still rely on the root copy being available at session start.

Suggested fix: List the two current sources and update the affected rationale and consequences, or record the removal in a dated addendum.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in 32a1455: reverted the inline edit and added a dated addendum that lists the two current sources and notes the rationale change.

🤖 Addressed by Claude Code

Comment thread tools/repo-policy.ts
Comment on lines +289 to +297
const handle = yield* spawner.spawn(ChildProcess.make(command, args, { cwd }));
const [stdout, exitCode] = yield* Effect.all(
[Stream.mkString(Stream.decodeText(handle.stdout)), handle.exitCode],
{ concurrency: "unbounded" },
);
if (exitCode !== ChildProcessSpawner.ExitCode(0)) {
return yield* fail(`\`${command} ${args.join(" ")}\` exited with code ${exitCode}`);
}
return stdout;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚪ NIT · error-handling · source: claude

A failed git ls-files loses the diagnostic Git writes to stderr.

Evidence: tools/repo-policy.ts:289–295 consumes stdout and the exit code, then constructs an error with the command and exit code. The Bun spawner delegates to the shared implementation, which pipes stderr by default in vendor/effect/packages/platform/node-shared/src/NodeChildProcessSpawner.ts:278–289.

Suggested fix: Drain stderr concurrently with stdout and include the captured diagnostic on nonzero exit.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in 3f0ed91: stderr is drained with stdout and included in the error on a nonzero exit.

🤖 Addressed by Claude Code

kanadgupta and others added 3 commits December 3, 2026 19:04
…ources

Review prompts no longer send reviewers to package-level CLAUDE.md files,
which this PR removes. ADR 0020 records the root section's removal in a dated
addendum instead of editing the original body.

Generated with AI

Co-Authored-By: Claude <noreply@anthropic.com>
- Report a count below its allowance as a note, not a failure, so unrelated
  cleanups and merge queues do not break.
- Measure instruction budgets with LF line endings.
- Accept a CLAUDE.md written as a plain file under core.symlinks=false, and
  flag links whose target is missing.
- Skip tracked links deleted from the working tree.
- Allow reusable-workflow jobs in the PR lint workflow.
- Include git's stderr when a git command fails.

Generated with AI

Co-Authored-By: Claude <noreply@anthropic.com>
…-agent-text-pruning-21ec83

# Conflicts:
#	packages/config/AGENTS.md
Comment thread AGENTS.md
`pnpm <script>`, never `bun run <script>` or `npm run`.

## Workspaces and naming
`pnpm check:all` (lint, format, knip, types, workflows, `tools/repo-policy.ts`) and the guard tests

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This PR moves the mechanical rules into tools/repo-policy.ts, but several non-mechanical contracts lived only in the deleted guides. No check covers them, and no doc that a writing agent reads restates them:

  • Overlay authorization. The rule now exists only in .github/ai-review/README.md and the review prompts. Its audience is the agent writing the change ("a command implementation request does not grant it"), and that agent never loads those files. The develop → next sync agents are a second case: their resolve and repair prompts (.github/sync-branches/resolve-prompt.md, repair-prompt.md) point at AGENTS.md/CLAUDE.md/ADRs, and they can edit an overlay while resolving a conflict.
  • Removing a command or flag. The rule was: ship a stable deprecation warning first, keep the old flags so old invocations hit removedCommand/removedFlag instead of a parse error, register the command with Command.unlisted, and test the tombstone through the parser. removedCommand's JSDoc covers the wrapper, but nothing states the procedure.
  • Telemetry stability. The rule was to keep custom event names, payloads and timing, and to keep free-form user input out of safeFlags. apps/cli/docs/analytics.md documents the current events, not the rule against changing them.
  • Load config once per command. config-context-reload only counts calls within one file. The local storage ls path loads config in one file and again in another (storage.frame.ts:70, storage-credentials.ts:167), and it passes.
  • Instrument by default. This rule covered new I/O. ADR 0027 and tracing-monitoring.md keep the naming conventions, but nothing the agent loads points to them anymore.

The ablation ran two ordinary CLI changes. These rules govern rare, high-impact changes it couldn't exercise, as the PR notes for some of them. Could they move into the existing CLI docs (apps/cli/docs/, packages/config/docs/cli-config-loading.md), the way the config runbook and the e2e replay guide moved? The root file would then need one pointer, keeping in mind it's at 985 of its 1,000 bytes. The sync prompts should get a pointer too.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Agreed. 2ca8a3a adds apps/cli/docs/contracts.md with all five: command and flag removal, telemetry stability, overlay authorization (including during conflict resolution), loading config once per command (it notes the check only sees one file, so cases like storage ls pass), and instrumenting I/O. The root AGENTS.md points to it in one sentence (now 988 bytes), and both sync prompts list it; the resolve prompt also says to keep both sides of a conflicted overlay and write no new prose.

🤖 Addressed by Claude Code

Comment thread tools/repo-policy.ts Outdated
return violations;
};

const testTierViolations = (file: string): ReadonlyArray<Violation> =>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

test-tier-name accepts every tier in every workspace, but each workspace runs only some tiers. packages/config and packages/cli-test-helpers only run **/*.unit.test.ts, and packages/stack has no live project. So a file like packages/config/tests/foo.integration.test.ts passes this check and Vitest never runs it, even though the message says "no Vitest project runs an untiered file". Could the allowed suffixes come from the owning workspace's Vitest projects, or could the message at least say that the workspace decides which tiers run?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in 49682e4: the allowed tiers now come from the **/*.<tier>.test.ts includes in the owning workspace's vitest.config.ts, so packages/config/tests/foo.integration.test.ts fails with "packages/config's Vitest config runs only unit".

🤖 Addressed by Claude Code

Comment thread tools/repo-policy.ts Outdated
continue;
}
if (found.length === allowed) continue;
if (found.length < allowed) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

When the count drops below the allowed number, the check only prints a note. A cleanup from 176 to 175 leaves the allowance at 176, and a later PR can add a violation back without failing. So "can only go down" in the description doesn't hold. Failing until the number is lowered would make it a real ratchet, and lowering the number is a one-line change in the same PR. When the check does fail, it prints every violation for the rule (about 177 lines for filler words), which makes the new one hard to find.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in 49682e4: the totals are replaced by tools/repo-policy.baseline.json, with counts per rule and file. A file under its baseline fails until pnpm policy:baseline lowers the entry, and a file over it fails listing only that file's violations, so the new one is easy to find.

🤖 Addressed by Claude Code

kanadgupta and others added 2 commits December 4, 2026 03:08
Removing a command or flag, telemetry stability, overlay authorization,
loading config once per command, and instrumenting I/O lived only in the
deleted CLI guide. They now live in apps/cli/docs/contracts.md. The root
AGENTS.md and the develop-to-next sync prompts point to it.

Generated with AI

Co-Authored-By: Claude <noreply@anthropic.com>
Replace the per-rule totals with tools/repo-policy.baseline.json, which
records existing violations by rule and file. A file over its baseline fails
and lists only its own violations. A file under its baseline fails until
`pnpm policy:baseline` lowers the entry, so the baseline only goes down.

Test files must now use a tier that their workspace's Vitest config runs.

Generated with AI

Co-Authored-By: Claude <noreply@anthropic.com>

@jgoux jgoux left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No blocking findings. The new check, typecheck, lint, format and knip all pass at this head. Two non-blocking notes inline.

Comment thread tools/repo-policy.ts
violations.filter((violation) => violation.rule === rule),
(violation) => violation.file,
);
if (mode === "baseline") {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P3: baseline mode writes every observed count without reading the existing baseline, so it can raise allowances. If a PR removes one baselined violation and adds another elsewhere, check asks for a refresh because of the removal, and the refresh records the new violation too; the next check passes. "The baseline only goes down" then rests on someone reviewing the JSON diff rather than on the tool. Consider having baseline keep min(existing, observed) per rule and file and refuse to add entries or raise counts.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in c0bdb74: baseline now writes min(recorded, observed) per rule and file and never adds an entry. Anything it would have raised is listed with a note to fix it or edit the file by hand, and check keeps failing until then.

🤖 Addressed by Claude Code

Comment thread tools/repo-policy.ts
const isRunnerSurface = (file: string) =>
/^\.github\/(workflows|actions)\/.*\.ya?ml$/.test(file) || file.startsWith(".husky/");

const commentText = (line: string) => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P3: commentText is line-based, so text inside template strings counts as comments. project-init.templates.ts is already baselined for this: the DO NOT warnings in the config template that init writes to users' config.jsonc count as caps-emphasis. Adding a similar warning or a standard reference to that template would fail check:all even though it is output, not a source comment. Consider scanning TypeScript comment tokens, or skipping template-string contents.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in c0bdb74: a small scan marks lines that start inside a template literal (tracking ${…} nesting, skipping comments and quoted strings), and the comment rules treat those lines as code. The project-init.templates.ts entries left the baseline; a real comment after a template is still caught. It doesn't model regex literals, which I judged acceptable here.

🤖 Addressed by Claude Code

`pnpm policy:baseline` now keeps the lower of the recorded and observed
count per rule and file, and never adds an entry, so a refresh can't
absorb a new violation. Comment rules skip lines inside template
literals, which are output (such as the `init` config template), not
source comments.

Generated with AI

Co-Authored-By: Claude <noreply@anthropic.com>
kanadgupta and others added 2 commits December 4, 2026 05:01
develop dropped the comment-ratio violation in status-values.ts.

Generated with AI

Co-Authored-By: Claude <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

run-ci Run full develop CI (tests) on drafts and non-develop PRs.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants