Commit Graph

3887 Commits

Author SHA1 Message Date
gsxdsm
a3bb584bff chore(release): v0.74.0
Version bump via changesets.
2026-08-02 20:31:14 -07:00
gsxdsm
bc34b724ac chore(release): v0.74.0-beta.9
Version bump via changesets.
2026-08-02 20:00:46 -07:00
gsxdsm
0e69ed9a5b fix: stop stale-active-branch rescue spam for done squash leftovers (#3311)
## Summary
- Local `fusion/*` branches for **done** tasks kept unique tip SHAs
after squash/AI merge, so self-healing logged
`stale-active-branch-rescue-needed` on every maintenance sweep without
ever deleting them.
- **Completion fan-out** now force-deletes the task branch even when
unique commits remain (squash-safe).
- **`reclaim-stale-active-branches`** force-deletes complete-lane
leftovers (`reason=complete-column-unique-commits-force`) and no longer
emits rescue-needed for those lanes; non-complete columns still warn and
preserve unmerged work. Archived lanes still skip reclaim entirely.

Also cleaned up 116 leftover local fusion branches on this machine
(done/orphan only; 9 active kept).

## Test plan
- [x] `pnpm --filter @fusion/engine exec vitest run
src/__tests__/self-healing-completion-fanout.test.ts
src/__tests__/self-healing.test.ts -t "SelfHealingManager
reclaimStaleActiveBranches|self-healing completion
fan-out|force-deletes"`
- [ ] After merge/restart engine: confirm logs no longer spam
rescue-needed for done tasks
- [ ] Confirm active todo/in-progress fusion branches still get
rescue-needed when unique and no worktree

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **Bug Fixes**
* Improved cleanup of stale task branches after completion, including
branches with unique commits remaining after squash or AI-assisted
merges.
* Completed tasks now reliably remove residual branches and worktree
metadata.
* Non-completed tasks continue to preserve recoverable branches and
display rescue warnings.
* Added clearer recovery logging and audit records for forced branch
cleanup.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-08-02 19:05:59 -07:00
gsxdsm
0ae6c396d0 chore(release): v0.74.0-beta.8
Version bump via changesets.
2026-08-02 18:32:41 -07:00
gsxdsm
6cc687d3a3 FN-8728: retry incomplete planner runs before review
Retry planner attempts until a clean, changed artifact is ready for Plan Review.

- Track each planning attempt's prompt baseline and fallback provenance.
- Require a runtime-owned fallback-dispatch boundary before review handoff.
- Back off and surface actionable errors for empty, unchanged, or fallback-engaged attempts.

Files changed:
 .changeset/fn-8728-planner-retry-before-review.md |   7 +
 docs/architecture.md                              |   2 +-
 packages/engine/src/__tests__/triage.test.ts      | 492 ++++++++++++++++++++++
 packages/engine/src/agent-runtime.ts              |   8 +
 packages/engine/src/agent-session-helpers.ts      |   3 +
 packages/engine/src/pi.ts                         |  14 +-
 packages/engine/src/runtime-resolution.ts         |  14 +-
 packages/engine/src/triage.ts                     | 135 +++++-
 8 files changed, 656 insertions(+), 19 deletions(-)

Fusion-Task-Id: FN-8728

Fusion-Task-Lineage: e7581d29-5bd6-43dc-aa0b-6594b9dd9c0d

Co-authored-by: Fusion (runfusion.ai) <noreply@runfusion.ai>
2026-08-02 18:26:18 -07:00
gsxdsm
a84e16118a fix(engine): keep settle-window ledger updates synchronous on task moves
FN-8656 moved the recentEngineTodoRequeues / dispatch-oscillation reset behind
await resolveTaskParkedColumns, racing sync delete/update handlers. A hold
requeue then delete in the same tick could re-set the settle guard after the
clear and leave the card undispatchable. Consume the sync parked lanes in the
emitter prologue again.
2026-08-02 17:33:11 -07:00
gsxdsm
1e7f510ee2 fix: stop blocking tasks on open-PR file claims — board tasks are the only blockers
Remove the FN-8700 PR/file-claim blocking mechanism end to end (operator
decision after FN-8728 parked on unrelated PR #2398):

- Drop the AGENTS.md claim-check rule and scripts/check-file-claimed.mjs
- Executor prompt + fn_task_done no longer accept pr:N refs or treat open
  PRs as blocked-exit reasons
- execution-block-classifier classifies on Fusion task dependencies only;
  legacy pr refs are discarded, reason prose never makes a block durable
- Remove the session-log BLOCKED promotion and the gh-backed
  reconcile-external-pr-blockers self-healing sweep
- Legacy file-claim parks are no longer honored, so previously PR-blocked
  rows recover via normal paths

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-08-02 17:06:38 -07:00
gsxdsm
546a19aef6 chore(release): v0.74.0-beta.7
Version bump via changesets.
2026-08-01 20:22:07 -07:00
Phil Larson
fab2b3a7b1 fix(i18n): restore reverted-task locale parity (#3302)
## Summary
- add reverted-task resolution keys to every secondary app catalog
- restore structural locale parity after the reverted-task dashboard UI
landed
- include labeled patch release metadata

## Test plan
- `pnpm --filter @fusion/i18n test`
- `pnpm i18n:status`
- `pnpm check:changesets -- --strict`
- `pnpm build`

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **Localization**
* Added localized labels for reverted tasks, resolution actions,
revision actions, and related task titles in French, Korean, Simplified
Chinese, and Traditional Chinese.
* Added Spanish locale entries for consistent support of these task
actions.
  * Improved terminology coverage across supported secondary locales.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-08-01 19:18:15 -07:00
gsxdsm
9e0f29abc9 fix: durable parks for file-claim and PR blockers (FN-8700)
Classify blocked exits so check-file-claimed / open-PR collisions never
auto-replan. Park failed with externalBlockers metadata (pr:N supported),
promote BLOCKED session logs instead of incomplete-step requeue, thrash-
exhaust after 3 identical durable blocks, and clear parks when gh reports
blocking PRs merged or closed.
2026-08-01 18:34:42 -07:00
gsxdsm
af138d73ee test: harden engine fixtures after lane and session refactors
Scope stuck-requeue merge-base failure to the task-branch proof so setup
still reaches the session; loosen MCP coverage to allow let session
rebinding; mock getRootDir for stranded-hold capacity; and expect the
scheduler parked-role site to use awaited resolveTaskParkedColumns after
FN-8656.
2026-08-01 18:21:19 -07:00
gsxdsm
400c640c85 fix: stop inactive DUPLICATE replan loop (FN-8704)
After one free needs-replan clear of an inactive DUPLICATE marker, a
re-emit of the same dismissed canonical parks status failed
(DUPLICATE_REPLAN_EXHAUSTED) so triage no longer re-admits the card.
Tracks clear count in sourceMetadata; self-healing mirrors triage.
2026-08-01 17:48:29 -07:00
gsxdsm
6d176a9372 FN-8721: reconcile census, delegation routing, and archive repair
Align lifecycle census coverage while routing delegated work to workflow-ready lanes and safely repairing archived tasks.

- Route delegated tasks through the selected workflow's hold or entry column.
- Scope soft-deleted archive repairs by project and protect them with compare-and-set updates.
- Refresh lifecycle-column census detection, baseline, documentation, and coverage.

Files changed:
 docs/testing.md                                    | 21 +++---
 .../u15-engine-dashboard-consumers.test.ts         | 31 ++++++++-
 .../core/src/task-store/archive-lifecycle-2.ts     |  5 ++
 .../core/src/task-store/async-archive-lineage.ts   |  5 ++
 packages/core/src/task-store/async-persistence.ts  | 11 ++++
 packages/core/src/task-store/async-self-healing.ts | 76 +++++++++++++++-------
 .../src/__tests__/agent-tools-delegation.test.ts   | 43 +++++++++++-
 .../__tests__/lifecycle-column-census-ast.test.ts  | 20 ++++++
 .../src/__tests__/lifecycle-column-census.test.ts  | 29 ++++++---
 packages/engine/src/agent-tools.ts                 | 29 +++++++--
 scripts/lib/lifecycle-column-census-ast.mjs        | 21 +++++-
 scripts/lib/lifecycle-column-census-baseline.json  | 17 ++---
 scripts/lifecycle-column-census.mjs                |  3 +-
 13 files changed, 245 insertions(+), 66 deletions(-)

Fusion-Task-Id: FN-8721
Fusion-Task-Lineage: ff78481f-5ecb-4d9b-b21a-a095682372ed
Co-authored-by: Fusion (runfusion.ai) <noreply@runfusion.ai>
2026-08-01 16:57:49 -07:00
gsxdsm
3b633512d8 FN-8707: recover noisy mission validator JSON
Recover bounded, valid mission validator payloads amid ordinary response formatting noise.

- Extract bounded, string-aware fenced and balanced JSON candidates and prefer the final valid payload.
- Conservatively repair trailing commas and missing closing delimiters while retaining fail-closed assertion validation.
- Cover recovery and irreparable-response behavior, document the safety bounds, and add a patch changeset.

Files changed:
 .../fn-8707-mission-validator-json-recovery.md     |   7 +
 docs/missions.md                                   |   2 +
 .../src/__tests__/mission-execution-loop.test.ts   |  74 ++++++++-
 packages/engine/src/mission-execution-loop.ts      | 183 +++++++++++++++------
 4 files changed, 204 insertions(+), 62 deletions(-)

Fusion-Task-Id: FN-8707

Fusion-Task-Lineage: 0eb5e5c0-a520-4485-9f54-0376a47a5b5e

Co-authored-by: Fusion (runfusion.ai) <noreply@runfusion.ai>
2026-08-01 13:37:23 -07:00
gsxdsm
494362cd23 FN-8697: preserve redacted failed-tool diagnostics
Persist safe error detail so operators can diagnose repeated executor tool failures.

- Redact and retain failed-tool diagnostics even when tool output persistence is disabled.
- Cover redaction, disclosure independence, inert rendering, and retry-backoff normalization.

Files changed:
 .../__tests__/AgentLogViewer.rendering.test.tsx    | 29 +++++++++++++++++
 .../src/__tests__/agent-logger-diagnostics.test.ts | 38 ++++++++++++++++++++++
 packages/engine/src/__tests__/agent-logger.test.ts |  4 +--
 .../__tests__/executor-tool-failure-retry.test.ts  | 22 ++++++++++++-
 packages/engine/src/agent-logger.ts                | 11 +++++--
 5 files changed, 99 insertions(+), 5 deletions(-)

Fusion-Task-Id: FN-8697

Fusion-Task-Lineage: 5ed900b6-a42b-4ad7-9270-47053295e6e1

Co-authored-by: Fusion (runfusion.ai) <noreply@runfusion.ai>
2026-08-01 12:48:30 -07:00
gsxdsm
39368f4bb8 FN-8694: add content-addressed validation memoization
Memoizes mission validation inputs and bounds repeat failures.

- Persist validator input fingerprints and atomically admit validation runs.
- Reuse unchanged static passes while enforcing per-fingerprint failure budgets.
- Add migration coverage, execution-loop tests, and operator documentation.

Files changed:
 .changeset/fn-8694-validation-memoization.md       |   7 +
 docs/missions.md                                   |   6 +
 docs/storage.md                                    |   6 +
 .../__tests__/postgres/mission-store.pg.test.ts    |  40 +++-
 packages/core/src/async-mission-store-queries.ts   |  24 ++-
 packages/core/src/async-mission-store.ts           |  65 +++++-
 packages/core/src/mission-store.ts                 |  10 +-
 packages/core/src/mission-types.ts                 |  19 ++
 .../0042_fn_8694_validator_input_fingerprint.sql   |   9 +
 packages/core/src/postgres/schema-applier.ts       |  13 +-
 packages/core/src/postgres/schema/project.ts       |   5 +
 .../src/__tests__/mission-execution-loop.test.ts   |  72 ++++++-
 packages/engine/src/mission-execution-loop.ts      | 217 +++++++++++++++++----
 13 files changed, 443 insertions(+), 50 deletions(-)

Fusion-Task-Id: FN-8694

Fusion-Task-Lineage: 92a790d5-f2fc-4e71-b9ee-8334ff38b20d

Co-authored-by: Fusion (runfusion.ai) <noreply@runfusion.ai>
2026-08-01 12:40:24 -07:00
gsxdsm
6e98e16e70 fix: reject DUPLICATE-only PROMPT at dispatch (FN-8704)
FN-8704 failed at the graph parse node because PROMPT.md was only
"DUPLICATE: FN-8676". Filesystem validation treated non-empty as planned
and admitted the card into WIP, which then looped on parse failure.

Treat a sole DUPLICATE redirect as unplanned: block dispatch and hold
release, badge as awaiting planning, and if parse still sees that shape
rebound to needs-replan with feedback instead of parking failed.
2026-08-01 12:26:53 -07:00
gsxdsm
7f29809728 fix: exclude failed WIP from live capacity holders
Failed parks left in the WIP column still counted as running agents and
file-scope lease holders, so they consumed maxWorktrees/maxConcurrent and
could serialize unrelated todos. Match review-lane semantics: status
failed is never a live top-level holder.
2026-08-01 12:23:59 -07:00
gsxdsm
e3fbd2ebf5 fix: stop inactive-duplicate clear from replan-storming
Clearing a DUPLICATE marker for an inactive or kept canonical left
status:null without PROMPT.md. The scheduler treats planning→null as
"finished planning" and re-dispatched the card; FS validation rebounded
to needs-replan with no ceiling, and triage re-planned with empty
feedback so the planner could re-emit the same inactive marker forever
(FN-8704 / FN-8676).

Leave needs-replan + dismissal metadata + replan feedback instead, share
the clear contract across triage and self-healing, and bound scheduler
filesystem-validation rebounds with the shared recovery budget.
2026-08-01 11:53:53 -07:00
gsxdsm
60706ed5e4 fix: demote high-frequency TUI log lines to debug
Session setup, track bookkeeping, intentional skill exclusions, token-cache
metrics, zero-count recovery summaries, and expected-missing PROMPT seed reads
were flooding the default log pane. Gate them behind FUSION_DEBUG so only
state transitions and operator-actionable warnings remain visible.
2026-08-01 11:48:56 -07:00
gsxdsm
01d65805c3 FN-8693: refresh reused worktree bases before execution
Refresh reused execution worktrees against the current integration baseline.

- Rebase or reset clean reused worktrees before coding sessions while preserving task commits.
- Persist and audit refreshed base SHAs, and block unsafe refresh states before execution.
- Cover executor, graph, and heartbeat refresh paths with regression tests.

Files changed:
 .changeset/fn-8693-stale-worktree-base.md          |   7 +
 docs/architecture.md                               |   1 +
 .../src/__tests__/agent-heartbeat-worktree.test.ts |  28 ++++
 .../__tests__/ce-workflow-step-executor.test.ts    |  44 ++++++
 .../src/__tests__/worktree-base-refresh.test.ts    |  90 ++++++++++++
 packages/engine/src/agent-heartbeat.ts             |  35 ++++-
 packages/engine/src/executor.ts                    |  67 ++++++++-
 packages/engine/src/merger.ts                      |   5 +
 packages/engine/src/run-audit.ts                   |  11 ++
 packages/engine/src/workflow-graph-executor.ts     |  32 ++++-
 packages/engine/src/worktree-acquisition.ts        |  28 +++-
 packages/engine/src/worktree-base-refresh.ts       | 158 +++++++++++++++++++++
 12 files changed, 498 insertions(+), 8 deletions(-)

Fusion-Task-Id: FN-8693
Fusion-Task-Lineage: e39a441f-39b5-4723-b503-753e921018f3
Co-authored-by: Fusion (runfusion.ai) <noreply@runfusion.ai>
2026-08-01 10:03:28 -07:00
gsxdsm
e8ca86d5ee FN-8705: prioritize review and execution slot admission
Prioritize lifecycle-critical work whenever project capacity becomes available.

- Rank admission candidates as review/merge, execution, then planning.
- Coordinate scheduler handoffs with project and host capacity reservations.
- Cover lane priority and document the updated operator behavior.

Files changed: .changeset/fn-8705-slot-priority.md                |  7 ++
 docs/architecture.md                               |  2 +-
 docs/dashboard-guide.md                            |  2 +-
 packages/engine/src/__tests__/concurrency.test.ts  | 95 +++++++++++-----------
 .../engine/src/__tests__/project-engine.test.ts    |  4 +-
 .../starved-refinement-x-triage-poll.test.ts       | 11 ++-
 .../__tests__/triage-refinement-routing.test.ts    | 16 ++--
 .../workflow-continuation-capacity.test.ts         |  3 +-
 packages/engine/src/concurrency.ts                 | 37 +++++++--
 packages/engine/src/project-engine.ts              | 10 ++-
 packages/engine/src/runtimes/in-process-runtime.ts |  3 +-
 packages/engine/src/scheduler.ts                   | 40 ++++-----
 packages/engine/src/triage.ts                      |  7 +-
 13 files changed, 133 insertions(+), 104 deletions(-)

Fusion-Task-Id: FN-8705

Fusion-Task-Lineage: ef66360b-e504-4e3f-b25e-b032a719d8c0

Co-authored-by: Fusion (runfusion.ai) <noreply@runfusion.ai>
2026-08-01 09:24:18 -07:00
gsxdsm
1aa1516023 FN-8692: harden mission validator assertion matching
Make validator assertion identity handling explicit and fail closed for ambiguous legacy responses.

- Include authoritative assertion IDs in validator prompts
- Recover only unique exact-count legacy results positionally
- Reject duplicate unknown and empty assertion IDs with regression coverage
- Document the assertion identity contract and add a patch changeset

Files changed:
 .changeset/fn-8692-validator-assertion-ids.md      |   7 +
 docs/missions.md                                   |   2 +-
 .../src/__tests__/mission-execution-loop.test.ts   | 142 ++++++++++++++++++++-
 packages/engine/src/mission-execution-loop.ts      |  70 ++++++++--
 4 files changed, 204 insertions(+), 17 deletions(-)

Fusion-Task-Id: FN-8692

Fusion-Task-Lineage: 973c65e9-962f-472b-8d42-aef1de830d70

Co-authored-by: Fusion (runfusion.ai) <noreply@runfusion.ai>
2026-08-01 09:18:49 -07:00
gsxdsm
ac8ce148d5 FN-8691: suppress repeated task wedge notifications
Prevent resolved-and-rewedged tasks from flooding operator notification channels.

- Persist per-reason notification timestamps with a six-hour cooldown.
- Apply cooldown claims consistently in durable storage and in-memory fallback paths.
- Cover reason transitions, legacy state, invalid timestamps, and cooldown expiry.

Files changed:
 .changeset/fn-8691-wedge-notification-cooldown.md  |   7 ++
 docs/architecture.md                               |   4 +-
 .../postgres/store-wedge-resolution.pg.test.ts     |  67 +++++++++++-
 packages/core/src/index.ts                         |   1 +
 packages/core/src/store.ts                         |  21 +++-
 packages/core/src/task-store/task-mutation-ops.ts  |   6 ++
 packages/core/src/types.ts                         |   2 +
 packages/core/src/types/task-core.ts               |  15 +++
 .../__tests__/task-wedge-notification.test.ts      | 117 ++++++++++++++++++++-
 .../src/notification/notification-service.ts       |  30 +++++-
 10 files changed, 261 insertions(+), 9 deletions(-)

Fusion-Task-Id: FN-8691

Fusion-Task-Lineage: b7460508-f9b0-488b-828c-a51e9477304d

Co-authored-by: Fusion (runfusion.ai) <noreply@runfusion.ai>
2026-08-01 08:58:49 -07:00
gsxdsm
04c2bb4707 FN-8654: rotate credential instances after provider limits
Retry provider-limit failures with eligible credential instances before falling back to existing pauses and backoff.

- Add a runtime-shared credential rotator with cooldown, exhaustion, and audit handling.
- Wire credential rotation into executor and heartbeat retry lanes while preserving user pause controls.
- Document the behavior and cover rotation, recovery, and retry paths.

Files changed:
 .changeset/fn-8654-credential-instance-rotation.md |   7 +
 AGENTS.md                                          |   1 +
 docs/architecture.md                               |   2 +-
 docs/settings-reference.md                         |   4 +
 .../__tests__/credential-instance-rotation.test.ts |  88 +++++++++++
 .../__tests__/credential-rotation-lanes.test.ts    |  20 +++
 .../__tests__/credential-rotation-recovery.test.ts |  19 +++
 .../__tests__/credential-rotation-wiring.test.ts   |  15 ++
 .../__tests__/rate-limit-retry-rotation.test.ts    |  50 ++++++
 .../src/__tests__/usage-limit-detector.test.ts     |  14 ++
 packages/engine/src/agent-heartbeat.ts             | 102 +++++++++++-
 .../engine/src/credential-instance-rotation.ts     | 175 +++++++++++++++++++++
 packages/engine/src/executor.ts                    | 141 +++++++++++++++--
 packages/engine/src/index.ts                       |   7 +
 packages/engine/src/project-engine.ts              |   5 +
 packages/engine/src/rate-limit-retry.ts            |  32 +++-
 packages/engine/src/runtimes/in-process-runtime.ts |  29 +++-
 packages/engine/src/usage-limit-detector.ts        |  18 ++-
 18 files changed, 699 insertions(+), 30 deletions(-)

Fusion-Task-Id: FN-8654
Fusion-Task-Lineage: 44d63441-270c-4949-8c34-47ec4c9992e4
Co-authored-by: Fusion (runfusion.ai) <noreply@runfusion.ai>
2026-08-01 08:20:29 -07:00
gsxdsm
006cc40454 FN-8685: add durable cross-process task deletion consumers
Deliver durable, replay-safe cross-process task deletion observation.

- Add PostgreSQL lifecycle consumer cursors, leases, acknowledgements, retention, and recovery.
- Start named consumers in dashboard, serve, and engine runtime paths.
- Preserve delete integration metadata while suppressing replayed GitHub and GitLab side effects.
- Cover outbox identity, observed delivery, fencing, and reconciliation behavior.

Files changed:
 ...fn-8685-cross-process-task-deleted-observers.md |   7 +
 .../fn-8685-task-deleted-outbox-consumers.md       |   7 +
 docs/architecture.md                               |   8 +-
 ...tgres-cross-process-task-deleted-observation.md |   8 +-
 docs/storage.md                                    |  10 +-
 packages/cli/src/commands/dashboard.ts             |   9 +-
 packages/cli/src/commands/serve.ts                 |   9 +-
 packages/cli/src/project-context.ts                |   9 +-
 .../task-deleted-outbox-consumer.pg.test.ts        | 157 ++++++++
 ...-deleted-observed-dispatch-side-effects.test.ts |  36 ++
 .../task-lifecycle-consumer-identity.test.ts       |  22 ++
 packages/core/src/index.ts                         |  11 +
 .../0041_fn_8685_task_lifecycle_consumers.sql      |  88 +++++
 packages/core/src/postgres/schema-applier.ts       |  16 +-
 packages/core/src/postgres/schema/project.ts       |  45 +++
 packages/core/src/postgres/startup-factory.ts      |   4 +
 packages/core/src/store.ts                         |  54 ++-
 .../__tests__/lifecycle-outbox-writer.test.ts      |   4 +-
 .../core/src/task-store/archive-lifecycle-2.ts     |   1 +
 packages/core/src/task-store/lifecycle-ops.ts      |  13 +-
 packages/core/src/task-store/lifecycle-outbox.ts   |   2 +
 packages/core/src/task-store/project-store-ops.ts  |   4 +-
 .../src/task-store/task-deleted-outbox-consumer.ts | 333 +++++++++++++++++
 .../task-store/task-lifecycle-consumer-identity.ts |  32 ++
 .../task-store/task-lifecycle-consumer-registry.ts | 396 +++++++++++++++++++++
 .../task-store/task-lifecycle-event-retention.ts   | 104 ++++++
 packages/core/src/task-store/task-mutation-ops.ts  |   1 +
 packages/dashboard/src/github-tracking-state.ts    |  12 +-
 packages/dashboard/src/gitlab-delete-close.ts      |   3 +
 packages/dashboard/src/gitlab-split-close.ts       |   7 +-
 packages/dashboard/src/project-store-resolver.ts   |   9 +-
 packages/engine/src/project-manager.ts             |   4 +-
 packages/engine/src/project-runtime.ts             |   2 +-
 packages/engine/src/runtimes/in-process-runtime.ts |  17 +-
 packages/engine/src/self-healing.ts                |  27 ++
 35 files changed, 1439 insertions(+), 32 deletions(-)

Fusion-Task-Id: FN-8685
Fusion-Task-Lineage: 63eca9ac-d2af-44b0-ba79-388a950148d3
Co-authored-by: Fusion (runfusion.ai) <noreply@runfusion.ai>
2026-08-01 06:09:04 -07:00
gsxdsm
4f09758dc8 FN-8681: retarget executor step credential instances
Enable executor step sessions to use selected and rotated credential instances.

- Pass task-selected credential instances into step-session execution.
- Re-resolve live credential targets after usage-limit retries using the effective agent runtime configuration.
- Retarget future sessions safely and cover retry behavior.
- Document the runtime behavior and add a patch changeset.

Files changed:
 .changeset/fn-8681-credential-instance-retarget.md |   7 +
 docs/settings-reference.md                         |   7 +-
 .../src/__tests__/step-session-executor.test.ts    | 211 +++++++++++++++++++++
 packages/engine/src/executor.ts                    |  21 ++
 packages/engine/src/step-session-executor.ts       |  94 ++++++++-
 5 files changed, 332 insertions(+), 8 deletions(-)

Fusion-Task-Id: FN-8681

Fusion-Task-Lineage: 99724283-6f5d-4890-b7f8-65af1d88b12c

Co-authored-by: Fusion (runfusion.ai) <noreply@runfusion.ai>
2026-08-01 03:45:59 -07:00
gsxdsm
4009eb34cb FN-8683: remove unreachable SQLite task polling replica
Document PostgreSQL task-deletion observation and remove the obsolete SQLite polling path.

- Remove polling state, replica emissions, and activity-log suppression from TaskStore.
- Retain backend-aware cache warming while documenting the transactional-outbox follow-up.
- Add tombstone and soft-delete abort coverage across core and engine lanes.

Files changed:
 docs/architecture.md                               |   3 +-
 ...tgres-cross-process-task-deleted-observation.md | 128 ++++++++++++++++
 docs/storage.md                                    |   3 +-
 .../task-delete-nonblocking-cleanup.test.ts        |  54 +++++++
 .../task-deleted-polling-replica-tombstone.test.ts |  57 +++++++
 .../task-updated-lanes-emit-surfaces.test.ts       |  26 ----
 packages/core/src/store.ts                         |  13 +-
 packages/core/src/task-store/lifecycle-ops.ts      | 168 ++-------------------
 packages/core/src/task-store/task-artifacts-ops.ts |   4 -
 .../__tests__/executor-soft-delete-abort.test.ts   |  15 ++
 .../src/__tests__/triage-soft-delete-abort.test.ts |  14 ++
 11 files changed, 284 insertions(+), 201 deletions(-)

Fusion-Task-Id: FN-8683
Fusion-Task-Lineage: a052db0c-b6fc-4b05-b6b2-f8217b56ded0
Co-authored-by: Fusion (runfusion.ai) <noreply@runfusion.ai>
2026-08-01 03:24:36 -07:00
gsxdsm
3793b576d8 FN-8673: comment on split source issue closures
Explain GitHub source-issue closures when imported work is split into subtasks.

- carry split closure context through task deletion and triage
- post one explanatory comment before closing source and tracking GitHub issues
- preserve exactly-one-comment behavior when close retries after transient failures
- document split closure behavior and cover source/tracking scenarios

Files changed:
 .changeset/fn-8673-split-close-issue-comment.md    |  7 ++
 docs/settings-reference.md                         |  2 +-
 docs/task-management.md                            |  1 +
 .../task-delete-caller-attribution.test.ts         | 32 +++++++
 packages/core/src/index.ts                         |  2 +-
 packages/core/src/store.ts                         | 10 +--
 packages/core/src/task-delete-attribution.ts       | 16 ++++
 .../core/src/task-store/archive-lifecycle-2.ts     | 14 ++--
 packages/core/src/task-store/archive-lifecycle.ts  |  6 +-
 packages/core/src/types.ts                         | 13 +++
 .../src/__tests__/github-tracking-state.test.ts    | 98 +++++++++++++++++++++-
 packages/dashboard/src/github-tracking-state.ts    | 82 +++++++++++++++---
 packages/engine/src/__tests__/triage.test.ts       |  4 +
 packages/engine/src/triage.ts                      | 10 +++
 14 files changed, 268 insertions(+), 29 deletions(-)

Fusion-Task-Id: FN-8673

Fusion-Task-Lineage: 904c2445-64d9-47b9-b706-f64b23c4e3a6

Co-authored-by: Fusion (runfusion.ai) <noreply@runfusion.ai>
2026-08-01 02:47:25 -07:00
gsxdsm
8a6949dd24 FN-8661: resolve selected credential instances for sessions
Resolve requested provider credential instances before creating agent sessions.

- Thread lane credential instance selections through planning, validation, execution, review, and merge sessions.
- Resolve selected instances into runtime credential stores while retaining provider-default fallback behavior.
- Preserve selected credentials for mission validation, executor retries, and spawned child agents.

Files changed:
 .../fn-8661-credential-instance-resolution.md      |  7 ++
 AGENTS.md                                          |  1 +
 docs/architecture.md                               |  2 +-
 docs/secrets.md                                    |  2 +
 docs/settings-reference.md                         |  1 +
 .../dashboard/src/__tests__/routes-auth.test.ts    | 80 +++++++++++++++++++
 .../dashboard/src/routes/register-model-routes.ts  | 78 +++++++++++++++++++
 .../src/__tests__/agent-session-helpers.test.ts    | 16 ++++
 .../credential-instance-resolution.test.ts         | 49 ++++++++++++
 packages/engine/src/agent-heartbeat.ts             |  1 +
 packages/engine/src/agent-runtime.ts               |  9 ++-
 packages/engine/src/agent-session-helpers.ts       | 67 +++++++++++-----
 packages/engine/src/auth-storage.ts                | 90 ++++++++++++++++++----
 packages/engine/src/executor.ts                    | 29 ++++++-
 packages/engine/src/merger-ai.ts                   |  2 +
 packages/engine/src/merger.ts                      |  5 ++
 packages/engine/src/mission-execution-loop.ts      |  4 +-
 packages/engine/src/pi.ts                          |  7 +-
 packages/engine/src/pr-response-run-ops.ts         |  1 +
 packages/engine/src/reviewer.ts                    |  7 ++
 packages/engine/src/triage.ts                      |  2 +
 21 files changed, 420 insertions(+), 40 deletions(-)

Fusion-Task-Id: FN-8661

Fusion-Task-Lineage: 1e34a3ce-0857-4619-9746-ce0dc12dc2ba

Co-authored-by: Fusion (runfusion.ai) <noreply@runfusion.ai>
2026-08-01 02:05:03 -07:00
gsxdsm
13f7266b67 FN-8670: reuse model runtime fixtures in engine tests
Share a warmed Pi model runtime across engine catalog tests.

- Add an isolated in-memory model registry fixture backed by a per-file shared runtime.
- Warm the runtime before catalog tests and verify custom-provider registry isolation.
- Document the required fixture pattern for real Pi SDK catalog tests.

Files changed:
 docs/testing.md                                    |  1 +
 .../engine/src/__tests__/_model-runtime-fixture.ts | 40 ++++++++++++++++++++++
 .../custom-providers-openai-completions.test.ts    | 15 +++-----
 .../custom-providers-openai-responses.test.ts      | 15 +++-----
 .../src/__tests__/provider-registration.test.ts    | 33 ++++++++++++------
 5 files changed, 73 insertions(+), 31 deletions(-)

Fusion-Task-Id: FN-8670

Fusion-Task-Lineage: 7410d114-1853-44cc-a09b-a997fbc7f119

Co-authored-by: Fusion (runfusion.ai) <noreply@runfusion.ai>
2026-08-01 01:34:43 -07:00
gsxdsm
ebe514c3e4 FN-8677: propagate task update lanes before conversion
Propagate cache-warmed workflow lanes through task updates so synchronous engine consumers support renamed boards.

- Add task lane cache and attach resolved lanes to task:updated metadata.
- Update scheduler, triage, and notification consumers to use carried lanes with bridge-safe fallbacks.
- Cover lane propagation and renamed-lane event behavior with core and engine tests.

Files changed:
 .changeset/fn-8677-manual-merge-hold-lanes.md      |   7 ++
 .changeset/task-updated-carries-lanes.md           |   7 ++
 ...orkflow-ir-readers-always-return-the-default.md |  22 +++++
 .../sync-workflow-ir-second-blocker.test.ts        |  43 +++-----
 .../core/src/__tests__/task-lane-cache.test.ts     |  30 ++++++
 .../task-updated-lanes-emit-surfaces.test.ts       |  92 ++++++++++++++++++
 .../__tests__/task-updated-lanes-payload.test.ts   |  42 ++++++++
 packages/core/src/index.ts                         |   1 +
 packages/core/src/store.ts                         |  36 ++++++-
 packages/core/src/task-lane-cache.ts               |  63 ++++++++++++
 .../core/src/task-store/archive-lifecycle-2.ts     |   3 +
 packages/core/src/task-store/moves.ts              |   1 +
 packages/core/src/task-store/task-artifacts-ops.ts |   1 +
 packages/core/src/task-store/task-update.ts        |   1 +
 packages/core/src/task-store/update-task-deps.ts   |   4 +-
 .../core/src/task-store/workflow-definitions.ts    |  71 +++++---------
 .../__tests__/scheduler-task-updated-lanes.test.ts | 108 +++++++++++++++++++++
 .../task-updated-lanes-bridge-compat.test.ts       |  94 ++++++++++++++++++
 ...task-updated-lanes-engine-emit-surfaces.test.ts | 101 +++++++++++++++++++
 .../src/__tests__/triage-pause-abort.test.ts       |  22 +++++
 .../src/__tests__/triage-planning-wake.test.ts     |  25 +++++
 .../notification-renamed-lifecycle-columns.test.ts |  84 +++++++++++++++-
 .../__tests__/task-wedge-notification.test.ts      |  19 ++++
 .../src/notification/notification-service.ts       |  56 ++++-------
 packages/engine/src/scheduler.ts                   |  62 +++---------
 packages/engine/src/triage.ts                      | 105 ++++++--------------
 scripts/lib/inert-sync-lane-baseline.json          |   5 +-
 27 files changed, 858 insertions(+), 247 deletions(-)

Fusion-Task-Id: FN-8677

Fusion-Task-Lineage: d8fef9db-0f88-4dfd-9813-be25e10e3588

Co-authored-by: Fusion (runfusion.ai) <noreply@runfusion.ai>
2026-08-01 01:15:10 -07:00
gsxdsm
5f12044168 FN-8652: add multiple provider credential instances
Enable operators to create, select, and remove named credentials for each supported provider.

- Add provider-auth instance discovery and credential mutation endpoints.
- Add dashboard authentication controls, status handling, and instance coverage.
- Document instance behavior and add a release changeset.

Files changed:
 .changeset/fn-8652-provider-credential-instances.md       |   7 +
 docs/secrets.md                                    |   2 +
 docs/settings-reference.md                         |   4 +
 packages/dashboard/app/api.ts                      |   1 +
 packages/dashboard/app/api/provider-status.ts      |  94 +++++-
 .../dashboard/app/components/SettingsModal.tsx     | 138 ++++-----
 .../AuthenticationSection.instances.test.tsx       |  75 +++++
 .../settings/sections/AuthenticationSection.css    |  13 +
 .../settings/sections/AuthenticationSection.tsx    | 199 +++++++-----
 .../dashboard/src/__tests__/routes-auth.test.ts    |  27 +-
 packages/dashboard/src/routes.ts                   |  12 +-
 .../dashboard/src/routes/register-auth-routes.ts   | 334 ++++++++++++++++++---
 .../src/__tests__/provider-auth-instances.test.ts  |  65 ++++
 packages/engine/src/provider-auth.ts               |  89 ++++++
 14 files changed, 845 insertions(+), 215 deletions(-)

Fusion-Task-Id: FN-8652

Fusion-Task-Lineage: 39568d58-7f57-4d17-97cb-1837323b3a94

Co-authored-by: Fusion (runfusion.ai) <noreply@runfusion.ai>
2026-08-01 01:07:59 -07:00
gsxdsm
1e83dcceec chore(release): v0.74.0-beta.6
Version bump via changesets.
2026-08-01 00:55:04 -07:00
gsxdsm
9b82ff29e1 fix: enforce active capacity and clarify queued cards
Refresh canonical live-task claims at serialized scheduler, planning, and merge admission boundaries, including workflow-step leases and reservation handoffs. Back off capacity-denied merges safely across abort and restart lifecycles. Render queued planning cards in the header badge family with compact reason-specific icons.
2026-08-01 00:32:25 -07:00
gsxdsm
dd569395e8 FN-8671: isolate triage admission state in tests
Prevent leaked singleton admission state from affecting later triage polling tests.

- Add test-only coordinator reset and inspection seams for all admission categories.
- Stop tracked triage processors before clearing shared reservation and pre-held-slot state.
- Cover teardown behavior and document singleton-state isolation guidance.

Files changed:
 docs/testing.md                                   |  6 ++
 packages/engine/src/__tests__/concurrency.test.ts | 56 ++++++++++++++++
 packages/engine/src/__tests__/triage.test.ts      | 82 ++++++++++++++++++++---
 packages/engine/src/concurrency.ts                | 30 +++++++++
 4 files changed, 166 insertions(+), 8 deletions(-)

Fusion-Task-Id: FN-8671

Fusion-Task-Lineage: 41217db4-1fd6-45d6-a846-c57fc3c7052e

Co-authored-by: Fusion (runfusion.ai) <noreply@runfusion.ai>
2026-08-01 00:14:32 -07:00
gsxdsm
713e9320b0 fix(engine): enforce capacity for workflow continuations
Route durable planning and review continuations through shared project admission, retain reservations through execution, and prevent duplicate continuations from releasing another run's slot.
2026-07-31 23:33:47 -07:00
gsxdsm
897cce9d94 FN-8656: resolve scheduler lanes for renamed holds
Resolve scheduler lane lookup against workflow-defined hold and terminal columns.

- Use asynchronous workflow lane resolution after the synchronous event prologue
- Preserve legacy lane fallback and recognize all terminal workflow columns
- Update scheduler regression coverage, sync-lane guardrails, and release notes

Files changed:
 .changeset/fn-8656-scheduler-renamed-hold-lanes.md |   7 ++
 .../sync-workflow-ir-callsite-allowlist.test.ts    |  10 +-
 .../scheduler-renamed-hold-events.test.ts          |  20 ++--
 ...ow-scheduler-parked-columns-live-e2e.pg.test.ts |  13 ++-
 ...-sync-role-conversion-inert-live-e2e.pg.test.ts |   8 +-
 packages/engine/src/scheduler.ts                   | 121 +++++++++------------
 scripts/check-inert-sync-lane-conversions.mjs      |   5 +
 scripts/lib/inert-sync-lane-baseline.json          |   3 +-
 8 files changed, 92 insertions(+), 95 deletions(-)

Fusion-Task-Id: FN-8656

Fusion-Task-Lineage: 389a95a1-289f-4dde-86b3-1e450f8d43db

Co-authored-by: Fusion (runfusion.ai) <noreply@runfusion.ai>
2026-07-31 22:19:32 -07:00
gsxdsm
dcf1b921a3 fix(engine): close active-slot reservation handoff gaps 2026-07-31 22:10:14 -07:00
gsxdsm
5a19d1da6e fix: count only actively running tasks against worktree capacity
Retained directories on queued, paused, blocked, or terminal tasks no longer
consume scheduler slots. Agent concurrency and worktree capacity now count the
same canonical live-task population through one project admission ceiling
(resolveActiveTaskCapacityLimit) with an atomic reserveIfAvailable claim, so
planning, execute, and merge lanes cannot each observe and claim the final
worktree slot independently.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-31 22:07:05 -07:00
gsxdsm
182e3fdbe8 FN-8651: add named provider credential instances
Add provider-instance identity and auth.json storage for multiple credentials per provider.

- Export provider-instance key parsing, validation, and reserved metadata helpers.
- Resolve, list, mutate, and select named credential instances atomically in auth storage.
- Preserve legacy bare-key hydration and document the auth.json instance contract.
- Cover provider instance parsing, storage behavior, and concurrent writes.

Files changed:
 .changeset/fn-8651-provider-instances.md           |   7 +
 docs/secrets.md                                    |   8 +
 .../src/__tests__/oauth-credential-interop.test.ts |  16 ++
 packages/core/src/index.ts                         |  16 ++
 packages/core/src/oauth-credential-interop.ts      |  15 +-
 packages/core/src/provider-instance.test.ts        |  24 +++
 packages/core/src/provider-instance.ts             |  65 +++++++
 .../src/__tests__/auth-storage-concurrency.test.ts |  13 ++
 .../src/__tests__/auth-storage-instances.test.ts   |  75 ++++++++
 packages/engine/src/auth-storage.ts                | 214 +++++++++++++--------
 10 files changed, 367 insertions(+), 86 deletions(-)

Fusion-Task-Id: FN-8651

Fusion-Task-Lineage: cfabe496-60f9-4166-a09f-87ea2028cfd9

Co-authored-by: Fusion (runfusion.ai) <noreply@runfusion.ai>
2026-07-31 21:56:30 -07:00
gsxdsm
a3c0501822 fix(engine): unblock retained worktree dispatch
Allow queued tasks to reuse worktrees they already hold when the durable worktree ledger is at or above capacity. Preserve independent agent and semaphore limits, and avoid releasing a worktree slot that a rejected transfer never acquired.
2026-07-31 21:21:28 -07:00
gsxdsm
408e558f54 FN-8648: audit sync workflow resolver test fixtures
Audit workflow resolver test fixtures so they reflect authoritative async resolution and document intentional sync coverage.

- Remove redundant synchronous resolver fixtures from async workflow tests.
- Preserve and document the scheduler fixture that exposes the known synchronous listener defect.
- Clarify the deliberate default-workflow sync contrast and strengthen recovery fixture intent.

Files changed:
 .../executor-planner-lanes-resolved.test.ts        | 45 +++++-----------------
 .../src/__tests__/planner-lane-resolution.test.ts  | 11 +++---
 .../planner-lanes-async-resolution.test.ts         |  9 ++++-
 .../recover-approved-intake-post-u11.test.ts       | 11 +++---
 .../scheduler-renamed-hold-events.test.ts          |  9 +++++
 .../__tests__/triage-release-renamed-hold.test.ts  |  6 ++-
 .../triage-undeclared-column-rescue.test.ts        | 11 +++---
 packages/engine/src/__tests__/triage.test.ts       | 23 +++++------
 8 files changed, 56 insertions(+), 69 deletions(-)

Fusion-Task-Id: FN-8648

Fusion-Task-Lineage: c75fe9ca-30a3-467e-9268-f8d6d95c49e7

Co-authored-by: Fusion (runfusion.ai) <noreply@runfusion.ai>
2026-07-31 19:26:23 -07:00
gsxdsm
7bdeaa8b0c fix(engine): the new worktree ledgers count terminal lanes by NAME — renamed boards stall (#3296)
## Census

**Before: `COLUMN guards (the backlog): 2`, `--strict` RED. After:
`BACKLOG ZERO`, all five gates green.**

Two commits from last night's `maxWorktrees` rollout copied the same
holder ledger, both with literals:

| commit | file | gate |
|---|---|---|
| `374956ef23` | `triage.ts` | planning admission |
| `6c7467a78d` | `executor.ts` | `fn_spawn_agent` |

```ts
t.column !== "done" && t.column !== "archived"
```

## What it costs

Both exclude terminal lanes because a finished card's worktree is
**cleanup-owned, not capacity**. On a renamed board neither literal
matches, so every finished card keeps counting as a live holder. The
count only grows, the gate reaches zero room on a board with free slots,
and planning admission is withheld forever / every spawn is refused.

That is the **mirror** of the breach these commits fixed, and strictly
worse: 8 planners on a 4-slot board is visible; a permanent stall is
silent. The recorded reason even names the worktree budget, which the
operator then checks and finds has room.

## The conversion

`resolveProjectColumnsForRoles(store, ["complete", "archived"])` —
project-level, because the ledger spans the whole board with no single
task to resolve against. Matches triage's existing use in
`sweepStalePlanningStatuses` and executor's at the wip gates.
Legacy-seeded, so a default board still excludes exactly `done` and
`archived` — byte-identical there.

## Both conversions were UNCOVERED when written

Measured with #3214's blinding procedure **before** writing tests:
reverting either to the literals left **all 19 tests in the capacity
suites green**. Nothing in the tree could tell the conversion from what
it replaced — which is how the literals got there in the first place.

Each now has a renamed-board case that fails when blinded:

```
triage    converted 2 passed  |  BLINDED 1 failed | 1 passed  |  restored 2 passed
executor  converted 8 passed  |  BLINDED 1 failed | 7 passed  |  restored 8 passed
```

## The pairing earned itself immediately

Both new cases assert an **absence** (no throttle / no refusal), so each
is paired with a positive proving the gate still fires on the same
renamed board when a card genuinely holds the last worktree.

That caught a real defect in my own fixture: the candidate scan resolves
each task's **own workflow selection**, not `listWorkflowDefinitions`,
so my first version fell back to the default board where `drafting`
isn't a hold lane. No card was eligible, nothing throttled, and the
absence assertion **passed for the wrong reason**. The positive failed
and exposed it. Recorded at the fixture so the next reader doesn't
reintroduce it.

## Verification

```
42 tests across 6 capacity suites             pass
check-fnxc-future-dates                       green
check-inert-sync-lane-conversions             green
check-lane-wiring                             green
check-sql-column-literals                     green
census --strict                               green   (BACKLOG ZERO restored)
```

No changeset: internal engine fix, no published-package surface change.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-31 19:16:07 -07:00
gsxdsm
69bc9fc7ab fix(engine): near-duplicate check runs before planning for imported issues
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-31 18:53:38 -07:00
gsxdsm
c19bec3752 fix(fnxc): two scheduler stamps to their authoring commits' real times (10 days and 1 day off) (#3294)
Last loose thread from the 2026-07-31 stamp-repointing wave. Two comment
lines.

```
line 1027  ConcurrencyAdmission      2026-07-31-09:00  ->  2026-07-21-22:30   (eef5eb751e)
line 1471  WorkflowLifecycleColumns  2026-07-31-05:00  ->  2026-07-30-20:55   (109204c590)
```

## Not a revert — neither value was ever right

| stamp | originally | after #3280 | authoring commit (UTC) |
|---|---|---|---|
| `ConcurrencyAdmission` | `2026-08-06-09:00` (16 days ahead) |
`2026-07-31-09:00` (10 days late) | **2026-07-21 22:30** |
| `WorkflowLifecycleColumns` | `2026-08-01-05:00` (~1.5 days ahead) |
`2026-07-31-05:00` (~1 day late) | **2026-07-30 20:55** |

Both were written **ahead of their own commits** to begin with. Three
lanes then repointed stamps to turn `main` green (#3261, #3269, #3280),
moving the **date** back a day while keeping the clock time — which
converts an hours-off stamp into a days-off one in the opposite
direction. #3282 reverted the batch it owned; these two were outside its
scope.

So restoring the originals would be wrong too. The defensible values are
the authoring commits' UTC timestamps, per the `date -u` rule #3281
settled.

## Why now

`scheduler.ts` is a hot file. This survived two successive claimants — I
flagged it on #3262 and again on #3288 rather than opening a conflicting
PR, and said I'd take it once the file was unclaimed.
`check-file-claimed` now reports UNCLAIMED, so here it is.

## Scope

The gate is **green either way** — #3277 fixed the comparison, so
nothing is blocked by this. It is purely about the FNXC trail recording
when the work actually happened, which is the only reason the trail
exists. A stamp that satisfies a check while misstating the date by ten
days is worse than no stamp.

## Verification

```
check-fnxc-future-dates           green
check-inert-sync-lane-conversions green
check-lane-wiring                 green
check-sql-column-literals         green
census --strict                   green
```

Diff is two comment lines — no executable change. No changeset.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-31 18:51:50 -07:00
gsxdsm
6c7467a78d fix(engine): spawned children gate on maxWorktrees too — the spawn note promised both dimensions
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-31 18:43:37 -07:00
gsxdsm
374956ef23 fix(engine): planning admission respects maxWorktrees — the merge-drain freeze was masking the missing gate
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-31 18:39:40 -07:00
gsxdsm
42a2699b9a test(scheduler): pin the worktree-capacity arithmetic — both failure directions (#3288)
## What

Pins the **worktree-capacity arithmetic** — the gap #3262 measured,
named, and explicitly left for someone to claim. Two commits: a
behaviour-preserving seam extraction, then the test.

#3262's own scope note:

> blinding this predicate to `false` leaves all 22 scheduler suites
green (365 tests). The capacity logic it feeds has no behavioural
coverage at all.

## Two live defects, opposite directions

Both came out of these few lines:

- **UNDER-COUNT admits work over the cap.** `maxWorktrees=4`, four
planning sessions each holding a worktree, and a replan dispatch
admitted as the **fifth** — the ledger counted WIP cards only and never
learned to count planners.
- **OVER-COUNT self-deadlocks.** A planned Ready card *retains* its
planning worktree for execution reuse, so counting it as a holder blocks
its own release: `2 wip + 3 idle-held = 5/4`, and the first unpause
released 2 of 4 slots' worth of work.

**Both are pinned, and the asymmetry is why.** Under-counting breaks the
cap and lets real work over it; over-counting only starves dispatch. A
test covering the "safe" direction alone would leave the expensive one
open.

## Mutation-tested — all four caught

| mutation | result |
|---|---|
| drop the terminal exclusion | 1 failed / 7 passed |
| count WIP cards twice | 2 failed / 6 passed |
| count cards holding no worktree | 1 failed / 7 passed |
| drop the self-slot subtraction | 1 failed / 7 passed |

```
clean:            8 passed (8)
scheduler suite:  16 files / 151 tests passed  (behaviour preserved by the extraction)
typecheck, lint:  clean
```

## Scope, stated rather than implied

The terminal predicate is **injected**, not resolved here. Which lanes
are terminal is #3262's test; resolving it in this file would make it
fail for that reason instead of this one. This pins the **set
arithmetic** — who is excluded, and how the total is formed.

Still not covered, and I am not claiming otherwise: the *stateful* half
of the ledger — the `+= 1` on dispatch and the `Math.max(0, … - 1)` on
failure inside `schedule()`'s loop. Extracting that would mean
restructuring dispatch itself, which is a different change from this
one.

## Process note

I claimed this on #3262 **before** starting rather than after, because
`scheduler.ts` is the hottest file in the tree and I produced three
duplicate PRs earlier tonight by picking up small shared-surface work
someone else already had in flight. Announcing first cost one comment;
the duplicates cost three PRs and two closes.


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **Bug Fixes**
* Improved scheduler capacity calculations for tasks that retain
existing worktrees.
  * Prevented WIP tasks from being counted twice.
  * Excluded completed and worktree-less tasks from reserved capacity.
* Corrected candidate capacity calculations when no worktree capacity is
reserved.

* **Tests**
* Added coverage for worktree reservation totals and candidate reuse
scenarios.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-07-31 18:33:41 -07:00
gsxdsm
6834ba35bd fix(engine): hung-pass watchdogs on scheduler, merge queue, and continuation drain
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-31 18:19:17 -07:00