Skip to content

fix: close dogfood reliability issues 1–8#75

Merged
heggria merged 6 commits into
mainfrom
fix/dogfood-reliability-0.2
Jul 14, 2026
Merged

fix: close dogfood reliability issues 1–8#75
heggria merged 6 commits into
mainfrom
fix/dogfood-reliability-0.2

Conversation

@heggria

@heggria heggria commented Jul 13, 2026

Copy link
Copy Markdown
Owner

Summary

Closes all eight reliability gaps found while dogfooding taskflow 0.2 across the core runtime, event kernel, Pi adapter, MCP adapters, release artifacts, tests, and generated skills.

Core behavior

  • make reduce.from + {previous.output} aggregate every completed source in deterministic from[] order
  • add configurable idleTimeout with the 0 = disabled only with finite wall timeout safety invariant
  • add top-level/per-step shorthand cwd, including containment and workspace-binding hardening
  • add durable build/host identity and host-specific MCP serverInfo.name
  • make resume immutable via child-run forks, optional phase overrides, and failed/paused-only validation
  • expose the actual outputSourcePhaseId selected by final-output fallback logic
  • add exact per-attempt prompt diagnostics and bounded tree reduction
  • add a first-run trace regression guard

Reliability hardening

  • tree reduce enforces a 256-call hard cap, incorporates intermediate usage into live budget admission, preserves untouched inputs on truncation, fails on abort, and never caches partial budget results
  • event-kernel execution now persists observed reads and exact prompt-call diagnostics with imperative-runtime parity
  • prompt diagnostics count every actual subagent attempt, including retries, fan-out, loops, tournament judges, tree rounds, and shared-context spawned children
  • resume forks deep-clone retained state, preserve workspace provenance, and stamp current build metadata
  • build stamping is reproducible (SOURCE_DATE_EPOCH or immutable commit time) and valid plain JavaScript
  • packed-package smoke tests validate every host-specific MCP identity

Compatibility notes

  • Breaking: reduce.from + {previous.output} now receives all completed sources. Use explicit {steps.ID.output} refs when a reducer should consume only one source.
  • Resume now accepts only failed and paused runs. Use a fresh run for terminal work or recompute for stale-frontier refresh.
  • MCP clients that assert serverInfo.name must accept taskflow-codex, taskflow-claude, taskflow-opencode, or taskflow-grok for the corresponding adapter.

Validation

  • pnpm run typecheck
  • pnpm test1887/1887 passed
  • pnpm run build
  • node scripts/smoke-packed-packages.mjs9 packages, 24 explicit imports, 63 wildcard exports, 5 bins
  • pnpm run build:website — docs/sample/typecheck/static-export checks passed
  • node scripts/build-skills.mjs --check
  • git diff --check

Live-provider E2E suites were not invoked locally; all corresponding host metadata assertions and packed MCP binary checks were updated and passed.

heggria added 5 commits July 13, 2026 23:43
…rompt diagnostics + tree reduce

Implements dogfood reliability issues 1, 3, and 7.

BREAKING — reduce.from + {previous.output} now aggregates all sources
(0.2.0 dogfood issue 1):
- A reduce phase's {previous.output} resolves to ALL completed from[]
  outputs in from-array order — not just the last completed dependency.
  One completed input → raw output; multiple →
  sections joined by . join:any includes only completed
  branches (skipped/failed omitted). Explicit {steps.*} refs unchanged.
- Observed reads include the aggregated from IDs (staleness tracks them).
- Imperative + event-kernel parity: executeReduceBody now threads the
  aggregated previousOutput via interpCtx, mirroring aggregateReduceFrom.

Configurable idle watchdog (issue 2):
- New flow-level + phase-level DSL field  (ms). Positive
  (>= 1000) overrides the host default (300000);  disables the
  watchdog but validation requires a finite wall  >= 1000 on
  every agent-running phase that can use it. Per-phase overrides flow.
- Threaded into RunOptions.idleTimeoutMs on both imperative and
  event-kernel paths (runAgentCall + runOneAgent). runSubagentProcess
  + the pi runner already honor idleMs<=0 as disabled.
- Included in cache identity/fingerprints automatically via the FlowIR
  definition hash: idleTimeout/reduceStrategy/batchSize added to
  compile.ts SIDECAR_PHASE_FIELDS; flow-level idleTimeout added to the
  CanonicalFlowIR type + canonicalizeFlowIR + translate stub.

Prompt diagnostics + hierarchical (tree) reduce (issue 3):
- Durable PhaseState.promptStats for each agent call's resolved prompt:
  exact UTF-8 bytes, char count, ceil(chars/4) estTokens. A warning
  fires when a prompt crosses a conservative ~32K-token threshold.
  reduce phases also record reduceInputs aggregate stats (count + totals).
- Opt-in reducer tree via reduceStrategy:"tree" + batchSize (>= 2):
  batches aggregated from[] inputs, runs intermediate reducer calls
  reusing the phase's runOne (same agent/model/options/timeout/
  idleTimeout + retry/budget), reduces round outputs until one remains.
  Default remains one-shot; corrected {previous.output} always applies.
- reduceStrategy:"tree" forces imperative fallback (encoded in
  kernelUnsupportedReason); one-shot reduce stays on the kernel.
