* test(#3676): add failing tests for quick-batch dispatch core Failing-first tests for Phase 4 of epic #3344 (ADR-1239 "Quick-batch binding"): quick-batch-dispatch.test.cjs / .property.test.cjs cover the new pure decision-logic module (arg validation, effective concurrency, deterministic merge order, spawn backpressure, verification/merge routing, cleanup-entry construction — design doc rows 3-15,24,26-28, 30-36,39; property rows 51-53). quick-batch-update-items.test.cjs covers the new updateBatchItems export on src/quick-batch.cts (rows 15,22-23, including the negative cycle-rejection case). quick-batch-command-router.test.cjs covers the new gsd-tools quick-batch CLI family (rows 46-47). These reference modules/ exports that do not exist yet. * feat(#3676): implement quick-batch dispatch core, updateBatchItems, and command router Phase 4 of epic #3344 (ADR-1239 "Quick-batch binding") CORE decision layer — CLI verbs and pure orchestration logic only; no workflow markdown, no Agent()/git-worktree I/O. - src/quick-batch-dispatch.cts (new): pure decision functions consumed by the (separate, follow-up) /gsd:quick-batch workflow markdown — parseQuickBatchArgs, computeEffectiveConcurrency, computeMergeOrder, computeSpawnPlan, routeVerificationOutcome, routeMergeOutcome, buildCleanupManifestEntry (the last parses caller-supplied plan text via the existing parsePlanDocument; no filesystem access). - src/quick-batch.cts: adds updateBatchItems, resolving the design doc's Open Question 1 as ONE additive export on this module instead of the second, independent BATCH.json writer the design doc originally proposed. Reuses the same withPlanningLock transaction shape, computeWaves, and platformWriteSync call resumeBatch/ completeQuickItem already use; fails closed without persisting on an unknown item, an unknown/self dependency, or an introduced cycle. - src/quick-batch-command-router.cts (new): gsd-tools quick-batch CLI family, wired into HOST_COMMAND_ROUTERS (gsd-core/bin/gsd-tools.cjs) as a first-party always-on command (like /gsd:quick), not the opt-in capability-registry path graphify uses. Verbs: create/update/resume/ complete (wrap quick-batch.cts) and effective-concurrency/ merge-eligible/spawn-plan/verification-routing/merge-routing/ cleanup-entry/parse-args (wrap quick-batch-dispatch.cts). Design doc rows covered: 3-15, 22-24, 26-28, 30-39, 46-47. Property rows 51-53. Rows covering workflow markdown / Agent() dispatch / `git worktree` behavior (16-21, 25, 29, 40-45, 48-50) remain for the follow-up markdown-authoring pass, per the phase brief's explicit scope boundary. * docs(#3676): register quick-batch-dispatch/command-router modules in bookkeeping surfaces New-.cts-module ripple for the two Phase 4 modules (epic #3344, ADR-1239 "Quick-batch binding"): .gitignore (compiled .cjs artifacts, ADR-457 build-at-publish), eslint.config.mjs (lint the .cts source, not the emitted .cjs), docs/INVENTORY.md + docs/INVENTORY-MANIFEST.json (via `node scripts/gen-inventory-manifest.cjs --write`, after `npm run build:lib`), and CONTEXT.md glossary entries for "Quick-Batch Dispatch Core Module" and "Quick-Batch Command Router Module", plus an update to the existing "Quick-Batch Core Primitives Module" entry documenting the new updateBatchItems export. * test(#3676): fold updateBatchItems tests into quick-batch.test.cjs (fix lint-test-file-count) scripts/lint-test-file-count.cjs buckets any quick-batch-*.test.cjs file under the quick-batch production module by longest-prefix match, and that module is already at its 2-file cap (quick-batch.test.cjs + quick-batch.property.test.cjs). The standalone tests/quick-batch-update-items.test.cjs added in the prior commit pushed it to 3 and failed `npm run lint:ci`. Fold its content into quick-batch.test.cjs (append-only — no existing test in that file is modified) and update the CONTEXT.md glossary reference to match. Surfaced while re-running `GITHUB_BASE_REF=next npm run lint:ci` after `npm ci` (this worktree previously had no local node_modules, which also made gen-scripts-cli-exit/gen-hooks-cli-exit/gen-exit-code-* unable to resolve typescript — resolved by npm ci, no code change needed there). `npm run lint:ci` and `npx tsc -p tsconfig.build.json --noEmit` are both green after this fix. * test(#3676): add failing tests for the quick-batch command/workflow markdown Failing-first tests for Phase 4's markdown-authoring pass (epic #3344, ADR-1239 "Quick-batch binding"): gsd-quick-batch-workflow.test.cjs covers commands/gsd/quick-batch.md's frontmatter/objective/process, gsd-core/workflows/quick-batch.md's byte-size boundary (row 49, ADR 1610 NEW_FILE_CAP) and step-fragment count, the isolation model (rows 20-22), the executor single-writer invariant (row 18), merge validation reusing the existing bounded primitive (row 25), the optional research/plan-checker/verification leaves (rows 16,17,19, 30,31), planning-failure blocking execution (row 29), the submodule guard (rows 36,44), and the new agents/gsd-planner.md quick-batch mode (rows 13-15). gsd-quick-batch-quick-regression.test.cjs covers row 48 (ordinary /gsd:quick stays byte-identical). Named `gsd-quick-batch-*` (not `quick-batch-*`) so lint-test-file-count's longest-prefix bucketing doesn't fold these markdown-only tests into the already-capped quick-batch/quick-batch-dispatch/ quick-batch-command-router production-module buckets from the CORE pass. These reference files that do not exist yet. * feat(#3676): author the quick-batch command, workflow, and planner mode Phase 4 markdown-authoring pass (epic #3344, ADR-1239 "Quick-batch binding") — the orchestration layer that calls into Pass 1's CLI verbs (src/quick-batch-command-router.cts). - commands/gsd/quick-batch.md (new): frontmatter/objective/process, delegates argument validation to `quick-batch parse-args` (parseQuickBatchArgs) rather than re-deriving the grammar. - gsd-core/workflows/quick-batch.md (new, 11843 bytes — under ADR 1610's 32768-byte NEW_FILE_CAP for a brand-new file) + 9 lazy-loaded step fragments under gsd-core/workflows/quick-batch/steps/: resume-mode, batch-init, research-phase (flag:--research), planner-wave (+ nested plan-checker-loop when --validate), worktree-dispatch, merge-wave, verification-wave (flag:--validate), completion. Covers design doc rows 3-45: capacity/isolation resolution (reusing dispatch-isolation-gate.md verbatim), per-DAG- layer planning with full-task-catalog prompts and always-required depends_on/files_modified frontmatter, serialized worktree create/ merge/cleanup via the existing worktree.cleanup-wave primitive, deterministic wave-order merging, verification routing (human_needed/gaps_found), the executor single-writer invariant, submodule fail-loud guard, and #1941 fork-base auto-degrade. - agents/gsd-planner.md: additive new `load_mode_context` bullet for `**Mode:** quick-batch`, pointing at the new gsd-core/references/planner-quick-batch.md reference (documents the always-required depends_on/files_modified contract, reusing the existing frontmatter grammar — no new keys). Existing modes byte-identical, only a new bullet added. - src/init.cts (+init-command-router.cts, +command-aliases.cts): cmdInitQuickBatch / `init.quick-batch` — model profiles, commit_docs, roadmap/planning existence checks, and the section_manifest field gating research-phase/verification-wave (reuses the existing flag:--research/flag:--validate WHEN_VOCABULARY atoms — no new atom needed). Rows 16-21, 25, 29, 36, 38, 39, 44, 46-50 covered structurally by the prior test(#3676) commit; rows 3-15, 22-24, 26-28, 30-35, 37, 40-43, 45 covered by construction (verb wiring, single-writer prompt constraints, crash-window resume via unmodified Phase 3 primitives). * docs(#3676): regenerate skills/inventory/section-manifest/install-tree; baseline the intentional word-splitting pattern npm run regen:derived output for the new command/workflow/reference (epic #3344, ADR-1239 "Quick-batch binding"): - skills/gsd-quick-batch/SKILL.md (generated from commands/gsd/quick-batch.md) - docs/INVENTORY.md rows for /gsd-quick-batch, quick-batch.md, planner-quick-batch.md, and the quick-batch-dispatch.cjs/ quick-batch-command-router.cjs CLI-module rows' now-live `/gsd-quick-batch` cross-reference (was "(separate, follow-up)") + docs/INVENTORY-MANIFEST.json (`node scripts/gen-inventory-manifest.cjs --write`) - gsd-core/workflows/section-manifest.json (`npm run gen:section-manifest`) — research-phase/verification-wave gsd:section entries for the new quick-batch workflow - tests/fixtures/install-tree/*.json (`npm run gen:install-tree`) — the new command/workflow/skill/reference files now ship to every runtime scripts/lint-workflow-shellcheck-baseline.json: 3 new entries for gsd-core/workflows/quick-batch.md's intentional flag-token/$ARGUMENTS word-splitting (SC2046/SC2086) — the same deliberate unquoted-optional- flag pattern gsd-core/workflows/quick.md already carries baselined (e.g. `$DISCUSS_PARAM $RESEARCH_PARAM` in quick.md's own Step 2); quoting would break the intended "omit this arg when the flag is false" splitting. * fix(#3676): close prompt-injection and argv/glob-injection gaps in quick-batch leaf dispatch Security review pass findings, both confirmed real: 1. HIGH — prompt injection, no boundaries. Every leaf-dispatch fragment interpolated the raw, attacker-influenced task ${description} (and the shared ${TASK_CATALOG_TABLE}, broadcasting every item's raw description into every planner's prompt in the layer) straight into Agent() prompt bodies with no boundary. Fixed by wrapping every such interpolation in a <security_context> + DATA_START/DATA_END boundary, matching the CONCRETE convention already implemented in this repo (agents/gsd-debug-session-manager.md, agents/gsd-debugger.md, gsd-core/workflows/debug.md) — commands/gsd/quick.md's own <security_notes> only asserts this convention in prose, so the debug-agent files are the real precedent followed here. Added a new <security_notes> block to commands/gsd/quick-batch.md (it had none) documenting both this fix and the one below. 2. MEDIUM — unquoted $ARGUMENTS -> argv/glob injection. gsd-core/workflows/quick-batch.md and commands/gsd/quick-batch.md both ran `gsd_run quick-batch parse-args --raw -- $ARGUMENTS` UNQUOTED, causing shell word-splitting and pathname expansion on raw task-list text before the parser ever saw it. Fixed at the source: added a `--text <string>` form to the `parse-args` verb (src/quick-batch-command-router.cts) that accepts the ENTIRE $ARGUMENTS as ONE quoted argv element and does the whitespace split itself, in Node — which is never glob-aware, unlike the shell. Both call sites now use `--text "$ARGUMENTS"`. The `-- <tokens>` form is kept for direct/test callers that already have a real argv array. The SC2086 baseline entry added for the original unquoted line is now stale (`node scripts/lint-workflow-shellcheck.cjs` no longer reports it) and has been removed; the two SC2046 entries for the UNRELATED, still-unquoted `$([ "$VALIDATE_MODE" = true ] && echo --validate)`-style conditional-flag splitting remain — that line only ever expands to one of a few known-safe literal strings (never raw user text), matching quick.md's own already-baselined convention exactly. Tests: quick-batch-command-router.test.cjs covers the new --text form (token splitting, glob-shaped text passing through literally unexpanded, whitespace-only input). gsd-quick-batch-workflow.test.cjs asserts the DATA_START/DATA_END boundary on every leaf prompt (research-phase/planner-wave/plan-checker-loop/verification-wave, including the shared task catalog) and the quoted --text call sites. * fix(#3676): strengthen test-depth gaps in rows 9, 18, 24, 34, 35 Spec review pass findings — the test matrix claimed "yes" coverage these assertions did not actually support: - Row 9 (--jobs 0/-1/abc hostile case): previously asserted rejection only. Added an end-to-end assertion (tests/quick-batch-command-router.test.cjs, committed alongside the security fix that touches the same file) that .planning/quick-batches/ is never created for any rejected value — createBatch is genuinely never reached. - Row 18 (--resume <unknown-batch-id>): previously only exercised a hand-corrupted BATCH.json, never a genuinely nonexistent batch directory. Added the real nonexistent-id case (also in quick-batch-command-router.test.cjs). - Row 24 (post-planning updateBatchItems racing a concurrent completeQuickItem for a different item, both through withPlanningLock): zero test existed. Added a property test (tests/quick-batch.property.test.cjs, appended — Phase 3's own file, no existing test touched) exercising both call orders and asserting no lost update in the final on-disk manifest — the same technique Phase 3's own row-15 lock-contention property test uses (sequential calls through the real lock; a working mutex makes any interleaving equivalent to some serial order, so this is the same claim a literal concurrent-thread test would make without OS-level threading). - Row 34 (worktree preserved on merge_failed) and row 35 (undeclared- deletion detection): both were previously asserted only at the pure routeMergeOutcome level. Added tests/gsd-quick-batch-merge-integration.test.cjs using the SAME real-git-fixture pattern tests/worktree-safety.test.cjs already establishes for executeWorktreeWaveCleanupPlan (real repo, real worktree, a REAL merge conflict / a REAL file deletion diffed against declared_deletions) — asserting the actual worktree directory survives on disk, not just that a pure function returns a preserveWorktree:true field. Named gsd-quick-batch-* so lint-test- file-count's bucketing doesn't fold it into any capped module bucket. Row 48 (/gsd:quick regression) intentionally left as-is per the reviewer's own framing: the byte-identity claim is already mechanically proven by the changed-path diff (git diff --name-only empty on those two paths IS byte-identity), and a genuine execution- level regression test would require actually running the workflow — out of scope for this repo's unit-test model (no other quick.md regression test in this repo does that either). * docs(#3676): add the changeset and user-facing docs the command needed Standards review pass findings — both HARD: - Missing changeset. None of the 6 prior #3676 commits touched .changeset/*. /gsd-quick-batch is a new user-facing command; CLAUDE.md/CONTRIBUTING.md require one. Added .changeset/silly-rams-caper.md (type: Added, pr: 0 placeholder — backfilled after the PR opens, matching CLAUDE.md's own documented convention and Phase 3's own precedent, #4190's .changeset/mellow-yaks-squeak.md). Uses the docs-convention hyphen form `/gsd-quick-batch` throughout, never the source-artifact colon form (`scripts/lint-docs-command-form.cjs` confirms 0 violations; that check scans docs/**, not .changeset/, so it was never actually in scope for the fragment itself, but the wording still follows the doc convention for consistency, matching how Phase 3's own fragment named the not-yet-shipped command). - Missing docs. Added docs/how-to/batch-quick-tasks.md (Diátaxis how-to, matching docs/how-to/handle-quick-and-fast-tasks.md's existing convention for /gsd-quick /gsd-fast) covering --jobs, --validate, --research, --resume, --file, the capacity/isolation interaction, and resume/failure recovery. Cross-linked from docs/README.md's how-to index and from handle-quick-and-fast-tasks.md's own "Related" section. Added a /gsd-quick-batch section to docs/COMMANDS.md (same table format as the existing /gsd-quick entry) and docs/features/quick-batch.md (REQ-QB-01..12, same frontmatter shape as docs/features/quick-mode.md) — regenerated docs/FEATURES.md (179 features) and skills/gsd-quick-batch/SKILL.md via the standard generators. * fix(#3676): close docs-parity, attribution, and generated-registry gaps gsd-test caught gsd-test's real run against 155e8975b3 found 43 failures, all rooted in this phase's own new command/workflow never being registered across ~10 independent generated/hand-maintained registries this repo keeps in parity by convention. Root-caused each, no test weakened or special-cased. - help.md ↔ commands/gsd/ bidirectional parity (docs-parity-live- registry.test.cjs): added a /gsd:quick-batch entry to gsd-core/workflows/help/modes/full.md (the real help.md content; gsd-core/workflows/help.md is a thin dispatcher) documenting every flag (--file/--jobs/--validate/--research/--resume), matching the existing /gsd:quick entry's format. - gen-section-manifest.test.cjs: quick-batch.md's `gsd_run query init.quick-batch` invocation used inline `$([ ... ] && echo --flag)` substitutions, which never satisfy the test's exact-whitespace-token / assigned-variable detection (the trailing `))` glued onto `--research` in the compound substitution broke the "exact token" match). Rewrote to the same VALIDATE_PARAM/RESEARCH_PARAM two-line pattern gsd-core/workflows/quick.md's own Step 2 already uses. - runtime-launcher-parity.test.cjs: the 8 quick-batch/steps/*.md fragments that call gsd_run each needed their OWN embedded copy of the canonical shim preamble (every workflow .md that calls gsd_run carries its own copy — reading one file does not persist shell state into another). Ran `node scripts/sync-runtime-launcher.cjs`, which inserted it before each file's first gsd_run call. plan-checker-loop.md correctly has none — it never calls gsd_run directly. - Namespace routing (skill-manifest.test.cjs, install-nested- layout.test.cjs, runtime-artifact-layout-surface.test.cjs): added `quick-batch` to commands/gsd/ns-workflow.md's `requires:` array and routing table (same namespace `quick` already routes through), and to src/clusters.cts's `utility` cluster (same cluster `quick` already belongs to). Verified by hand-running installRuntimeArtifacts + applySurface for augment/cline against a real temp install: exactly 6 top-level gsd-ns-* router dirs, gsd-quick-batch correctly nested under gsd-ns-workflow/skills/, never re-flattened. - mcp-server-catalog.test.cjs: hardcoded command count 71 -> 72 (a brand-new command is a real count change, not a bug this test should hide). - model-omit-when-inherit-guard.test.cjs: added the canonical `<!-- #2517 model-omit-on-inherit -->` marker block to gsd-core/workflows/quick-batch.md (every leaf dispatch — planner/ researcher/checker/executor/verifier — lives in a steps/ fragment, read combined with the host by this test's own readWorkflowCombined, same as quick.md's own research-phase.md carries it for its gated section). Also fixed a genuine pre-existing inconsistency in the test's own "#2711: the guarded set is derived from dispatch sites" check: its `nonDispatching` computation read the BARE host file while `derived` (the set it's checked against) reads the combined host+steps content — inconsistent with that same test file's own #2994 doc comment explaining why the combined read is necessary. quick-batch.md is the first workflow whose EVERY model="{...}" dispatch site lives in a mandatory (never gated) steps/ fragment — extracted to stay under ADR-1610's tighter NEW_FILE_CAP for a brand-new file — which is what exposed the mismatch. Fixed by using the same readWorkflowCombined read in both places. - skill-frontmatter-contract.test.cjs: shortened commands/gsd/quick-batch.md's frontmatter `description` from 107 to 91 chars (<=100 budget), and added `quick-batch.md` to the hand- maintained KNOWN_SKILLS consolidation allowlist with a #3676 justification comment (a genuinely new first-party command, not a consolidation of an existing skill). - workflow-fragments-emission.install.test.cjs: added `quick-batch.md` to the hand-maintained MARKED_WORKFLOWS set (composeWorkflow is deliberately NOT a no-op for it — its research-phase/verification- wave sections are gated). - Regenerated all downstream artifacts (npm run build:lib && npm run regen:derived && npm run gen:plugin-skills -- --write && npm run gen:features -- --write): skills/gsd-quick-batch/SKILL.md, skills/gsd-ns-workflow/SKILL.md, install-tree fixtures for augment/cline/hermes/qwen/trae/zcode. - emitted-attribution.test.cjs: agents/gsd-planner.md's #3676 addition (one new `load_mode_context` bullet pointing at the new gsd-core/references/planner-quick-batch.md reference) grew the file 124 bytes without an acknowledgment trailer. Acknowledged below — the growth is the deliberate, additive, single-bullet change from the earlier feat(#3676) commit, not drift. Verified: npm run build:lib clean, npx tsc -p tsconfig.build.json --noEmit clean, GITHUB_BASE_REF=next npm run lint:ci fully green (includes lint-workflow-shellcheck, lint-test-file-count, lint-docs-command-form). The deep install/spawn/registry tests gsd-test actually runs (docs-parity-live-registry, gen-section-manifest, runtime-launcher-parity, install-nested-layout, runtime-artifact-layout-surface, skill-manifest, skill-frontmatter- contract, mcp-server-catalog, model-omit-when-inherit-guard, workflow-fragments-emission) are not part of lint:ci — each fix above was independently verified by hand-invoking the exact production function the failing test calls (installRuntimeArtifacts, applySurface, composeWorkflow, the CLUSTERS union, the section-manifest forwarding regex) against the real repo tree and confirming the expected shape. Emitted-Drift-Ack-Growth: gsd-planner.md — additive #3676 quick-batch mode bullet in load_mode_context (one new line pointing at gsd-core/references/planner-quick-batch.md); not drift. * fix(#3676): trim the /gsd:quick-batch help.md entry to fit the LARGE tier line budget skill-frontmatter-contract.test.cjs's "feature #3039: tiered help — size budgets" enforces a SEPARATE line-count ceiling for gsd-core/workflows/help/modes/full.md (FULL_BUDGET = 844 lines, tighten-only ratchet, scripts/lib/allowlist-ratchet.cjs's assertTightCeiling) — independent of the skill-frontmatter description- length budget and consolidation allowlist I touched in the prior round; those are unrelated checks in the same test FILE, not the same check. Root cause: the /gsd:quick-batch entry I added to full.md in the docs-parity fix round was 17 lines, pushing the file from 834 to 851 lines — 7 over the 844 ceiling. Condensed the entry (merged the per-flag bullet list into one dense "Flags:" line, dropped from 3 Usage examples to 1) to 844 lines exactly — at the ceiling with zero slack, which assertTightCeiling accepts (it only fails on actualMax > ceiling, or on slack > grace when the ceiling is too LOOSE — zero slack triggers neither). Verified after trimming: full.md still contains a live /gsd:quick-batch reference (bidirectional parity) and all 5 argument-hint flags (--jobs/--validate/--research/--resume/--file) still appear as literal tokens (docs-parity-live-registry.test.cjs's own flag-coverage check, re-run by hand against the trimmed content). Verified: npm run build:lib clean, npx tsc -p tsconfig.build.json --noEmit clean, GITHUB_BASE_REF=next npm run lint:ci fully green. * docs(#3676): backfill changeset pr number to 4212 Follow-up to fix(#3676) commits — .changeset/silly-rams-caper.md's pr:0 placeholder backfilled with the real PR number now that gh api POST /pulls has returned it (#4212). Matches CLAUDE.md's PR Number Handling convention and Phase 3's own #4190 precedent (708c5a3f8c). Doc-only (root-level .changeset/*.md fragment), exempt from a fresh gsd-test run per pre-pr-gate.sh's DOC_ONLY_RE. * fix(#3676): resolve prompt-injection-scan false positive on test fixture tests/quick-batch.test.cjs:232's row 11b regression proves the task-list parser carries a prompt-injection-shaped task description through createBatch as inert data, never interpreted. The fixture has to be a real "ignore all previous instructions..." phrase or the test asserts nothing, but the full-file --diff scan flagged it once unrelated edits in the same file pulled it into the changed-file set. Add the file to prompt-injection-scan.sh's ALLOWLIST, matching the sanctioned, precedented exemption already used for other legitimate security-regression fixtures (tests/windsurf-conversion.test.cjs, tests/health-validation.test.cjs, tests/continuation-grammar-parity.test.cjs) per DEFECT.PROMPT-INJECTION-SCAN-COLLISION. --------- Co-authored-by: sim <sim@local>
This commit is contained in:
12
tests/fixtures/install-tree/antigravity.json
vendored
12
tests/fixtures/install-tree/antigravity.json
vendored
@@ -129,6 +129,7 @@
|
||||
"gsd-core/references/planner-load-graph-context.md",
|
||||
"gsd-core/references/planner-mvp-mode.md",
|
||||
"gsd-core/references/planner-preconditions.md",
|
||||
"gsd-core/references/planner-quick-batch.md",
|
||||
"gsd-core/references/planner-reversibility.md",
|
||||
"gsd-core/references/planner-reviews.md",
|
||||
"gsd-core/references/planner-revision.md",
|
||||
@@ -339,6 +340,16 @@
|
||||
"gsd-core/workflows/progress.md",
|
||||
"gsd-core/workflows/progress/steps/forensic-audit.md",
|
||||
"gsd-core/workflows/progress/steps/mvp-display.md",
|
||||
"gsd-core/workflows/quick-batch.md",
|
||||
"gsd-core/workflows/quick-batch/steps/batch-init.md",
|
||||
"gsd-core/workflows/quick-batch/steps/completion.md",
|
||||
"gsd-core/workflows/quick-batch/steps/merge-wave.md",
|
||||
"gsd-core/workflows/quick-batch/steps/plan-checker-loop.md",
|
||||
"gsd-core/workflows/quick-batch/steps/planner-wave.md",
|
||||
"gsd-core/workflows/quick-batch/steps/research-phase.md",
|
||||
"gsd-core/workflows/quick-batch/steps/resume-mode.md",
|
||||
"gsd-core/workflows/quick-batch/steps/verification-wave.md",
|
||||
"gsd-core/workflows/quick-batch/steps/worktree-dispatch.md",
|
||||
"gsd-core/workflows/quick.md",
|
||||
"gsd-core/workflows/quick/steps/discussion-phase.md",
|
||||
"gsd-core/workflows/quick/steps/plan-checker-loop.md",
|
||||
@@ -489,6 +500,7 @@
|
||||
"skills/gsd-pr-branch/SKILL.md",
|
||||
"skills/gsd-profile-user/SKILL.md",
|
||||
"skills/gsd-progress/SKILL.md",
|
||||
"skills/gsd-quick-batch/SKILL.md",
|
||||
"skills/gsd-quick/SKILL.md",
|
||||
"skills/gsd-resume-work/SKILL.md",
|
||||
"skills/gsd-review-backlog/SKILL.md",
|
||||
|
||||
13
tests/fixtures/install-tree/augment.json
vendored
13
tests/fixtures/install-tree/augment.json
vendored
@@ -84,6 +84,7 @@
|
||||
"commands/gsd-pr-branch.md",
|
||||
"commands/gsd-profile-user.md",
|
||||
"commands/gsd-progress.md",
|
||||
"commands/gsd-quick-batch.md",
|
||||
"commands/gsd-quick.md",
|
||||
"commands/gsd-resume-work.md",
|
||||
"commands/gsd-review-backlog.md",
|
||||
@@ -200,6 +201,7 @@
|
||||
"gsd-core/references/planner-load-graph-context.md",
|
||||
"gsd-core/references/planner-mvp-mode.md",
|
||||
"gsd-core/references/planner-preconditions.md",
|
||||
"gsd-core/references/planner-quick-batch.md",
|
||||
"gsd-core/references/planner-reversibility.md",
|
||||
"gsd-core/references/planner-reviews.md",
|
||||
"gsd-core/references/planner-revision.md",
|
||||
@@ -410,6 +412,16 @@
|
||||
"gsd-core/workflows/progress.md",
|
||||
"gsd-core/workflows/progress/steps/forensic-audit.md",
|
||||
"gsd-core/workflows/progress/steps/mvp-display.md",
|
||||
"gsd-core/workflows/quick-batch.md",
|
||||
"gsd-core/workflows/quick-batch/steps/batch-init.md",
|
||||
"gsd-core/workflows/quick-batch/steps/completion.md",
|
||||
"gsd-core/workflows/quick-batch/steps/merge-wave.md",
|
||||
"gsd-core/workflows/quick-batch/steps/plan-checker-loop.md",
|
||||
"gsd-core/workflows/quick-batch/steps/planner-wave.md",
|
||||
"gsd-core/workflows/quick-batch/steps/research-phase.md",
|
||||
"gsd-core/workflows/quick-batch/steps/resume-mode.md",
|
||||
"gsd-core/workflows/quick-batch/steps/verification-wave.md",
|
||||
"gsd-core/workflows/quick-batch/steps/worktree-dispatch.md",
|
||||
"gsd-core/workflows/quick.md",
|
||||
"gsd-core/workflows/quick/steps/discussion-phase.md",
|
||||
"gsd-core/workflows/quick/steps/plan-checker-loop.md",
|
||||
@@ -578,6 +590,7 @@
|
||||
"skills/gsd-ns-workflow/skills/plan-phase/SKILL.md",
|
||||
"skills/gsd-ns-workflow/skills/plan-review-convergence/SKILL.md",
|
||||
"skills/gsd-ns-workflow/skills/progress/SKILL.md",
|
||||
"skills/gsd-ns-workflow/skills/quick-batch/SKILL.md",
|
||||
"skills/gsd-ns-workflow/skills/quick/SKILL.md",
|
||||
"skills/gsd-ns-workflow/skills/spec-phase/SKILL.md",
|
||||
"skills/gsd-ns-workflow/skills/ultraplan-phase/SKILL.md",
|
||||
|
||||
12
tests/fixtures/install-tree/claude-local.json
vendored
12
tests/fixtures/install-tree/claude-local.json
vendored
@@ -84,6 +84,7 @@
|
||||
"commands/gsd-pr-branch.md",
|
||||
"commands/gsd-profile-user.md",
|
||||
"commands/gsd-progress.md",
|
||||
"commands/gsd-quick-batch.md",
|
||||
"commands/gsd-quick.md",
|
||||
"commands/gsd-resume-work.md",
|
||||
"commands/gsd-review-backlog.md",
|
||||
@@ -200,6 +201,7 @@
|
||||
"gsd-core/references/planner-load-graph-context.md",
|
||||
"gsd-core/references/planner-mvp-mode.md",
|
||||
"gsd-core/references/planner-preconditions.md",
|
||||
"gsd-core/references/planner-quick-batch.md",
|
||||
"gsd-core/references/planner-reversibility.md",
|
||||
"gsd-core/references/planner-reviews.md",
|
||||
"gsd-core/references/planner-revision.md",
|
||||
@@ -410,6 +412,16 @@
|
||||
"gsd-core/workflows/progress.md",
|
||||
"gsd-core/workflows/progress/steps/forensic-audit.md",
|
||||
"gsd-core/workflows/progress/steps/mvp-display.md",
|
||||
"gsd-core/workflows/quick-batch.md",
|
||||
"gsd-core/workflows/quick-batch/steps/batch-init.md",
|
||||
"gsd-core/workflows/quick-batch/steps/completion.md",
|
||||
"gsd-core/workflows/quick-batch/steps/merge-wave.md",
|
||||
"gsd-core/workflows/quick-batch/steps/plan-checker-loop.md",
|
||||
"gsd-core/workflows/quick-batch/steps/planner-wave.md",
|
||||
"gsd-core/workflows/quick-batch/steps/research-phase.md",
|
||||
"gsd-core/workflows/quick-batch/steps/resume-mode.md",
|
||||
"gsd-core/workflows/quick-batch/steps/verification-wave.md",
|
||||
"gsd-core/workflows/quick-batch/steps/worktree-dispatch.md",
|
||||
"gsd-core/workflows/quick.md",
|
||||
"gsd-core/workflows/quick/steps/discussion-phase.md",
|
||||
"gsd-core/workflows/quick/steps/plan-checker-loop.md",
|
||||
|
||||
12
tests/fixtures/install-tree/claude.json
vendored
12
tests/fixtures/install-tree/claude.json
vendored
@@ -129,6 +129,7 @@
|
||||
"gsd-core/references/planner-load-graph-context.md",
|
||||
"gsd-core/references/planner-mvp-mode.md",
|
||||
"gsd-core/references/planner-preconditions.md",
|
||||
"gsd-core/references/planner-quick-batch.md",
|
||||
"gsd-core/references/planner-reversibility.md",
|
||||
"gsd-core/references/planner-reviews.md",
|
||||
"gsd-core/references/planner-revision.md",
|
||||
@@ -339,6 +340,16 @@
|
||||
"gsd-core/workflows/progress.md",
|
||||
"gsd-core/workflows/progress/steps/forensic-audit.md",
|
||||
"gsd-core/workflows/progress/steps/mvp-display.md",
|
||||
"gsd-core/workflows/quick-batch.md",
|
||||
"gsd-core/workflows/quick-batch/steps/batch-init.md",
|
||||
"gsd-core/workflows/quick-batch/steps/completion.md",
|
||||
"gsd-core/workflows/quick-batch/steps/merge-wave.md",
|
||||
"gsd-core/workflows/quick-batch/steps/plan-checker-loop.md",
|
||||
"gsd-core/workflows/quick-batch/steps/planner-wave.md",
|
||||
"gsd-core/workflows/quick-batch/steps/research-phase.md",
|
||||
"gsd-core/workflows/quick-batch/steps/resume-mode.md",
|
||||
"gsd-core/workflows/quick-batch/steps/verification-wave.md",
|
||||
"gsd-core/workflows/quick-batch/steps/worktree-dispatch.md",
|
||||
"gsd-core/workflows/quick.md",
|
||||
"gsd-core/workflows/quick/steps/discussion-phase.md",
|
||||
"gsd-core/workflows/quick/steps/plan-checker-loop.md",
|
||||
@@ -488,6 +499,7 @@
|
||||
"skills/gsd-pr-branch/SKILL.md",
|
||||
"skills/gsd-profile-user/SKILL.md",
|
||||
"skills/gsd-progress/SKILL.md",
|
||||
"skills/gsd-quick-batch/SKILL.md",
|
||||
"skills/gsd-quick/SKILL.md",
|
||||
"skills/gsd-resume-work/SKILL.md",
|
||||
"skills/gsd-review-backlog/SKILL.md",
|
||||
|
||||
12
tests/fixtures/install-tree/cline.json
vendored
12
tests/fixtures/install-tree/cline.json
vendored
@@ -131,6 +131,7 @@
|
||||
"gsd-core/references/planner-load-graph-context.md",
|
||||
"gsd-core/references/planner-mvp-mode.md",
|
||||
"gsd-core/references/planner-preconditions.md",
|
||||
"gsd-core/references/planner-quick-batch.md",
|
||||
"gsd-core/references/planner-reversibility.md",
|
||||
"gsd-core/references/planner-reviews.md",
|
||||
"gsd-core/references/planner-revision.md",
|
||||
@@ -341,6 +342,16 @@
|
||||
"gsd-core/workflows/progress.md",
|
||||
"gsd-core/workflows/progress/steps/forensic-audit.md",
|
||||
"gsd-core/workflows/progress/steps/mvp-display.md",
|
||||
"gsd-core/workflows/quick-batch.md",
|
||||
"gsd-core/workflows/quick-batch/steps/batch-init.md",
|
||||
"gsd-core/workflows/quick-batch/steps/completion.md",
|
||||
"gsd-core/workflows/quick-batch/steps/merge-wave.md",
|
||||
"gsd-core/workflows/quick-batch/steps/plan-checker-loop.md",
|
||||
"gsd-core/workflows/quick-batch/steps/planner-wave.md",
|
||||
"gsd-core/workflows/quick-batch/steps/research-phase.md",
|
||||
"gsd-core/workflows/quick-batch/steps/resume-mode.md",
|
||||
"gsd-core/workflows/quick-batch/steps/verification-wave.md",
|
||||
"gsd-core/workflows/quick-batch/steps/worktree-dispatch.md",
|
||||
"gsd-core/workflows/quick.md",
|
||||
"gsd-core/workflows/quick/steps/discussion-phase.md",
|
||||
"gsd-core/workflows/quick/steps/plan-checker-loop.md",
|
||||
@@ -470,6 +481,7 @@
|
||||
"skills/gsd-ns-workflow/skills/plan-phase/SKILL.md",
|
||||
"skills/gsd-ns-workflow/skills/plan-review-convergence/SKILL.md",
|
||||
"skills/gsd-ns-workflow/skills/progress/SKILL.md",
|
||||
"skills/gsd-ns-workflow/skills/quick-batch/SKILL.md",
|
||||
"skills/gsd-ns-workflow/skills/quick/SKILL.md",
|
||||
"skills/gsd-ns-workflow/skills/spec-phase/SKILL.md",
|
||||
"skills/gsd-ns-workflow/skills/ultraplan-phase/SKILL.md",
|
||||
|
||||
13
tests/fixtures/install-tree/codebuddy.json
vendored
13
tests/fixtures/install-tree/codebuddy.json
vendored
@@ -84,6 +84,7 @@
|
||||
"commands/gsd-pr-branch.md",
|
||||
"commands/gsd-profile-user.md",
|
||||
"commands/gsd-progress.md",
|
||||
"commands/gsd-quick-batch.md",
|
||||
"commands/gsd-quick.md",
|
||||
"commands/gsd-resume-work.md",
|
||||
"commands/gsd-review-backlog.md",
|
||||
@@ -200,6 +201,7 @@
|
||||
"gsd-core/references/planner-load-graph-context.md",
|
||||
"gsd-core/references/planner-mvp-mode.md",
|
||||
"gsd-core/references/planner-preconditions.md",
|
||||
"gsd-core/references/planner-quick-batch.md",
|
||||
"gsd-core/references/planner-reversibility.md",
|
||||
"gsd-core/references/planner-reviews.md",
|
||||
"gsd-core/references/planner-revision.md",
|
||||
@@ -410,6 +412,16 @@
|
||||
"gsd-core/workflows/progress.md",
|
||||
"gsd-core/workflows/progress/steps/forensic-audit.md",
|
||||
"gsd-core/workflows/progress/steps/mvp-display.md",
|
||||
"gsd-core/workflows/quick-batch.md",
|
||||
"gsd-core/workflows/quick-batch/steps/batch-init.md",
|
||||
"gsd-core/workflows/quick-batch/steps/completion.md",
|
||||
"gsd-core/workflows/quick-batch/steps/merge-wave.md",
|
||||
"gsd-core/workflows/quick-batch/steps/plan-checker-loop.md",
|
||||
"gsd-core/workflows/quick-batch/steps/planner-wave.md",
|
||||
"gsd-core/workflows/quick-batch/steps/research-phase.md",
|
||||
"gsd-core/workflows/quick-batch/steps/resume-mode.md",
|
||||
"gsd-core/workflows/quick-batch/steps/verification-wave.md",
|
||||
"gsd-core/workflows/quick-batch/steps/worktree-dispatch.md",
|
||||
"gsd-core/workflows/quick.md",
|
||||
"gsd-core/workflows/quick/steps/discussion-phase.md",
|
||||
"gsd-core/workflows/quick/steps/plan-checker-loop.md",
|
||||
@@ -559,6 +571,7 @@
|
||||
"skills/gsd-pr-branch/SKILL.md",
|
||||
"skills/gsd-profile-user/SKILL.md",
|
||||
"skills/gsd-progress/SKILL.md",
|
||||
"skills/gsd-quick-batch/SKILL.md",
|
||||
"skills/gsd-quick/SKILL.md",
|
||||
"skills/gsd-resume-work/SKILL.md",
|
||||
"skills/gsd-review-backlog/SKILL.md",
|
||||
|
||||
11
tests/fixtures/install-tree/codex.json
vendored
11
tests/fixtures/install-tree/codex.json
vendored
@@ -165,6 +165,7 @@
|
||||
"gsd-core/references/planner-load-graph-context.md",
|
||||
"gsd-core/references/planner-mvp-mode.md",
|
||||
"gsd-core/references/planner-preconditions.md",
|
||||
"gsd-core/references/planner-quick-batch.md",
|
||||
"gsd-core/references/planner-reversibility.md",
|
||||
"gsd-core/references/planner-reviews.md",
|
||||
"gsd-core/references/planner-revision.md",
|
||||
@@ -375,6 +376,16 @@
|
||||
"gsd-core/workflows/progress.md",
|
||||
"gsd-core/workflows/progress/steps/forensic-audit.md",
|
||||
"gsd-core/workflows/progress/steps/mvp-display.md",
|
||||
"gsd-core/workflows/quick-batch.md",
|
||||
"gsd-core/workflows/quick-batch/steps/batch-init.md",
|
||||
"gsd-core/workflows/quick-batch/steps/completion.md",
|
||||
"gsd-core/workflows/quick-batch/steps/merge-wave.md",
|
||||
"gsd-core/workflows/quick-batch/steps/plan-checker-loop.md",
|
||||
"gsd-core/workflows/quick-batch/steps/planner-wave.md",
|
||||
"gsd-core/workflows/quick-batch/steps/research-phase.md",
|
||||
"gsd-core/workflows/quick-batch/steps/resume-mode.md",
|
||||
"gsd-core/workflows/quick-batch/steps/verification-wave.md",
|
||||
"gsd-core/workflows/quick-batch/steps/worktree-dispatch.md",
|
||||
"gsd-core/workflows/quick.md",
|
||||
"gsd-core/workflows/quick/steps/discussion-phase.md",
|
||||
"gsd-core/workflows/quick/steps/plan-checker-loop.md",
|
||||
|
||||
12
tests/fixtures/install-tree/copilot.json
vendored
12
tests/fixtures/install-tree/copilot.json
vendored
@@ -130,6 +130,7 @@
|
||||
"gsd-core/references/planner-load-graph-context.md",
|
||||
"gsd-core/references/planner-mvp-mode.md",
|
||||
"gsd-core/references/planner-preconditions.md",
|
||||
"gsd-core/references/planner-quick-batch.md",
|
||||
"gsd-core/references/planner-reversibility.md",
|
||||
"gsd-core/references/planner-reviews.md",
|
||||
"gsd-core/references/planner-revision.md",
|
||||
@@ -340,6 +341,16 @@
|
||||
"gsd-core/workflows/progress.md",
|
||||
"gsd-core/workflows/progress/steps/forensic-audit.md",
|
||||
"gsd-core/workflows/progress/steps/mvp-display.md",
|
||||
"gsd-core/workflows/quick-batch.md",
|
||||
"gsd-core/workflows/quick-batch/steps/batch-init.md",
|
||||
"gsd-core/workflows/quick-batch/steps/completion.md",
|
||||
"gsd-core/workflows/quick-batch/steps/merge-wave.md",
|
||||
"gsd-core/workflows/quick-batch/steps/plan-checker-loop.md",
|
||||
"gsd-core/workflows/quick-batch/steps/planner-wave.md",
|
||||
"gsd-core/workflows/quick-batch/steps/research-phase.md",
|
||||
"gsd-core/workflows/quick-batch/steps/resume-mode.md",
|
||||
"gsd-core/workflows/quick-batch/steps/verification-wave.md",
|
||||
"gsd-core/workflows/quick-batch/steps/worktree-dispatch.md",
|
||||
"gsd-core/workflows/quick.md",
|
||||
"gsd-core/workflows/quick/steps/discussion-phase.md",
|
||||
"gsd-core/workflows/quick/steps/plan-checker-loop.md",
|
||||
@@ -451,6 +462,7 @@
|
||||
"skills/gsd-pr-branch/SKILL.md",
|
||||
"skills/gsd-profile-user/SKILL.md",
|
||||
"skills/gsd-progress/SKILL.md",
|
||||
"skills/gsd-quick-batch/SKILL.md",
|
||||
"skills/gsd-quick/SKILL.md",
|
||||
"skills/gsd-resume-work/SKILL.md",
|
||||
"skills/gsd-review-backlog/SKILL.md",
|
||||
|
||||
12
tests/fixtures/install-tree/cursor.json
vendored
12
tests/fixtures/install-tree/cursor.json
vendored
@@ -129,6 +129,7 @@
|
||||
"gsd-core/references/planner-load-graph-context.md",
|
||||
"gsd-core/references/planner-mvp-mode.md",
|
||||
"gsd-core/references/planner-preconditions.md",
|
||||
"gsd-core/references/planner-quick-batch.md",
|
||||
"gsd-core/references/planner-reversibility.md",
|
||||
"gsd-core/references/planner-reviews.md",
|
||||
"gsd-core/references/planner-revision.md",
|
||||
@@ -339,6 +340,16 @@
|
||||
"gsd-core/workflows/progress.md",
|
||||
"gsd-core/workflows/progress/steps/forensic-audit.md",
|
||||
"gsd-core/workflows/progress/steps/mvp-display.md",
|
||||
"gsd-core/workflows/quick-batch.md",
|
||||
"gsd-core/workflows/quick-batch/steps/batch-init.md",
|
||||
"gsd-core/workflows/quick-batch/steps/completion.md",
|
||||
"gsd-core/workflows/quick-batch/steps/merge-wave.md",
|
||||
"gsd-core/workflows/quick-batch/steps/plan-checker-loop.md",
|
||||
"gsd-core/workflows/quick-batch/steps/planner-wave.md",
|
||||
"gsd-core/workflows/quick-batch/steps/research-phase.md",
|
||||
"gsd-core/workflows/quick-batch/steps/resume-mode.md",
|
||||
"gsd-core/workflows/quick-batch/steps/verification-wave.md",
|
||||
"gsd-core/workflows/quick-batch/steps/worktree-dispatch.md",
|
||||
"gsd-core/workflows/quick.md",
|
||||
"gsd-core/workflows/quick/steps/discussion-phase.md",
|
||||
"gsd-core/workflows/quick/steps/plan-checker-loop.md",
|
||||
@@ -462,6 +473,7 @@
|
||||
"skills/gsd-pr-branch/SKILL.md",
|
||||
"skills/gsd-profile-user/SKILL.md",
|
||||
"skills/gsd-progress/SKILL.md",
|
||||
"skills/gsd-quick-batch/SKILL.md",
|
||||
"skills/gsd-quick/SKILL.md",
|
||||
"skills/gsd-resume-work/SKILL.md",
|
||||
"skills/gsd-review-backlog/SKILL.md",
|
||||
|
||||
12
tests/fixtures/install-tree/hermes.json
vendored
12
tests/fixtures/install-tree/hermes.json
vendored
@@ -129,6 +129,7 @@
|
||||
"gsd-core/references/planner-load-graph-context.md",
|
||||
"gsd-core/references/planner-mvp-mode.md",
|
||||
"gsd-core/references/planner-preconditions.md",
|
||||
"gsd-core/references/planner-quick-batch.md",
|
||||
"gsd-core/references/planner-reversibility.md",
|
||||
"gsd-core/references/planner-reviews.md",
|
||||
"gsd-core/references/planner-revision.md",
|
||||
@@ -339,6 +340,16 @@
|
||||
"gsd-core/workflows/progress.md",
|
||||
"gsd-core/workflows/progress/steps/forensic-audit.md",
|
||||
"gsd-core/workflows/progress/steps/mvp-display.md",
|
||||
"gsd-core/workflows/quick-batch.md",
|
||||
"gsd-core/workflows/quick-batch/steps/batch-init.md",
|
||||
"gsd-core/workflows/quick-batch/steps/completion.md",
|
||||
"gsd-core/workflows/quick-batch/steps/merge-wave.md",
|
||||
"gsd-core/workflows/quick-batch/steps/plan-checker-loop.md",
|
||||
"gsd-core/workflows/quick-batch/steps/planner-wave.md",
|
||||
"gsd-core/workflows/quick-batch/steps/research-phase.md",
|
||||
"gsd-core/workflows/quick-batch/steps/resume-mode.md",
|
||||
"gsd-core/workflows/quick-batch/steps/verification-wave.md",
|
||||
"gsd-core/workflows/quick-batch/steps/worktree-dispatch.md",
|
||||
"gsd-core/workflows/quick.md",
|
||||
"gsd-core/workflows/quick/steps/discussion-phase.md",
|
||||
"gsd-core/workflows/quick/steps/plan-checker-loop.md",
|
||||
@@ -508,6 +519,7 @@
|
||||
"skills/gsd/gsd-ns-workflow/skills/plan-phase/SKILL.md",
|
||||
"skills/gsd/gsd-ns-workflow/skills/plan-review-convergence/SKILL.md",
|
||||
"skills/gsd/gsd-ns-workflow/skills/progress/SKILL.md",
|
||||
"skills/gsd/gsd-ns-workflow/skills/quick-batch/SKILL.md",
|
||||
"skills/gsd/gsd-ns-workflow/skills/quick/SKILL.md",
|
||||
"skills/gsd/gsd-ns-workflow/skills/spec-phase/SKILL.md",
|
||||
"skills/gsd/gsd-ns-workflow/skills/ultraplan-phase/SKILL.md",
|
||||
|
||||
13
tests/fixtures/install-tree/kilo.json
vendored
13
tests/fixtures/install-tree/kilo.json
vendored
@@ -84,6 +84,7 @@
|
||||
"command/gsd-pr-branch.md",
|
||||
"command/gsd-profile-user.md",
|
||||
"command/gsd-progress.md",
|
||||
"command/gsd-quick-batch.md",
|
||||
"command/gsd-quick.md",
|
||||
"command/gsd-resume-work.md",
|
||||
"command/gsd-review-backlog.md",
|
||||
@@ -200,6 +201,7 @@
|
||||
"gsd-core/references/planner-load-graph-context.md",
|
||||
"gsd-core/references/planner-mvp-mode.md",
|
||||
"gsd-core/references/planner-preconditions.md",
|
||||
"gsd-core/references/planner-quick-batch.md",
|
||||
"gsd-core/references/planner-reversibility.md",
|
||||
"gsd-core/references/planner-reviews.md",
|
||||
"gsd-core/references/planner-revision.md",
|
||||
@@ -410,6 +412,16 @@
|
||||
"gsd-core/workflows/progress.md",
|
||||
"gsd-core/workflows/progress/steps/forensic-audit.md",
|
||||
"gsd-core/workflows/progress/steps/mvp-display.md",
|
||||
"gsd-core/workflows/quick-batch.md",
|
||||
"gsd-core/workflows/quick-batch/steps/batch-init.md",
|
||||
"gsd-core/workflows/quick-batch/steps/completion.md",
|
||||
"gsd-core/workflows/quick-batch/steps/merge-wave.md",
|
||||
"gsd-core/workflows/quick-batch/steps/plan-checker-loop.md",
|
||||
"gsd-core/workflows/quick-batch/steps/planner-wave.md",
|
||||
"gsd-core/workflows/quick-batch/steps/research-phase.md",
|
||||
"gsd-core/workflows/quick-batch/steps/resume-mode.md",
|
||||
"gsd-core/workflows/quick-batch/steps/verification-wave.md",
|
||||
"gsd-core/workflows/quick-batch/steps/worktree-dispatch.md",
|
||||
"gsd-core/workflows/quick.md",
|
||||
"gsd-core/workflows/quick/steps/discussion-phase.md",
|
||||
"gsd-core/workflows/quick/steps/plan-checker-loop.md",
|
||||
@@ -562,6 +574,7 @@
|
||||
"skills/gsd-pr-branch/SKILL.md",
|
||||
"skills/gsd-profile-user/SKILL.md",
|
||||
"skills/gsd-progress/SKILL.md",
|
||||
"skills/gsd-quick-batch/SKILL.md",
|
||||
"skills/gsd-quick/SKILL.md",
|
||||
"skills/gsd-resume-work/SKILL.md",
|
||||
"skills/gsd-review-backlog/SKILL.md",
|
||||
|
||||
12
tests/fixtures/install-tree/kimi-code.json
vendored
12
tests/fixtures/install-tree/kimi-code.json
vendored
@@ -130,6 +130,7 @@
|
||||
"gsd-core/references/planner-load-graph-context.md",
|
||||
"gsd-core/references/planner-mvp-mode.md",
|
||||
"gsd-core/references/planner-preconditions.md",
|
||||
"gsd-core/references/planner-quick-batch.md",
|
||||
"gsd-core/references/planner-reversibility.md",
|
||||
"gsd-core/references/planner-reviews.md",
|
||||
"gsd-core/references/planner-revision.md",
|
||||
@@ -340,6 +341,16 @@
|
||||
"gsd-core/workflows/progress.md",
|
||||
"gsd-core/workflows/progress/steps/forensic-audit.md",
|
||||
"gsd-core/workflows/progress/steps/mvp-display.md",
|
||||
"gsd-core/workflows/quick-batch.md",
|
||||
"gsd-core/workflows/quick-batch/steps/batch-init.md",
|
||||
"gsd-core/workflows/quick-batch/steps/completion.md",
|
||||
"gsd-core/workflows/quick-batch/steps/merge-wave.md",
|
||||
"gsd-core/workflows/quick-batch/steps/plan-checker-loop.md",
|
||||
"gsd-core/workflows/quick-batch/steps/planner-wave.md",
|
||||
"gsd-core/workflows/quick-batch/steps/research-phase.md",
|
||||
"gsd-core/workflows/quick-batch/steps/resume-mode.md",
|
||||
"gsd-core/workflows/quick-batch/steps/verification-wave.md",
|
||||
"gsd-core/workflows/quick-batch/steps/worktree-dispatch.md",
|
||||
"gsd-core/workflows/quick.md",
|
||||
"gsd-core/workflows/quick/steps/discussion-phase.md",
|
||||
"gsd-core/workflows/quick/steps/plan-checker-loop.md",
|
||||
@@ -489,6 +500,7 @@
|
||||
"skills/gsd-pr-branch/SKILL.md",
|
||||
"skills/gsd-profile-user/SKILL.md",
|
||||
"skills/gsd-progress/SKILL.md",
|
||||
"skills/gsd-quick-batch/SKILL.md",
|
||||
"skills/gsd-quick/SKILL.md",
|
||||
"skills/gsd-resume-work/SKILL.md",
|
||||
"skills/gsd-review-backlog/SKILL.md",
|
||||
|
||||
12
tests/fixtures/install-tree/kimi.json
vendored
12
tests/fixtures/install-tree/kimi.json
vendored
@@ -166,6 +166,7 @@
|
||||
"gsd-core/references/planner-load-graph-context.md",
|
||||
"gsd-core/references/planner-mvp-mode.md",
|
||||
"gsd-core/references/planner-preconditions.md",
|
||||
"gsd-core/references/planner-quick-batch.md",
|
||||
"gsd-core/references/planner-reversibility.md",
|
||||
"gsd-core/references/planner-reviews.md",
|
||||
"gsd-core/references/planner-revision.md",
|
||||
@@ -376,6 +377,16 @@
|
||||
"gsd-core/workflows/progress.md",
|
||||
"gsd-core/workflows/progress/steps/forensic-audit.md",
|
||||
"gsd-core/workflows/progress/steps/mvp-display.md",
|
||||
"gsd-core/workflows/quick-batch.md",
|
||||
"gsd-core/workflows/quick-batch/steps/batch-init.md",
|
||||
"gsd-core/workflows/quick-batch/steps/completion.md",
|
||||
"gsd-core/workflows/quick-batch/steps/merge-wave.md",
|
||||
"gsd-core/workflows/quick-batch/steps/plan-checker-loop.md",
|
||||
"gsd-core/workflows/quick-batch/steps/planner-wave.md",
|
||||
"gsd-core/workflows/quick-batch/steps/research-phase.md",
|
||||
"gsd-core/workflows/quick-batch/steps/resume-mode.md",
|
||||
"gsd-core/workflows/quick-batch/steps/verification-wave.md",
|
||||
"gsd-core/workflows/quick-batch/steps/worktree-dispatch.md",
|
||||
"gsd-core/workflows/quick.md",
|
||||
"gsd-core/workflows/quick/steps/discussion-phase.md",
|
||||
"gsd-core/workflows/quick/steps/plan-checker-loop.md",
|
||||
@@ -486,6 +497,7 @@
|
||||
"skills/gsd-pr-branch/SKILL.md",
|
||||
"skills/gsd-profile-user/SKILL.md",
|
||||
"skills/gsd-progress/SKILL.md",
|
||||
"skills/gsd-quick-batch/SKILL.md",
|
||||
"skills/gsd-quick/SKILL.md",
|
||||
"skills/gsd-resume-work/SKILL.md",
|
||||
"skills/gsd-review-backlog/SKILL.md",
|
||||
|
||||
13
tests/fixtures/install-tree/opencode.json
vendored
13
tests/fixtures/install-tree/opencode.json
vendored
@@ -84,6 +84,7 @@
|
||||
"commands/gsd-pr-branch.md",
|
||||
"commands/gsd-profile-user.md",
|
||||
"commands/gsd-progress.md",
|
||||
"commands/gsd-quick-batch.md",
|
||||
"commands/gsd-quick.md",
|
||||
"commands/gsd-resume-work.md",
|
||||
"commands/gsd-review-backlog.md",
|
||||
@@ -200,6 +201,7 @@
|
||||
"gsd-core/references/planner-load-graph-context.md",
|
||||
"gsd-core/references/planner-mvp-mode.md",
|
||||
"gsd-core/references/planner-preconditions.md",
|
||||
"gsd-core/references/planner-quick-batch.md",
|
||||
"gsd-core/references/planner-reversibility.md",
|
||||
"gsd-core/references/planner-reviews.md",
|
||||
"gsd-core/references/planner-revision.md",
|
||||
@@ -410,6 +412,16 @@
|
||||
"gsd-core/workflows/progress.md",
|
||||
"gsd-core/workflows/progress/steps/forensic-audit.md",
|
||||
"gsd-core/workflows/progress/steps/mvp-display.md",
|
||||
"gsd-core/workflows/quick-batch.md",
|
||||
"gsd-core/workflows/quick-batch/steps/batch-init.md",
|
||||
"gsd-core/workflows/quick-batch/steps/completion.md",
|
||||
"gsd-core/workflows/quick-batch/steps/merge-wave.md",
|
||||
"gsd-core/workflows/quick-batch/steps/plan-checker-loop.md",
|
||||
"gsd-core/workflows/quick-batch/steps/planner-wave.md",
|
||||
"gsd-core/workflows/quick-batch/steps/research-phase.md",
|
||||
"gsd-core/workflows/quick-batch/steps/resume-mode.md",
|
||||
"gsd-core/workflows/quick-batch/steps/verification-wave.md",
|
||||
"gsd-core/workflows/quick-batch/steps/worktree-dispatch.md",
|
||||
"gsd-core/workflows/quick.md",
|
||||
"gsd-core/workflows/quick/steps/discussion-phase.md",
|
||||
"gsd-core/workflows/quick/steps/plan-checker-loop.md",
|
||||
@@ -562,6 +574,7 @@
|
||||
"skills/gsd-pr-branch/SKILL.md",
|
||||
"skills/gsd-profile-user/SKILL.md",
|
||||
"skills/gsd-progress/SKILL.md",
|
||||
"skills/gsd-quick-batch/SKILL.md",
|
||||
"skills/gsd-quick/SKILL.md",
|
||||
"skills/gsd-resume-work/SKILL.md",
|
||||
"skills/gsd-review-backlog/SKILL.md",
|
||||
|
||||
11
tests/fixtures/install-tree/pi.json
vendored
11
tests/fixtures/install-tree/pi.json
vendored
@@ -96,6 +96,7 @@
|
||||
"gsd-core/references/planner-load-graph-context.md",
|
||||
"gsd-core/references/planner-mvp-mode.md",
|
||||
"gsd-core/references/planner-preconditions.md",
|
||||
"gsd-core/references/planner-quick-batch.md",
|
||||
"gsd-core/references/planner-reversibility.md",
|
||||
"gsd-core/references/planner-reviews.md",
|
||||
"gsd-core/references/planner-revision.md",
|
||||
@@ -306,6 +307,16 @@
|
||||
"gsd-core/workflows/progress.md",
|
||||
"gsd-core/workflows/progress/steps/forensic-audit.md",
|
||||
"gsd-core/workflows/progress/steps/mvp-display.md",
|
||||
"gsd-core/workflows/quick-batch.md",
|
||||
"gsd-core/workflows/quick-batch/steps/batch-init.md",
|
||||
"gsd-core/workflows/quick-batch/steps/completion.md",
|
||||
"gsd-core/workflows/quick-batch/steps/merge-wave.md",
|
||||
"gsd-core/workflows/quick-batch/steps/plan-checker-loop.md",
|
||||
"gsd-core/workflows/quick-batch/steps/planner-wave.md",
|
||||
"gsd-core/workflows/quick-batch/steps/research-phase.md",
|
||||
"gsd-core/workflows/quick-batch/steps/resume-mode.md",
|
||||
"gsd-core/workflows/quick-batch/steps/verification-wave.md",
|
||||
"gsd-core/workflows/quick-batch/steps/worktree-dispatch.md",
|
||||
"gsd-core/workflows/quick.md",
|
||||
"gsd-core/workflows/quick/steps/discussion-phase.md",
|
||||
"gsd-core/workflows/quick/steps/plan-checker-loop.md",
|
||||
|
||||
12
tests/fixtures/install-tree/qwen.json
vendored
12
tests/fixtures/install-tree/qwen.json
vendored
@@ -129,6 +129,7 @@
|
||||
"gsd-core/references/planner-load-graph-context.md",
|
||||
"gsd-core/references/planner-mvp-mode.md",
|
||||
"gsd-core/references/planner-preconditions.md",
|
||||
"gsd-core/references/planner-quick-batch.md",
|
||||
"gsd-core/references/planner-reversibility.md",
|
||||
"gsd-core/references/planner-reviews.md",
|
||||
"gsd-core/references/planner-revision.md",
|
||||
@@ -339,6 +340,16 @@
|
||||
"gsd-core/workflows/progress.md",
|
||||
"gsd-core/workflows/progress/steps/forensic-audit.md",
|
||||
"gsd-core/workflows/progress/steps/mvp-display.md",
|
||||
"gsd-core/workflows/quick-batch.md",
|
||||
"gsd-core/workflows/quick-batch/steps/batch-init.md",
|
||||
"gsd-core/workflows/quick-batch/steps/completion.md",
|
||||
"gsd-core/workflows/quick-batch/steps/merge-wave.md",
|
||||
"gsd-core/workflows/quick-batch/steps/plan-checker-loop.md",
|
||||
"gsd-core/workflows/quick-batch/steps/planner-wave.md",
|
||||
"gsd-core/workflows/quick-batch/steps/research-phase.md",
|
||||
"gsd-core/workflows/quick-batch/steps/resume-mode.md",
|
||||
"gsd-core/workflows/quick-batch/steps/verification-wave.md",
|
||||
"gsd-core/workflows/quick-batch/steps/worktree-dispatch.md",
|
||||
"gsd-core/workflows/quick.md",
|
||||
"gsd-core/workflows/quick/steps/discussion-phase.md",
|
||||
"gsd-core/workflows/quick/steps/plan-checker-loop.md",
|
||||
@@ -507,6 +518,7 @@
|
||||
"skills/gsd-ns-workflow/skills/plan-phase/SKILL.md",
|
||||
"skills/gsd-ns-workflow/skills/plan-review-convergence/SKILL.md",
|
||||
"skills/gsd-ns-workflow/skills/progress/SKILL.md",
|
||||
"skills/gsd-ns-workflow/skills/quick-batch/SKILL.md",
|
||||
"skills/gsd-ns-workflow/skills/quick/SKILL.md",
|
||||
"skills/gsd-ns-workflow/skills/spec-phase/SKILL.md",
|
||||
"skills/gsd-ns-workflow/skills/ultraplan-phase/SKILL.md",
|
||||
|
||||
12
tests/fixtures/install-tree/trae.json
vendored
12
tests/fixtures/install-tree/trae.json
vendored
@@ -129,6 +129,7 @@
|
||||
"gsd-core/references/planner-load-graph-context.md",
|
||||
"gsd-core/references/planner-mvp-mode.md",
|
||||
"gsd-core/references/planner-preconditions.md",
|
||||
"gsd-core/references/planner-quick-batch.md",
|
||||
"gsd-core/references/planner-reversibility.md",
|
||||
"gsd-core/references/planner-reviews.md",
|
||||
"gsd-core/references/planner-revision.md",
|
||||
@@ -339,6 +340,16 @@
|
||||
"gsd-core/workflows/progress.md",
|
||||
"gsd-core/workflows/progress/steps/forensic-audit.md",
|
||||
"gsd-core/workflows/progress/steps/mvp-display.md",
|
||||
"gsd-core/workflows/quick-batch.md",
|
||||
"gsd-core/workflows/quick-batch/steps/batch-init.md",
|
||||
"gsd-core/workflows/quick-batch/steps/completion.md",
|
||||
"gsd-core/workflows/quick-batch/steps/merge-wave.md",
|
||||
"gsd-core/workflows/quick-batch/steps/plan-checker-loop.md",
|
||||
"gsd-core/workflows/quick-batch/steps/planner-wave.md",
|
||||
"gsd-core/workflows/quick-batch/steps/research-phase.md",
|
||||
"gsd-core/workflows/quick-batch/steps/resume-mode.md",
|
||||
"gsd-core/workflows/quick-batch/steps/verification-wave.md",
|
||||
"gsd-core/workflows/quick-batch/steps/worktree-dispatch.md",
|
||||
"gsd-core/workflows/quick.md",
|
||||
"gsd-core/workflows/quick/steps/discussion-phase.md",
|
||||
"gsd-core/workflows/quick/steps/plan-checker-loop.md",
|
||||
@@ -468,6 +479,7 @@
|
||||
"skills/gsd-ns-workflow/skills/plan-phase/SKILL.md",
|
||||
"skills/gsd-ns-workflow/skills/plan-review-convergence/SKILL.md",
|
||||
"skills/gsd-ns-workflow/skills/progress/SKILL.md",
|
||||
"skills/gsd-ns-workflow/skills/quick-batch/SKILL.md",
|
||||
"skills/gsd-ns-workflow/skills/quick/SKILL.md",
|
||||
"skills/gsd-ns-workflow/skills/spec-phase/SKILL.md",
|
||||
"skills/gsd-ns-workflow/skills/ultraplan-phase/SKILL.md",
|
||||
|
||||
11
tests/fixtures/install-tree/windsurf.json
vendored
11
tests/fixtures/install-tree/windsurf.json
vendored
@@ -129,6 +129,7 @@
|
||||
"gsd-core/references/planner-load-graph-context.md",
|
||||
"gsd-core/references/planner-mvp-mode.md",
|
||||
"gsd-core/references/planner-preconditions.md",
|
||||
"gsd-core/references/planner-quick-batch.md",
|
||||
"gsd-core/references/planner-reversibility.md",
|
||||
"gsd-core/references/planner-reviews.md",
|
||||
"gsd-core/references/planner-revision.md",
|
||||
@@ -339,6 +340,16 @@
|
||||
"gsd-core/workflows/progress.md",
|
||||
"gsd-core/workflows/progress/steps/forensic-audit.md",
|
||||
"gsd-core/workflows/progress/steps/mvp-display.md",
|
||||
"gsd-core/workflows/quick-batch.md",
|
||||
"gsd-core/workflows/quick-batch/steps/batch-init.md",
|
||||
"gsd-core/workflows/quick-batch/steps/completion.md",
|
||||
"gsd-core/workflows/quick-batch/steps/merge-wave.md",
|
||||
"gsd-core/workflows/quick-batch/steps/plan-checker-loop.md",
|
||||
"gsd-core/workflows/quick-batch/steps/planner-wave.md",
|
||||
"gsd-core/workflows/quick-batch/steps/research-phase.md",
|
||||
"gsd-core/workflows/quick-batch/steps/resume-mode.md",
|
||||
"gsd-core/workflows/quick-batch/steps/verification-wave.md",
|
||||
"gsd-core/workflows/quick-batch/steps/worktree-dispatch.md",
|
||||
"gsd-core/workflows/quick.md",
|
||||
"gsd-core/workflows/quick/steps/discussion-phase.md",
|
||||
"gsd-core/workflows/quick/steps/plan-checker-loop.md",
|
||||
|
||||
13
tests/fixtures/install-tree/zcode.json
vendored
13
tests/fixtures/install-tree/zcode.json
vendored
@@ -84,6 +84,7 @@
|
||||
"commands/gsd-pr-branch.md",
|
||||
"commands/gsd-profile-user.md",
|
||||
"commands/gsd-progress.md",
|
||||
"commands/gsd-quick-batch.md",
|
||||
"commands/gsd-quick.md",
|
||||
"commands/gsd-resume-work.md",
|
||||
"commands/gsd-review-backlog.md",
|
||||
@@ -200,6 +201,7 @@
|
||||
"gsd-core/references/planner-load-graph-context.md",
|
||||
"gsd-core/references/planner-mvp-mode.md",
|
||||
"gsd-core/references/planner-preconditions.md",
|
||||
"gsd-core/references/planner-quick-batch.md",
|
||||
"gsd-core/references/planner-reversibility.md",
|
||||
"gsd-core/references/planner-reviews.md",
|
||||
"gsd-core/references/planner-revision.md",
|
||||
@@ -410,6 +412,16 @@
|
||||
"gsd-core/workflows/progress.md",
|
||||
"gsd-core/workflows/progress/steps/forensic-audit.md",
|
||||
"gsd-core/workflows/progress/steps/mvp-display.md",
|
||||
"gsd-core/workflows/quick-batch.md",
|
||||
"gsd-core/workflows/quick-batch/steps/batch-init.md",
|
||||
"gsd-core/workflows/quick-batch/steps/completion.md",
|
||||
"gsd-core/workflows/quick-batch/steps/merge-wave.md",
|
||||
"gsd-core/workflows/quick-batch/steps/plan-checker-loop.md",
|
||||
"gsd-core/workflows/quick-batch/steps/planner-wave.md",
|
||||
"gsd-core/workflows/quick-batch/steps/research-phase.md",
|
||||
"gsd-core/workflows/quick-batch/steps/resume-mode.md",
|
||||
"gsd-core/workflows/quick-batch/steps/verification-wave.md",
|
||||
"gsd-core/workflows/quick-batch/steps/worktree-dispatch.md",
|
||||
"gsd-core/workflows/quick.md",
|
||||
"gsd-core/workflows/quick/steps/discussion-phase.md",
|
||||
"gsd-core/workflows/quick/steps/plan-checker-loop.md",
|
||||
@@ -539,6 +551,7 @@
|
||||
"skills/gsd-ns-workflow/skills/plan-phase/SKILL.md",
|
||||
"skills/gsd-ns-workflow/skills/plan-review-convergence/SKILL.md",
|
||||
"skills/gsd-ns-workflow/skills/progress/SKILL.md",
|
||||
"skills/gsd-ns-workflow/skills/quick-batch/SKILL.md",
|
||||
"skills/gsd-ns-workflow/skills/quick/SKILL.md",
|
||||
"skills/gsd-ns-workflow/skills/spec-phase/SKILL.md",
|
||||
"skills/gsd-ns-workflow/skills/ultraplan-phase/SKILL.md",
|
||||
|
||||
201
tests/gsd-quick-batch-merge-integration.test.cjs
Normal file
201
tests/gsd-quick-batch-merge-integration.test.cjs
Normal file
@@ -0,0 +1,201 @@
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* gsd-quick-batch-merge-integration.test.cjs — real-git-fixture integration
|
||||
* tests connecting quick-batch's PURE merge routing (`routeMergeOutcome`,
|
||||
* `src/quick-batch-dispatch.cts`) to the REAL underlying bounded primitive
|
||||
* (`executeWorktreeWaveCleanupPlan`, `src/worktree-safety.cts`) it wraps.
|
||||
*
|
||||
* #3676 review pass 3 (Spec finding): rows 34/35 were previously asserted
|
||||
* only at the pure-function level (`routeMergeOutcome({kind:'merge_failed'})`
|
||||
* returns `preserveWorktree:true` as a field on an object) — never against a
|
||||
* REAL worktree directory or a REAL undeclared-deletion diff. This file
|
||||
* closes that gap using the SAME real-git-fixture pattern `tests/
|
||||
* worktree-safety.test.cjs` already establishes for `executeWorktreeWaveCleanupPlan`
|
||||
* (`initRepo`/`addWorktree`/`commitInWorktree`, real `git`, real
|
||||
* `fs.existsSync(wtDir)` assertions) — reimplemented locally since those
|
||||
* helpers are module-private there, never duplicating the underlying
|
||||
* primitive's OWN extensive test coverage (conflict isolation, deletion
|
||||
* declaration parsing, etc. — that stays exclusively in worktree-safety's
|
||||
* own suite).
|
||||
*
|
||||
* Named `gsd-quick-batch-*` (not `quick-batch-*`) so `scripts/
|
||||
* lint-test-file-count.cjs`'s longest-prefix bucketing does not fold this
|
||||
* cross-module integration test into any already-capped production-module
|
||||
* bucket.
|
||||
*/
|
||||
|
||||
const { describe, test } = require('node:test');
|
||||
const assert = require('node:assert/strict');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const { gitOrThrow } = require('./helpers/git-fixture.cjs');
|
||||
const { createTempDir, cleanup } = require('./helpers.cjs');
|
||||
|
||||
const { executeWorktreeWaveCleanupPlan } = require('../gsd-core/bin/lib/worktree-safety.cjs');
|
||||
const { routeMergeOutcome } = require('../gsd-core/bin/lib/quick-batch-dispatch.cjs');
|
||||
|
||||
const SUBPROCESS_TIMEOUT_MS = 30_000;
|
||||
|
||||
function git(args, cwd) {
|
||||
return gitOrThrow(args, { cwd, timeoutMs: SUBPROCESS_TIMEOUT_MS });
|
||||
}
|
||||
|
||||
function initRepo(dir) {
|
||||
fs.mkdirSync(dir, { recursive: true });
|
||||
git(['init'], dir);
|
||||
git(['config', 'user.email', 'test@test.com'], dir);
|
||||
git(['config', 'user.name', 'Test'], dir);
|
||||
git(['config', 'commit.gpgsign', 'false'], dir);
|
||||
fs.writeFileSync(path.join(dir, 'README.md'), '# Test\n');
|
||||
git(['add', '-A'], dir);
|
||||
git(['commit', '-m', 'initial commit'], dir);
|
||||
try { git(['branch', '-m', 'master', 'main'], dir); } catch { /* already main */ }
|
||||
}
|
||||
|
||||
function addWorktree(repoDir, wtDir, branchName) {
|
||||
git(['worktree', 'add', wtDir, '-b', branchName], repoDir);
|
||||
}
|
||||
|
||||
describe('quick-batch merge routing — real worktree preserved on merge_failed (row 34)', () => {
|
||||
test('a genuine merge conflict blocks the entry AND leaves the real worktree directory on disk; routeMergeOutcome confirms preserveWorktree', () => {
|
||||
const tmpBase = createTempDir('qb-merge-fail-');
|
||||
try {
|
||||
const repoDir = path.join(tmpBase, 'repo');
|
||||
const wtDir = path.join(tmpBase, 'wt-conflict');
|
||||
const branchName = 'worktree-agent-conflict';
|
||||
|
||||
initRepo(repoDir);
|
||||
addWorktree(repoDir, wtDir, branchName);
|
||||
|
||||
const baseCommit = git(['merge-base', 'HEAD', branchName], repoDir).trim();
|
||||
|
||||
// Diverge BOTH sides on the SAME file so the merge produces a real
|
||||
// conflict — not a refused merge, an actual MERGE_HEAD conflict.
|
||||
fs.writeFileSync(path.join(repoDir, 'shared.txt'), 'main branch version\n');
|
||||
git(['add', '-A'], repoDir);
|
||||
git(['commit', '-m', 'main: edit shared.txt'], repoDir);
|
||||
|
||||
fs.writeFileSync(path.join(wtDir, 'shared.txt'), 'worktree branch version\n');
|
||||
git(['add', '-A'], wtDir);
|
||||
git(['commit', '-m', 'worktree: edit shared.txt'], wtDir);
|
||||
|
||||
const plan = {
|
||||
ok: true,
|
||||
repoRoot: repoDir,
|
||||
action: 'cleanup_wave',
|
||||
discovery: 'manifest',
|
||||
entries: [{
|
||||
agent_id: 'conflict1',
|
||||
worktree_path: wtDir,
|
||||
branch: branchName,
|
||||
expected_base: baseCommit,
|
||||
}],
|
||||
};
|
||||
|
||||
const result = executeWorktreeWaveCleanupPlan(plan);
|
||||
|
||||
assert.equal(result.entries[0].status, 'blocked', `expected a blocked entry, got: ${JSON.stringify(result.entries[0])}`);
|
||||
assert.equal(result.entries[0].reason, 'merge_failed');
|
||||
|
||||
// The REAL worktree directory must still exist — the primitive never
|
||||
// removed it for a blocked entry.
|
||||
assert.ok(fs.existsSync(wtDir), 'worktree directory must survive a real merge conflict');
|
||||
|
||||
// quick-batch's own pure routing over this REAL result must agree:
|
||||
// fail, with preserveWorktree explicitly true.
|
||||
const routing = routeMergeOutcome({ kind: 'merge_failed', detail: result.entries[0].reason });
|
||||
assert.equal(routing.action, 'fail');
|
||||
assert.equal(routing.preserveWorktree, true);
|
||||
|
||||
// Consistency check: quick-batch's routing decision and the real
|
||||
// primitive's own behavior agree — neither removed the worktree.
|
||||
assert.ok(fs.existsSync(wtDir), 'worktree directory still exists after routing — routeMergeOutcome never performs I/O, this reasserts the invariant held');
|
||||
} finally {
|
||||
cleanup(tmpBase);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe('quick-batch merge routing — real undeclared-deletion detection (row 35)', () => {
|
||||
test('a real, undeclared file deletion blocks the merge and preserves the worktree; a declared one merges and removes it', () => {
|
||||
const tmpBase = createTempDir('qb-merge-deletion-');
|
||||
try {
|
||||
const repoDir = path.join(tmpBase, 'repo');
|
||||
initRepo(repoDir);
|
||||
fs.writeFileSync(path.join(repoDir, 'legacy.txt'), 'to be deleted\n');
|
||||
git(['add', '-A'], repoDir);
|
||||
git(['commit', '-m', 'add legacy.txt'], repoDir);
|
||||
|
||||
// ── Case 1: UNDECLARED deletion — must block, worktree preserved ─────
|
||||
const wtDirUndeclared = path.join(tmpBase, 'wt-undeclared');
|
||||
const branchUndeclared = 'worktree-agent-undeclared';
|
||||
addWorktree(repoDir, wtDirUndeclared, branchUndeclared);
|
||||
const baseCommit = git(['merge-base', 'HEAD', branchUndeclared], repoDir).trim();
|
||||
|
||||
// A REAL deletion — actually remove the file and commit that removal.
|
||||
fs.unlinkSync(path.join(wtDirUndeclared, 'legacy.txt'));
|
||||
git(['add', '-A'], wtDirUndeclared);
|
||||
git(['commit', '-m', 'delete legacy.txt'], wtDirUndeclared);
|
||||
|
||||
const undeclaredPlan = {
|
||||
ok: true,
|
||||
repoRoot: repoDir,
|
||||
action: 'cleanup_wave',
|
||||
discovery: 'manifest',
|
||||
entries: [{
|
||||
agent_id: 'undeclared1',
|
||||
worktree_path: wtDirUndeclared,
|
||||
branch: branchUndeclared,
|
||||
expected_base: baseCommit,
|
||||
// declared_deletions intentionally OMITTED — an undeclared deletion
|
||||
// is indistinguishable from a forgotten one, per the design doc's
|
||||
// own documented negative space; the guard blocks either way.
|
||||
}],
|
||||
};
|
||||
|
||||
const undeclaredResult = executeWorktreeWaveCleanupPlan(undeclaredPlan);
|
||||
assert.equal(undeclaredResult.entries[0].status, 'blocked', `expected a blocked entry for the undeclared deletion, got: ${JSON.stringify(undeclaredResult.entries[0])}`);
|
||||
assert.equal(undeclaredResult.entries[0].reason, 'branch_contains_deletions');
|
||||
assert.ok(fs.existsSync(wtDirUndeclared), 'worktree with an undeclared real deletion must be preserved on disk');
|
||||
|
||||
const scopeRouting = routeMergeOutcome({ kind: 'scope_violation', detail: undeclaredResult.entries[0].reason });
|
||||
assert.equal(scopeRouting.action, 'fail');
|
||||
assert.equal(scopeRouting.preserveWorktree, true);
|
||||
assert.match(scopeRouting.failureReason, /branch_contains_deletions/);
|
||||
|
||||
// ── Case 2: DECLARED deletion of the SAME real change — must merge ───
|
||||
const wtDirDeclared = path.join(tmpBase, 'wt-declared');
|
||||
const branchDeclared = 'worktree-agent-declared';
|
||||
addWorktree(repoDir, wtDirDeclared, branchDeclared);
|
||||
const baseCommit2 = git(['merge-base', 'HEAD', branchDeclared], repoDir).trim();
|
||||
|
||||
fs.unlinkSync(path.join(wtDirDeclared, 'legacy.txt'));
|
||||
git(['add', '-A'], wtDirDeclared);
|
||||
git(['commit', '-m', 'delete legacy.txt (declared)'], wtDirDeclared);
|
||||
|
||||
const declaredPlan = {
|
||||
ok: true,
|
||||
repoRoot: repoDir,
|
||||
action: 'cleanup_wave',
|
||||
discovery: 'manifest',
|
||||
entries: [{
|
||||
agent_id: 'declared1',
|
||||
worktree_path: wtDirDeclared,
|
||||
branch: branchDeclared,
|
||||
expected_base: baseCommit2,
|
||||
declared_deletions: ['legacy.txt'],
|
||||
}],
|
||||
};
|
||||
|
||||
const declaredResult = executeWorktreeWaveCleanupPlan(declaredPlan);
|
||||
assert.equal(declaredResult.entries[0].status, 'merged_removed', `expected a declared deletion to merge cleanly, got: ${JSON.stringify(declaredResult.entries[0])}`);
|
||||
assert.ok(!fs.existsSync(wtDirDeclared), 'worktree with a fully declared deletion must be removed after a successful merge');
|
||||
|
||||
const mergedRouting = routeMergeOutcome({ kind: 'merged' });
|
||||
assert.equal(mergedRouting.action, 'complete');
|
||||
} finally {
|
||||
cleanup(tmpBase);
|
||||
}
|
||||
});
|
||||
});
|
||||
59
tests/gsd-quick-batch-quick-regression.test.cjs
Normal file
59
tests/gsd-quick-batch-quick-regression.test.cjs
Normal file
@@ -0,0 +1,59 @@
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* gsd-quick-batch-quick-regression.test.cjs — row 48 of the #3676 test
|
||||
* matrix: ordinary `/gsd:quick` (non-batch) stays byte-identical after
|
||||
* Phase 4 lands.
|
||||
*
|
||||
* Named `gsd-quick-batch-*` (not `quick-batch-*`) so `scripts/
|
||||
* lint-test-file-count.cjs`'s longest-prefix bucketing does not fold this
|
||||
* markdown-only test into the already-capped `quick-batch` production-module
|
||||
* bucket (2/2 test files from the CORE-layer pass).
|
||||
*
|
||||
* `commands/gsd/quick.md` / `gsd-core/workflows/quick.md` are never touched
|
||||
* by this phase (design doc row 38/48) — quick-batch adds new call sites
|
||||
* onto shared primitives, never edits the ordinary quick command/workflow.
|
||||
* Asserted via the same base-ref resolution helper `tests/
|
||||
* emitted-attribution.test.cjs` already uses (`resolveBase`/`resolveChangedPaths`,
|
||||
* `tests/helpers/emitted-runtime.cjs`) — a three-dot diff against the merge
|
||||
* base, never a hand-rolled git call.
|
||||
*/
|
||||
|
||||
const { describe, test } = require('node:test');
|
||||
const assert = require('node:assert/strict');
|
||||
const {
|
||||
resolveBase,
|
||||
resolveChangedPaths,
|
||||
baseRefCandidates,
|
||||
} = require('./helpers/emitted-runtime.cjs');
|
||||
|
||||
describe('quick-batch: /gsd:quick command + workflow stay byte-identical (row 48)', () => {
|
||||
test('commands/gsd/quick.md and gsd-core/workflows/quick.md are not in this branch\'s changed-path set', (t) => {
|
||||
// Environmental skip (ADR-2719 §6 idiom) — same as tests/emitted-attribution.test.cjs:
|
||||
// a base ref is not universally resolvable (gsd-test's shallow-merged container
|
||||
// carries no origin/* remote-tracking refs). t.skip is REPORTED as skipped, unlike
|
||||
// a bare `return`, which node:test scores as a silent pass.
|
||||
const resolved = resolveBase();
|
||||
if (!resolved) {
|
||||
t.skip(
|
||||
'no base ref resolvable — tried ' + baseRefCandidates().join(', ') +
|
||||
'. Set GSD_EMITTED_BASE=<ref|sha> to run this regression check elsewhere.',
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
const changed = resolveChangedPaths(resolved.ref);
|
||||
assert.ok(
|
||||
!changed.includes('commands/gsd/quick.md'),
|
||||
'commands/gsd/quick.md must stay untouched by the #3676 quick-batch phase',
|
||||
);
|
||||
assert.ok(
|
||||
!changed.includes('gsd-core/workflows/quick.md'),
|
||||
'gsd-core/workflows/quick.md must stay untouched by the #3676 quick-batch phase',
|
||||
);
|
||||
// The step fragments under quick/steps/ are likewise untouched — quick-batch
|
||||
// has its own, separate quick-batch/steps/ tree.
|
||||
const touchedQuickSteps = changed.filter((p) => p.startsWith('gsd-core/workflows/quick/steps/'));
|
||||
assert.deepEqual(touchedQuickSteps, [], `unexpected changes under gsd-core/workflows/quick/steps/: ${touchedQuickSteps.join(', ')}`);
|
||||
});
|
||||
});
|
||||
304
tests/gsd-quick-batch-workflow.test.cjs
Normal file
304
tests/gsd-quick-batch-workflow.test.cjs
Normal file
@@ -0,0 +1,304 @@
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* gsd-quick-batch-workflow.test.cjs — structural + byte-budget tests for the
|
||||
* `/gsd:quick-batch` command and workflow markdown (#3676, Phase 4 of epic
|
||||
* #3344, ADR-1239 "Quick-batch binding").
|
||||
*
|
||||
* Named `gsd-quick-batch-*` (not `quick-batch-*`) deliberately:
|
||||
* `scripts/lint-test-file-count.cjs` buckets any `quick-batch-*.test.cjs`
|
||||
* file under the `quick-batch`/`quick-batch-dispatch`/
|
||||
* `quick-batch-command-router` production-module buckets by longest-prefix
|
||||
* match, and all three are already at their 2-file cap from the CORE-layer
|
||||
* pass. This file tests MARKDOWN (no corresponding compiled `.cjs` module),
|
||||
* so a `gsd-` prefix keeps it out of every existing bucket.
|
||||
*
|
||||
* Follows the SAME established testing convention this repo already uses
|
||||
* for large workflow files — structural assertions on parsed sections/
|
||||
* fenced blocks (e.g. `tests/quick-research.test.cjs`, `tests/
|
||||
* quick-branching.test.cjs`) — not `.includes()` on production `.cjs`
|
||||
* SOURCE (the `local/no-source-grep` rule targets `.cjs`/`.js`/`.ts`
|
||||
* source files, not workflow/command markdown, which is data/prose).
|
||||
*
|
||||
* Design doc: `.gsd/phase/feat-3676-quick-batch-command-workflow/40-design.md`
|
||||
* Test matrix: `.gsd/phase/feat-3676-quick-batch-command-workflow/50-test-matrix.md`
|
||||
* Rows covered here: 13-21, 25, 29, 30, 31, 36, 38, 39 (byte cap), 44.
|
||||
* Rows 46/47 (CLI routing) are already covered end-to-end by
|
||||
* tests/quick-batch-command-router.test.cjs.
|
||||
*/
|
||||
|
||||
const { describe, test } = require('node:test');
|
||||
const assert = require('node:assert/strict');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const { lfByteCount } = require('../scripts/workflow-size.cjs');
|
||||
const { NEW_FILE_CAP } = require('./helpers/emitted-diff.cjs');
|
||||
const { splitLines } = require('../gsd-core/bin/lib/text-lines.cjs');
|
||||
|
||||
/**
|
||||
* Extract the text strictly between an opening and closing tag, by line
|
||||
* index rather than a `[\s\S]*?` regex over readFileSync content (CWE-1333
|
||||
* catastrophic-backtracking class; `local/no-unbounded-quantifier`).
|
||||
*/
|
||||
function extractTagBody(content, openTag, closeTag) {
|
||||
const lines = splitLines(content);
|
||||
const startIdx = lines.findIndex((l) => l.includes(openTag));
|
||||
if (startIdx === -1) return null;
|
||||
const endIdx = lines.findIndex((l, i) => i > startIdx && l.includes(closeTag));
|
||||
if (endIdx === -1) return null;
|
||||
return lines.slice(startIdx + 1, endIdx).join('\n');
|
||||
}
|
||||
|
||||
const COMMAND_PATH = path.join(__dirname, '..', 'commands', 'gsd', 'quick-batch.md');
|
||||
const WORKFLOW_PATH = path.join(__dirname, '..', 'gsd-core', 'workflows', 'quick-batch.md');
|
||||
const STEPS_DIR = path.join(__dirname, '..', 'gsd-core', 'workflows', 'quick-batch', 'steps');
|
||||
|
||||
function readStep(name) {
|
||||
return fs.readFileSync(path.join(STEPS_DIR, name), 'utf-8');
|
||||
}
|
||||
|
||||
// ─── Command frontmatter (rows 5,7,8,9,10,13-15) ────────────────────────────
|
||||
|
||||
describe('quick-batch command: frontmatter and objective', () => {
|
||||
test('commands/gsd/quick-batch.md exists', () => {
|
||||
assert.ok(fs.existsSync(COMMAND_PATH));
|
||||
});
|
||||
|
||||
test('argument-hint advertises --jobs/--validate/--research/--resume/--file', () => {
|
||||
const content = fs.readFileSync(COMMAND_PATH, 'utf-8');
|
||||
const hintLine = splitLines(content).find((l) => l.includes('argument-hint'));
|
||||
assert.ok(hintLine, 'should have argument-hint line');
|
||||
for (const flag of ['--file', '--jobs', '--validate', '--research', '--resume']) {
|
||||
assert.ok(hintLine.includes(flag), `argument-hint should mention ${flag}`);
|
||||
}
|
||||
});
|
||||
|
||||
test('objective documents --discuss/--full as rejected in v1', () => {
|
||||
const content = fs.readFileSync(COMMAND_PATH, 'utf-8');
|
||||
const objectiveBody = extractTagBody(content, '<objective>', '</objective>');
|
||||
assert.ok(objectiveBody, 'should have <objective> section');
|
||||
assert.match(objectiveBody, /--discuss/);
|
||||
assert.match(objectiveBody, /--full/);
|
||||
assert.match(objectiveBody, /rejected/i);
|
||||
});
|
||||
|
||||
test('process routes argument validation through the quick-batch CLI verb, not inline re-derivation', () => {
|
||||
const content = fs.readFileSync(COMMAND_PATH, 'utf-8');
|
||||
const processBody = extractTagBody(content, '<process>', '</process>');
|
||||
assert.ok(processBody, 'should have <process> section');
|
||||
assert.match(processBody, /quick-batch parse-args/);
|
||||
});
|
||||
|
||||
// #3676 review pass 3 (Security finding 1): commands/gsd/quick.md carries a
|
||||
// <security_notes> block naming the DATA_START/DATA_END boundary
|
||||
// convention for content reaching agent prompts (line 176) — quick-batch.md
|
||||
// had no equivalent section at all.
|
||||
test('security_notes documents the $ARGUMENTS quoting fix and the DATA_START/DATA_END prompt boundary', () => {
|
||||
const content = fs.readFileSync(COMMAND_PATH, 'utf-8');
|
||||
const securityBody = extractTagBody(content, '<security_notes>', '</security_notes>');
|
||||
assert.ok(securityBody, 'should have <security_notes> section');
|
||||
assert.match(securityBody, /--text/);
|
||||
assert.match(securityBody, /DATA_START/);
|
||||
assert.match(securityBody, /DATA_END/);
|
||||
});
|
||||
|
||||
test('$ARGUMENTS is passed to quick-batch parse-args via quoted --text, never unquoted word-splitting', () => {
|
||||
const content = fs.readFileSync(COMMAND_PATH, 'utf-8');
|
||||
const processBody = extractTagBody(content, '<process>', '</process>');
|
||||
assert.ok(processBody, 'should have <process> section');
|
||||
assert.match(processBody, /--text "\$ARGUMENTS"/);
|
||||
});
|
||||
});
|
||||
|
||||
// ─── Workflow byte-size boundary (row 49, ADR 1610 NEW_FILE_CAP) ────────────
|
||||
|
||||
describe('quick-batch workflow: byte-size boundary (row 49)', () => {
|
||||
test('gsd-core/workflows/quick-batch.md exists', () => {
|
||||
assert.ok(fs.existsSync(WORKFLOW_PATH));
|
||||
});
|
||||
|
||||
test(`main workflow file is under the ${NEW_FILE_CAP}-byte NEW_FILE_CAP (ADR 1610) — a brand-new workflow file gets the tighter cap, not the grandfathered DEFAULT_CAP`, () => {
|
||||
const bytes = lfByteCount(WORKFLOW_PATH);
|
||||
assert.ok(
|
||||
bytes <= NEW_FILE_CAP,
|
||||
`gsd-core/workflows/quick-batch.md is ${bytes} bytes, exceeding NEW_FILE_CAP (${NEW_FILE_CAP}) — extract more content into gsd-core/workflows/quick-batch/steps/*.md fragments`,
|
||||
);
|
||||
});
|
||||
|
||||
test('quick-batch has at least 5 lazy-loaded step fragments (design doc requirement)', () => {
|
||||
const files = fs.readdirSync(STEPS_DIR).filter((f) => f.endsWith('.md'));
|
||||
assert.ok(files.length >= 5, `expected >= 5 step fragments, found ${files.length}: ${files.join(', ')}`);
|
||||
});
|
||||
|
||||
// #3676 review pass 3 (Security finding 2): the workflow's own runtime
|
||||
// invocation must use quoted --text "$ARGUMENTS", not unquoted -- $ARGUMENTS
|
||||
// (shell word-splitting/pathname expansion before the parser sees raw,
|
||||
// attacker-influenced task text).
|
||||
test('main workflow passes $ARGUMENTS to quick-batch parse-args via quoted --text', () => {
|
||||
const content = fs.readFileSync(WORKFLOW_PATH, 'utf-8');
|
||||
assert.match(content, /quick-batch parse-args --raw --text "\$ARGUMENTS"/);
|
||||
assert.doesNotMatch(content, /quick-batch parse-args --raw -- \$ARGUMENTS(?!")/, 'must never pass raw, unquoted $ARGUMENTS to the parser');
|
||||
});
|
||||
});
|
||||
|
||||
// ─── Prompt-injection boundaries on raw task text (Security finding 1) ──────
|
||||
|
||||
describe('quick-batch leaf prompts: DATA_START/DATA_END boundary on every raw task description (Security finding 1)', () => {
|
||||
for (const [file, label] of [
|
||||
['research-phase.md', 'researcher'],
|
||||
['planner-wave.md', 'planner'],
|
||||
['plan-checker-loop.md', 'plan-checker'],
|
||||
['verification-wave.md', 'verifier'],
|
||||
]) {
|
||||
test(`${file} (${label}) wraps \${description} in a DATA_START/DATA_END security_context boundary`, () => {
|
||||
const content = readStep(file);
|
||||
assert.match(content, /<security_context>/, `${file} must declare a <security_context> block`);
|
||||
assert.match(content, /SECURITY:.*DATA_START.*DATA_END/s, `${file}'s security_context must name the DATA_START/DATA_END boundary`);
|
||||
assert.match(content, /DATA_START\s*\n\s*\$\{description\}\s*\n\s*DATA_END/, `${file} must wrap \${description} itself between DATA_START/DATA_END, not just mention the convention`);
|
||||
});
|
||||
}
|
||||
|
||||
test('planner-wave.md ALSO wraps the shared ${TASK_CATALOG_TABLE} (every item\'s raw description) in its own DATA_START/DATA_END boundary', () => {
|
||||
const content = readStep('planner-wave.md');
|
||||
assert.match(content, /DATA_START\s*\n\s*\$\{TASK_CATALOG_TABLE\}\s*\n\s*DATA_END/);
|
||||
});
|
||||
});
|
||||
|
||||
// ─── Isolation model coverage (rows 20-22) ──────────────────────────────────
|
||||
|
||||
describe('quick-batch workflow: isolation model coverage (rows 20-22)', () => {
|
||||
test('worktree-dispatch.md covers harness-worktree, orchestrator-worktree, and none', () => {
|
||||
const content = readStep('worktree-dispatch.md');
|
||||
assert.match(content, /isolation == "harness-worktree"/);
|
||||
assert.match(content, /isolation == "orchestrator-worktree"/);
|
||||
assert.match(content, /isolation == "none"/);
|
||||
});
|
||||
|
||||
test('worktree create/executor dispatch is serialized (one Agent() per message, run_in_background)', () => {
|
||||
const content = readStep('worktree-dispatch.md');
|
||||
assert.match(content, /ONE AT A TIME/);
|
||||
assert.match(content, /run_in_background: true/);
|
||||
});
|
||||
|
||||
test('row 38: auto-degrades to sequential on stale worktree fork base', () => {
|
||||
const content = readStep('worktree-dispatch.md');
|
||||
assert.match(content, /worktree\.base-check/);
|
||||
assert.match(content, /shouldDegrade/);
|
||||
});
|
||||
});
|
||||
|
||||
// ─── Single-writer invariant (row 18) ───────────────────────────────────────
|
||||
|
||||
describe('quick-batch workflow: single-writer invariant on the executor (row 18)', () => {
|
||||
test('executor prompt forbids invoking /gsd:quick and forbids writing BATCH.json/STATE/ROADMAP', () => {
|
||||
const content = readStep('worktree-dispatch.md');
|
||||
assert.match(content, /NEVER invoke \/gsd:quick/);
|
||||
assert.match(content, /NEVER write .*BATCH\.json/);
|
||||
assert.match(content, /Do NOT update STATE\.md or ROADMAP\.md/);
|
||||
});
|
||||
});
|
||||
|
||||
// ─── Merge validation reuses the bounded primitive (row 25) ─────────────────
|
||||
|
||||
describe('quick-batch workflow: merge validated via the existing bounded primitive (row 25)', () => {
|
||||
test('merge-wave.md calls worktree.cleanup-wave, never hand-rolled git merge', () => {
|
||||
const content = readStep('merge-wave.md');
|
||||
assert.match(content, /worktree\.cleanup-wave/);
|
||||
assert.match(content, /never hand-roll `git merge`/);
|
||||
});
|
||||
|
||||
test('merge-wave.md routes non-merged outcomes via quick-batch merge-routing and preserves the worktree', () => {
|
||||
const content = readStep('merge-wave.md');
|
||||
assert.match(content, /quick-batch merge-routing/);
|
||||
assert.match(content, /preserveWorktree/);
|
||||
});
|
||||
});
|
||||
|
||||
// ─── Research / plan-checker / verification leaves (rows 16,17,19) ─────────
|
||||
|
||||
describe('quick-batch workflow: optional per-item leaves (rows 16,17,19)', () => {
|
||||
test('row 16: research-phase.md dispatches gsd-phase-researcher before planning', () => {
|
||||
const content = readStep('research-phase.md');
|
||||
assert.match(content, /subagent_type="gsd-phase-researcher"/);
|
||||
});
|
||||
|
||||
test('row 17: plan-checker-loop.md caps revision at 2 iterations', () => {
|
||||
const content = readStep('plan-checker-loop.md');
|
||||
assert.match(content, /max 2 iterations/i);
|
||||
assert.match(content, /iteration >= 2/);
|
||||
});
|
||||
|
||||
test('row 19: verification-wave.md routes status via the canonical verification.status query', () => {
|
||||
const content = readStep('verification-wave.md');
|
||||
assert.match(content, /query verification\.status/);
|
||||
});
|
||||
|
||||
test('row 30: verification-wave.md never calls quick-batch complete for a human_needed item', () => {
|
||||
const content = readStep('verification-wave.md');
|
||||
assert.match(content, /human_needed/);
|
||||
assert.match(content, /Do NOT call `quick-batch complete`/);
|
||||
});
|
||||
|
||||
test('row 31: verification-wave.md fails a gaps_found item without rollback or retry', () => {
|
||||
const content = readStep('verification-wave.md');
|
||||
assert.match(content, /gaps_found/);
|
||||
assert.match(content, /NO automatic gap-fix retry/);
|
||||
assert.match(content, /NO rollback/);
|
||||
});
|
||||
});
|
||||
|
||||
// ─── Planning/checking failure blocks execution (row 29) ────────────────────
|
||||
|
||||
describe('quick-batch workflow: a plan/check failure blocks that item\'s execution (row 29)', () => {
|
||||
test('planner-wave.md marks a missing PLAN.md item failed rather than dispatching an executor for it', () => {
|
||||
const content = readStep('planner-wave.md');
|
||||
assert.match(content, /mark[\s\S]{0,10}that item `failed`/);
|
||||
});
|
||||
});
|
||||
|
||||
// ─── Submodule guard (rows 36,44) ────────────────────────────────────────────
|
||||
|
||||
describe('quick-batch workflow: submodule fail-loud commit-time guard (rows 36,44)', () => {
|
||||
test('main workflow parses SUBMODULE_PATHS from .gitmodules', () => {
|
||||
const content = fs.readFileSync(WORKFLOW_PATH, 'utf-8');
|
||||
assert.match(content, /SUBMODULE_PATHS/);
|
||||
assert.match(content, /\.gitmodules/);
|
||||
});
|
||||
|
||||
test('worktree-dispatch.md embeds the submodule_commit_guard per executor prompt', () => {
|
||||
const content = readStep('worktree-dispatch.md');
|
||||
assert.match(content, /submodule_commit_guard/);
|
||||
});
|
||||
});
|
||||
|
||||
// ─── planner-quick-batch mode (rows 13-15) ──────────────────────────────────
|
||||
|
||||
describe('quick-batch planner mode: agents/gsd-planner.md extension (rows 13-15)', () => {
|
||||
const plannerPath = path.join(__dirname, '..', 'agents', 'gsd-planner.md');
|
||||
const refPath = path.join(__dirname, '..', 'gsd-core', 'references', 'planner-quick-batch.md');
|
||||
|
||||
test('agents/gsd-planner.md additively wires the quick-batch mode reference', () => {
|
||||
const content = fs.readFileSync(plannerPath, 'utf-8');
|
||||
assert.match(content, /quick-batch.*planner-quick-batch\.md|planner-quick-batch\.md/);
|
||||
});
|
||||
|
||||
test('gsd-core/references/planner-quick-batch.md exists and requires depends_on/files_modified ALWAYS', () => {
|
||||
assert.ok(fs.existsSync(refPath));
|
||||
const content = fs.readFileSync(refPath, 'utf-8');
|
||||
assert.match(content, /ALWAYS required, regardless of whether/);
|
||||
assert.match(content, /depends_on/);
|
||||
assert.match(content, /files_modified/);
|
||||
});
|
||||
|
||||
test('planner-wave.md always requests depends_on/files_modified regardless of --validate (row 14)', () => {
|
||||
const content = readStep('planner-wave.md');
|
||||
assert.match(content, /ALWAYS emit `depends_on`/);
|
||||
assert.match(content, /ALWAYS emit `files_modified`/);
|
||||
assert.match(content, /required regardless of\s*\n?\s*`--validate`/);
|
||||
});
|
||||
|
||||
test('planner-wave.md includes the full batch task catalog in every planner prompt (row 13)', () => {
|
||||
const content = readStep('planner-wave.md');
|
||||
assert.match(content, /Full batch task catalog/);
|
||||
});
|
||||
});
|
||||
@@ -63,7 +63,7 @@ describe('prompts — protocol surface', () => {
|
||||
const res = handleMessage({ jsonrpc: '2.0', id: 1, method: 'prompts/list' });
|
||||
assert.equal(res.error, undefined, 'prompts/list must not error');
|
||||
assert.ok(res.result && Array.isArray(res.result.prompts), 'result.prompts must be an array');
|
||||
assert.equal(res.result.prompts.length, 71, 'must list all 71 commands/gsd/*.md as prompts');
|
||||
assert.equal(res.result.prompts.length, 72, 'must list all 72 commands/gsd/*.md as prompts');
|
||||
for (const p of res.result.prompts) {
|
||||
assert.equal(typeof p.name, 'string');
|
||||
assert.equal(p.name.includes('/'), false, 'name must be the bare command, not a path');
|
||||
|
||||
@@ -105,9 +105,19 @@ test('#2711: the guarded set is derived from dispatch sites, not hand-maintained
|
||||
'a workflow with 10 dispatch sites must be derived exactly once',
|
||||
);
|
||||
// limit-1: a workflow that never emits model= must NOT be dragged in.
|
||||
// #3676: must use the SAME readWorkflowCombined (host + steps/*.md) read
|
||||
// `workflowsThatDispatchWithAModel()` itself uses (per that function's own
|
||||
// #2994 doc comment above) — a bare-host-only read here was inconsistent
|
||||
// with `derived`'s combined read, and a workflow whose EVERY model="{...}"
|
||||
// dispatch site lives in a mandatory (never gated) steps/ fragment — true
|
||||
// for quick-batch.md, which extracts even its non-optional planner/executor
|
||||
// dispatch to stay under ADR-1610's tighter NEW_FILE_CAP for a brand-new
|
||||
// file — has zero model="{" occurrences in its bare host text while still
|
||||
// correctly appearing in `derived`. The mismatch made this limit-1 check
|
||||
// wrongly flag a genuinely-dispatching workflow as "must not be derived in".
|
||||
const nonDispatching = fs
|
||||
.readdirSync(WORKFLOWS)
|
||||
.filter((f) => f.endsWith('.md') && !/model="\{/.test(fs.readFileSync(path.join(WORKFLOWS, f), 'utf8')));
|
||||
.filter((f) => f.endsWith('.md') && !/model="\{/.test(readWorkflowCombined(path.join(WORKFLOWS, f))));
|
||||
assert.ok(nonDispatching.length > 0, 'expected some workflows to dispatch no model= at all');
|
||||
for (const f of nonDispatching) {
|
||||
assert.ok(!derived.includes(f), `${f} emits no model= and must not be required to carry the rule`);
|
||||
|
||||
488
tests/quick-batch-command-router.test.cjs
Normal file
488
tests/quick-batch-command-router.test.cjs
Normal file
@@ -0,0 +1,488 @@
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* quick-batch-command-router.test.cjs — Behavioral tests for the
|
||||
* `gsd-tools quick-batch` command router (#3676, Phase 4 of epic #3344 /
|
||||
* ADR-1239 "Quick-batch binding").
|
||||
*
|
||||
* Module: gsd-core/bin/lib/quick-batch-command-router.cjs
|
||||
* (compiled from src/quick-batch-command-router.cts)
|
||||
*
|
||||
* Follows `tests/roadmap-command-router.test.cjs`'s pattern: unit-level
|
||||
* tests inject `_quickBatch`/`_quickBatchDispatch` mocks (same `_`-prefix
|
||||
* seam convention `graphify-command-router.cts` established) and assert on
|
||||
* recorded call shapes; a smaller set of end-to-end tests drive the REAL
|
||||
* compiled router through `gsd-tools quick-batch <verb>` via `runGsdTools`
|
||||
* to prove the `HOST_COMMAND_ROUTERS` wiring itself (test-matrix rows 46-47).
|
||||
*/
|
||||
|
||||
const { describe, test } = require('node:test');
|
||||
const assert = require('node:assert/strict');
|
||||
const fs = require('fs');
|
||||
const os = require('os');
|
||||
const path = require('path');
|
||||
|
||||
const { routeQuickBatchCommand } = require('../gsd-core/bin/lib/quick-batch-command-router.cjs');
|
||||
const { runGsdTools, cleanup } = require('./helpers.cjs');
|
||||
|
||||
function mkTmpProject() {
|
||||
const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'quick-batch-router-'));
|
||||
fs.mkdirSync(path.join(dir, '.planning'), { recursive: true });
|
||||
return dir;
|
||||
}
|
||||
|
||||
// ─── Unit-level: argument shaping against injected mocks ───────────────────
|
||||
|
||||
describe('quick-batch-command-router: argument shaping (mocked modules)', () => {
|
||||
test('create requires --file', () => {
|
||||
let message = null;
|
||||
routeQuickBatchCommand({
|
||||
args: ['quick-batch', 'create'],
|
||||
cwd: '/tmp/proj',
|
||||
raw: true,
|
||||
error: (msg) => { message = msg; },
|
||||
_quickBatch: {},
|
||||
_quickBatchDispatch: {},
|
||||
});
|
||||
assert.match(message, /--file/);
|
||||
});
|
||||
|
||||
test('create parses --file/--base-revision/--options and forwards to parseTaskListFromFile + createBatch', () => {
|
||||
const calls = [];
|
||||
routeQuickBatchCommand({
|
||||
args: ['quick-batch', 'create', '--file', 'tasks.md', '--base-revision', 'deadbeef', '--options', '{"note":"x"}'],
|
||||
cwd: '/tmp/proj',
|
||||
raw: true,
|
||||
error: (msg) => { throw new Error(`unexpected error: ${msg}`); },
|
||||
_quickBatch: {
|
||||
parseTaskListFromFile: (cwd, filePath) => {
|
||||
calls.push({ fn: 'parseTaskListFromFile', cwd, filePath });
|
||||
return { ok: true, value: [{ description: 'a' }, { description: 'b' }] };
|
||||
},
|
||||
createBatch: (cwd, items, options) => {
|
||||
calls.push({ fn: 'createBatch', cwd, items, options });
|
||||
return { ok: true, value: { batchId: 'x' } };
|
||||
},
|
||||
},
|
||||
_quickBatchDispatch: {},
|
||||
});
|
||||
assert.equal(calls[0].fn, 'parseTaskListFromFile');
|
||||
assert.equal(calls[0].filePath, 'tasks.md');
|
||||
assert.equal(calls[1].fn, 'createBatch');
|
||||
assert.deepEqual(calls[1].items, [{ description: 'a' }, { description: 'b' }]);
|
||||
assert.equal(calls[1].options.baseRevision, 'deadbeef');
|
||||
assert.deepEqual(calls[1].options.batchOptions, { note: 'x' });
|
||||
});
|
||||
|
||||
test('update requires --batch and --updates', () => {
|
||||
let message = null;
|
||||
routeQuickBatchCommand({
|
||||
args: ['quick-batch', 'update', '--batch', 'b1'],
|
||||
cwd: '/tmp/proj',
|
||||
raw: true,
|
||||
error: (msg) => { message = msg; },
|
||||
_quickBatch: {},
|
||||
_quickBatchDispatch: {},
|
||||
});
|
||||
assert.match(message, /--updates/);
|
||||
});
|
||||
|
||||
test('update parses --updates JSON and forwards to updateBatchItems', () => {
|
||||
const calls = [];
|
||||
routeQuickBatchCommand({
|
||||
args: ['quick-batch', 'update', '--batch', 'b1', '--updates', '[{"quickId":"260101-abc","dependsOn":[]}]'],
|
||||
cwd: '/tmp/proj',
|
||||
raw: true,
|
||||
error: (msg) => { throw new Error(`unexpected error: ${msg}`); },
|
||||
_quickBatch: {
|
||||
updateBatchItems: (cwd, batchId, updates) => {
|
||||
calls.push({ cwd, batchId, updates });
|
||||
return { ok: true, value: { manifest: {} } };
|
||||
},
|
||||
},
|
||||
_quickBatchDispatch: {},
|
||||
});
|
||||
assert.equal(calls[0].batchId, 'b1');
|
||||
assert.deepEqual(calls[0].updates, [{ quickId: '260101-abc', dependsOn: [] }]);
|
||||
});
|
||||
|
||||
test('update rejects malformed --updates JSON before calling updateBatchItems', () => {
|
||||
let message = null;
|
||||
let called = false;
|
||||
routeQuickBatchCommand({
|
||||
args: ['quick-batch', 'update', '--batch', 'b1', '--updates', 'not-json'],
|
||||
cwd: '/tmp/proj',
|
||||
raw: true,
|
||||
error: (msg) => { message = msg; },
|
||||
_quickBatch: { updateBatchItems: () => { called = true; return { ok: true, value: {} }; } },
|
||||
_quickBatchDispatch: {},
|
||||
});
|
||||
assert.match(message, /not valid JSON/);
|
||||
assert.equal(called, false);
|
||||
});
|
||||
|
||||
test('resume requires --batch', () => {
|
||||
let message = null;
|
||||
routeQuickBatchCommand({
|
||||
args: ['quick-batch', 'resume'],
|
||||
cwd: '/tmp/proj',
|
||||
raw: true,
|
||||
error: (msg) => { message = msg; },
|
||||
_quickBatch: {},
|
||||
_quickBatchDispatch: {},
|
||||
});
|
||||
assert.match(message, /--batch/);
|
||||
});
|
||||
|
||||
test('resume forwards --current-base-revision when present', () => {
|
||||
const calls = [];
|
||||
routeQuickBatchCommand({
|
||||
args: ['quick-batch', 'resume', '--batch', 'b1', '--current-base-revision', 'cafebabe'],
|
||||
cwd: '/tmp/proj',
|
||||
raw: true,
|
||||
error: (msg) => { throw new Error(`unexpected error: ${msg}`); },
|
||||
_quickBatch: {
|
||||
resumeBatch: (cwd, batchId, options) => {
|
||||
calls.push({ cwd, batchId, options });
|
||||
return { ok: true, value: { eligible: [] } };
|
||||
},
|
||||
},
|
||||
_quickBatchDispatch: {},
|
||||
});
|
||||
assert.equal(calls[0].options.currentBaseRevision, 'cafebabe');
|
||||
});
|
||||
|
||||
test('complete requires all of --batch/--quick-id/--description/--date/--commit', () => {
|
||||
let message = null;
|
||||
routeQuickBatchCommand({
|
||||
args: ['quick-batch', 'complete', '--batch', 'b1', '--quick-id', '260101-abc'],
|
||||
cwd: '/tmp/proj',
|
||||
raw: true,
|
||||
error: (msg) => { message = msg; },
|
||||
_quickBatch: {},
|
||||
_quickBatchDispatch: {},
|
||||
});
|
||||
assert.match(message, /Usage: gsd-tools quick-batch complete/);
|
||||
});
|
||||
|
||||
test('effective-concurrency forwards jobs/task-count/capacity/isolation/mutating to the dispatch module', () => {
|
||||
const calls = [];
|
||||
routeQuickBatchCommand({
|
||||
args: ['quick-batch', 'effective-concurrency', '--jobs', '4', '--task-count', '8', '--capacity', '3', '--isolation', 'none', '--mutating'],
|
||||
cwd: '/tmp/proj',
|
||||
raw: true,
|
||||
error: (msg) => { throw new Error(`unexpected error: ${msg}`); },
|
||||
_quickBatch: {},
|
||||
_quickBatchDispatch: {
|
||||
computeEffectiveConcurrency: (input) => { calls.push(input); return 1; },
|
||||
},
|
||||
});
|
||||
assert.deepEqual(calls[0], { jobs: 4, taskCount: 8, capacity: 3, isolation: 'none', mutating: true });
|
||||
});
|
||||
|
||||
test('effective-concurrency accepts --jobs auto', () => {
|
||||
const calls = [];
|
||||
routeQuickBatchCommand({
|
||||
args: ['quick-batch', 'effective-concurrency', '--jobs', 'auto', '--task-count', '8', '--capacity', '3', '--isolation', 'harness-worktree'],
|
||||
cwd: '/tmp/proj',
|
||||
raw: true,
|
||||
error: (msg) => { throw new Error(`unexpected error: ${msg}`); },
|
||||
_quickBatch: {},
|
||||
_quickBatchDispatch: {
|
||||
computeEffectiveConcurrency: (input) => { calls.push(input); return 3; },
|
||||
},
|
||||
});
|
||||
assert.equal(calls[0].jobs, 'auto');
|
||||
assert.equal(calls[0].mutating, false, '--mutating omitted defaults to false');
|
||||
});
|
||||
|
||||
test('merge-eligible parses --wave-order/--ready JSON arrays', () => {
|
||||
const calls = [];
|
||||
routeQuickBatchCommand({
|
||||
args: ['quick-batch', 'merge-eligible', '--wave-order', '["a","b"]', '--ready', '["a"]'],
|
||||
cwd: '/tmp/proj',
|
||||
raw: true,
|
||||
error: (msg) => { throw new Error(`unexpected error: ${msg}`); },
|
||||
_quickBatch: {},
|
||||
_quickBatchDispatch: {
|
||||
computeMergeOrder: (waveOrder, readyIds) => { calls.push({ waveOrder, readyIds }); return ['a']; },
|
||||
},
|
||||
});
|
||||
assert.deepEqual(calls[0].waveOrder, ['a', 'b']);
|
||||
assert.deepEqual([...calls[0].readyIds], ['a']);
|
||||
});
|
||||
|
||||
test('spawn-plan forwards eligible/capacity/in-flight/refused', () => {
|
||||
const calls = [];
|
||||
routeQuickBatchCommand({
|
||||
args: ['quick-batch', 'spawn-plan', '--eligible', '["a","b","c"]', '--capacity', '2', '--in-flight', '0', '--refused', '["b"]'],
|
||||
cwd: '/tmp/proj',
|
||||
raw: true,
|
||||
error: (msg) => { throw new Error(`unexpected error: ${msg}`); },
|
||||
_quickBatch: {},
|
||||
_quickBatchDispatch: {
|
||||
computeSpawnPlan: (input) => { calls.push(input); return { spawn: [], pending: [] }; },
|
||||
},
|
||||
});
|
||||
assert.deepEqual(calls[0], { eligibleIds: ['a', 'b', 'c'], capacity: 2, currentInFlight: 0, refused: ['b'] });
|
||||
});
|
||||
|
||||
test('verification-routing rejects an invalid --status', () => {
|
||||
let message = null;
|
||||
routeQuickBatchCommand({
|
||||
args: ['quick-batch', 'verification-routing', '--status', 'bogus'],
|
||||
cwd: '/tmp/proj',
|
||||
raw: true,
|
||||
error: (msg) => { message = msg; },
|
||||
_quickBatch: {},
|
||||
_quickBatchDispatch: {},
|
||||
});
|
||||
assert.match(message, /--status/);
|
||||
});
|
||||
|
||||
test('verification-routing forwards a valid --status', () => {
|
||||
const calls = [];
|
||||
routeQuickBatchCommand({
|
||||
args: ['quick-batch', 'verification-routing', '--status', 'gaps_found'],
|
||||
cwd: '/tmp/proj',
|
||||
raw: true,
|
||||
error: (msg) => { throw new Error(`unexpected error: ${msg}`); },
|
||||
_quickBatch: {},
|
||||
_quickBatchDispatch: { routeVerificationOutcome: (status) => { calls.push(status); return { action: 'fail' }; } },
|
||||
});
|
||||
assert.deepEqual(calls, ['gaps_found']);
|
||||
});
|
||||
|
||||
test('merge-routing rejects an invalid --kind', () => {
|
||||
let message = null;
|
||||
routeQuickBatchCommand({
|
||||
args: ['quick-batch', 'merge-routing', '--kind', 'bogus'],
|
||||
cwd: '/tmp/proj',
|
||||
raw: true,
|
||||
error: (msg) => { message = msg; },
|
||||
_quickBatch: {},
|
||||
_quickBatchDispatch: {},
|
||||
});
|
||||
assert.match(message, /--kind/);
|
||||
});
|
||||
|
||||
test('merge-routing forwards --kind and optional --detail', () => {
|
||||
const calls = [];
|
||||
routeQuickBatchCommand({
|
||||
args: ['quick-batch', 'merge-routing', '--kind', 'merge_failed', '--detail', 'conflict'],
|
||||
cwd: '/tmp/proj',
|
||||
raw: true,
|
||||
error: (msg) => { throw new Error(`unexpected error: ${msg}`); },
|
||||
_quickBatch: {},
|
||||
_quickBatchDispatch: { routeMergeOutcome: (outcome) => { calls.push(outcome); return { action: 'fail' }; } },
|
||||
});
|
||||
assert.deepEqual(calls[0], { kind: 'merge_failed', detail: 'conflict' });
|
||||
});
|
||||
|
||||
test('cleanup-entry requires --worktree-path/--branch/--expected-base/--plan-content', () => {
|
||||
let message = null;
|
||||
routeQuickBatchCommand({
|
||||
args: ['quick-batch', 'cleanup-entry', '--branch', 'b'],
|
||||
cwd: '/tmp/proj',
|
||||
raw: true,
|
||||
error: (msg) => { message = msg; },
|
||||
_quickBatch: {},
|
||||
_quickBatchDispatch: {},
|
||||
});
|
||||
assert.match(message, /Usage: gsd-tools quick-batch cleanup-entry/);
|
||||
});
|
||||
|
||||
test('cleanup-entry forwards all fields, defaulting --agent-id to null when omitted', () => {
|
||||
const calls = [];
|
||||
routeQuickBatchCommand({
|
||||
args: ['quick-batch', 'cleanup-entry', '--worktree-path', '/tmp/wt', '--branch', 'b', '--expected-base', 'main', '--plan-content', 'text', '--allowed-bases', '["main"]'],
|
||||
cwd: '/tmp/proj',
|
||||
raw: true,
|
||||
error: (msg) => { throw new Error(`unexpected error: ${msg}`); },
|
||||
_quickBatch: {},
|
||||
_quickBatchDispatch: { buildCleanupManifestEntry: (input) => { calls.push(input); return {}; } },
|
||||
});
|
||||
assert.deepEqual(calls[0], {
|
||||
agentId: null,
|
||||
worktreePath: '/tmp/wt',
|
||||
branch: 'b',
|
||||
expectedBase: 'main',
|
||||
allowedBases: ['main'],
|
||||
planContent: 'text',
|
||||
});
|
||||
});
|
||||
|
||||
test('parse-args forwards everything after -- to parseQuickBatchArgs', () => {
|
||||
const calls = [];
|
||||
routeQuickBatchCommand({
|
||||
args: ['quick-batch', 'parse-args', '--', '--jobs', '4', '--validate'],
|
||||
cwd: '/tmp/proj',
|
||||
raw: true,
|
||||
error: (msg) => { throw new Error(`unexpected error: ${msg}`); },
|
||||
_quickBatch: {},
|
||||
_quickBatchDispatch: {
|
||||
parseQuickBatchArgs: (rawArgs) => { calls.push(rawArgs); return { ok: true, value: {} }; },
|
||||
},
|
||||
});
|
||||
assert.deepEqual(calls[0], ['--jobs', '4', '--validate']);
|
||||
});
|
||||
|
||||
// #3676 security fix: `--text` accepts the ENTIRE raw $ARGUMENTS string as
|
||||
// ONE argv element (the caller quotes it, e.g. `--text "$ARGUMENTS"`), so
|
||||
// shell word-splitting/pathname-expansion on attacker-influenced task text
|
||||
// never happens before this parser sees it. The split into tokens happens
|
||||
// HERE, in Node, which never glob-expands.
|
||||
test('parse-args --text splits the whole string into tokens itself (no shell involvement)', () => {
|
||||
const calls = [];
|
||||
routeQuickBatchCommand({
|
||||
args: ['quick-batch', 'parse-args', '--text', '--jobs 4 --validate'],
|
||||
cwd: '/tmp/proj',
|
||||
raw: true,
|
||||
error: (msg) => { throw new Error(`unexpected error: ${msg}`); },
|
||||
_quickBatch: {},
|
||||
_quickBatchDispatch: {
|
||||
parseQuickBatchArgs: (rawArgs) => { calls.push(rawArgs); return { ok: true, value: {} }; },
|
||||
},
|
||||
});
|
||||
assert.deepEqual(calls[0], ['--jobs', '4', '--validate']);
|
||||
});
|
||||
|
||||
test('parse-args --text with an embedded glob-shaped token passes it through literally, unexpanded', () => {
|
||||
const calls = [];
|
||||
routeQuickBatchCommand({
|
||||
args: ['quick-batch', 'parse-args', '--text', '- fix files matching *.txt\n- second task'],
|
||||
cwd: '/tmp/proj',
|
||||
raw: true,
|
||||
error: (msg) => { throw new Error(`unexpected error: ${msg}`); },
|
||||
_quickBatch: {},
|
||||
_quickBatchDispatch: {
|
||||
parseQuickBatchArgs: (rawArgs) => { calls.push(rawArgs); return { ok: true, value: {} }; },
|
||||
},
|
||||
});
|
||||
// The glob-shaped token survives as literal text tokens — never
|
||||
// expanded to matching filenames, because it never passed through a
|
||||
// shell glob context (the caller quoted it; this handler's own
|
||||
// whitespace split is not glob-aware).
|
||||
assert.ok(calls[0].includes('*.txt'));
|
||||
});
|
||||
|
||||
test('parse-args --text with only whitespace produces an empty token array', () => {
|
||||
const calls = [];
|
||||
routeQuickBatchCommand({
|
||||
args: ['quick-batch', 'parse-args', '--text', ' '],
|
||||
cwd: '/tmp/proj',
|
||||
raw: true,
|
||||
error: (msg) => { throw new Error(`unexpected error: ${msg}`); },
|
||||
_quickBatch: {},
|
||||
_quickBatchDispatch: {
|
||||
parseQuickBatchArgs: (rawArgs) => { calls.push(rawArgs); return { ok: true, value: {} }; },
|
||||
},
|
||||
});
|
||||
assert.deepEqual(calls[0], []);
|
||||
});
|
||||
|
||||
test('a domain Result failure (ok:false) is routed through error(), not treated as success', () => {
|
||||
let message = null;
|
||||
routeQuickBatchCommand({
|
||||
args: ['quick-batch', 'resume', '--batch', 'b1'],
|
||||
cwd: '/tmp/proj',
|
||||
raw: true,
|
||||
error: (msg) => { message = msg; },
|
||||
_quickBatch: { resumeBatch: () => ({ ok: false, reason: 'no BATCH.json found for batch b1' }) },
|
||||
_quickBatchDispatch: {},
|
||||
});
|
||||
assert.equal(message, 'no BATCH.json found for batch b1');
|
||||
});
|
||||
});
|
||||
|
||||
// ─── End-to-end: real router wiring via HOST_COMMAND_ROUTERS (rows 46-47) ──
|
||||
|
||||
describe('quick-batch-command-router: end-to-end via gsd-tools (rows 46-47)', () => {
|
||||
test('row 47: unknown subcommand errors via the Hub\'s manifest check, same shape as graphify\'s', () => {
|
||||
const dir = mkTmpProject();
|
||||
try {
|
||||
const result = runGsdTools(['quick-batch', 'nonsense'], dir);
|
||||
assert.equal(result.success, false);
|
||||
assert.match(result.error, /Unknown quick-batch subcommand\. Available:/);
|
||||
} finally {
|
||||
cleanup(dir);
|
||||
}
|
||||
});
|
||||
|
||||
test('row 46: create -> resume round-trips a real batch through the real router', () => {
|
||||
const dir = mkTmpProject();
|
||||
try {
|
||||
const tasksFile = path.join(dir, '.planning', 'tasks.md');
|
||||
fs.writeFileSync(tasksFile, '- first task\n- second task\n');
|
||||
|
||||
const created = runGsdTools(['quick-batch', 'create', '--file', tasksFile, '--raw'], dir);
|
||||
assert.equal(created.success, true, `create failed: ${created.error}`);
|
||||
const createdJson = JSON.parse(created.output);
|
||||
assert.ok(createdJson.batchId);
|
||||
|
||||
const resumed = runGsdTools(['quick-batch', 'resume', '--batch', createdJson.batchId, '--raw'], dir);
|
||||
assert.equal(resumed.success, true, `resume failed: ${resumed.error}`);
|
||||
const resumedJson = JSON.parse(resumed.output);
|
||||
assert.equal(resumedJson.eligible.length, 2, 'both items are eligible before any leaf runs');
|
||||
} finally {
|
||||
cleanup(dir);
|
||||
}
|
||||
});
|
||||
|
||||
test('effective-concurrency verb is reachable end-to-end and returns a number', () => {
|
||||
const dir = mkTmpProject();
|
||||
try {
|
||||
const result = runGsdTools(['quick-batch', 'effective-concurrency', '--jobs', 'auto', '--task-count', '5', '--capacity', '3', '--isolation', 'harness-worktree', '--raw'], dir);
|
||||
assert.equal(result.success, true, `command failed: ${result.error}`);
|
||||
assert.deepEqual(JSON.parse(result.output), { concurrency: 3 });
|
||||
} finally {
|
||||
cleanup(dir);
|
||||
}
|
||||
});
|
||||
|
||||
// Security/Spec review fix (#3676 review pass 3): row 9 previously asserted
|
||||
// rejection only at the pure parseQuickBatchArgs level, which has no I/O to
|
||||
// begin with — it never proves the WORKFLOW-LEVEL invariant "a rejected
|
||||
// --jobs value never reaches quick-batch create, so no partial BATCH.json
|
||||
// exists." Assert that end-to-end: reject via the real CLI parse-args verb,
|
||||
// then confirm .planning/quick-batches/ was never created at all.
|
||||
describe('row 9: a rejected --jobs value leaves no partial BATCH.json (hostile)', () => {
|
||||
for (const badJobs of ['0', '-1', 'abc']) {
|
||||
test(`--jobs ${badJobs} is rejected and .planning/quick-batches/ stays absent`, () => {
|
||||
const dir = mkTmpProject();
|
||||
try {
|
||||
const result = runGsdTools(['quick-batch', 'parse-args', '--raw', '--text', `--jobs ${badJobs}`], dir);
|
||||
assert.equal(result.success, false, `expected rejection for --jobs ${badJobs}`);
|
||||
assert.equal(
|
||||
fs.existsSync(path.join(dir, '.planning', 'quick-batches')),
|
||||
false,
|
||||
'parse-args must never create .planning/quick-batches/ — createBatch is never reached after a rejected --jobs value',
|
||||
);
|
||||
} finally {
|
||||
cleanup(dir);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Spec review fix: row 18 previously only exercised loadBatch against a
|
||||
// hand-corrupted BATCH.json — never a genuinely nonexistent batch
|
||||
// directory (the actual row-18 shape: "--resume <unknown-batch-id>").
|
||||
test('row 18: --resume <unknown-batch-id> fails closed with no batch directory ever created', () => {
|
||||
const dir = mkTmpProject();
|
||||
try {
|
||||
// No .planning/quick-batches/<id>/ directory exists at all for this id —
|
||||
// never created, never touched by any prior call in this test.
|
||||
const result = runGsdTools(['quick-batch', 'resume', '--batch', '999999-zzz', '--raw'], dir);
|
||||
assert.equal(result.success, false);
|
||||
assert.match(result.error, /no BATCH\.json found for batch 999999-zzz/);
|
||||
assert.equal(
|
||||
fs.existsSync(path.join(dir, '.planning', 'quick-batches', '999999-zzz')),
|
||||
false,
|
||||
'resume must never create a batch directory for an unknown id',
|
||||
);
|
||||
} finally {
|
||||
cleanup(dir);
|
||||
}
|
||||
});
|
||||
});
|
||||
169
tests/quick-batch-dispatch.property.test.cjs
Normal file
169
tests/quick-batch-dispatch.property.test.cjs
Normal file
@@ -0,0 +1,169 @@
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* quick-batch-dispatch.property.test.cjs — Property-based tests for the
|
||||
* quick-batch dispatch decision core (#3676, Phase 4 of epic #3344 /
|
||||
* ADR-1239 "Quick-batch binding").
|
||||
*
|
||||
* Test matrix rows 51-53 (`.gsd/phase/feat-3676-quick-batch-command-workflow/
|
||||
* 50-test-matrix.md`):
|
||||
* 51 — post-planning `updateBatchItems` wave recompute (src/quick-batch.cts)
|
||||
* terminates and every item lands in exactly one wave, for any valid
|
||||
* (acyclic, in-batch-only) generated depends_on/files_modified
|
||||
* assignment — same invariant class as Phase 3's row 32, now exercised
|
||||
* through the Phase-4 recompute path.
|
||||
* 52 — merge order for any wave, under any interleaving of leaf-completion
|
||||
* timing, always matches the deterministic input order computeWaves
|
||||
* assigned (src/quick-batch-dispatch.cts's computeMergeOrder).
|
||||
* 53 — for any sequence of refused-then-accepted spawns, total fan-out
|
||||
* never exceeds effective capacity at any point in time
|
||||
* (src/quick-batch-dispatch.cts's computeSpawnPlan).
|
||||
*/
|
||||
|
||||
const { describe, test } = require('node:test');
|
||||
const assert = require('node:assert/strict');
|
||||
const fs = require('fs');
|
||||
const os = require('os');
|
||||
const path = require('path');
|
||||
const fc = require('./helpers/fast-check-setup.cjs');
|
||||
|
||||
const { createBatch, updateBatchItems } = require('../gsd-core/bin/lib/quick-batch.cjs');
|
||||
const { computeMergeOrder, computeSpawnPlan } = require('../gsd-core/bin/lib/quick-batch-dispatch.cjs');
|
||||
const { cleanup } = require('./helpers.cjs');
|
||||
|
||||
function mkTmpProject() {
|
||||
const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'quick-batch-dispatch-prop-'));
|
||||
fs.mkdirSync(path.join(dir, '.planning'), { recursive: true });
|
||||
return dir;
|
||||
}
|
||||
|
||||
/** A small acyclic dependency graph: item i may depend on any j < i (DAG by construction). */
|
||||
const dagItemsArb = fc.integer({ min: 2, max: 7 }).chain((n) =>
|
||||
fc.tuple(
|
||||
...Array.from({ length: n }, (_, i) =>
|
||||
fc.record({
|
||||
dependsOnPrevious: fc.subarray(Array.from({ length: i }, (_, j) => j), { maxLength: i }),
|
||||
files: fc.array(fc.constantFrom('f0', 'f1', 'f2', 'f3'), { maxLength: 2 }),
|
||||
}),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
describe('quick-batch-dispatch: property — post-planning wave recompute totality (row 51)', () => {
|
||||
test('property: for any valid (acyclic, in-batch-only) post-planning assignment, updateBatchItems recompute terminates and every item lands in exactly one wave', () => {
|
||||
fc.assert(fc.property(
|
||||
dagItemsArb,
|
||||
(rawItems) => {
|
||||
const dir = mkTmpProject();
|
||||
try {
|
||||
const items = rawItems.map((_, i) => ({ description: `item-${i}`, clientId: `c${i}` }));
|
||||
const created = createBatch(dir, items);
|
||||
assert.equal(created.ok, true);
|
||||
const byClient = created.value.manifest.items; // same order as `items`
|
||||
|
||||
const updates = rawItems.map((it, i) => ({
|
||||
quickId: byClient[i].quick_id,
|
||||
dependsOn: it.dependsOnPrevious.map((j) => byClient[j].quick_id),
|
||||
plannedFiles: it.files,
|
||||
}));
|
||||
|
||||
const result = updateBatchItems(dir, created.value.batchId, updates);
|
||||
assert.equal(result.ok, true, result.ok ? '' : result.reason);
|
||||
|
||||
const manifestItems = result.value.manifest.items;
|
||||
// Termination + totality: every item has a defined, non-negative wave.
|
||||
for (const it of manifestItems) {
|
||||
assert.ok(Number.isInteger(it.wave) && it.wave >= 0, `item ${it.quick_id} has an invalid wave ${it.wave}`);
|
||||
}
|
||||
// Exactly one wave each: group by wave index and confirm the counts
|
||||
// sum to the total item count with no gaps between 0..maxWave.
|
||||
const maxWave = Math.max(...manifestItems.map((it) => it.wave));
|
||||
const counted = new Array(maxWave + 1).fill(0);
|
||||
for (const it of manifestItems) counted[it.wave] += 1;
|
||||
assert.ok(counted.every((c) => c > 0), 'no empty wave gaps');
|
||||
assert.equal(counted.reduce((a, b) => a + b, 0), manifestItems.length);
|
||||
|
||||
// DAG readiness: every dependency's wave strictly precedes its dependent's.
|
||||
const waveOf = new Map(manifestItems.map((it) => [it.quick_id, it.wave]));
|
||||
for (const it of manifestItems) {
|
||||
for (const dep of it.depends_on) {
|
||||
assert.ok(waveOf.get(dep) < waveOf.get(it.quick_id), `${dep} must strictly precede ${it.quick_id}`);
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
cleanup(dir);
|
||||
}
|
||||
},
|
||||
), { numRuns: 25 }); // filesystem-backed property — bounded below the global default
|
||||
});
|
||||
});
|
||||
|
||||
describe('quick-batch-dispatch: property — deterministic merge order under any completion interleaving (row 52)', () => {
|
||||
test('property: computeMergeOrder always returns the maximal READY prefix of waveOrder, never a completion-order result', () => {
|
||||
fc.assert(fc.property(
|
||||
fc.uniqueArray(fc.string({ minLength: 1, maxLength: 6 }).filter((s) => s.trim() === s && s.length > 0), { minLength: 1, maxLength: 10 }),
|
||||
fc.array(fc.boolean(), { minLength: 0, maxLength: 10 }),
|
||||
(waveOrder, readyFlags) => {
|
||||
// Build an arbitrary "ready" subset — readyFlags[i] says whether
|
||||
// waveOrder[i] finished its leaf, in NO particular arrival order
|
||||
// (that's the point: the function must not depend on arrival order,
|
||||
// only on the ORIGINAL waveOrder position).
|
||||
const readyIds = new Set(waveOrder.filter((_, i) => readyFlags[i] === true));
|
||||
|
||||
const result = computeMergeOrder(waveOrder, readyIds);
|
||||
|
||||
// Independently derive the expected maximal ready PREFIX.
|
||||
const expected = [];
|
||||
for (const id of waveOrder) {
|
||||
if (!readyIds.has(id)) break;
|
||||
expected.push(id);
|
||||
}
|
||||
assert.deepEqual(result, expected);
|
||||
// The result is always a genuine prefix of waveOrder (same relative order).
|
||||
assert.deepEqual(result, waveOrder.slice(0, result.length));
|
||||
},
|
||||
), { numRuns: 100 });
|
||||
});
|
||||
});
|
||||
|
||||
describe('quick-batch-dispatch: property — spawn backpressure never exceeds capacity (row 53)', () => {
|
||||
test('property: for any sequence of refused-then-accepted spawn rounds, in-flight + newly spawned never exceeds capacity', () => {
|
||||
fc.assert(fc.property(
|
||||
fc.integer({ min: 1, max: 8 }), // capacity
|
||||
fc.array(
|
||||
fc.record({
|
||||
eligibleCount: fc.integer({ min: 0, max: 10 }),
|
||||
refusedCount: fc.integer({ min: 0, max: 10 }),
|
||||
currentInFlight: fc.integer({ min: 0, max: 12 }),
|
||||
}),
|
||||
{ minLength: 1, maxLength: 15 },
|
||||
),
|
||||
(capacity, rounds) => {
|
||||
for (const round of rounds) {
|
||||
const eligibleIds = Array.from({ length: round.eligibleCount }, (_, i) => `e${i}`);
|
||||
const refusedIds = eligibleIds.slice(0, Math.min(round.refusedCount, eligibleIds.length));
|
||||
|
||||
const result = computeSpawnPlan({
|
||||
eligibleIds,
|
||||
capacity,
|
||||
currentInFlight: round.currentInFlight,
|
||||
refused: refusedIds,
|
||||
});
|
||||
|
||||
assert.ok(
|
||||
round.currentInFlight + result.spawn.length <= Math.max(capacity, round.currentInFlight),
|
||||
'spawning never increases fan-out beyond the capacity ceiling (once already over capacity, nothing new spawns)',
|
||||
);
|
||||
assert.ok(result.spawn.length <= Math.max(capacity - round.currentInFlight, 0), 'spawn count never exceeds remaining capacity');
|
||||
// Every refused id is in pending, never in spawn.
|
||||
for (const id of refusedIds) {
|
||||
assert.ok(!result.spawn.includes(id), `refused id ${id} must never be spawned`);
|
||||
assert.ok(result.pending.includes(id), `refused id ${id} must return to pending`);
|
||||
}
|
||||
// spawn and pending partition eligibleIds exactly (no id lost, none duplicated).
|
||||
assert.deepEqual([...result.spawn, ...result.pending].sort(), eligibleIds.slice().sort());
|
||||
}
|
||||
},
|
||||
), { numRuns: 100 });
|
||||
});
|
||||
});
|
||||
367
tests/quick-batch-dispatch.test.cjs
Normal file
367
tests/quick-batch-dispatch.test.cjs
Normal file
@@ -0,0 +1,367 @@
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* quick-batch-dispatch.test.cjs — Behavioral tests for the quick-batch
|
||||
* dispatch decision core (#3676, Phase 4 of epic #3344 / ADR-1239
|
||||
* "Quick-batch binding").
|
||||
*
|
||||
* Module: gsd-core/bin/lib/quick-batch-dispatch.cjs
|
||||
* (compiled from src/quick-batch-dispatch.cts)
|
||||
*
|
||||
* Design doc: `.gsd/phase/feat-3676-quick-batch-command-workflow/40-design.md`
|
||||
* Test matrix: `.gsd/phase/feat-3676-quick-batch-command-workflow/50-test-matrix.md`
|
||||
* This file covers matrix rows: 5,7,8,9,10,13,14,15 (args), 3,4,6,7,8,9,10,12
|
||||
* (effective concurrency), 24,32,33 (merge order), 27,39 (spawn backpressure),
|
||||
* 30,31 (verification routing), 28,34,35,36 (merge routing), 26 (cleanup entry).
|
||||
* Property rows 51-53 live in quick-batch-dispatch.property.test.cjs.
|
||||
*
|
||||
* This module is PURE — no filesystem or lock I/O — so every test here runs
|
||||
* without a temp project directory.
|
||||
*/
|
||||
|
||||
const { describe, test } = require('node:test');
|
||||
const assert = require('node:assert/strict');
|
||||
|
||||
const {
|
||||
parseQuickBatchArgs,
|
||||
computeEffectiveConcurrency,
|
||||
computeMergeOrder,
|
||||
computeSpawnPlan,
|
||||
routeVerificationOutcome,
|
||||
routeMergeOutcome,
|
||||
buildCleanupManifestEntry,
|
||||
} = require('../gsd-core/bin/lib/quick-batch-dispatch.cjs');
|
||||
|
||||
// ─── parseQuickBatchArgs (rows 5,7-10,13-15) ────────────────────────────────
|
||||
|
||||
describe('quick-batch-dispatch: parseQuickBatchArgs', () => {
|
||||
test('row 10: --jobs omitted defaults to auto', () => {
|
||||
const result = parseQuickBatchArgs([]);
|
||||
assert.equal(result.ok, true);
|
||||
assert.deepEqual(result.value, { jobs: 'auto', validate: false, research: false, resume: null });
|
||||
});
|
||||
|
||||
test('--jobs auto parses explicitly', () => {
|
||||
const result = parseQuickBatchArgs(['--jobs', 'auto']);
|
||||
assert.equal(result.ok, true);
|
||||
assert.equal(result.value.jobs, 'auto');
|
||||
});
|
||||
|
||||
test('--jobs N (positive integer) parses to a number', () => {
|
||||
const result = parseQuickBatchArgs(['--jobs', '4']);
|
||||
assert.equal(result.ok, true);
|
||||
assert.equal(result.value.jobs, 4);
|
||||
});
|
||||
|
||||
test('boundary: --jobs 1 (limit) is accepted', () => {
|
||||
const result = parseQuickBatchArgs(['--jobs', '1']);
|
||||
assert.equal(result.ok, true);
|
||||
assert.equal(result.value.jobs, 1);
|
||||
});
|
||||
|
||||
test('row 9 (hostile): --jobs 0 rejected before dispatch', () => {
|
||||
const result = parseQuickBatchArgs(['--jobs', '0']);
|
||||
assert.equal(result.ok, false);
|
||||
});
|
||||
|
||||
test('row 9 (hostile): --jobs -1 rejected before dispatch', () => {
|
||||
const result = parseQuickBatchArgs(['--jobs', '-1']);
|
||||
assert.equal(result.ok, false);
|
||||
});
|
||||
|
||||
test('row 9 (hostile): --jobs abc (non-numeric) rejected before dispatch', () => {
|
||||
const result = parseQuickBatchArgs(['--jobs', 'abc']);
|
||||
assert.equal(result.ok, false);
|
||||
});
|
||||
|
||||
test('--jobs with a missing value is rejected', () => {
|
||||
const result = parseQuickBatchArgs(['--jobs']);
|
||||
assert.equal(result.ok, false);
|
||||
});
|
||||
|
||||
test('--validate and --research set their respective flags', () => {
|
||||
const result = parseQuickBatchArgs(['--validate', '--research']);
|
||||
assert.equal(result.ok, true);
|
||||
assert.equal(result.value.validate, true);
|
||||
assert.equal(result.value.research, true);
|
||||
});
|
||||
|
||||
test('row 16: --resume <batch-id> is parsed', () => {
|
||||
const result = parseQuickBatchArgs(['--resume', '260101-abc']);
|
||||
assert.equal(result.ok, true);
|
||||
assert.equal(result.value.resume, '260101-abc');
|
||||
});
|
||||
|
||||
test('--resume with a missing value is rejected', () => {
|
||||
const result = parseQuickBatchArgs(['--resume']);
|
||||
assert.equal(result.ok, false);
|
||||
});
|
||||
|
||||
test('row 7: --discuss is rejected before any dispatch', () => {
|
||||
const result = parseQuickBatchArgs(['--discuss']);
|
||||
assert.equal(result.ok, false);
|
||||
});
|
||||
|
||||
test('row 8: --full is rejected before any dispatch', () => {
|
||||
const result = parseQuickBatchArgs(['--full']);
|
||||
assert.equal(result.ok, false);
|
||||
});
|
||||
|
||||
test('row 15 (hostile): --discuss --validate is still rejected — presence alone is sufficient', () => {
|
||||
const result = parseQuickBatchArgs(['--discuss', '--validate']);
|
||||
assert.equal(result.ok, false);
|
||||
});
|
||||
|
||||
test('row 15 (hostile): --full mixed with otherwise-valid flags is still rejected', () => {
|
||||
const result = parseQuickBatchArgs(['--jobs', '4', '--full', '--research']);
|
||||
assert.equal(result.ok, false);
|
||||
});
|
||||
});
|
||||
|
||||
// ─── computeEffectiveConcurrency (rows 3,4,6,7,8,9,10,12) ───────────────────
|
||||
|
||||
describe('quick-batch-dispatch: computeEffectiveConcurrency', () => {
|
||||
test('row 3: --jobs auto uses capacity alone', () => {
|
||||
const n = computeEffectiveConcurrency({ jobs: 'auto', taskCount: 25, capacity: 4, isolation: 'harness-worktree', mutating: true });
|
||||
assert.equal(n, 4);
|
||||
});
|
||||
|
||||
test('row 7: --jobs 10 with 3 tasks and capacity 4 -> min(3,10,4) = 3', () => {
|
||||
const n = computeEffectiveConcurrency({ jobs: 10, taskCount: 3, capacity: 4, isolation: 'harness-worktree', mutating: true });
|
||||
assert.equal(n, 3);
|
||||
});
|
||||
|
||||
test('row 8: --jobs 2 with 8 tasks and capacity 4 -> min(8,2,4) = 2', () => {
|
||||
const n = computeEffectiveConcurrency({ jobs: 2, taskCount: 8, capacity: 4, isolation: 'harness-worktree', mutating: true });
|
||||
assert.equal(n, 2);
|
||||
});
|
||||
|
||||
test('boundary: --jobs equal to capacity and task count (limit) never exceeds either', () => {
|
||||
const n = computeEffectiveConcurrency({ jobs: 4, taskCount: 4, capacity: 4, isolation: 'harness-worktree', mutating: true });
|
||||
assert.equal(n, 4);
|
||||
});
|
||||
|
||||
test('boundary: --jobs one more than task count (limit+1) still bounded by task count', () => {
|
||||
const n = computeEffectiveConcurrency({ jobs: 5, taskCount: 4, capacity: 10, isolation: 'harness-worktree', mutating: true });
|
||||
assert.equal(n, 4);
|
||||
});
|
||||
|
||||
test('boundary: --jobs one less than task count (limit-1) is honored', () => {
|
||||
const n = computeEffectiveConcurrency({ jobs: 3, taskCount: 4, capacity: 10, isolation: 'harness-worktree', mutating: true });
|
||||
assert.equal(n, 3);
|
||||
});
|
||||
|
||||
test('row 6: isolation none forces a MUTATING wave to concurrency 1 regardless of --jobs/capacity', () => {
|
||||
const n = computeEffectiveConcurrency({ jobs: 4, taskCount: 4, capacity: 4, isolation: 'none', mutating: true });
|
||||
assert.equal(n, 1);
|
||||
});
|
||||
|
||||
test('row 6: isolation none forces --jobs auto down to 1 for a mutating wave too', () => {
|
||||
const n = computeEffectiveConcurrency({ jobs: 'auto', taskCount: 4, capacity: 4, isolation: 'none', mutating: true });
|
||||
assert.equal(n, 1);
|
||||
});
|
||||
|
||||
test('row 12: isolation none does NOT cap a non-mutating (research-only) wave', () => {
|
||||
const n = computeEffectiveConcurrency({ jobs: 4, taskCount: 4, capacity: 4, isolation: 'none', mutating: false });
|
||||
assert.equal(n, 4, 'research-only stage is not subject to the isolation=none cap');
|
||||
});
|
||||
|
||||
test('a non-none isolation never triggers the cap regardless of mutating', () => {
|
||||
const n = computeEffectiveConcurrency({ jobs: 4, taskCount: 4, capacity: 4, isolation: 'harness-worktree', mutating: true });
|
||||
assert.equal(n, 4);
|
||||
});
|
||||
});
|
||||
|
||||
// ─── computeMergeOrder (row 24; matrix rows 32-33) ──────────────────────────
|
||||
|
||||
describe('quick-batch-dispatch: computeMergeOrder — deterministic wave order, never completion order', () => {
|
||||
test('row 32: all items ready simultaneously merge in the original wave order', () => {
|
||||
const order = computeMergeOrder(['x', 'y', 'z'], new Set(['x', 'y', 'z']));
|
||||
assert.deepEqual(order, ['x', 'y', 'z']);
|
||||
});
|
||||
|
||||
test('row 33: item 2 finishing before item 1 does not reorder the merge — item 2 waits', () => {
|
||||
// Only 'y' (wave position 2) is ready; 'x' (position 1) is not yet.
|
||||
const order = computeMergeOrder(['x', 'y', 'z'], new Set(['y']));
|
||||
assert.deepEqual(order, [], 'y must wait for x, which precedes it in wave order');
|
||||
});
|
||||
|
||||
test('partial readiness returns only the contiguous ready PREFIX', () => {
|
||||
const order = computeMergeOrder(['x', 'y', 'z'], new Set(['x', 'y']));
|
||||
assert.deepEqual(order, ['x', 'y'], 'z is not ready yet, so it is excluded even though x and y are');
|
||||
});
|
||||
|
||||
test('empty wave order returns empty', () => {
|
||||
assert.deepEqual(computeMergeOrder([], new Set(['x'])), []);
|
||||
});
|
||||
|
||||
test('nothing ready returns empty', () => {
|
||||
assert.deepEqual(computeMergeOrder(['x', 'y'], new Set()), []);
|
||||
});
|
||||
});
|
||||
|
||||
// ─── computeSpawnPlan (row 27; matrix row 39) ───────────────────────────────
|
||||
|
||||
describe('quick-batch-dispatch: computeSpawnPlan — backpressure never increases fan-out', () => {
|
||||
test('row 39: spawns up to remaining capacity, backpressures the rest to pending', () => {
|
||||
const result = computeSpawnPlan({ eligibleIds: ['a', 'b', 'c'], capacity: 2, currentInFlight: 0 });
|
||||
assert.deepEqual(result.spawn, ['a', 'b']);
|
||||
assert.deepEqual(result.pending, ['c']);
|
||||
});
|
||||
|
||||
test('boundary: eligible count exactly at capacity (limit) spawns everything', () => {
|
||||
const result = computeSpawnPlan({ eligibleIds: ['a', 'b'], capacity: 2, currentInFlight: 0 });
|
||||
assert.deepEqual(result.spawn, ['a', 'b']);
|
||||
assert.deepEqual(result.pending, []);
|
||||
});
|
||||
|
||||
test('boundary: eligible count one over capacity (limit+1) backpressures exactly one', () => {
|
||||
const result = computeSpawnPlan({ eligibleIds: ['a', 'b', 'c'], capacity: 2, currentInFlight: 0 });
|
||||
assert.equal(result.spawn.length, 2);
|
||||
assert.equal(result.pending.length, 1);
|
||||
});
|
||||
|
||||
test('boundary: eligible count one under capacity (limit-1) spawns everything, no backpressure', () => {
|
||||
const result = computeSpawnPlan({ eligibleIds: ['a'], capacity: 2, currentInFlight: 0 });
|
||||
assert.deepEqual(result.spawn, ['a']);
|
||||
assert.deepEqual(result.pending, []);
|
||||
});
|
||||
|
||||
test('row 27: a refused id returns to pending — never counted against capacity, never spawned', () => {
|
||||
const result = computeSpawnPlan({ eligibleIds: ['a', 'b', 'c'], capacity: 3, currentInFlight: 0, refused: ['b'] });
|
||||
assert.deepEqual(result.spawn, ['a', 'c']);
|
||||
assert.deepEqual(result.pending, ['b']);
|
||||
});
|
||||
|
||||
test('currentInFlight reduces available capacity for new spawns', () => {
|
||||
const result = computeSpawnPlan({ eligibleIds: ['a', 'b'], capacity: 2, currentInFlight: 1 });
|
||||
assert.deepEqual(result.spawn, ['a']);
|
||||
assert.deepEqual(result.pending, ['b']);
|
||||
});
|
||||
|
||||
test('currentInFlight already at or over capacity spawns nothing (never negative fan-out)', () => {
|
||||
const result = computeSpawnPlan({ eligibleIds: ['a', 'b'], capacity: 2, currentInFlight: 5 });
|
||||
assert.deepEqual(result.spawn, []);
|
||||
assert.deepEqual(result.pending, ['a', 'b']);
|
||||
});
|
||||
|
||||
test('accepts a Set for refused, same as an array', () => {
|
||||
const result = computeSpawnPlan({ eligibleIds: ['a', 'b'], capacity: 2, currentInFlight: 0, refused: new Set(['a']) });
|
||||
assert.deepEqual(result.spawn, ['b']);
|
||||
assert.deepEqual(result.pending, ['a']);
|
||||
});
|
||||
});
|
||||
|
||||
// ─── routeVerificationOutcome (rows 30,31) ──────────────────────────────────
|
||||
|
||||
describe('quick-batch-dispatch: routeVerificationOutcome', () => {
|
||||
test('passed routes to complete', () => {
|
||||
assert.deepEqual(routeVerificationOutcome('passed'), { action: 'complete' });
|
||||
});
|
||||
|
||||
test('row 30: human_needed routes to a terminal human_needed action — never complete', () => {
|
||||
const routing = routeVerificationOutcome('human_needed');
|
||||
assert.deepEqual(routing, { action: 'human_needed' });
|
||||
assert.notEqual(routing.action, 'complete');
|
||||
});
|
||||
|
||||
test('row 31: gaps_found routes to fail, with a failure reason — no rollback signal, no retry signal', () => {
|
||||
const routing = routeVerificationOutcome('gaps_found');
|
||||
assert.equal(routing.action, 'fail');
|
||||
assert.match(routing.failureReason, /gaps_found/);
|
||||
});
|
||||
});
|
||||
|
||||
// ─── routeMergeOutcome (rows 28,34-35,36) ───────────────────────────────────
|
||||
|
||||
describe('quick-batch-dispatch: routeMergeOutcome', () => {
|
||||
test('row 36: merged routes to complete', () => {
|
||||
assert.deepEqual(routeMergeOutcome({ kind: 'merged' }), { action: 'complete' });
|
||||
});
|
||||
|
||||
test('row 34: merge_failed routes to fail and preserves the worktree', () => {
|
||||
const routing = routeMergeOutcome({ kind: 'merge_failed', detail: 'conflict in src/x.ts' });
|
||||
assert.equal(routing.action, 'fail');
|
||||
assert.equal(routing.preserveWorktree, true);
|
||||
assert.match(routing.failureReason, /merge_failed/);
|
||||
});
|
||||
|
||||
test('row 28/35: scope_violation (undeclared deletion) routes to fail and preserves the worktree', () => {
|
||||
const routing = routeMergeOutcome({ kind: 'scope_violation', detail: 'undeclared deletion: src/y.ts' });
|
||||
assert.equal(routing.action, 'fail');
|
||||
assert.equal(routing.preserveWorktree, true);
|
||||
assert.match(routing.failureReason, /scope_violation/);
|
||||
});
|
||||
|
||||
test('detail is optional — a bare kind still routes correctly', () => {
|
||||
const routing = routeMergeOutcome({ kind: 'merge_failed' });
|
||||
assert.equal(routing.action, 'fail');
|
||||
assert.equal(routing.failureReason, 'merge_failed');
|
||||
});
|
||||
});
|
||||
|
||||
// ─── buildCleanupManifestEntry (row 26, Open Question 2) ────────────────────
|
||||
|
||||
describe('quick-batch-dispatch: buildCleanupManifestEntry — sourced FRESH from the plan, never BATCH.json', () => {
|
||||
test('row 26: derives files_modified/declared_deletions from the plan frontmatter', () => {
|
||||
const planContent = [
|
||||
'---',
|
||||
'files_modified:',
|
||||
' - src/a.ts',
|
||||
' - src/b.ts',
|
||||
'files_deleted:',
|
||||
' - src/old.ts',
|
||||
'---',
|
||||
'',
|
||||
'<objective>Do the thing</objective>',
|
||||
].join('\n');
|
||||
|
||||
const entry = buildCleanupManifestEntry({
|
||||
agentId: 'agent-1',
|
||||
worktreePath: '/tmp/wt-1',
|
||||
branch: 'gsd/quick-batch/260101-abc',
|
||||
expectedBase: 'main',
|
||||
planContent,
|
||||
});
|
||||
|
||||
assert.equal(entry.agent_id, 'agent-1');
|
||||
assert.equal(entry.worktree_path, '/tmp/wt-1');
|
||||
assert.equal(entry.branch, 'gsd/quick-batch/260101-abc');
|
||||
assert.equal(entry.expected_base, 'main');
|
||||
assert.deepEqual(entry.files_modified, ['src/a.ts', 'src/b.ts']);
|
||||
assert.deepEqual(entry.declared_deletions, ['src/old.ts']);
|
||||
});
|
||||
|
||||
test('a plan declaring no files_modified/files_deleted produces empty arrays (never undefined, never guessed)', () => {
|
||||
const entry = buildCleanupManifestEntry({
|
||||
agentId: null,
|
||||
worktreePath: '/tmp/wt-2',
|
||||
branch: 'gsd/quick-batch/260101-def',
|
||||
expectedBase: 'main',
|
||||
planContent: '<objective>Do another thing</objective>',
|
||||
});
|
||||
assert.deepEqual(entry.files_modified, []);
|
||||
assert.deepEqual(entry.declared_deletions, []);
|
||||
});
|
||||
|
||||
test('allowedBases is passed through only when supplied', () => {
|
||||
const withBases = buildCleanupManifestEntry({
|
||||
agentId: null,
|
||||
worktreePath: '/tmp/wt-3',
|
||||
branch: 'gsd/quick-batch/260101-ghi',
|
||||
expectedBase: 'main',
|
||||
allowedBases: ['main', 'next'],
|
||||
planContent: '',
|
||||
});
|
||||
assert.deepEqual(withBases.allowed_bases, ['main', 'next']);
|
||||
|
||||
const withoutBases = buildCleanupManifestEntry({
|
||||
agentId: null,
|
||||
worktreePath: '/tmp/wt-4',
|
||||
branch: 'gsd/quick-batch/260101-jkl',
|
||||
expectedBase: 'main',
|
||||
planContent: '',
|
||||
});
|
||||
assert.equal('allowed_bases' in withoutBases, false);
|
||||
});
|
||||
});
|
||||
@@ -34,6 +34,7 @@ const {
|
||||
computeWaves,
|
||||
resumeBatch,
|
||||
completeQuickItem,
|
||||
updateBatchItems,
|
||||
} = require('../gsd-core/bin/lib/quick-batch.cjs');
|
||||
const { makeFakeClock } = require('./helpers/clock.cjs');
|
||||
const { cleanup } = require('./helpers.cjs');
|
||||
@@ -242,3 +243,60 @@ describe('quick-batch: property — wave order respects the DAG (row 33)', () =>
|
||||
));
|
||||
});
|
||||
});
|
||||
|
||||
// #3676 review pass 3 (Spec finding, test matrix row 24): a post-planning
|
||||
// updateBatchItems write racing a concurrent completeQuickItem write for a
|
||||
// DIFFERENT already-dispatched item — both go through withPlanningLock, so
|
||||
// no update should ever be lost regardless of call order. Mirrors row 15's
|
||||
// own technique above: real lock serialization exercised via SEQUENTIAL
|
||||
// calls (a working mutex makes any interleaving equivalent to SOME serial
|
||||
// order — proving no ordering loses an update is the same claim a literal
|
||||
// concurrent-thread test would make, without OS-level threading).
|
||||
describe('quick-batch: property — updateBatchItems does not lose a concurrent completeQuickItem update, or vice versa (row 24)', () => {
|
||||
test('property: for any call order, both a post-planning update AND a different item\'s completion survive in the final manifest', () => {
|
||||
fc.assert(fc.property(
|
||||
fc.boolean(), // true: updateBatchItems first; false: completeQuickItem first
|
||||
fc.array(fc.constantFrom('f0', 'f1', 'f2'), { maxLength: 2 }),
|
||||
(updateFirst, plannedFiles) => {
|
||||
const dir = mkTmpProject();
|
||||
fs.writeFileSync(path.join(dir, '.planning', 'STATE.md'), stateWithQuickTasksSection());
|
||||
try {
|
||||
const created = createBatch(dir, [
|
||||
{ description: 'item A (gets the post-planning update)', clientId: 'a' },
|
||||
{ description: 'item B (gets completed concurrently)', clientId: 'b' },
|
||||
]);
|
||||
assert.equal(created.ok, true);
|
||||
const [itemA, itemB] = created.value.manifest.items;
|
||||
|
||||
const doUpdate = () => updateBatchItems(dir, created.value.batchId, [
|
||||
{ quickId: itemA.quick_id, plannedFiles },
|
||||
]);
|
||||
const doComplete = () => completeQuickItem(dir, created.value.batchId, itemB.quick_id, {
|
||||
description: itemB.description,
|
||||
date: '2026-01-01',
|
||||
commit: 'deadbeef',
|
||||
});
|
||||
|
||||
const [first, second] = updateFirst ? [doUpdate, doComplete] : [doComplete, doUpdate];
|
||||
const firstResult = first();
|
||||
assert.equal(firstResult.ok, true, firstResult.ok ? '' : firstResult.reason);
|
||||
const secondResult = second();
|
||||
assert.equal(secondResult.ok, true, secondResult.ok ? '' : secondResult.reason);
|
||||
|
||||
// No lost update, regardless of order: the FINAL on-disk manifest
|
||||
// (re-read fresh, not either call's own stale in-memory copy)
|
||||
// reflects BOTH mutations — valid JSON, both writers' changes present.
|
||||
const raw = fs.readFileSync(path.join(dir, '.planning', 'quick-batches', created.value.batchId, 'BATCH.json'), 'utf-8');
|
||||
const finalManifest = JSON.parse(raw); // throws (property fails) on invalid JSON
|
||||
const finalA = finalManifest.items.find((it) => it.quick_id === itemA.quick_id);
|
||||
const finalB = finalManifest.items.find((it) => it.quick_id === itemB.quick_id);
|
||||
assert.deepEqual(finalA.planned_files, plannedFiles, 'item A\'s post-planning update was not lost');
|
||||
assert.equal(finalB.status, 'complete', 'item B\'s completion was not lost');
|
||||
assert.equal(finalB.commit, 'deadbeef');
|
||||
} finally {
|
||||
cleanupDir(dir);
|
||||
}
|
||||
},
|
||||
), { numRuns: 20 }); // filesystem-backed property — bounded below the global default
|
||||
});
|
||||
});
|
||||
|
||||
@@ -35,6 +35,7 @@ const {
|
||||
resumeBatch,
|
||||
completeQuickItem,
|
||||
hasQuickTaskRow,
|
||||
updateBatchItems,
|
||||
} = require('../gsd-core/bin/lib/quick-batch.cjs');
|
||||
|
||||
const { auditOpenArtifacts } = require('../gsd-core/bin/lib/audit.cjs');
|
||||
@@ -960,3 +961,264 @@ describe('quick-batch: hasQuickTaskRow idempotency primitive', () => {
|
||||
assert.equal(hasQuickTaskRow(appended.value.content, '260101-xyz'), false);
|
||||
});
|
||||
});
|
||||
|
||||
// ─── updateBatchItems (#3676, Phase 4): post-planning depends_on/planned_files ──
|
||||
//
|
||||
// Resolves the design doc's Open Question 1 as ONE new, purely-additive
|
||||
// exported function on THIS SAME module (never a second, independent writer
|
||||
// against `BATCH.json`). Folded in here (rather than a standalone file)
|
||||
// because `scripts/lint-test-file-count.cjs` buckets any
|
||||
// `quick-batch-*.test.cjs` file under the `quick-batch` production module,
|
||||
// and that module is already at its 2-file cap
|
||||
// (quick-batch.test.cjs + quick-batch.property.test.cjs) — every existing
|
||||
// test above this point is untouched, only new coverage is appended.
|
||||
// Design doc: `.gsd/phase/feat-3676-quick-batch-command-workflow/40-design.md`
|
||||
// (row 15, rows 22-23). Test matrix rows 22-24.
|
||||
|
||||
describe('quick-batch: updateBatchItems — basic mutation + persistence', () => {
|
||||
test('updates depends_on and planned_files for a named item and persists them', () => {
|
||||
const dir = mkTmpProject();
|
||||
try {
|
||||
const created = createBatch(dir, [
|
||||
{ description: 'item A', clientId: 'a' },
|
||||
{ description: 'item B', clientId: 'b' },
|
||||
]);
|
||||
assert.equal(created.ok, true);
|
||||
const [itemA, itemB] = created.value.manifest.items;
|
||||
|
||||
const result = updateBatchItems(dir, created.value.batchId, [
|
||||
{ quickId: itemB.quick_id, dependsOn: [itemA.quick_id], plannedFiles: ['src/b.ts'] },
|
||||
]);
|
||||
assert.equal(result.ok, true, result.ok ? '' : result.reason);
|
||||
|
||||
const updatedB = result.value.manifest.items.find((it) => it.quick_id === itemB.quick_id);
|
||||
assert.deepEqual(updatedB.depends_on, [itemA.quick_id]);
|
||||
assert.deepEqual(updatedB.planned_files, ['src/b.ts']);
|
||||
|
||||
// Durably persisted — a fresh loadBatch sees the same values.
|
||||
const reloaded = loadBatch(dir, created.value.batchId);
|
||||
assert.equal(reloaded.ok, true);
|
||||
const reloadedB = reloaded.value.items.find((it) => it.quick_id === itemB.quick_id);
|
||||
assert.deepEqual(reloadedB.depends_on, [itemA.quick_id]);
|
||||
assert.deepEqual(reloadedB.planned_files, ['src/b.ts']);
|
||||
} finally {
|
||||
cleanupDir(dir);
|
||||
}
|
||||
});
|
||||
|
||||
test('normalizes plannedFiles with posixNormalize, same as createBatch', () => {
|
||||
const dir = mkTmpProject();
|
||||
try {
|
||||
const created = createBatch(dir, [{ description: 'a' }, { description: 'b' }]);
|
||||
assert.equal(created.ok, true);
|
||||
const [itemA] = created.value.manifest.items;
|
||||
|
||||
const result = updateBatchItems(dir, created.value.batchId, [
|
||||
{ quickId: itemA.quick_id, plannedFiles: ['src\\windows\\path.ts'] },
|
||||
]);
|
||||
assert.equal(result.ok, true);
|
||||
const updated = result.value.manifest.items.find((it) => it.quick_id === itemA.quick_id);
|
||||
assert.deepEqual(updated.planned_files, ['src/windows/path.ts']);
|
||||
} finally {
|
||||
cleanupDir(dir);
|
||||
}
|
||||
});
|
||||
|
||||
test('omitting a field on an update leaves that item field untouched', () => {
|
||||
const dir = mkTmpProject();
|
||||
try {
|
||||
const created = createBatch(dir, [
|
||||
{ description: 'a', clientId: 'a', plannedFiles: ['src/a.ts'] },
|
||||
{ description: 'b', clientId: 'b' },
|
||||
]);
|
||||
assert.equal(created.ok, true);
|
||||
const [itemA] = created.value.manifest.items;
|
||||
|
||||
// Only dependsOn supplied — plannedFiles must survive unchanged.
|
||||
const result = updateBatchItems(dir, created.value.batchId, [
|
||||
{ quickId: itemA.quick_id, dependsOn: [] },
|
||||
]);
|
||||
assert.equal(result.ok, true);
|
||||
const updated = result.value.manifest.items.find((it) => it.quick_id === itemA.quick_id);
|
||||
assert.deepEqual(updated.planned_files, ['src/a.ts'], 'planned_files untouched when omitted from the update');
|
||||
} finally {
|
||||
cleanupDir(dir);
|
||||
}
|
||||
});
|
||||
|
||||
test('updates for multiple items in one call apply atomically', () => {
|
||||
const dir = mkTmpProject();
|
||||
try {
|
||||
const created = createBatch(dir, [
|
||||
{ description: 'a', clientId: 'a' },
|
||||
{ description: 'b', clientId: 'b' },
|
||||
{ description: 'c', clientId: 'c' },
|
||||
]);
|
||||
assert.equal(created.ok, true);
|
||||
const [itemA, itemB, itemC] = created.value.manifest.items;
|
||||
|
||||
const result = updateBatchItems(dir, created.value.batchId, [
|
||||
{ quickId: itemB.quick_id, dependsOn: [itemA.quick_id] },
|
||||
{ quickId: itemC.quick_id, dependsOn: [itemB.quick_id] },
|
||||
]);
|
||||
assert.equal(result.ok, true);
|
||||
const byId = new Map(result.value.manifest.items.map((it) => [it.quick_id, it]));
|
||||
assert.deepEqual(byId.get(itemB.quick_id).depends_on, [itemA.quick_id]);
|
||||
assert.deepEqual(byId.get(itemC.quick_id).depends_on, [itemB.quick_id]);
|
||||
} finally {
|
||||
cleanupDir(dir);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe('quick-batch: updateBatchItems — fails closed, never persists on a bad update', () => {
|
||||
test('rejects an unknown quickId without persisting anything', () => {
|
||||
const dir = mkTmpProject();
|
||||
try {
|
||||
const created = createBatch(dir, [{ description: 'a' }, { description: 'b' }]);
|
||||
assert.equal(created.ok, true);
|
||||
|
||||
const result = updateBatchItems(dir, created.value.batchId, [
|
||||
{ quickId: '999999-zzz', dependsOn: [] },
|
||||
]);
|
||||
assert.equal(result.ok, false);
|
||||
assert.match(result.reason, /no item 999999-zzz/);
|
||||
|
||||
const reloaded = loadBatch(dir, created.value.batchId);
|
||||
assert.equal(reloaded.ok, true);
|
||||
assert.deepEqual(reloaded.value.items, created.value.manifest.items, 'manifest is byte-unchanged after a rejected update');
|
||||
} finally {
|
||||
cleanupDir(dir);
|
||||
}
|
||||
});
|
||||
|
||||
test('rejects an unknown dependency reference without persisting', () => {
|
||||
const dir = mkTmpProject();
|
||||
try {
|
||||
const created = createBatch(dir, [{ description: 'a' }, { description: 'b' }]);
|
||||
assert.equal(created.ok, true);
|
||||
const [itemA] = created.value.manifest.items;
|
||||
|
||||
const result = updateBatchItems(dir, created.value.batchId, [
|
||||
{ quickId: itemA.quick_id, dependsOn: ['999999-zzz'] },
|
||||
]);
|
||||
assert.equal(result.ok, false);
|
||||
assert.match(result.reason, /unknown dependency reference/);
|
||||
|
||||
const reloaded = loadBatch(dir, created.value.batchId);
|
||||
assert.equal(reloaded.ok, true);
|
||||
assert.deepEqual(reloaded.value.items.find((it) => it.quick_id === itemA.quick_id).depends_on, []);
|
||||
} finally {
|
||||
cleanupDir(dir);
|
||||
}
|
||||
});
|
||||
|
||||
test('rejects a self-dependency without persisting', () => {
|
||||
const dir = mkTmpProject();
|
||||
try {
|
||||
const created = createBatch(dir, [{ description: 'a' }, { description: 'b' }]);
|
||||
assert.equal(created.ok, true);
|
||||
const [itemA] = created.value.manifest.items;
|
||||
|
||||
const result = updateBatchItems(dir, created.value.batchId, [
|
||||
{ quickId: itemA.quick_id, dependsOn: [itemA.quick_id] },
|
||||
]);
|
||||
assert.equal(result.ok, false);
|
||||
assert.match(result.reason, /dependency on itself/);
|
||||
} finally {
|
||||
cleanupDir(dir);
|
||||
}
|
||||
});
|
||||
|
||||
test('rejects an update that introduces a dependency cycle — fails closed, no partial write (negative case)', () => {
|
||||
const dir = mkTmpProject();
|
||||
try {
|
||||
const created = createBatch(dir, [
|
||||
{ description: 'a', clientId: 'a' },
|
||||
{ description: 'b', clientId: 'b' },
|
||||
]);
|
||||
assert.equal(created.ok, true);
|
||||
const [itemA, itemB] = created.value.manifest.items;
|
||||
|
||||
// First make B depend on A (valid).
|
||||
const first = updateBatchItems(dir, created.value.batchId, [
|
||||
{ quickId: itemB.quick_id, dependsOn: [itemA.quick_id] },
|
||||
]);
|
||||
assert.equal(first.ok, true);
|
||||
|
||||
// Now try to make A depend on B too — a two-item cycle.
|
||||
const cyclic = updateBatchItems(dir, created.value.batchId, [
|
||||
{ quickId: itemA.quick_id, dependsOn: [itemB.quick_id] },
|
||||
]);
|
||||
assert.equal(cyclic.ok, false);
|
||||
assert.match(cyclic.reason, /cycle/);
|
||||
|
||||
// The manifest still reflects only the first (valid) update — the
|
||||
// rejected cyclic update never persisted.
|
||||
const reloaded = loadBatch(dir, created.value.batchId);
|
||||
assert.equal(reloaded.ok, true);
|
||||
const reloadedA = reloaded.value.items.find((it) => it.quick_id === itemA.quick_id);
|
||||
assert.deepEqual(reloadedA.depends_on, [], 'A was never actually updated to depend on B');
|
||||
} finally {
|
||||
cleanupDir(dir);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe('quick-batch: updateBatchItems — post-planning wave recompute (design rows 15,22-23)', () => {
|
||||
test('row 22: a dependency declared after planning strictly separates waves', () => {
|
||||
const dir = mkTmpProject();
|
||||
try {
|
||||
// No dependency/file-overlap signal at createBatch time — both items
|
||||
// land in wave 0 (Open Question 1's documented negative space).
|
||||
const created = createBatch(dir, [
|
||||
{ description: 'A', clientId: 'a' },
|
||||
{ description: 'B', clientId: 'b' },
|
||||
]);
|
||||
assert.equal(created.ok, true);
|
||||
const [itemA, itemB] = created.value.manifest.items;
|
||||
assert.equal(itemA.wave, 0);
|
||||
assert.equal(itemB.wave, 0, 'before planning, both items land in wave 0 (no signal yet)');
|
||||
|
||||
// Planner for B declares depends_on: [A], files disjoint from A.
|
||||
const result = updateBatchItems(dir, created.value.batchId, [
|
||||
{ quickId: itemA.quick_id, plannedFiles: ['src/a.ts'] },
|
||||
{ quickId: itemB.quick_id, dependsOn: [itemA.quick_id], plannedFiles: ['src/b.ts'] },
|
||||
]);
|
||||
assert.equal(result.ok, true, result.ok ? '' : result.reason);
|
||||
const byId = new Map(result.value.manifest.items.map((it) => [it.quick_id, it]));
|
||||
assert.ok(byId.get(itemB.quick_id).wave > byId.get(itemA.quick_id).wave, 'B strictly follows A after the recompute');
|
||||
} finally {
|
||||
cleanupDir(dir);
|
||||
}
|
||||
});
|
||||
|
||||
test('row 23: file-overlap declared after planning separates two independent items into different waves', () => {
|
||||
const dir = mkTmpProject();
|
||||
try {
|
||||
const created = createBatch(dir, [
|
||||
{ description: 'A', clientId: 'a' },
|
||||
{ description: 'B', clientId: 'b' },
|
||||
]);
|
||||
assert.equal(created.ok, true);
|
||||
const [itemA, itemB] = created.value.manifest.items;
|
||||
assert.equal(itemA.wave, itemB.wave, 'both start in the same wave — no DAG edge, no file signal yet');
|
||||
|
||||
// Two independent items (no depends_on edge) but their plans declare
|
||||
// OVERLAPPING files — partitionByFileOverlap must separate them.
|
||||
const result = updateBatchItems(dir, created.value.batchId, [
|
||||
{ quickId: itemA.quick_id, plannedFiles: ['src/shared.ts'] },
|
||||
{ quickId: itemB.quick_id, plannedFiles: ['src/shared.ts'] },
|
||||
]);
|
||||
assert.equal(result.ok, true, result.ok ? '' : result.reason);
|
||||
const byId = new Map(result.value.manifest.items.map((it) => [it.quick_id, it]));
|
||||
assert.notEqual(
|
||||
byId.get(itemA.quick_id).wave,
|
||||
byId.get(itemB.quick_id).wave,
|
||||
'overlapping planned_files must land the two items in different waves, even though createBatch originally put them together',
|
||||
);
|
||||
} finally {
|
||||
cleanupDir(dir);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -493,6 +493,10 @@ const KNOWN_SKILLS = new Set([
|
||||
'pr-branch.md',
|
||||
'profile-user.md',
|
||||
'progress.md',
|
||||
// #3676 (epic #3344, ADR-1239 "Quick-batch binding"): genuinely new
|
||||
// first-party command batching several /gsd:quick-shaped tasks together —
|
||||
// not a consolidation of an existing skill.
|
||||
'quick-batch.md',
|
||||
'quick.md',
|
||||
'resume-work.md',
|
||||
'review-backlog.md',
|
||||
|
||||
@@ -420,6 +420,9 @@ test('leavesUnmarkedWorkflowEmissionByteIdentical', () => {
|
||||
'new-project.md',
|
||||
'plan-phase.md',
|
||||
'progress.md',
|
||||
// #3676 (epic #3344, ADR-1239 "Quick-batch binding"): research-phase and
|
||||
// verification-wave sections are gated on flag:--research/flag:--validate.
|
||||
'quick-batch.md',
|
||||
'quick.md',
|
||||
'review.md',
|
||||
'transition.md',
|
||||
|
||||
Reference in New Issue
Block a user