Commit graph

3141 commits

Author SHA1 Message Date
Derek Pearson
71c202c792 Merge remote-tracking branch 'upstream/main' into fix/stale-interrupted-session-resume
# Conflicts:
#	src/resources/extensions/gsd/auto.ts
2026-03-21 22:09:45 -04:00
Derek Pearson
bd4da09510 Merge remote-tracking branch 'origin/main' into fix/stale-interrupted-session-resume 2026-03-21 22:04:19 -04:00
Derek Pearson
3b9b109a4e fix(gsd): address QA round 4
- Add unitType/unitId round-trip test for paused-session metadata.
- Add backward-compatibility test for legacy metadata without
  unitType/unitId fields.
2026-03-21 21:45:44 -04:00
Derek Pearson
690bcbd79c fix(gsd): address QA round 3
- Set resourceVersionOnStart on paused-session resume so resource
  staleness detection works for resumed sessions.
- Re-register setLevelChangeCallback on resume so health-level
  transition notifications fire after process restart.
- Persist unitType/unitId in paused-session metadata and restore them
  on resume so recovery synthesis framing text shows the actual unit
  instead of "unknown"/"unknown".
- Check worktreePath existence before showing "(worktree)" in resume
  notification to avoid misleading the user when the worktree was
  already torn down.
- Fix showDiscuss skip_milestone to use step:false (matching
  discuss_draft and discuss_fresh) instead of hardcoded step:true.
2026-03-21 21:27:44 -04:00
Derek Pearson
364cc7dcbc fix(gsd): address QA round 2
- Initialize autoStartTime, originalModelId, originalModelProvider, and
  autoModeStartModel on file-based paused-session resume path so
  dashboard elapsed time, model restore on stop, and error-recovery
  model fallback all work correctly.
- Validate worktreePath existence before using it as assessment base;
  fall back to project root when the worktree has been torn down.
- Add tests for paused-session-only (no lock) with resumable disk state
  and for worktreePath fallback when the directory no longer exists.
2026-03-21 21:11:11 -04:00
Derek Pearson
9e357f8a85 fix(gsd): address QA round 1
- Re-derive state from project root after stale/recoverable cleanup in
  guided flow; the assessment may have derived state from a worktree
  path that was cleaned up, leading to stale state being used downstream.
- Add test for the "none" classification path (clean startup with no
  lock and no paused session) to close coverage gap.
2026-03-21 20:57:21 -04:00
Derek Pearson
d3db0cb411 fix(gsd): address review feedback from trek-e
- Remove redundant `void verboseMode` suppression (parameter is used at line 364)
- Simplify hasStrongRecoverySignal: `hasResumableDiskState || recoveryToolCallCount > 0`
  (the previous expression had a redundant third disjunct)
