Commit Graph

2710 Commits

Author SHA1 Message Date
gsxdsm
af06170a51 FN-6778: add agent artifact registry tools
Adds engine and chat tools for registering, discovering, and viewing artifacts with inbox notifications.

- Add fn_artifact_register, fn_artifact_list, and fn_artifact_view tools for heartbeat, executor, and chat sessions.
- Send best-effort dashboard system inbox notifications when artifacts are registered.
- Classify artifact tools for action gating and coordination exemptions, with coverage for executor, heartbeat, permanent agent, and chat flows.
- Document the artifact registry behavior and update package metadata, quarantine ledger, and line-count baseline.

Files changed:
 .changeset/fn-6778-artifact-agent-tools.md         |   5 +
 CONCEPTS.md                                        |   3 +
 docs/agents.md                                     |   1 +
 packages/core/src/db.ts                            |   1 +
 .../src/__tests__/session-error-recovery.test.ts   |   1 +
 .../session-persistence-roundtrip.test.ts          |   1 +
 .../src/__tests__/session-reconnect.test.ts        |   1 +
 .../src/__tests__/session-resume-history.test.ts   |   1 +
 packages/dashboard/src/chat.ts                     |   6 +-
 packages/dashboard/src/planning.ts                 |   4 +
 packages/dashboard/src/test/mockCoreEngine.ts      |   1 +
 .../engine/src/__tests__/agent-action-gate.test.ts |   3 +
 .../src/__tests__/agent-artifact-tools.test.ts     | 458 +++++++++++++++++++++
 .../src/__tests__/executor-step-session.test.ts    |  48 +++
 .../src/__tests__/gating-classifications.test.ts   |   3 +
 .../src/__tests__/heartbeat-executor.test.ts       |  40 +-
 .../src/__tests__/heartbeat-session-prompt.test.ts |  25 +-
 .../src/__tests__/permanent-agent-gating.test.ts   |   6 +
 packages/engine/src/agent-heartbeat.ts             |   6 +-
 packages/engine/src/agent-tools.ts                 | 288 ++++++++++++-
 packages/engine/src/executor.ts                    |  25 ++
 packages/engine/src/gating-classifications.ts      |   7 +
 packages/engine/src/index.ts                       |   9 +
 scripts/lib/test-quarantine.json                   |   8 +-
 scripts/line-count-baseline.json                   |  54 +--
 25 files changed, 945 insertions(+), 60 deletions(-)

Fusion-Task-Id: FN-6778
Fusion-Task-Lineage: 7eb4afcb-8140-4f86-9540-eb3b83e64148
2026-06-22 03:34:14 -07:00
gsxdsm
26c8d960a2 FN-6893: add editable built-in workflow prompts
Enable project-scoped prompt overrides for built-in workflows without allowing structural edits.

- Add workflow prompt override storage, normalization, and IR overlay support for prompt and gate nodes.
- Expose dashboard API routes and Workflow Node Editor controls to edit or reset built-in prompts.
- Cover override persistence, route behavior, editor flows, and engine workflow resolution with tests.
- Document editable built-in prompts and reset-to-default behavior.

Files changed:
 docs/dashboard-guide.md                            |   2 +-
 docs/settings-reference.md                         |   2 +
 docs/workflow-steps.md                             |  20 ++-
 .../__tests__/workflow-definition-store.test.ts    |  25 +++
 .../workflow-prompt-overrides-store.test.ts        | 190 ++++++++++++++++++++
 .../__tests__/workflow-prompt-overrides.test.ts    |  58 +++++++
 packages/core/src/db.ts                            |  35 +++-
 packages/core/src/index.ts                         |   7 +
 packages/core/src/store.ts                         |  97 ++++++++++-
 packages/core/src/workflow-ir-resolver.ts          |  21 ++-
 packages/core/src/workflow-prompt-overrides.ts     |  65 +++++++
 packages/dashboard/app/api/legacy.ts               |  34 ++++
 .../app/components/WorkflowNodeEditor.css          |  35 ++++
 .../app/components/WorkflowNodeEditor.tsx          | 191 ++++++++++++++++++++-
 .../__tests__/WorkflowNodeEditor.test.tsx          | 136 ++++++++++++++-
 .../src/__tests__/workflow-routes.test.ts          |  59 +++++++
 .../src/routes/register-workflow-routes.ts         |  86 +++++++++-
 .../workflow-prompt-overrides-resolution.test.ts   |  61 +++++++
 packages/i18n/locales/en/app.json                  |  14 +-
 packages/i18n/locales/es/app.json                  |  14 +-
 packages/i18n/locales/fr/app.json                  |  14 +-
 packages/i18n/locales/ko/app.json                  |  14 +-
 packages/i18n/locales/zh-CN/app.json               |  14 +-
 packages/i18n/locales/zh-TW/app.json               |  14 +-
 24 files changed, 1168 insertions(+), 40 deletions(-)

Fusion-Task-Id: FN-6893

Fusion-Task-Lineage: 961eb119-32e1-44c3-9b51-6edd982fa565
2026-06-21 21:23:41 -07:00
gsxdsm
d5ea17d8ab FN-6873: exclude archived tasks from auto-claim scans
Auto-claim now revalidates cached candidates so archived tasks cannot be surfaced or claimed.

- Restrict auto-claim candidate runnability to live todo rows while still allowing archived dependencies to satisfy blockers.
- Rebuild fresh auto-claim candidates from canonical task fields before heartbeat prompt rendering and claim selection.
- Cover archived-while-cached snapshots and executor/engineer heartbeat behavior with regression tests.