- Event-kernel parity: promptStats + reduceInputs mirrored on the
  StepResult/BodyResult → driver → PhaseState path.

Docs:
- skills-src configuration.md + core.md updated (reduceStrategy/
  batchSize/idleTimeout rows; {previous.output} aggregation note).
- website interpolation docs (en + zh) updated with the breaking
  reduce aggregation semantics.
- build-skills regenerated all per-host skill files (drift guard green).
- CHANGELOG: prominent migration note for the reduce.from + {previous.output}
  breaking change, plus Added entries for the three features.

Tests: 28 focused tests in dogfood-reliability.test.ts covering all
three categories (reduce aggregation + parity, idleTimeout validation/
threading/cache-identity, prompt diagnostics + tree reduce + kernel
admission). FlowIR hash sensitivity tests extended for the new fields.
Typecheck + full core suite green (3 pre-existing flaky tests unchanged).
…put source attribution

Implements dogfood reliability issues 2, 4, 5, 6, and 8 (first-run trace
regression). Builds on the already-shipped reduce/idle/tree-reduce work
(issues 1, 3, 7) without reverting it.

Issue 2 — shorthand cwd:
- Top-level + per-step `cwd` for shorthand specs (single / chain / parallel).
  Single+chain propagate to each Phase.cwd (full workspace-keyword lifecycle).
  Parallel honors each branch's own literal cwd (mixed values across
  branches); per-branch workspace keywords are rejected at validation time
  (the workspace lifecycle is per-phase — use the phase-level cwd).
- New ParallelTask.cwd field; runFanout/baseRun/runOne thread a per-call cwd
  override so a branch runs in its own literal cwd.
- Pi tool TypeBox params + desugar/readStep carry cwd; skills + tests updated.

Issue 4 — version/build/host identity:
- New exported getBuildInfo() (packageVersion, gitCommit, schemaVersion,
  buildTime). Package version read from package metadata; git commit stamped
  at BUILD time into dist/build-info.json (gitignored) — git is NEVER invoked
  at runtime (deterministic "unknown" fallback; PI_TASKFLOW_BUILD_COMMIT env
  override). New scripts/stamp-build-info.mjs wired into the core build.
- RunState gains optional packageVersion/gitCommit/host/schemaVersion/
  parentRunId; index entries preserve host/packageVersion/parentRunId.
- Pi runs stamp host=pi; MCP runs stamp the bound host. Pi action=version +
  MCP taskflow_version tool; MCP initialize serverInfo name reflects the host
  (taskflow-codex, …). Host adapters thread host via a backward-compatible
  McpHostOptions.

Issue 5 — resume overrides + immutable history:
- Resume now FORKS a new run (new runId + parentRunId); the original run file
  is never mutated or overwritten. ResumeOverrides API (phaseId + optional
  task/model/timeout/idleTimeout; at least one override required) re-runs
  exactly one phase with overrides applied to the CHILD's def only; the
  target + transitive downstream re-run, completed unaffected phases are
  reused. Without overrides, ordinary resume forks + re-runs non-done phases.
- Pure helpers (forkRunForResume/applyResumeOverrides/validateResumeOverrides/
  transitiveDownstream) in taskflow-core/resume.ts. Pi action=resume accepts
  phaseId + resumeTask/resumeModel/resumeTimeout/resumeIdleTimeout; new MCP
  taskflow_resume tool; resume rendering reports new run id + parent run id.

Issue 6 — output source attribution:
- RuntimeResult/EventKernelResult gain outputSourcePhaseId (the phase whose
  output supplied finalOutput — the fallback final phase, or the blocking
  gate/approval phase for a gate/budget prefix; undefined when no phase
  output). Final-phase selection/fallback + no-output default unified between
  the imperative runtime and the event kernel via shared resolveFinalOutput
  (taskflow-core/final-output.ts). Pi finalResult + MCP taskflow_run/resume
  rendering label the ACTUAL source phase, never the designated skipped/failed
  final phase.

Issue 8 — first-run trace regression:
- New integration test: FileTraceSink built before the runs dir exists, a
  first run executes, and the trace is immediately readable + non-empty.

Docs: CHANGELOG, README, AGENTS.md, and skills-src (cwd/resume/version) +
regenerated per-host skills.

Tests: +6 focused suites (output-source-attribution, shorthand-cwd,
build-info, resume, trace-firstrun; updated all four host MCP tests for the
new taskflow_version + taskflow_resume tools and host-identity serverInfo).
Full suite 1685 pass; typecheck clean.
Close event-kernel parity gaps, make prompt diagnostics count every actual subagent attempt, harden tree-reduce interruption handling, and validate immutable resume forks.\n\nAdd release-build and packed-artifact guards for deterministic build metadata, portable Pi declarations, and host-specific MCP identity.
Harden budgeted fan-out, tree-reduce caching and context spawning, resume overrides, build metadata, and host discovery surfaces. Add regression coverage and synchronize the 0.2.2 release documentation.
Comment thread packages/taskflow-core/src/runtime.ts Fixed
@heggria
heggria merged commit 300da53 into main Jul 14, 2026
11 checks passed
@heggria
heggria deleted the fix/dogfood-reliability-0.2 branch July 14, 2026 08:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants