singularity-forge/src
Mikael Hugo 62dacb6270 feat(sf): foundation for mid-execution escalation (ADR-011 P2)
Type-level + DB scaffolding for the escalation feature gsd-2 has but
SF lacks. Pure additive — no behavior change yet. Mirrors the same
incremental pattern that worked for progressive planning (types +
DDL first, state derivation + dispatch + module port in subsequent
fires).

PDD spec:

Purpose: lay the foundation so a task agent can write
  tasks.escalation_pending=1 + escalation_artifact_path=<file> when
  it hits a decision the user must make. Future fires will: (1) add
  detectPendingEscalation() to state.ts, (2) add a dispatch rule that
  returns 'stop' on phase='escalating-task', (3) port the escalation
  helper module from gsd-2.
Consumer: task agents (execute-task) when they hit ambiguity that
  shouldn't be silently resolved. Operators running future
  /sf escalate list/resolve commands.
Contract:
  - types.ts:23 Phase union now includes 'escalating-task'.
  - sf-db.ts:370-371 fresh CREATE TABLE for tasks gains
    escalation_pending + escalation_artifact_path.
  - sf-db.ts:1430+ schema_version 23 migration adds the columns +
    an opportunistic index for fast pending-escalation lookups.
  - TaskRow type gains escalation_pending?: number and
    escalation_artifact_path?: string | null. rowToTask returns
    them with safe defaults (0 and null).
Failure boundary: index creation is wrapped in try/catch — backends
  without index support fall through silently. Pre-migration installs
  treat the column as 0 default (no escalation pending) on first
  read, matching post-migration default.
Evidence: typecheck passes; smoke test deferred to next fire when the
  state derivation rule lands and we have something observable to
  test.
Non-goals:
  - state.ts emission of phase='escalating-task' (next fire)
  - auto-dispatch.ts pause rule (next fire)
  - escalation.ts helper module port (next fire — 367 LOC in gsd-2)
  - /sf escalate user command (later fire)
  - Escalation artifact format/validation (later fire)
Invariants:
  - Safety: ALTER TABLE adds nullable/defaulted columns; existing
    rows behave identically (escalation_pending defaults to 0).
  - Liveness: migration runs in same atomic transaction block as
    other version 23 work — never half-applied.
Assumptions verified:
  - SF already has EscalationOption + EscalationArtifact types
    (types.ts:692-704) — they were stubs with no producers; this
    commit is the producer-side scaffolding.
  - schema_version 22 already exists and is the current latest;
    23 is the next available.