- Remove extra blank line in auto.ts between stepMode assignment and lock-clear block
2026-03-21 20:48:12 -04:00
TÂCHES
60885610ac feat(gsd): unified rule registry, event journal, journal query tool, and tool naming convention (#1928)
Unify dispatch rules and hooks into a flat rule registry, add structured event journal with causal tracing, expose journal query as an LLM tool, and adopt gsd_concept_action tool naming.

- RuleRegistry class absorbs dispatch rules + hooks into UnifiedRule objects with common when/where/then shape
- post-unit-hooks.ts refactored from 524 lines → 90-line thin facade delegating to the registry
- Event journal emits structured JSONL events with per-iteration flowId grouping and causedBy chains
- gsd_journal_query LLM-callable tool for AI self-debugging of autonomous runs
- 4 DB tools renamed to gsd_concept_action pattern with backward-compatible aliases
- 164 new tests, zero regressions

Closes #1763, closes #1764, closes #1766

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-21 18:47:41 -06:00
Derek Pearson
71f14269a5 fix(gsd): assess recovery from paused worktree state
Use paused-session worktree metadata when deriving interrupted-session state so
worktree isolation decisions follow the authoritative disk state without
changing /gsd discuss auto handoff semantics.
2026-03-21 20:36:03 -04:00
Jeremy McSpadden
bdd1e765f5 feat(ci): PR risk checker — classify changed files by system and surface risk level (#1930) 2026-03-21 18:12:01 -06:00
Derek Pearson
3bb3ca8020 fix(gsd): satisfy extension typecheck for interrupted recovery
Remove a dead running-state comparison after the early return in startAuto so
extension typechecking passes alongside the interrupted-session regressions.
2026-03-21 20:08:05 -04:00
Derek Pearson
11e126a1a6 fix(gsd): restore hook dispatch export and guided flow imports
Remove a duplicate guided-flow import that broke module loading and restore the
public dispatchHookUnit export so /gsd run-hook continues to work.
2026-03-21 19:52:22 -04:00
Derek Pearson
7a384a45d1 fix(gsd): clear stale paused metadata in guided flow
Remove stale paused-session state when guided entry suppresses interrupted
resume prompts and keep discuss-triggered auto resumes in step mode.
2026-03-21 19:32:59 -04:00
Tom Boucher
8e0e4c136b fix: prevent worktree sync from overwriting state and forward-sync completed-units.json
syncProjectRootToWorktree used cpSync defaults which overwrote worktree-authoritative
files (VALIDATION.md, SUMMARY.md). This caused validate-milestone to loop infinitely
because its output got clobbered each iteration. Additionally, completed-units.json
was never forward-synced from project root to worktree, so after crash recovery the
worktree re-dispatched already-completed units.

- Add `{ force: false }` to safeCopyRecursive in syncProjectRootToWorktree so
  existing worktree files are never overwritten (additive-only copy).
- Add forward-sync of completed-units.json from project root to worktree with
  `{ force: true }` (project root is authoritative for completion state).
- Add regression tests covering both bugs and edge cases.

Fixes #1886

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-21 18:23:10 -04:00
snowdamiz
80750b7d40 fix(web): lazily compute default package root to avoid Windows standalone crash
The standalone Next.js bundle bakes import.meta.url at build time with
the Linux CI runner's absolute path. On Windows, fileURLToPath() rejects
the Unix file:// URL at module load time, crashing all API routes with
ERR_INVALID_FILE_URL_PATH before GSD_WEB_PACKAGE_ROOT can be checked.

Replace the eager top-level const with a lazy getter that:
1. Defers evaluation until GSD_WEB_PACKAGE_ROOT is actually absent
2. Catches the cross-platform fileURLToPath failure gracefully
3. Falls back to process.cwd() when the baked-in URL is invalid
4. Caches the result so the computation only runs once

Add regression tests verifying:
- GSD_WEB_PACKAGE_ROOT is used when set
- Lazy fallback returns a valid absolute path without throwing
- Memoization is stable across calls
- Module loads without crash (the original failure mode)

Closes gsd-build/gsd-2#1881
2026-03-21 18:08:58 -04:00
Jeremy McSpadden
c1a35dd1b3 feat: ADR attribution — distinguish human vs agent vs collaborative decisions (#1830)
* feat: add made_by attribution field to decisions (human/agent/collaborative)

Add a 'made_by' field to the Decision type that tracks whether a
decision was made by the human, the agent, or collaboratively. This
enables ADR-style accountability — you can always tell who actually
made each call.

Schema:
- New DecisionMadeBy type: 'human' | 'agent' | 'collaborative'
- DB schema v3 → v4: ALTER TABLE decisions ADD COLUMN made_by
- Existing decisions default to 'agent' (backward compatible)
- DECISIONS.md gains a 'Made By' column
- Parser handles old 7-column format gracefully (defaults to 'agent')

Surfaces updated:
- gsd_save_decision tool accepts optional made_by parameter
- Markdown generator/parser round-trips the new column
- Prompt formatter shows attribution in LLM context
- Compact formatter includes made_by in pipe-separated output
- Worktree reconciliation includes made_by in conflict detection + merge

Tests: 476 assertions across 9 test suites, all passing.

* fix(gsd-db): resolve CI failures and address review findings

- Update memory-store.test.ts to expect schema version 4
- Recreate active_decisions view in v4 migration to pick up new made_by column
- Handle missing made_by column in older worktrees during reconciliation
- Optimize VALID_MADE_BY Set by moving it outside the parser loop

* fix(types): resolve missing made_by property errors in context-store and tests
2026-03-21 15:26:28 -06:00
Tom Boucher
f4db25b9b8 fix(web): persist auth token in sessionStorage to survive page refreshes (#1877)
Next.js 16 auto-detects web/proxy.ts as middleware, gating all /api/*
routes behind bearer token validation. The token was only cached in
memory (lost on page refresh) and extracted from the URL hash fragment
(cleared after first extraction). This caused 401 errors on page
refresh and broke the sendBeacon shutdown call which cannot set
custom headers.

Changes:
- Persist the auth token to sessionStorage after extracting from the
  URL fragment so it survives page refreshes within the same tab
- Fall back to sessionStorage when the URL hash is absent (refresh,
  bookmark without hash)
- Pass the auth token as a _token query parameter in the sendBeacon
  shutdown call since sendBeacon cannot set Authorization headers
- Add regression tests for token persistence, sessionStorage fallback,
  and sendBeacon authentication

Fixes #1851

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-21 15:25:27 -06:00
Iouri Goussev
e0011a897a test: replace shape-only assertions with value checks (#1875)
Several test files used assert.ok(Array.isArray(x)) or assert.ok(result)
patterns that verify structure/existence without checking actual values.
These pass even when the code returns wrong data.

- web-diagnostics-contract: Array.isArray() checks → deepEqual([], [])
  for fields constructed as empty; DoctorFixResult uses deepEqual(["fix1"])
  instead of Array.isArray + length; InstanceType<typeof GSDWorkspaceStore>
  for type assertions from dynamic import
- skill-lifecycle: computeStaleAvoidList → deepEqual(result, []) since
  nonexistent path must return empty
- blob-store: remove redundant assert.ok(retrieved) before deepEqual
- discovery-cache: assert.ok(entry) existence check → verify models[0].id

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-21 15:25:10 -06:00
Tom Boucher
747e29b9b4 fix: clean up SQUASH_MSG after squash-merge and guard worktree teardown against uncommitted changes (#1868)
Three changes to prevent data loss and persistent doctor errors in the
worktree merge-back lifecycle:

1. After nativeCommit in mergeMilestoneToMain, explicitly delete
   .git/SQUASH_MSG. The native libgit2 path and git commit -F - on
   some versions do not auto-remove it, causing doctor to report
   corrupt_merge_state on every run.

2. Before worktree removal (step 11), check for uncommitted changes
   and force a final auto-commit if dirty. This prevents code files
   written by task agents from being destroyed by git worktree remove.

3. Invalidate the nativeHasChanges 10-second cache before the
   post-unit auto-commit in auto-post-unit.ts. A stale false result
   causes autoCommit to skip staging entirely.

Fixes #1853

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-21 15:24:53 -06:00
Tom Boucher
99032444eb fix: populate RecoveryContext in hook unit supervision to prevent crash on stalled tool recovery (#1867)
The buildRecoveryContext callback in auto/phases.ts returned an empty
object instead of a valid RecoveryContext. When the idle watchdog detected
a stalled tool and called recoverTimedOutUnit, basePath was undefined,
causing join(undefined, ".gsd") to throw "The path argument must be of
type string. Received undefined". The error left the session permanently
hung because the unit promise was never resolved.

Fixes #1855

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-21 15:24:37 -06:00
Tom Boucher
f79de8a583 fix: resolve worktree path from git registry when .gsd/ symlink is shadowed (#1866)
When .gsd/ is a symlink to an external state directory, git registers
worktrees at the resolved (real) path. If syncStateToProjectRoot later
creates a real .gsd/ directory that shadows the symlink, worktreePath()
computes a local path that diverges from git's registered path. The
stale local directory passes existsSync but is not a git worktree, so
nativeWorktreeRemove fails silently.

removeWorktree now queries nativeWorktreeList to find the actual
git-registered path by matching on branch name before attempting
removal, falling back to the computed path if the lookup fails.

Fixes #1852

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-21 15:24:21 -06:00
Tom Boucher
2e04253c0b fix: resolve Node v24 web boot failure — ERR_UNSUPPORTED_NODE_MODULES_TYPE_STRIPPING (#1864)
Node v24 forbids --experimental-strip-types for files under node_modules/.
When GSD is globally installed, all src/ files live under node_modules/gsd-pi/,
causing every subprocess worker to crash with ERR_UNSUPPORTED_NODE_MODULES_TYPE_STRIPPING.

Bug 1: Extract resolveTypeStrippingFlag() into src/web/ts-subprocess-flags.ts.
When the package root is under node_modules/ and Node >= 22.7, the function
returns --experimental-transform-types (which handles node_modules paths).
All 15 service files and cli-entry.ts now call this function instead of
hardcoding --experimental-strip-types.

Bug 2: waitForBootReady() now tracks consecutive 5xx responses and aborts
after 3 in a row, including the response body in the error message.
Connection-level errors (transient during cold start) reset the counter.

Bug 3: The /api/boot route handler now wraps collectBootPayload() in
try/catch and returns { error: message } with status 500, matching the
error response pattern used by other API routes.

Fixes #1849

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-21 15:24:07 -06:00
Tom Boucher
7140ee0f53 feat: add /gsd fast command and gate service tier icon to supported models (#1848) (#1862)
Add `/gsd fast [on|off|flex|status]` command for toggling OpenAI service
tiers, with `supportsServiceTier()` gating so the status bar icon only
appears on models that actually support service tiers (gpt-5.4 variants).

Fixes #1848

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-21 15:23:54 -06:00
Iouri Goussev
0dd7176af6 test: replace shape-only assertions with value checks in preferences and routing-history (#1842)
- preferences.test.ts: hook config tests were testing Math.max/min and a
  locally-constructed Set (testing JS builtins, not production code); replaced
  with validatePreferences calls that exercise real clamping in
  preferences-validation.ts and action validation for pre_dispatch_hooks.
  assert.ok(prefs) existence checks replaced with assert.notEqual(prefs, null).
- routing-history.test.ts: removed assert.ok(history) and assert.ok(pattern)
  guards that only verified object existence; assertions now go directly to
  the values that matter.
2026-03-21 15:23:26 -06:00
Tom Boucher
b49cb8cbad fix(auto): broaden worktree health check to all ecosystems (#1860)
* fix(auto): use PROJECT_FILES from detection.ts in worktree health check

The worktree health check introduced in #1833 hard-coded package.json
and src/ as the only valid project markers, blocking auto-mode dispatch
for Rust (Cargo.toml), Go (go.mod), Python (pyproject.toml), and 14
other ecosystems. Replace the JS-centric heuristic with the shared
PROJECT_FILES array from detection.ts which already covers 17+
ecosystems.

Fixes #1843

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix: update test assertion to match new project files message

The health check now says "no recognized project files" instead of
"no package.json or src/" after broadening to PROJECT_FILES.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-21 15:22:34 -06:00
Tom Boucher
358dc1da6b fix(doctor): cascade slice uncheck when task_done_missing_summary unchecks tasks (#1850) (#1858)
When tasks are [x] done but no T##-SUMMARY.md exists, doctor unchecks
the tasks but left the slice [x] done in the roadmap. The state machine
skips done slices, so unchecked tasks never re-execute and doctor fires
again on every start — infinite loop.

After unchecking tasks via task_done_missing_summary, also uncheck the
slice in the roadmap so the state machine re-enters the executing phase.

Fixes #1850

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-21 15:22:23 -06:00
Tom Boucher
1ad1b5d061 fix: defend exit path against ESM module cache mismatch (#1854)
* fix: defend exit path against ESM module cache mismatch (#1839)

Wrap the stopAuto import/call in exit-command.ts with try/catch so
that a mid-session gsd-pi update (which causes stale ESM cache for
native-git-bridge.js exports) does not crash the /exit handler.
A warning is emitted instead. The user's work is already saved;
this path is cleanup only.

Fixes #1839

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix: use "warning" not "warn" for notify severity type

TS2345: "warn" is not in the severity union type.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix: update test assertion to match "warning" severity

The source was corrected to "warning" (valid union type), test must match.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-21 15:22:13 -06:00
Andrew
3f8d7921ca feat: add --host, --port, --allowed-origins flags for web mode (#1847) (#1873)
Wire CLI flags through parseCliArgs → runWebCliBranch → launchWebMode
so users can bind to a custom host/port and whitelist CORS origins for
LAN/Tailscale access.

- Add webHost, webPort, webAllowedOrigins to CliFlags
- Parse --host, --port (validated 1-65535), --allowed-origins (csv)
- Forward into launchWebMode options
- Set GSD_WEB_ALLOWED_ORIGINS in subprocess env when provided
- Add allowedOrigins to WebModeLaunchOptions

Usage: gsd --web --host 0.0.0.0 --port 8080 --allowed-origins http://192.168.1.10:8080

Closes #1847
2026-03-21 15:22:01 -06:00
TÂCHES
8bed02c077 fix: escape parentheses in paths before bash shell-out, fix __extensionDir fallback (#1872)
Closes #1437
2026-03-21 15:14:40 -06:00
TÂCHES
77b220e9e5 fix: use PowerShell Start-Process for Windows browser launch, prevent URL wrapping (#1870)
Closes #1574
2026-03-21 15:12:24 -06:00
TÂCHES
0188b8eaa8 fix: clear stale unit state and restore CWD when step-wizard exits auto-loop (#1869)
Closes #1698
2026-03-21 15:12:16 -06:00
TÂCHES
05a535598d fix: prevent cross-project state leak in brand-new directories (#1639) (#1861)
When GSD is launched in a new empty directory that happens to be inside
an existing git repo (e.g. mkdir ~/Projects/newproject where ~/Projects
has a .git), repoIdentity() resolves to the parent repo's hash and
loads milestones from an unrelated project.

Add isInheritedRepo() to detect when basePath inherits a parent repo's
git root without having its own .gsd. When detected, git init creates
an independent repo so the directory gets a unique identity hash.
Legitimate subdirectory access (cd src/ inside an existing GSD project)
is preserved — the check only triggers when the parent repo has no .gsd.

Closes #1639

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-21 14:58:25 -06:00
Tom Boucher
7054e5dde6 fix: reconcile worktree HEAD with milestone branch ref before squash merge (#1846) (#1859)
When the worktree HEAD detaches and advances past the named milestone
branch, the branch ref becomes stale. The squash merge only captured
the stale ref, silently orphaning all commits between the branch ref
and the actual worktree HEAD.

Before the squash merge, compare the milestone branch ref with the
worktree's actual HEAD. If the branch ref is an ancestor of the
worktree HEAD, fast-forward the branch ref. If they have diverged,
throw a clear error instead of silently losing commits.

Guarded by worktreeCwd !== originalBasePath_ so non-worktree merge
paths (e.g. parallel-merge) are unaffected.

Fixes #1846
2026-03-21 14:58:16 -06:00
TÂCHES
e5ae9fd249 fix: normalize Windows backslash paths in bash command strings (#1436) (#1863)
On Windows, paths embedded in bash command strings have backslashes
stripped by the shell (e.g. C:\Users\user becomes C:Useruser), causing
cd and other commands to fail silently. This left ~1.4 GB orphaned
worktree directories after milestone completion.

- Normalize all paths to forward slashes before embedding in the
  subagent cmux bash script (cd, tee, process args)
- Add post-teardown orphan detection: warn and attempt rmSync fallback
  if the worktree directory persists after removeWorktree
- Add regression tests for Windows path normalization

Closes #1436

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-21 14:57:58 -06:00
TÂCHES
333c769e21 fix: parsePlan and verifyExpectedArtifact recognize heading-style task entries (#1691) (#1857)
Closes #1691
2026-03-21 14:53:30 -06:00
TÂCHES
a0031d321e fix: sync all milestone dirs regardless of naming convention (#1547) (#1845)
Remove hardcoded /^M\d{3}/ regex filter from syncGsdStateToWorktree and
syncWorktreeStateBack so milestone directories with non-standard names
(e.g. sprint-alpha, M001-abc123) are synced between main and worktree.

Closes #1547

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-21 14:47:57 -06:00
Tom Boucher
9fe82c18dc docs: add v2.41.0 release notes to README and docs (#1840)
Update README "What's New" section with v2.41.0 highlights organized by
category: new features (web interface, doctor lifecycle), data loss
prevention (7 critical fixes), auto-mode stability, roadmap parser
improvements, state/git fixes, Windows/platform support, and DX.

- Add web-interface.md documenting the new browser-based UI
- Add web interface entry to docs/README.md index
- Move v2.39-v2.40 highlights to "Previous highlights" section

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-21 13:55:28 -06:00
github-actions[bot]
3aaf6951fc release: v2.41.0 2026-03-21 19:45:20 +00:00
Lex Christopherson
626ad25edc fix: skip web build on Windows — Next.js webpack hits EPERM on system dirs
The Windows CI runner's Application Data directory triggers EPERM
when webpack scans it. The web build is a Linux/macOS deployment
target and doesn't need to run on Windows.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-21 13:30:23 -06:00
Lex Christopherson
1031400ec3 fix: include web build in main build command
The validate-pack step requires dist/web/standalone/server.js but
the build command didn't produce it. Add build-web-if-stale.cjs to
the build chain — it skips when up-to-date and rebuilds when needed.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-21 13:25:01 -06:00
Tom Boucher
897237ab0a fix: fall through to prose slice parser when checkbox parser yields empty under ## Slices (#1744)
When the ## Slices section exists but contains H3 prose headers instead of
checkboxes, parseRoadmapSlices returned an empty array because the prose
fallback was only invoked when the ## Slices heading was entirely absent.
Now, when the checkbox parser finds zero slices, it falls through to
parseProseSliceHeaders as a second-chance fallback.

Also adds a missing_slice_dir diagnostic in doctor.ts when resolveSlicePath
returns null, with auto-fix via mkdir.

Fixes #1711

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-21 13:24:05 -06:00
Tom Boucher
a7ad0caf9f fix(auto): verify merge anchored before worktree teardown (#1829)
* fix(auto): verify merge anchored before worktree teardown

Fixes #1792

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix: replace unconditional empty-commit throw with anchor check

Step 10's unconditional throw on nothingToCommit conflicted with step
8b's smarter anchor check (#1792). Step 8b correctly distinguishes
"genuinely safe empty" (code already on main) from "data loss risk"
(unanchored code changes). Updated tests accordingly.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-21 13:23:50 -06:00
Tom Boucher
77d88407ab fix(auto): reject execute-task with zero tool calls as hallucinated (#1838)
* fix(auto): reject execute-task with zero tool calls as hallucinated

Adds two safeguards against agents that complete with exit 0 but make
no tool calls, producing hallucinated summaries:

1. Zero tool-call guard: after closeoutUnit snapshots metrics for an
   execute-task, check the ledger for toolCalls === 0. If zero, log a
   warning and skip adding the unit to completedUnits so the task is
   retried on the next loop iteration instead of silently advancing.

2. Worktree health check: before dispatching an execute-task, verify
   the basePath has a .git marker and at least one of package.json or
   src/. A broken worktree causes agents to hallucinate since they
   cannot read or write files. Stops auto-mode immediately on failure.

Fixes #1833

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix: replace findLast with reverse().find() for ES2022 compat

findLast requires ES2023 lib target. The project uses ES2022.
Functionally identical: [...arr].reverse().find() with explicit type.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-21 13:23:35 -06:00
Iouri Goussev
563a3797c2 test: add missing git-service coverage for 6 untested paths (#1837)
- MergeConflictError constructor fields (conflictedFiles, strategy,
  branch, mainBranch, name, message content, instanceof checks)
- writeIntegrationBranch rejects gsd/quick/* ephemeral branches
- resolveMilestoneIntegrationBranch returns status:missing when no
  metadata file exists
- resolveMilestoneIntegrationBranch returns status:missing when both
  recorded and configured main_branch are absent (full fallback chain)
- buildTaskCommitMessage appends Resolves #N trailer when issueNumber set
- runPreMergeCheck skips gracefully when no package.json found

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-21 13:23:25 -06:00
Lex Christopherson
958b8e752d fix: also convert --import resolver path to file URL for Windows
The spawnSync --import flag also receives a bare Windows path.
Convert it with pathToFileURL like the script import.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-21 13:11:50 -06:00
Lex Christopherson
702f1a578c fix: use pathToFileURL for Windows-safe ESM import in verification-gate test
Bare "file://" + windowsPath produces invalid URLs on Windows
(e.g. file://D:\...). pathToFileURL correctly produces file:///D:/...

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-21 13:04:05 -06:00
Tom Boucher
e2b85d4e7f fix(gsd): read depends_on from CONTEXT-DRAFT.md when CONTEXT.md is absent (#1743)
When a milestone has only CONTEXT-DRAFT.md (no CONTEXT.md), the depends_on
frontmatter was silently ignored because _deriveStateImpl() only read from
CONTEXT.md. This caused dep-blocked milestones to be incorrectly promoted
to active status. Now all three dependency-reading paths fall back to
CONTEXT-DRAFT.md when CONTEXT.md is absent.

Fixes #1724

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-21 12:56:52 -06:00
Tom Boucher
ab2eab01d2 fix(roadmap): detect ✓ completion marker in prose slice headers (#1816)
parseProseSliceHeaders() always set done:false regardless of ✓ or
(Complete) markers in the title, causing auto-mode to repeatedly
dispatch complete-slice for already-finished slices.

- Detect ✓ prefix before slice ID ("## ✓ S01: Title")
- Detect ✓ after separator ("## S01: ✓ Title")
- Detect (Complete) suffix ("## S01: Title (Complete)")
- Strip markers from title so downstream consumers get clean names
- Add prose format support to markSliceDoneInRoadmap

Fixes #1803

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-21 12:55:34 -06:00
Tom Boucher
72f39b6e23 fix(auto): reverse-sync root-level .gsd files on worktree teardown (#1831)
Add QUEUE.md and completed-units.json to the durable file whitelist in
both syncGsdStateToWorktree (forward sync) and syncWorktreeStateBack
(reverse sync). These files are written during milestone closeout but
were not being copied back to the project root, causing state loss on
worktree teardown.

Adds regression test verifying both files survive reverse sync.

Fixes #1787

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-21 12:55:25 -06:00
Tom Boucher
f29d54b7e0 fix(tui): prevent freeze when using @ file finder (#1832)
The @ file autocomplete triggered a synchronous native fuzzyFind call
that walks the entire directory tree. On large repos this blocked the
Node.js event loop and froze the TUI.

Three changes fix this:

1. Skip the fuzzy search when the query is empty (bare "@" with nothing
   typed yet) — there is no point walking the full tree with no query.

2. Debounce the initial "@" keystroke instead of firing the search
   synchronously, so rapid typing cancels pending walks and the search
   only runs once the user pauses.

3. Deduplicate consecutive lookups using lastAutocompleteLookupPrefix
   (previously declared but unused) to avoid redundant synchronous
   searches when the prefix hasn't changed.

Fixes #1824

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-21 12:55:12 -06:00