Commit Graph

2703 Commits

Author SHA1 Message Date
gsxdsm
bbac132d71 Merge pull request #1708 from Runfusion/gsxdsm/slow-tests
fix: keep Fusion test verification bounded
2026-06-21 11:08:02 -07:00
gsxdsm
21df96cfbb fix(FN-5048): address PR feedback on test verification
Fusion-Task-Id: FN-5048
2026-06-21 10:53:08 -07:00
gsxdsm
03af93eb3a fix(FN-5048): direct agent + tool verification away from full workspace suite
Tighten the executor agent guidance and the fn_run_verification tool guidance so
verification stays scoped to changed files instead of running the full workspace
test suite, which (for a foundational-package edit) reverse-expands across the
whole workspace and stalls the task.

- agent-prompts.ts: remove the "during final integration" blanket permission to
  run workspace-wide suites; name the forbidden full-run commands explicitly.
- run-verification-tool.ts: strengthen BOUNDED_VERIFICATION_GUIDANCE to forbid
  `pnpm test:full` / `pnpm verify:workspace` / whole-package runs as verification.

Engine + core typecheck pass; run-verification-command and executor-review-verdicts
prompt-assertion suites stay green (93 tests).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-21 10:50:48 -07:00
gsxdsm
bc1c7db4bc Merge pull request #1707 from Runfusion/gsxdsm/engine-worklow
fix(engine): preserve task progress when a single-session run is hard-cancelled (FN-6722)
2026-06-21 10:42:55 -07:00
gsxdsm
ce90cc9b62 fix(FN-5048): keep Fusion test verification bounded 2026-06-21 10:05:12 -07:00
gsxdsm
e6503ca872 Address PR review feedback (#1707)
- Read hasResumableProgress from latestTask (the store snapshot fetched
  at ~9226), not the frozen dispatch-time task param, so a freshly
  dispatched task that commits step progress mid-session is preserved on
  a hard-cancel teardown — not just the re-dispatch case (greptile P1)
- Add companion regression test for the fresh-task-with-in-session-progress
  case, which fails against the stale-task snapshot (greptile P1)
- Reformat the requirement comment block to the canonical FNXC heading
  (FNXC:WorkflowLifecycle yyyy-MM-dd-hh:mm:) convention (CodeRabbit)

Fusion-Task-Id: FN-6722

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-21 09:59:26 -07:00
gsxdsm
93017a3c4a fix(engine): preserve task progress when a single-session run is hard-cancelled
When the engine aborted in-flight work mid-execution and bounced the task
back to `todo`, the single-session teardown cleared the task `branch` and
re-queued without `preserveResumeState` — resetting every step to `pending`
(store.moveTaskInternal resetAllStepsToPending) and dropping the pointer to
the commits already on the task branch. The next dispatch then re-planned
from Step 0 and the committed work was stranded, observed as FN-6722 losing
all its progress and getting stuck in todo.

The teardown now keeps the branch and moves with `preserveResumeState`
whenever the task has resumable step progress, matching the sibling
step-session (executor ~8065) and pause-park (executor ~1826) paths, so
execute() resumes onto the existing branch from the first incomplete step.
The worktree is still removed to free its concurrency slot (FN-6782) — only
the durable pointers (branch + step state) are kept.

Adds a regression test driving the exact single-session catch teardown.

Fusion-Task-Id: FN-6722

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-21 09:41:51 -07:00
gsxdsm
7e478fb473 Merge pull request #1703 from Runfusion/gsxdsm/workflow-optional-steps
feat(dashboard): workflow optional steps — authoring, full-modal parity, stepwise seam
2026-06-21 09:04:39 -07:00
gsxdsm
c7b56a5ab7 FN-6832: preserve default workflow routing
Preserve the default workflow unless users explicitly request workflow routing changes.

- Update triage and fast-planning prompt guidance to stop inferring alternate workflows from task type or no-commit markers.
- Refresh workflow docs and prompt tests to assert explicit-request-only workflow selection.
- Add a patch changeset for the published CLI package.

Files changed:
 .changeset/fn-6832-workflow-routing.md               |  5 +++++
 docs/workflow-steps.md                               |  5 ++++-
 packages/core/src/agent-prompts.ts                   | 20 +++++++++++++-------
 .../src/__tests__/triage-threshold-settings.test.ts  |  7 +++++--
 packages/engine/src/__tests__/triage.test.ts         | 13 +++++--------
 5 files changed, 32 insertions(+), 18 deletions(-)

Fusion-Task-Id: FN-6832

Fusion-Task-Lineage: 5a7ad103-2081-4c4c-ac32-fd5e4f6adfda
2026-06-21 09:00:40 -07:00
gsxdsm
fbce59b707 FN-6777: add artifact registry storage
Add a core artifact registry for storing metadata and task-scoped artifact payloads.\n\n- Add artifact types, schema, migrations, store APIs, and exports for registering/listing artifact metadata.\n- Persist binary artifact payloads under task or project artifact directories and hydrate artifacts during worktree acquisition.\n- Cover registry behavior, DB schema, and worktree hydration with tests and document storage semantics.\n\nFiles changed:\n .changeset/fn-6777-artifact-registry.md            |   5 +\n docs/storage.md                                    |   8 +\n packages/core/src/__tests__/artifacts.test.ts      | 257 +++++++++++++++++++++\n packages/core/src/__tests__/db.test.ts             |   5 +\n packages/core/src/db.ts                            |  59 ++++-\n packages/core/src/index.ts                         |   2 +-\n packages/core/src/store.ts                         | 220 +++++++++++++++++-\n packages/core/src/types.ts                         |  75 ++++++\n .../engine/src/__tests__/executor-test-helpers.ts  |   1 +\n .../engine/src/__tests__/executor-worktree.test.ts |   2 +\n .../__tests__/worktree-acquisition-backend.test.ts |   2 +-\n .../worktree-acquisition-secrets-env.test.ts       |   2 +-\n .../worktree-acquisition-worktrunk.test.ts         |   2 +-\n .../src/__tests__/worktree-acquisition.test.ts     |   2 +-\n .../src/__tests__/worktree-db-hydrate.test.ts      |  59 +++++\n packages/engine/src/worktree-acquisition.ts        |   2 +-\n packages/engine/src/worktree-db-hydrate.ts         |  42 +++-\n 17 files changed, 732 insertions(+), 13 deletions(-)

Fusion-Task-Id: FN-6777

Fusion-Task-Lineage: 42cdcdcf-6388-42fe-8de1-6857ef20839d
2026-06-21 09:00:40 -07:00
gsxdsm
cc26b333ce FN-6856: restrict executor full-suite testing
Clarify executor verification guidance so agents default to targeted tests and reserve full workspace suites for explicit opt-in.

- Update canonical executor prompts to prohibit full/workspace-wide test suites as the normal verification path.
- Preserve workspace lint/build/typecheck gates while requiring targeted test verification unless task or workflow instructions opt in.
- Extend executor prompt coverage to assert the full-suite restriction and allowFullSuite opt-in language.

Files changed:
 packages/core/src/agent-prompts.ts                            | 11 ++++++++---
 .../engine/src/__tests__/executor-review-verdicts.test.ts     |  5 ++++-
 packages/engine/src/executor.ts                               | 11 ++++++++---
 3 files changed, 20 insertions(+), 7 deletions(-)

Fusion-Task-Id: FN-6856
Fusion-Task-Lineage: 78d698df-9e85-4371-bf59-af27e64e3069
2026-06-21 09:00:40 -07:00
gsxdsm
fa9a3cc52f Address PR review feedback (#1704): clear stale external marker on acquire
Move externalEngines.delete(projectId) to immediately after acquiring the
singleton lock instead of after engine.start() succeeds. If a project was
marked external, the holder exits, acquire succeeds, but start() then throws,
the success-path delete never ran and hasRunningEngine() reported a phantom
engine forever. Added a regression test for the failed-takeover path.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-21 03:32:53 -07:00
gsxdsm
0a49023f0b Address PR review feedback (#1704)
- Stop reconciliation/startAll/onProjectAccessed from warning every tick for
  externally-owned engines: swallow EngineAlreadyRunningError in the outer
  catches (it's expected and already logged once in createAndStart)
- Add FNXC:DashboardHealth requirement-trace comments on the externalEngines
  field and the dashboard hasRunningEngine health check
- Add regression test: reconciliation stays quiet across ticks for an
  externally-owned engine (inner refusal logged once, outer failure suppressed)
- Add regression test: hasDashboardEngine legacy fallback to getAllEngines when
  hasRunningEngine is unavailable on the manager

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-21 03:29:47 -07:00
gsxdsm
7635ba8682 fix: report engine available when another fusion process owns it
The dashboard's engine-availability health check only counted engines
this process started. A second launch (e.g. `pnpm dev dashboard`
alongside an already-running `fusion`) is correctly refused the
per-machine engine singleton lock, so its engine map stays empty and
the dashboard showed a false "engine not running" banner even though an
engine was live on the machine.

ProjectEngineManager now records projects whose singleton lock is held
by another process (via EngineAlreadyRunningError) and exposes
hasRunningEngine(), which the health endpoint consults so the banner
reflects machine-level truth. Reconciliation still retries so this
process takes over if the other exits, and the "refusing to start" log
fires once per project instead of on every 30s reconciliation tick.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-21 03:09:35 -07:00
gsxdsm
222e781dc0 Merge pull request #1702 from vamsi-ship-it/fix/anthropic-compatible-custom-provider-api-key
fix(engine): map anthropic-compatible custom providers to anthropic-messages api
2026-06-21 02:23:11 -07:00
gsxdsm
46e52b2c23 Merge pull request #1697 from Runfusion/fix/engine-pause-resume-auto-continue
fix(engine): auto-continue agent session after engine-internal pause/resume abort
2026-06-21 02:14:18 -07:00
gsxdsm
eafe6f7b28 Merge pull request #1696 from Runfusion/gsxdsm/ce-workflow-skill-loading
fix: make the compound-engineering workflow actually load skills and run the full CE flow
2026-06-21 02:04:17 -07:00
gsxdsm
adc8884219 Update packages/engine/src/executor.ts
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
2026-06-21 02:03:27 -07:00
vamsi-ship-it
efd3743624 fix(review): address CodeRabbit feedback on anthropic-compatible fix
- Add JSDoc to resolveCustomProviderApiType (docstring coverage + AGENTS.md
  jsdoc convention) and convert the inline rationale to FNXC format.
- FNXC-format the test rationale comment.
- Strengthen the regression test per FN-5893 (fix the invariant, not the repro):
  - negative assertion that no provider is ever registered with the bare
    "anthropic" api key;
  - assert every api key passed to registerProvider is one pi-ai's registry
    actually registers, so a typo in any arm (not just anthropic) fails here.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-21 14:30:04 +05:30
vamsi-ship-it
5a422b0c46 fix(engine): map anthropic-compatible custom providers to anthropic-messages api
resolveCustomProviderApiType mapped the `anthropic-compatible` provider type
to the api key "anthropic", but pi-ai (@earendil-works/pi-ai) registers the
Anthropic Messages API under "anthropic-messages". Any custom provider
configured as anthropic-compatible selected a model whose `api` did not match
a registered provider, throwing "No API provider registered for api: anthropic"
at stream time (the model registered fine, but failed when a task tried to
stream).

The openai-responses and default (openai-completions) arms already map to real
registry keys and work; only the anthropic arm pointed at an unregistered key.

Extend the existing custom-provider registration test (which covered
openai-compatible and openai-responses but not anthropic-compatible) with a
regression assertion that anthropic-compatible maps to "anthropic-messages".

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-21 13:52:47 +05:30
gsxdsm
92bd060b9b Address PR review feedback (#1697)
- Add fire-time safety guard tests: assert auto-continue aborts when the task
  becomes paused, user-paused, moved out of todo, or deleted during the backoff
  window (greptile P1 / coderabbit) — previously the guard was untested.
- Split the user-pause/global-pause negative test into it.each so a failure
  names the offending case (greptile P2).
- Document that the exhausted-retry fallback leaves the shared graphResumeRetryCount
  budget at MAX and that it cross-drains with the transient-resume path (greptile P2).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-21 00:28:03 -07:00
gsxdsm
40cea655b8 Merge main into validator behavioral verification
Resolve conflicts from main's analytics schema additions (plugin
activations, per-model token buckets) against the PR's contract-assertion
type column:
- db.ts: renumber behavioral-verification migration 124 -> 126, bump
  SCHEMA_VERSION to 126 so it follows main's migrations 124/125
- core/roadmap tests: adopt main's SCHEMA_VERSION-constant assertions
  instead of stale literal 124
- test-quarantine.json: keep all four quarantine entries from both sides

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-21 00:22:19 -07:00
gsxdsm
7235b25fb8 Address PR review feedback (#1696)
- step() test helper now carries skillName, so the WS-6 round-trip fixture
  actually exercises the INVERSION CONTRACT for skillName (was silently dropped).
- executeWorkflowStep now strips an inherited FUSION_HEADLESS on board runs
  (unattended=false), preserving the U3 default-safe invariant — a board step
  nested under a headless-env parent could otherwise skip user questions.
  Added a regression test for the inherited-env strip.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-21 00:07:20 -07:00
gsxdsm
d4e91d4597 feat(core): add workflow-step seam + browser-verification optional step to stepwise workflow
The stepwise-coding IR had no workflow-step seam node, so a per-task
enabledWorkflowSteps entry (e.g. browser verification) would never execute.
Add the seam node on the success path (steps -> workflow-step -> review,
once post-foreach) and declare browser-verification as an optional step,
matching the coding workflow. Covers the dead-toggle gap with resolver and
engine execution-divergence tests.
2026-06-21 00:02:31 -07:00
gsxdsm
c8a82e795b fix(engine): auto-continue agent session after engine-internal pause/resume abort
When the engine hard-cancels in-flight work during a pause/resume cycle and the
workflow graph run ends with the task re-queued to `todo`, the executor used to
leave it for a fresh scheduler dispatch and fire a spurious failure
notification. It now continues the agent session in place via a bounded internal
retry (reusing the graph-resume retry budget + backoff), falling back to the
benign todo re-queue only after retries are exhausted.

- Scoped strictly to engine-internal aborts via a typed `isEngineInternalAbort`
  discriminant; genuine user/global/task pauses are never auto-resumed.
- Re-checks the task at retry fire time and aborts the auto-continue if it was
  paused, moved, or deleted during the backoff window.
- Clears any stale `failed` status and emits an `Auto-recovered:` log so the
  deferred failure notification is suppressed.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-20 23:49:57 -07:00
gsxdsm
a768d36dae FN-6817: root reliability fixtures under worker temp
Reliability interaction fixtures now stay inside the Vitest worker temp root to avoid merge-reuse worktree collisions.

- Add a helper that prefers FUSION_TEST_WORKER_ROOT for reliability fixture roots.
- Verify fixture git initialization before tests use generated repositories.
- Clean up the paired worktree root during fixture teardown.
- Cover the worker-root placement and worktree-root cleanup behavior in the merge runner preflight test.

Files changed:
 .../__tests__/reliability-interactions/_helpers.ts | 21 ++++++++++++-
 .../merge-runner-spawn-enoent-prevention.test.ts   | 35 ++++++++++++++++++++--
 2 files changed, 53 insertions(+), 3 deletions(-)

Fusion-Task-Id: FN-6817

Fusion-Task-Lineage: dd5c5e7b-c7cd-42be-971d-7527c2334f36
2026-06-20 23:32:25 -07:00
gsxdsm
c0f330e70c fix(review): apply autofix feedback
Address confirmed code-review findings on the CE workflow-step change:
- Graph-path spawn lifecycle (adversarial A-1/A-2): the graph path returns from
  execute() before its outer finally that calls terminateAllChildren, so U8's new
  coding-mode fn_spawn_agent children orphaned their sessions/worktrees and their
  ids accumulated in the per-parent spawn budget, starving later steps' fan-out.
  Call terminateAllChildren in maybeExecuteWorkflowGraph's finally (mirrors the
  non-graph cleanup).
- INVERSION CONTRACT parity (api-contract AC-2 + testing TF-001): add skillName to
  the workflow-steps-to-ir round-trip projections + a skill-step fixture, so the
  contract the comment claims is actually asserted.
- Silent skill-load degradation (adversarial A-3 / Risk-4): warn when a step names
  a skill but FUSION_CE_SKILLS_DIR is unset, instead of failing silent.
- Dead branch (maintainability M-01): drop the always-false unattendedRun guard;
  keep the delete + extension-point comment.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-20 23:16:12 -07:00
gsxdsm
c8f97df34a test(engine): cover graph-step skill loading, preamble, spawn gating, headless, verdict (U6)
Two engine tests for the new compound-engineering workflow-step wiring:
- conventions: assert the exported preamble carries the await-input sentinel,
  FUSION_HEADLESS degrade, and path-confined persona/systemPromptOverride fan-out.
- executor: drive runGraphCustomNode + executeWorkflowStep and assert skillName is
  carried onto the synthesized step, requestedSkillNames merges bare+namespaced with
  additionalSkillPaths=[FUSION_CE_SKILLS_DIR], fn_spawn_agent present only in coding,
  FUSION_HEADLESS only when unattended, and the verdict-JSON contract is required
  only for gate/skill-less steps (relaxed for non-gate skill steps).

Session layer is mocked (asserts engine-owned wiring, not a model run); a full
model-driven e2e remains a documented residual.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-20 23:00:18 -07:00
gsxdsm
b564ee006c feat(engine): load CE skills + spawn + conventions on the graph-step path (U8/U1/U2/U3/U9)
The builtin compound-engineering workflow runs via runGraphCustomNode, which
never loaded the named skill or threaded the plugin-injected runtime env, and
fn_spawn_agent was registered only in the main session. This wires the real seam:

- U8: thread injected FUSION_CE_* env into skill/model graph steps (shared
  buildInjectedRuntimeEnv helper); register createSpawnAgentTool for coding-mode
  skill steps (readonly still strips spawn).
- U1: merge the step's skillName (namespaced + bare) into requestedSkillNames and
  pass FUSION_CE_SKILLS_DIR as additionalSkillPaths so the bundled SKILL.md is
  discovered and selected.
- U2: prepend the Fusion workflow-step conventions preamble (await-input sentinel,
  FUSION_HEADLESS degrade, persona fan-out via systemPromptOverride).
- U3: explicit unattended opt-in sets FUSION_HEADLESS=1 (default-safe board run).
- U9: path-confined persona read documented in the preamble; accepted
  write-capability posture documented at the coding-mode tool registration.
- KTD-6: verdict-JSON contract required only for gate / skill-less steps.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-20 22:47:39 -07:00
gsxdsm
7b85fead54 Address code-review findings on pause-abort + task-chat fixes
- Reliability (P3): emit an `Auto-recovered:`-prefixed log on the
  benign-todo stale-failure clear path so NotificationService
  proactively cancels the pending failure timer (recoveredStatus path)
  instead of relying only on the fire-time re-check, which is
  race-contingent when failureNotificationDelayMs is near 0. Scoped to
  the actual-clear path so the common no-failure re-queue isn't
  mislabeled as a recovery.
- Project-standards (P3): add the required yyyy-MM-dd-hh:mm stamp to the
  new FNXC comments (AGENTS.md FNXC_LOG convention).
- Maintainability (P3): extract the scheduler "queued" waiting marker to
  a named SCHEDULER_WAITING_STATUS constant.
- Testing: pin the guard's skip on a clean todo row, assert the
  Auto-recovered log fires on the stale-failure path, and add a
  paused+unassigned in-progress idle case (paused early-return wins over
  the ephemeral active-session path).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-20 20:07:07 -07:00
gsxdsm
2d327604ff Clear stale failed status on benign todo pause-abort
A pause/resume abort parked status:"failed" on an earlier non-todo
observation stays dispatchable (scheduler filters on column+paused, not
status, scheduler.ts:1288) and re-enters the FN-6782 benign-todo branch.
That branch logged "benign" but left status:"failed"/error on the row,
so the board kept showing it failed and the deferred failure
notification fired (notification-service fire-time check sees
status==="failed") — contradicting the benign log. recoverPausedAbortFailures
that would clear it is suppressed during global/engine pause
(self-healing.ts:8125), so the failure survived the pause window.

Reconcile the row with the benign reclassification: clear status/error
when the live row carries them, so the board agrees it's benign and the
pending notification is suppressed at dispatch.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-20 19:47:56 -07:00
gsxdsm
08d1f09107 FN-6796: preserve benign in-review pause aborts
Preserve completed in-review tasks when benign pause/resume aborts surface after executor handoff.

- Detect non-user hard-cancel pause aborts on clean completed in-review rows and clear the transient abort marker without moving the task.
- Let self-healing recover persisted safe in-review pause-abort parks in place while keeping hard-cancel, pause, autoMerge:false, terminal merge, and live-execution guards intact.
- Cover executor and self-healing recovery paths with regression tests, document the audit metadata, and add a patch changeset.

Files changed:
 .../fn-6796-pause-resume-in-review-recovery.md     |  5 ++
 AGENTS.md                                          |  1 +
 docs/architecture.md                               |  2 +
 .../engine/src/__tests__/executor-recovery.test.ts | 97 +++++++++++++++++++++-
 .../active-worktree-removal-liveness.test.ts       |  2 +-
 .../self-healing-paused-abort-recovery.test.ts     | 90 +++++++++++++++++++-
 packages/engine/src/executor.ts                    | 35 ++++++++
 packages/engine/src/self-healing.ts                | 38 +++++++--
 8 files changed, 257 insertions(+), 13 deletions(-)

Fusion-Task-Id: FN-6796

Fusion-Task-Lineage: d2fe6c6d-c118-4f2f-b19e-58e6f1b29384
2026-06-20 15:11:22 -07:00
gsxdsm
7e7eb6299d Harden orphan-worktree/stale-task-dir cleanup (code-review follow-up)
Addresses findings from a multi-agent review of the two prior fixes.

P0 (executor.ts): the stale-conflict recovery force-removed worktreePath with
no bounds check; that path can come from a git admin entry resolving outside
.worktrees/. Now refuses unless the path is inside the worktrees dir, not a
symlink (realpathSync), not a registered worktree, and not actively owned, and
re-verifies liveness in the catch instead of trusting the error string. Also
excludes spawn failures (spawn git ENOENT) from the stale-path classification.

worktree-pool.ts: resolveGitdirPointer -> dotGitPointerIsDangling. Reaps only
when a .git link's gitdir target is confirmed missing; a real .git dir,
unparseable pointer, or any read/stat failure is treated as NOT dangling
(conservative) so a transient read error on a live worktree can't trigger rm.
Drops the string|"directory"|null sentinel union.

core store.ts: bypass the reconcile recency window when the live task table is
empty (corruption/restore: surviving task.json keep old mtimes) and when
fusion.db was auto-recovered on startup, so .recover row loss isn't stranded.
Adds an ignoreRecencyWindow option.

Tests: executor recovery + out-of-bounds refusal, unparseable .git skip,
recency boundary, empty-DB/forced bypass. engine 135 + core 12 green.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-20 12:46:34 -07:00
gsxdsm
61ff17a057 FN-6797: harden in-review dependency rebound audits
Harden in-review dependency drift reconciliation with explicit guarded no-action audit evidence.

- Emit no-action run-audit events when pause, auto-merge, live execution, checkout, or rebound mutation guards prevent an in-review dependency rebound.
- Preserve scheduler dependency satisfaction semantics so in-review dependencies remain non-blocking under merge-request shadow mode without accepted markers.
- Extend regression coverage and run-audit documentation for guarded in-review rebounds.

Files changed:
 .changeset/fn-6797-in-review-dependency-drift.md   |   5 +
 AGENTS.md                                          |   2 +-
 docs/architecture.md                               |   4 +-
 .../in-review-unmet-dependency-reconcile.test.ts   |  18 ++-
 packages/engine/src/__tests__/self-healing.test.ts |  79 +++++++++++--
 packages/engine/src/self-healing.ts                | 129 ++++++++++++++++-----
 6 files changed, 190 insertions(+), 47 deletions(-)

Fusion-Task-Id: FN-6797

Fusion-Task-Lineage: f94c7875-619a-47be-88f5-320a4dda3b34
2026-06-20 10:21:26 -07:00
gsxdsm
438cd75eaf Fix leaked orphan worktree dirs failing execute node
Directories under .worktrees/ that survive with a dangling .git pointer
(present on disk, but their .git/worktrees/<name> admin entry is gone) are
invisible to `git worktree list`/`prune` yet collide with freshly generated
worktree names. The executor's conflict cleanup then fails with
"is not a working tree", failing the workflow graph at node 'execute' after
3 attempts.

- executor.ts: extend FN-4813 stale-conflict recovery to also treat
  "is not a working tree" and ENOENT (not just "validation failed, cannot
  remove working tree") as "no live worktree here" — prune the admin entry,
  force-remove the leftover dir, and proceed with fresh creation.
- worktree-pool.ts: reapOrphanWorktrees skipped any dir on mere .git-file
  presence, contradicting its own documented invariant. Resolve the .git
  pointer and only skip when the gitdir target exists; reap dangling
  pointers like any other orphan so they stop accumulating across runs.
- Tests for both the dangling (reaped) and valid (skipped) .git cases.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-20 09:58:23 -07:00
gsxdsm
d2fc70ac91 FN-6793: enforce dependency gates before review
Dependency gating now blocks executor and review recovery paths when dependencies remain unmet.

- Re-check unmet scheduling dependencies before workflow graph or authoritative executor dispatch and requeue blocked tasks with blockedBy.
- Rebound auto-merge-eligible in-review tasks with live unmet dependencies back to todo while preserving progress, worktree, and resume state.
- Add run-audit documentation, a patch changeset, and regression coverage for executor, scheduler, and self-healing behavior.

Files changed:
 .changeset/fn-6793-dependency-gating.md            |   7 +
 AGENTS.md                                          |   1 +
 docs/architecture.md                               |   2 +
 .../engine/src/__tests__/executor-core.test.ts     |  68 +++++++++
 .../in-review-unmet-dependency-reconcile.test.ts   | 115 +++++++++++++++
 packages/engine/src/__tests__/scheduler.test.ts    |  36 +++++
 packages/engine/src/__tests__/self-healing.test.ts | 159 +++++++++++++++++++++
 packages/engine/src/executor.ts                    |  46 ++++++
 packages/engine/src/self-healing.ts                | 112 +++++++++++++++
 9 files changed, 546 insertions(+)

Fusion-Task-Id: FN-6793

Fusion-Task-Lineage: b209264c-faae-41aa-a024-c33e0d8b61be
2026-06-20 08:13:33 -07:00
gsxdsm
c32c925321 FN-6783: recover orphaned task dirs into the task index
Reconcile on-disk task.json records that are missing from SQLite without resurrecting tombstoned IDs.

- Add TaskStore orphaned task directory scanning with metadata validation, FTS-safe insertion, cache updates, lifecycle events, and run-audit entries.
- Run the reconcile during store init and self-healing maintenance for tasks created after startup.
- Cover recovery, skip, and maintenance behavior with core and engine regression tests.
- Document task index reconciliation and add the published package changeset.

Files changed:
 .changeset/fn-6783-orphaned-task-dir-reconcile.md  |   5 +
 AGENTS.md                                          |   1 +
 docs/architecture.md                               |   2 +
 docs/storage.md                                    |   8 +
 .../store-orphaned-task-dir-reconcile.test.ts      | 179 +++++++++++++++++++++
 packages/core/src/store.ts                         | 170 ++++++++++++++++++-
 .../self-healing-orphaned-task-dirs.test.ts        |  40 +++++
 packages/engine/src/self-healing.ts                |  14 ++
 8 files changed, 412 insertions(+), 7 deletions(-)

Fusion-Task-Id: FN-6783
Fusion-Task-Lineage: 5c8d4690-5278-4c29-8f02-32d9f01d581d
2026-06-20 04:40:31 -07:00
gsxdsm
a63cf1c911 FN-6750: harden task chat steering coverage
Verify task chat timestamps and immediate steering delivery across UI, route, and executor surfaces.

- Assert inline and expanded TaskChatTab timestamp parity for agent output and user steering comments.
- Cover steering route wake payloads so assigned agents receive the newest steering comment id immediately.
- Harden executor real-time steering tests for seen-before-inject ordering, queued prompt delivery, duplicate suppression, and empty-comment no-ops.

Files changed:
 .../app/components/__tests__/TaskChatTab.test.tsx  |  79 +++++++++++-
 .../src/__tests__/routes-tasks-ops.test.ts         | 136 +++++++++++++++++++++
 .../src/__tests__/executor-step-session.test.ts    | 116 ++++++++++++++++--
 3 files changed, 316 insertions(+), 15 deletions(-)

Fusion-Task-Id: FN-6750

Fusion-Task-Lineage: 48e1d57d-fd37-4d45-9b98-766c4a2f704d
2026-06-19 22:24:18 -07:00
gsxdsm
e78853708a Raise min heartbeat staleness floor 5m -> 10m
Agents stop heartbeating during long legitimate work (e.g. a verification
step blocked on a multi-minute test command). The 5-minute floor could
misread a busy agent as dead and reclaim its in-progress task mid-run.
Raise MIN_HEARTBEAT_STALENESS_MS to 10 minutes and strengthen the floor
test (7-minute-silent fast-interval agent stays healthy — would have read
stale under the old 5-minute floor). Engine typecheck clean; heartbeat
suite 148/148 pass.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-19 21:46:00 -07:00
gsxdsm
7f0ad62731 Update executor-recovery test for benign todo pause-abort (FN-6782)
The gate test asserted the OLD behavior — a paused graph exit in the `todo`
column parked `status:"failed"` with "operator action required". FN-6782
made the todo case benign (no failed park; benign log + cleared marker), so
split the parameterized test: `todo` now asserts the benign path (never
parked failed), `done` keeps the operator-action surfacing (log only, no
park). Full engine-core gate suite passes (644/644).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-19 20:53:37 -07:00
gsxdsm
8c93e2ad6b Re-check execution ownership before reaping a leaked slot (PR #1687)
coderabbit Major: reapLeakedConcurrencySlots captured executingIds once
before the loop, but each holder awaits getTask — a task could start
executing mid-sweep and have its worktree slot pulled. Refresh the
executing set immediately before clearPhantomExecutorBinding and skip if
the holder is now executing (same race the A1 recovery fix closed).
clearPhantomExecutorBinding's live-session refusal remains the last line
of defense; this avoids racing it. Added a mid-sweep race test.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-19 20:34:53 -07:00
gsxdsm
7eaf513944 Address PR #1687 review: harden pause-abort recovery + FNXC comments
Substantive (A1 recoverPausedAbortFailures):
- Self-guard on globalPause/enginePaused at method entry (greptile P1) — the
  public method must not requeue tasks an operator intentionally froze.
- Re-validate the FULL predicate with a FRESH executing set on the re-read
  before the backward move (coderabbit Major + greptile): add fresh.userPaused
  and column re-check so a task that became ineligible across awaits is skipped.
- Isolate audit emission in its own try/catch (coderabbit) so an audit throw
  after a successful mutation can't log a false "recovery failed".
- Decouple the recovery predicate from the literal error text via shared
  PAUSE_ABORT_PARK_ERROR_MARKER/OPERATOR_MARKER constants (greptile) — the
  executor builds the parked message from the same constants.
- Use the wired clearPhantomExecutorBinding (live-session-guarded) instead of
  the declared-but-never-wired releaseExecutorWorktreeOwnership, which no-op'd.

Nits:
- FNXC-prefix new comments in executor.ts, run-audit.ts, and the benign test
  per repo comment policy.
- Fix a test-only type error on the clearPhantomExecutorBinding mock.

Added a test asserting the globalPause self-guard. Engine typecheck clean;
pause-abort/reaper/benign + regression suites pass.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-19 20:10:50 -07:00
gsxdsm
8e4b9e4f0f Add leaked-slot reaper (A2) to self-healing
reapLeakedConcurrencySlots() reclaims in-memory worktree slots whose
holder is no longer in-progress (the FN-6756 "in todo yet still a
maxWorktrees holder" leak) without an engine restart — defense-in-depth
behind the source fix.

- executor: new listWorktreeHolders() read-only introspection over
  activeWorktrees; wired through in-process-runtime to SelfHealingManager.
- reaper releases ONLY when every guard agrees: not executing, task
  missing or in todo/triage, past a 60s grace, and clearPhantomExecutor
  Binding itself refuses (returns false) if a live session surface is
  registered — so it can never pull a worktree from a running agent.
- registered in maintenance batch 2 (respects globalPause/enginePaused
  skip + FN-4962 ordering).
- widened the clearPhantomExecutorBinding option type to surface its
  boolean refusal signal.

Engine typecheck clean; 19 tests pass (new reaper 7 cases + regression).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-19 20:03:24 -07:00
gsxdsm
9643563874 Fix pause-abort worktree leak + retry storm; add auto-recovery
A global pause/resume cycle parked tasks that had re-queued to todo as
status:"failed" ("operator action required") and leaked their in-memory
worktree slot. The scheduler kept re-dispatching the todo task, the
genuine-pause-abort branch re-fired on the still-set pausedAborted marker,
and it re-parked instantly with no backoff — a retry storm (75x/hr) that
pinned maxWorktrees=3/3 and concurrency-starved the whole queue.

- R1+R2 (executor.ts handleGraphFailure): treat a pause-abort that left a
  task in `todo` as benign (FN-6782) — don't park failed, clear the
  pausedAborted marker so the next dispatch is clean, and release the
  leaked activeWorktrees slot. Operator-action failure preserved for
  genuinely stranded non-todo columns (FN-6478).
- A1 (self-healing.ts recoverPausedAbortFailures): new maintenance sweep
  that auto-recovers any pause-abort park still on the board and requeues
  it (status:null = schedulable) so the board self-heals.
- run-audit.ts: new mutation types for the recovery telemetry.

Corrected the spec's null-vs-queued assumption: the scheduler dispatch set
is column==="todo" && !paused (scheduler.ts:1288); status:"queued" is the
*blocked* marker, status:null is runnable — so recovered tasks are left null.

Deferred (documented): A2 leaked-slot reaper needs a new executor
listWorktreeHolders introspection API to reap in-memory worktree slots
safely; R1 closes the observed leak at its source.

Tests: self-healing-paused-abort-recovery.test.ts (3),
executor-paused-abort-todo-benign.test.ts (2). Engine typecheck clean;
106 existing pause/graph-failure/limbo tests still pass.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-19 19:50:46 -07:00
copilot-swe-agent[bot]
b0c42974d0 fix(engine): correct parameter order in runVerificationCommand after merge
Reorder backend/timeoutMsOverride params so timeoutMsOverride remains at
position 10 (matching callers in executor.ts, merger.ts from main).
Update mission-verification.ts call sites to pass undefined for
timeoutMsOverride before the isolating backend argument.
2026-06-19 23:50:37 +00:00
gsxdsm
711bf3e1b8 FN-6746: attribute token analytics per runtime model
Persist and expand per-model token usage so Command Center reports every model used by a task.

- Add a nullable per-model token usage column and task model bucket types.
- Merge session token deltas into provider/model buckets while retaining task-level totals.
- Expand model/provider analytics from per-model buckets with legacy fallbacks for older rows.
- Cover persistence, migration, aggregation, and session accumulation behavior with tests.
- Document the per-model storage contract alongside existing token analytics tables.

Files changed:
 docs/storage.md                                    |   2 +
 packages/core/src/__tests__/db-migrate.test.ts     |  62 ++++++++++
 .../core/src/__tests__/store-persistence.test.ts   |  49 ++++++++
 .../core/src/__tests__/token-analytics.test.ts     | 127 ++++++++++++++++++++-
 packages/core/src/db.ts                            |  13 ++-
 packages/core/src/index.ts                         |   2 +-
 packages/core/src/store.ts                         |   7 +-
 packages/core/src/token-analytics.ts               |  58 ++++++++--
 packages/core/src/types.ts                         |  32 ++++++
 .../src/__tests__/session-token-usage.test.ts      |  23 ++++
 packages/engine/src/executor.ts                    |  20 +++-
 packages/engine/src/session-token-usage.ts         |  50 +++++++-
 packages/engine/src/step-session-executor.ts       |   7 ++
 13 files changed, 429 insertions(+), 23 deletions(-)

Fusion-Task-Id: FN-6746

Fusion-Task-Lineage: 1b1a3b31-b669-4e89-ac38-a871f3349015
2026-06-19 16:47:34 -07:00
gsxdsm
c158dda8a6 FN-6745: add xhigh thinking level support
Adds the xhigh reasoning option across settings, task flows, APIs, and model adapter tests.

- Extend the shared thinking-level enum, validation paths, generated resource types, and settings documentation for `xhigh`.
- Surface `xhigh` in task, agent, and global model selectors with localized labels.
- Cover task route handling, task form rendering, and Pi adapter mapping behavior with regression tests.
- Add a patch changeset for the published Fusion package.

Files changed:
 .changeset/fn-6745-xhigh-thinking-level.md         |   5 +
 docs/settings-reference.md                         |   2 +-
 .../core/src/__tests__/thinking-levels.test.ts     |   9 ++
 packages/core/src/types.ts                         |  10 +-
 packages/dashboard/app/api/legacy.ts               |   6 +-
 .../dashboard/app/components/AgentDetailView.tsx   |   2 +-
 .../dashboard/app/components/ModelSelectorTab.tsx  |   1 +
 .../dashboard/app/components/NewAgentDialog.tsx    |   3 +-
 packages/dashboard/app/components/NewTaskModal.tsx |   2 +-
 .../dashboard/app/components/TaskDetailModal.tsx   |   2 +-
 packages/dashboard/app/components/TaskForm.tsx     |   2 +
 .../app/components/__tests__/TaskForm.test.tsx     |  14 +++
 .../settings/sections/GlobalModelsSection.tsx      |   1 +
 .../src/__tests__/routes-tasks-ops.test.ts         |   8 +-
 .../dashboard/src/__tests__/routes-tasks.test.ts   |   8 +-
 packages/dashboard/src/agent-generation.ts         |   4 +-
 packages/dashboard/src/agent-onboarding.ts         |   4 +-
 .../src/routes/register-task-workflow-routes.ts    |   5 +-
 packages/engine/src/__tests__/pi.test.ts           |  25 ++++
 packages/i18n/locales/en/app.json                  |   3 +
 packages/i18n/locales/es/app.json                  |   3 +
 packages/i18n/locales/fr/app.json                  |   3 +
 packages/i18n/locales/ko/app.json                  |   3 +
 packages/i18n/locales/zh-CN/app.json               |   3 +
 packages/i18n/locales/zh-TW/app.json               |   3 +
 packages/i18n/src/resources.d.ts                   | 126 ++++++++++++++++++++-
 26 files changed, 229 insertions(+), 28 deletions(-)

Fusion-Task-Id: FN-6745

Fusion-Task-Lineage: 779e1517-607b-482b-83a1-0f2bb94ae736
2026-06-19 16:47:34 -07:00
gsxdsm
df139ec84c FN-6736: reclaim phantom executor bindings
Recover wedged in-progress tasks by clearing stale executor bindings only after liveness proves the owner is gone.

- Add a guarded executor escape hatch that clears only stale in-memory task bookkeeping while refusing live session surfaces.
- Teach self-healing to identify phantom executor-active bindings using age, checkout, heartbeat, run-audit, and worktree liveness signals before requeueing preserved work.
- Record reclaim events in run audit and cover preserved-worktree recovery with reliability interaction tests.
- Document the recovery path and add a patch changeset for the published CLI package.

Files changed:
 .changeset/fn-6736-phantom-executor-binding.md     |   5 +
 AGENTS.md                                          |   1 +
 docs/architecture.md                               |   1 +
 .../reclaim-phantom-executor-binding.test.ts       | 244 +++++++++++++++++++++
 packages/engine/src/executor.ts                    |  35 +++
 packages/engine/src/run-audit.ts                   |   2 +
 packages/engine/src/runtimes/in-process-runtime.ts |   3 +-
 packages/engine/src/self-healing.ts                | 112 ++++++++++
 8 files changed, 402 insertions(+), 1 deletion(-)

Fusion-Task-Id: FN-6736

Fusion-Task-Lineage: c76191ba-f4c3-4832-a790-67676e258ba2
2026-06-19 16:47:33 -07:00
gsxdsm
340da92400 FN-6735: treat benign merge-seam pause aborts as retryable
Treat benign pause/resume aborts at workflow merge seams as retryable transient merge failures.

- Classify legacy, merge-region, manual-hold, and retry node ids as merge-seam graph failures.
- Route clean in-review pause/resume aborts back through bounded auto-merge retry when eligible.
- Keep conflict, contamination, foreign-work, exhausted-retry, global/user pause, and confirmed-merge cases terminal.
- Cover the lifecycle with a reliability regression test and architecture notes.

Files changed:
 docs/architecture.md                               |   4 +-
 .../merge-node-paused-abort-retryable.test.ts      | 227 +++++++++++++++++++++
 packages/engine/src/executor.ts                    |  77 ++++++-
 packages/engine/src/workflow-graph-executor.ts     |   2 +-
 4 files changed, 301 insertions(+), 9 deletions(-)

Fusion-Task-Id: FN-6735

Fusion-Task-Lineage: 3560c1e3-91e9-405a-bdfc-a243f7052803
2026-06-19 16:47:33 -07:00
copilot-swe-agent[bot]
78bd016743 fix(merge): resolve merge conflicts with origin/main
- Renumber behavioral verification schema migration from 118→124
  (main added migrations 118-123 for usage_events, knowledge_pages,
  deployments/incidents, token usage, source-issue closure, LOC stats)
- Combine backend + timeoutMsOverride params in verification-utils.ts
- Accept main's quarantine rescue for AI-merge suites (FN-6433)
- Update schema version assertions to 124 across test files
2026-06-19 23:47:20 +00:00