Files changed:
 .../src/__tests__/auto-claim-snapshot.test.ts      | 52 ++++++++++++++++--
 .../src/__tests__/heartbeat-executor.test.ts       | 63 ++++++++++++++++++++++
 packages/engine/src/auto-claim-snapshot.ts         |  6 +++
 3 files changed, 118 insertions(+), 3 deletions(-)

Fusion-Task-Id: FN-6873

Fusion-Task-Lineage: 3bd438f8-bbf8-428e-a7e2-56aebbbc6522
2026-06-21 16:23:42 -07:00
gsxdsm
7ee1fec22c FN-6861: reject repo-root task worktrees
Prevent stale task metadata from treating the project repository root as a reusable task worktree.

- Classify root-equal task worktree paths as repo-root before registered-worktree checks.
- Clear stale resumed repo-root assignments so acquisition creates a fresh configured task worktree.
- Add structured executor audit metadata and regression coverage for repo-root liveness collisions.
- Document the repo-root requeue-loop invariant and recovery behavior.

Files changed:
 docs/architecture.md                               |  2 +-
 .../repo-root-task-worktree-requeue-loop.md        | 49 ++++++++++++++++
 .../__tests__/executor-worktree-liveness.test.ts   | 23 +++++++-
 .../src/__tests__/worktree-acquisition.test.ts     | 67 +++++++++++++++++++++-
 .../src/__tests__/worktree-pool-liveness.test.ts   | 25 ++++++++
 packages/engine/src/executor.ts                    | 22 ++++++-
 packages/engine/src/worktree-acquisition.ts        |  4 ++
 packages/engine/src/worktree-pool.ts               | 13 ++++-
 8 files changed, 198 insertions(+), 7 deletions(-)

Fusion-Task-Id: FN-6861

Fusion-Task-Lineage: d6a4922e-5a21-4037-b2c2-86ff53d8e9e3
2026-06-21 14:28:58 -07:00
gsxdsm
d99246cb74 FN-6834: use OS-available memory for system metrics
Use shared OS-available memory readings so macOS cache/inactive pages are not counted as used.

- Add a core available-memory helper that prefers `process.availableMemory()` and flags `freemem` fallback reliability.
- Route core metrics, dashboard system stats, and the dashboard TUI through the shared helper.
- Move and expand memory tests across core, dashboard routes, and verification coverage while documenting the telemetry behavior.
- Add a patch changeset for the published CLI package.

Files changed:
 .changeset/fix-macos-memory-used.md                |  5 ++
 docs/architecture.md                               |  2 +-
 docs/dashboard-guide.md                            |  2 +-
 .../__tests__/available-memory.test.ts             | 54 --------------
 .../cli/src/commands/dashboard-tui/controller.ts   | 37 +---------
 .../core/src/__tests__/available-memory.test.ts    | 83 ++++++++++++++++++++++
 packages/core/src/__tests__/system-metrics.test.ts | 36 +++++++++-
 packages/core/src/available-memory.ts              | 32 +++++++++
 packages/core/src/index.ts                         |  1 +
 packages/core/src/system-metrics.ts                |  9 ++-
 .../dashboard/src/__tests__/routes-system.test.ts  | 27 +++++++
 packages/dashboard/src/routes.ts                   |  7 +-
 .../src/__tests__/run-verification-command.test.ts | 18 +++++
 13 files changed, 218 insertions(+), 95 deletions(-)

Fusion-Task-Id: FN-6834

Fusion-Task-Lineage: 2e651551-6c35-46d1-b517-535758c7ace2
2026-06-21 13:32:19 -07:00
gsxdsm
47ba99a25e FN-6853: bump pi SDK packages
Update the pi SDK dependency family across Fusion packages and record a patch changeset.

- Bump @earendil-works/pi-ai and @earendil-works/pi-coding-agent to ^0.79.9 where used by CLI, dashboard, and engine packages.
- Refresh pnpm-lock.yaml to resolve the updated pi SDK dependency graph.
- Add a patch changeset for the published @runfusion/fusion package.

Files changed:
 .changeset/fn-6853-pi-sdk-bump.md |   5 +
 packages/cli/package.json         |   4 +-
 packages/dashboard/package.json   |   2 +-
 packages/engine/package.json      |   4 +-
 pnpm-lock.yaml                    | 285 +++++++++++++++++++++++++++-----------
 5 files changed, 214 insertions(+), 86 deletions(-)

Fusion-Task-Id: FN-6853
Fusion-Task-Lineage: bc2dba95-b8c2-48d1-855d-847e6eec9606
2026-06-21 13:25:41 -07:00
gsxdsm
9620a50756 FN-6850: refresh auto-claim candidates before heartbeat claims
Auto-claim heartbeats now validate cached todo candidates against current task rows before displaying or claiming them.

- Share the auto-claim runnability predicate between snapshot generation and canonical freshness checks.
- Rebuild cached candidates from fresh slim task rows before role filtering, prompt rendering, and claim selection.
- Cover stale triage, assigned, checked-out, deleted, dependency-blocked, and retitled candidate cases in snapshot and heartbeat tests.

Files changed:
 .../src/__tests__/auto-claim-snapshot.test.ts      | 65 +++++++++++++++-
 .../src/__tests__/heartbeat-executor.test.ts       | 85 +++++++++++++++++++-
 packages/engine/src/agent-heartbeat.ts             | 15 ++--
 packages/engine/src/auto-claim-snapshot.ts         | 91 +++++++++++++++-------
 4 files changed, 220 insertions(+), 36 deletions(-)

Fusion-Task-Id: FN-6850

Fusion-Task-Lineage: 5af79319-46f4-4ee7-b6dc-d846f45abaa4
2026-06-21 13:25:41 -07:00
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