mirror of
https://github.com/garrytan/gstack.git
synced 2026-05-14 00:13:05 +08:00
Splits scripts/resolvers/preamble.ts (841 lines, 18 generator functions + composition root) into one file per generator under scripts/resolvers/preamble/. Root preamble.ts becomes a thin composition layer (~80 lines of imports + generatePreamble). Before: scripts/resolvers/preamble.ts 841 lines After: scripts/resolvers/preamble.ts 83 lines scripts/resolvers/preamble/generate-preamble-bash.ts 97 lines scripts/resolvers/preamble/generate-upgrade-check.ts 48 lines scripts/resolvers/preamble/generate-lake-intro.ts 16 lines scripts/resolvers/preamble/generate-telemetry-prompt.ts 37 lines scripts/resolvers/preamble/generate-proactive-prompt.ts 25 lines scripts/resolvers/preamble/generate-routing-injection.ts 49 lines scripts/resolvers/preamble/generate-vendoring-deprecation.ts 36 lines scripts/resolvers/preamble/generate-spawned-session-check.ts 11 lines scripts/resolvers/preamble/generate-ask-user-format.ts 16 lines scripts/resolvers/preamble/generate-completeness-section.ts 19 lines scripts/resolvers/preamble/generate-repo-mode-section.ts 12 lines scripts/resolvers/preamble/generate-test-failure-triage.ts 108 lines scripts/resolvers/preamble/generate-search-before-building.ts 14 lines scripts/resolvers/preamble/generate-completion-status.ts 161 lines scripts/resolvers/preamble/generate-voice-directive.ts 60 lines scripts/resolvers/preamble/generate-context-recovery.ts 51 lines scripts/resolvers/preamble/generate-continuous-checkpoint.ts 48 lines scripts/resolvers/preamble/generate-context-health.ts 31 lines Byte-identity verification (the real gate per Codex correction): - Before refactor: snapshotted 135 generated SKILL.md files via `find -name SKILL.md -type f | grep -v /gstack/` across all hosts. - After refactor: regenerated with `bun run gen:skill-docs --host all` and re-snapshotted. - `diff -r baseline after` returned zero differences and exit 0. The `--host all --dry-run` gate passes too. No template or host behavior changes — purely a code-organization refactor. Test fix: audit-compliance.test.ts's telemetry check previously grepped preamble.ts directly for `_TEL != "off"`. After the refactor that logic lives in preamble/generate-preamble-bash.ts. Test now concatenates all preamble submodule sources before asserting — tracks the semantic contract, not the file layout. Doing the minimum rewrite preserves the test's intent (conditional telemetry) without coupling it to file boundaries. Why now: we were in-session with full context. Codex had downgraded this from mandatory to optional, but the preamble had grown to 841 lines and was getting harder to navigate. User asked "why not?" given the context was hot. Shipping it as a clean bisectable commit while all the prior preamble.ts changes are fresh reduces rebase pain later. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
109 lines
4.9 KiB
TypeScript
109 lines
4.9 KiB
TypeScript
|
|
|
|
export function generateTestFailureTriage(): string {
|
|
return `## Test Failure Ownership Triage
|
|
|
|
When tests fail, do NOT immediately stop. First, determine ownership:
|
|
|
|
### Step T1: Classify each failure
|
|
|
|
For each failing test:
|
|
|
|
1. **Get the files changed on this branch:**
|
|
\`\`\`bash
|
|
git diff origin/<base>...HEAD --name-only
|
|
\`\`\`
|
|
|
|
2. **Classify the failure:**
|
|
- **In-branch** if: the failing test file itself was modified on this branch, OR the test output references code that was changed on this branch, OR you can trace the failure to a change in the branch diff.
|
|
- **Likely pre-existing** if: neither the test file nor the code it tests was modified on this branch, AND the failure is unrelated to any branch change you can identify.
|
|
- **When ambiguous, default to in-branch.** It is safer to stop the developer than to let a broken test ship. Only classify as pre-existing when you are confident.
|
|
|
|
This classification is heuristic — use your judgment reading the diff and the test output. You do not have a programmatic dependency graph.
|
|
|
|
### Step T2: Handle in-branch failures
|
|
|
|
**STOP.** These are your failures. Show them and do not proceed. The developer must fix their own broken tests before shipping.
|
|
|
|
### Step T3: Handle pre-existing failures
|
|
|
|
Check \`REPO_MODE\` from the preamble output.
|
|
|
|
**If REPO_MODE is \`solo\`:**
|
|
|
|
Use AskUserQuestion:
|
|
|
|
> These test failures appear pre-existing (not caused by your branch changes):
|
|
>
|
|
> [list each failure with file:line and brief error description]
|
|
>
|
|
> Since this is a solo repo, you're the only one who will fix these.
|
|
>
|
|
> RECOMMENDATION: Choose A — fix now while the context is fresh. Completeness: 9/10.
|
|
> A) Investigate and fix now (human: ~2-4h / CC: ~15min) — Completeness: 10/10
|
|
> B) Add as P0 TODO — fix after this branch lands — Completeness: 7/10
|
|
> C) Skip — I know about this, ship anyway — Completeness: 3/10
|
|
|
|
**If REPO_MODE is \`collaborative\` or \`unknown\`:**
|
|
|
|
Use AskUserQuestion:
|
|
|
|
> These test failures appear pre-existing (not caused by your branch changes):
|
|
>
|
|
> [list each failure with file:line and brief error description]
|
|
>
|
|
> This is a collaborative repo — these may be someone else's responsibility.
|
|
>
|
|
> RECOMMENDATION: Choose B — assign it to whoever broke it so the right person fixes it. Completeness: 9/10.
|
|
> A) Investigate and fix now anyway — Completeness: 10/10
|
|
> B) Blame + assign GitHub issue to the author — Completeness: 9/10
|
|
> C) Add as P0 TODO — Completeness: 7/10
|
|
> D) Skip — ship anyway — Completeness: 3/10
|
|
|
|
### Step T4: Execute the chosen action
|
|
|
|
**If "Investigate and fix now":**
|
|
- Switch to /investigate mindset: root cause first, then minimal fix.
|
|
- Fix the pre-existing failure.
|
|
- Commit the fix separately from the branch's changes: \`git commit -m "fix: pre-existing test failure in <test-file>"\`
|
|
- Continue with the workflow.
|
|
|
|
**If "Add as P0 TODO":**
|
|
- If \`TODOS.md\` exists, add the entry following the format in \`review/TODOS-format.md\` (or \`.claude/skills/review/TODOS-format.md\`).
|
|
- If \`TODOS.md\` does not exist, create it with the standard header and add the entry.
|
|
- Entry should include: title, the error output, which branch it was noticed on, and priority P0.
|
|
- Continue with the workflow — treat the pre-existing failure as non-blocking.
|
|
|
|
**If "Blame + assign GitHub issue" (collaborative only):**
|
|
- Find who likely broke it. Check BOTH the test file AND the production code it tests:
|
|
\`\`\`bash
|
|
# Who last touched the failing test?
|
|
git log --format="%an (%ae)" -1 -- <failing-test-file>
|
|
# Who last touched the production code the test covers? (often the actual breaker)
|
|
git log --format="%an (%ae)" -1 -- <source-file-under-test>
|
|
\`\`\`
|
|
If these are different people, prefer the production code author — they likely introduced the regression.
|
|
- Create an issue assigned to that person (use the platform detected in Step 0):
|
|
- **If GitHub:**
|
|
\`\`\`bash
|
|
gh issue create \\
|
|
--title "Pre-existing test failure: <test-name>" \\
|
|
--body "Found failing on branch <current-branch>. Failure is pre-existing.\\n\\n**Error:**\\n\`\`\`\\n<first 10 lines>\\n\`\`\`\\n\\n**Last modified by:** <author>\\n**Noticed by:** gstack /ship on <date>" \\
|
|
--assignee "<github-username>"
|
|
\`\`\`
|
|
- **If GitLab:**
|
|
\`\`\`bash
|
|
glab issue create \\
|
|
-t "Pre-existing test failure: <test-name>" \\
|
|
-d "Found failing on branch <current-branch>. Failure is pre-existing.\\n\\n**Error:**\\n\`\`\`\\n<first 10 lines>\\n\`\`\`\\n\\n**Last modified by:** <author>\\n**Noticed by:** gstack /ship on <date>" \\
|
|
-a "<gitlab-username>"
|
|
\`\`\`
|
|
- If neither CLI is available or \`--assignee\`/\`-a\` fails (user not in org, etc.), create the issue without assignee and note who should look at it in the body.
|
|
- Continue with the workflow.
|
|
|
|
**If "Skip":**
|
|
- Continue with the workflow.
|
|
- Note in output: "Pre-existing test failure skipped: <test-name>"`;
|
|
}
|
|
|