mirror of
https://github.com/garrytan/gstack.git
synced 2026-11-01 06:24:41 +01:00
* feat(pregate): lanes follows Python imports and mock.patch targets The import graph only parsed JS/TS imports, so in a Python repo every touched module failed `lanes` with PREGATE_NO_LANE even though SOURCE_EXT, TEST_FILE_RE and the pytest runner/summary already understood Python. Python sources now contribute `import a.b`, `from a.b import c` (c may be a submodule), parenthesised multi-line lists and relative `from ..pkg import x` edges, resolved to `a/b.py` or `a/b/__init__.py` from the repository root. Package `__init__.py` files on the path get edges too, since Python executes them on import. Modules outside the repo resolve to nothing. In test files, dotted string literals such as `'pkg.mod.Class.method'` (mock.patch targets) resolve to the longest dotted prefix that is a repo module. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(regen): report missing dependencies as REGEN_DEPS_MISSING, not REGEN_STALE When package.json declares dependencies and node_modules is missing, the scratch worktree runs the generator without them. A generator that degrades and still exits 0 then looked stale, and the fix line sent people to rerun the generator. gstack-regen check and the pregate regen check now report "dependencies missing; run <install>" with its own result code and troubleshooting anchor; the install command follows the lockfile. The fixture reproduces the shape GSTA-31 saw in gbrain. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix(pregate): keep Python import scanning linear and conservative Review of #3201 on the integrated tree found two quadratic paths on untrusted Python source and three ways a test could be left unselected: - The from-import module spec let two repetitions share a dot, so a failed match on a long run of dots backtracked quadratically. The spec is now dots followed by an optional word-led name. - Dotted literals and imports resolved every prefix with repeated split/join. Names are capped at 32 segments, deeper than any module path. - A literal that also named a repo file skipped its mock.patch reading; both readings now add edges. - A package and a same-named module both map (Python loads the package). - Imports after `;` or a compound statement's `:` are recognised. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix(pregate): linear Python string blanking, non-empty from-spec, repo-bounded depth Second review round on the Python import scanner: - An empty from-spec let the whitespace on both sides of it compete, so `from` followed by a long run of spaces backtracked quadratically. The spec now starts with a dot or a word character. - Strings and comments are blanked by a single linear scanner that honours backslash escapes, so an escaped triple quote no longer ends a docstring early and swallows the imports after it. - The fixed 32-segment cap dropped real deep modules. Dotted names are now bounded by the repo's deepest path, which no module can exceed. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * docs(changelog): unreleased entry for Python import lanes and REGEN_DEPS_MISSING Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * v1.91.126.0 stamp Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * release slot 1.91.126.0: back to unstamped (CHANGELOG entry unreleased) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix(changelog): resolve the main-merge conflict (Unreleased entry above 1.91.127.0) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * v1.91.131.0 stamp Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> --------- Co-authored-by: Scott Gigante <scott@gethubflow.ai> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
94 lines
6.3 KiB
TypeScript
94 lines
6.3 KiB
TypeScript
/**
|
||
* Result codes for the release path: gstack-ship-queue and the ship-policy
|
||
* floor, pregate timing and its working-tree fingerprint, regen with missing
|
||
* dependencies, approval classes and
|
||
* the state-machine matrix. Kept beside lib/result-codes.ts (which spreads
|
||
* this table into RESULT_CODES) so
|
||
* the owner module stays within the module-size ratchet; the same rules apply:
|
||
* one stable docs/troubleshooting.md anchor, a summary and a fix clause each.
|
||
*/
|
||
import type { ResultCode } from './result-codes';
|
||
|
||
export const RELEASE_RESULT_CODES = {
|
||
// Field list 2, W1: gstack-ship-queue and the ship-policy compatibility floor.
|
||
POLICY_GSTACK_TOO_OLD: {
|
||
anchor: 'policy-gstack-too-old',
|
||
summary: 'the ship policy sets min_gstack_version above this gstack, so this gstack refuses to read it',
|
||
fix: 'upgrade gstack (bin/gstack-upgrade, or the session install with --for <skill>) to the version named, then rerun',
|
||
},
|
||
QUEUE_NOT_READY: {
|
||
anchor: 'queue-not-ready',
|
||
summary: 'the lane is not ready to report: the working tree, HEAD or CI state does not match the pushed PR head',
|
||
fix: 'commit and push the work (or wait for CI on that exact head), then rerun gstack-ship-queue ready',
|
||
},
|
||
QUEUE_PROOF_MISSING: {
|
||
anchor: 'queue-proof-missing',
|
||
summary: 'a proof input the queue step needs is missing or does not match (gated head, base, stamp journal, version or tree)',
|
||
fix: 'supply the named input (fetch the gated head, pass the expected sha), or regate; nothing was written',
|
||
},
|
||
QUEUE_STAMP_NOT_STAMP_ONLY: {
|
||
anchor: 'queue-stamp-not-stamp-only',
|
||
summary: 'the stamp commit differs from the gated head by more than stamps, so the gate does not cover it',
|
||
fix: 'inspect the printed residual paths; drop the stray edit, or run the gate again on the stamped head',
|
||
},
|
||
QUEUE_VERIFY_MISMATCH: {
|
||
anchor: 'queue-verify-mismatch',
|
||
summary: 'the coordinator could not reproduce the lane’s stamp claim: the PR head, the recomputed gate-ahead merge or the gated tree differs',
|
||
fix: 'do not merge; ask the lane to rerun gstack-ship-queue stamp (or gate-ahead) on the current queue and report again',
|
||
},
|
||
QUEUE_GATE_MISSING: {
|
||
anchor: 'queue-gate-missing',
|
||
summary: 'the policy sets full_e2e and no passing full-gate record is bound to this tree',
|
||
fix: 'run the gate the policy names (gstack-ship-queue gate-ahead, then --record) or pass the record of a passing run on this head',
|
||
},
|
||
GATE_AHEAD_ATTEMPT_INVALID: {
|
||
anchor: 'gate-ahead-attempt-invalid',
|
||
summary: 'the gate-ahead attempt is unknown, already recorded, or its worktree no longer holds the gated commit',
|
||
fix: 'list attempts with gstack-ship-queue gate-ahead --list, then record the live one, or prepare a new attempt',
|
||
},
|
||
// Field list 2 W4 (pregate `timing`).
|
||
PREGATE_TIMING_ASSERTION: {
|
||
anchor: 'pregate-timing-assertion',
|
||
summary: 'an added or changed test line compares an elapsed wall-clock or CPU time against a bound, or sleeps and then asserts (a warning, not a block)',
|
||
fix: 'assert on the outcome, an injected clock or a forced deadline instead; when the bound is the contract, add `gstack-timing-ok: <reason>` in a comment on the line or the line above',
|
||
},
|
||
// Field list 2, W2 (approval classes) and W3 (state-machine round-trip matrix).
|
||
APPROVAL_CLASSES_INVALID: {
|
||
anchor: 'approval-classes-invalid',
|
||
summary: '`.gstack/approval-classes.json` is malformed, a class matches nothing, or a path escapes the repository',
|
||
fix: 'keep `classes` a non-empty list of uniquely named classes, each with `paths`, `patterns` or `migrations: true`, and every glob repo-relative (`gstack-approval-classes validate` checks the working-tree copy)',
|
||
},
|
||
APPROVAL_CLASS_FOUND: {
|
||
anchor: 'approval-class-found',
|
||
summary: 'the branch changes something a declared approval class covers',
|
||
fix: 'get the owner\'s approval and put `Approved by <owner> <YYYY-MM-DD> via <plan sha|comment or review URL> for <class>@<digest12>` in the PR body, using the APPROVAL_SCOPE token the check printed',
|
||
},
|
||
APPROVAL_CITATION_MISSING: {
|
||
anchor: 'approval-citation-missing',
|
||
summary: 'a declared approval class has no citation that resolves and binds to its current effects, so no receipt was written',
|
||
fix: 'add an `Approved by` line whose plan (with --approval-run <dir>) or maintainer comment names the APPROVAL_SCOPE token or the class and every effect path; for evidence gstack cannot read, attest it with `for <class>@<digest12>` on the line. Only the owner approves: never write the line without their approval',
|
||
},
|
||
APPROVAL_SOURCE_UNAVAILABLE: {
|
||
anchor: 'approval-source-unavailable',
|
||
summary: 'origin/<base> is not a resolvable commit, so the committed .gstack/approval-classes.json cannot be read and nothing was checked',
|
||
fix: 'git fetch origin <base> (classes are never read from the working tree)',
|
||
},
|
||
STATE_MATRIX_INCOMPLETE: {
|
||
anchor: 'state-matrix-incomplete',
|
||
summary: 'the state-machines specialist output lacks a kind × owner action cell, maps a cell to a test that does not exist, or leaves an untested cell without a CRITICAL finding',
|
||
fix: 'rerun the state-machines specialist on the same diff; its review coverage stays incomplete until gstack-state-matrix check passes',
|
||
},
|
||
// Fix wave 2026-10-15, PR 5 (item 10b, #3197).
|
||
WTREE_UNAVAILABLE: {
|
||
anchor: 'wtree-unavailable',
|
||
summary: 'cannot fingerprint the working tree: bin/gstack-wtree could not start (on Windows, no Git Bash was found) or it ran and failed',
|
||
fix: 'on Windows point GSTACK_GIT_BASH at Git Bash\'s bash.exe (Git Bash: export GSTACK_GIT_BASH=\'C:/Program Files/Git/bin/bash.exe\'; PowerShell: $env:GSTACK_GIT_BASH = \'C:\\Program Files\\Git\\bin\\bash.exe\'), or install Git for Windows (winget install --id Git.Git -e); elsewhere rerun ./setup so bin/gstack-wtree is present; then rerun gstack-pregate',
|
||
},
|
||
// Fix wave W5 (GSTA-31): pregate regen without installed dependencies.
|
||
REGEN_DEPS_MISSING: {
|
||
anchor: 'regen-deps-missing',
|
||
summary: 'a regen command exited 0 with different outputs while package.json declares dependencies and node_modules is missing, so the outputs were not verified',
|
||
fix: 'install the dependencies (the printed command, such as bun install), then rerun the check',
|
||
},
|
||
} as const satisfies Record<string, ResultCode>;
|