ADR-011 reference: gsd-2's docs/dev/ADR-011-progressive-planning-
escalation.md covers both progressive planning (already ported in
this session) and mid-execution escalation (in progress). SF's own
ADR-011 file (docs/dev/ADR-011-swarm-chat-and-debate-mode.md) is
unrelated to gsd-2's ADR-011 — same number, different topic.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-02 20:00:16 +02:00
..
resources feat(sf): foundation for mid-execution escalation (ADR-011 P2) 2026-05-02 20:00:16 +02:00
tests fix: inline-fix for high/critical self-feedback entries 2026-05-02 19:57:41 +02:00
web chore: clean up remaining sf-2 stale-name code comments 2026-05-02 18:14:22 +02:00
app-paths.ts feat: introduce repo-vcs skill and add JSDoc annotations across core modules 2026-05-01 21:36:32 +02:00
bundled-extension-paths.ts feat: introduce repo-vcs skill and add JSDoc annotations across core modules 2026-05-01 21:36:32 +02:00
bundled-resource-path.ts batch: snapshot of in-flight v2 work 2026-04-29 12:42:31 +02:00
claude-cli-check.ts batch: snapshot of in-flight v2 work 2026-04-29 12:42:31 +02:00
cli-logs.ts batch: snapshot of in-flight v2 work 2026-04-29 12:42:31 +02:00
cli-stats.ts refactor: migrate from better-sqlite3 to node:sqlite, npm glob to node:fs 2026-05-02 06:13:57 +02:00
cli-status.ts batch: snapshot of in-flight v2 work 2026-04-29 12:42:31 +02:00
cli-web-branch.ts feat: stabilize autonomous workflow system 2026-05-01 20:18:50 +02:00
cli.ts fix(sf): stabilize headless auto flow 2026-05-02 11:34:41 +02:00
errors.ts feat: introduce repo-vcs skill and add JSDoc annotations across core modules 2026-05-01 21:36:32 +02:00
extension-discovery.ts feat: introduce repo-vcs skill and add JSDoc annotations across core modules 2026-05-01 21:36:32 +02:00
extension-registry.ts feat: introduce repo-vcs skill and add JSDoc annotations across core modules 2026-05-01 21:36:32 +02:00
headless-answers.ts batch: snapshot of in-flight v2 work 2026-04-29 12:42:31 +02:00
headless-context.ts sf snapshot: pre-dispatch, uncommitted changes after 53m inactivity 2026-04-30 19:10:38 +02:00
headless-events.ts feat(sf): bug-hunt fixes, UOK phase hardening, model policy, record-promoter 2026-05-02 02:03:55 +02:00
headless-query.ts sf snapshot: pre-dispatch, uncommitted changes after 32m inactivity 2026-05-02 11:25:51 +02:00
headless-types.ts feat: structured notification event model with metadata-first classification 2026-05-01 23:07:57 +02:00
headless-ui.ts fix(sf): surface agent-end ordering failures 2026-05-02 14:25:44 +02:00
headless.ts chore(sf): add optional token telemetry 2026-05-02 11:50:34 +02:00
help-text.ts feat: stabilize autonomous workflow system 2026-05-01 20:18:50 +02:00
loader.ts fix(sf): stabilize auto notices and package checks 2026-05-02 12:39:27 +02:00
logo.ts batch: snapshot of in-flight v2 work 2026-04-29 12:42:31 +02:00
mcp-server.ts batch: snapshot of in-flight v2 work 2026-04-29 12:42:31 +02:00
models-resolver.ts batch: snapshot of in-flight v2 work 2026-04-29 12:42:31 +02:00
onboarding.ts batch: snapshot of in-flight v2 work 2026-04-29 12:42:31 +02:00
pi-migration.ts batch: snapshot of in-flight v2 work 2026-04-29 12:42:31 +02:00
project-sessions.ts batch: snapshot of in-flight v2 work 2026-04-29 12:42:31 +02:00
provider-migrations.ts batch: snapshot of in-flight v2 work 2026-04-29 12:42:31 +02:00
remote-questions-config.ts batch: snapshot of in-flight v2 work 2026-04-29 12:42:31 +02:00
resource-loader.ts chore: clean up remaining sf-2 stale-name code comments 2026-05-02 18:14:22 +02:00
rtk.ts batch: snapshot of in-flight v2 work 2026-04-29 12:42:31 +02:00
security-overrides.ts batch: snapshot of in-flight v2 work 2026-04-29 12:42:31 +02:00
startup-model-validation.ts feat: Replaced bare error writes in cli.ts, headless.ts, and startup-mo… 2026-04-30 15:43:29 +02:00
startup-timings.ts batch: snapshot of in-flight v2 work 2026-04-29 12:42:31 +02:00
tool-bootstrap.ts batch: snapshot of in-flight v2 work 2026-04-29 12:42:31 +02:00
traces.ts feat: introduce repo-vcs skill and add JSDoc annotations across core modules 2026-05-01 21:36:32 +02:00
update-check.ts batch: snapshot of in-flight v2 work 2026-04-29 12:42:31 +02:00
update-cmd.ts batch: snapshot of in-flight v2 work 2026-04-29 12:42:31 +02:00
web-mode.ts fix: inline-fix for high/critical self-feedback entries 2026-05-02 19:57:41 +02:00
welcome-screen.ts batch: snapshot of in-flight v2 work 2026-04-29 12:42:31 +02:00
wizard.ts batch: snapshot of in-flight v2 work 2026-04-29 12:42:31 +02:00
worktree-cli.ts chore: CI workflows, package.json updates, test fixes, docs cleanup 2026-05-02 06:30:45 +02:00
worktree-name-gen.ts batch: snapshot of in-flight v2 work 2026-04-29 12:42:31 +02:00