# WO-01 — Native research-to-feature workflow

Status: complete — repository implementation, twelve-scenario acceptance and scoped Git delivery. Authorized by the user request to bring the AIWG research-team mechanism into Omnius. Publication and live acceptance remain with the user.

Research: [AIWG mechanism and Omnius mapping](../../research/aiwg-long-horizon-feature-workflow.md).

## Result

An explicitly selected native feature workflow can research an objective, produce a reviewed specification, implement dependent slices, integrate them, execute declared acceptance checks, and hand off the result across restarts. The existing runner executes every child and tool operation. The existing workboard owns task state, the completion authority owns terminal eligibility, and CAS owns immutable evidence bodies.

This is one end-to-end tranche. A schema-only helper, generated skill text, unused exported planner, or successful isolated gate test does not complete this workorder.

## Execution ownership

- Core: strict plan/compiler, immutable artifact slots, durable accepted references, host-only operation admission/settlement and restart fixtures.
- Runner integration: native tool, ordinary admission, dependency/frontier projection, explicit completion constraints, scope retirement and production-loop tests.
- Root integration: independent review, accepted terminal handoff, test/build verification, durable workorder reconciliation and scoped Git delivery.
- Final Telegram reporting is delivered by [runtime WO-44](../runtime-health-remediation/WO-44-evidence-backed-terminal-results.md); this workflow consumes those evidence-backed results.

The first ownership audit found that model-callable workboard actor labels alone cannot establish independent review. The native integration must derive reviewer identity and source versions from a real admitted child operation. Model parameters such as reviewerId or passed are not proof.

## Minimal implementation boundary

1. Add a strict versioned plan/profile contract with objective identity, run/session/task epoch, plan revision, source/artifact references, requirement and acceptance IDs, stage dependencies, role/output contracts, and explicit verifier requirements. Its initial stage vocabulary is research, specification, implementation, integration, acceptance, and handoff. Stage state is derived from existing cards and accepted receipts. Ordinary stage changes preserve task epoch; authorized objective replacement uses the existing scope boundary.
2. Expose one native `feature_workflow` tool through normal tool registration and schemas. Keep its actions limited to creating/revising the plan, binding returned artifact references to declared slots, inspecting current readiness, selecting an exact program to resume, and reopening a scoped repair tied to a current failed review or acceptance gate. Existing delegation, file, terminal, workboard and completion tools do the work. The host validates references and transitions; the model does not submit a trustworthy `passed: true` or directly mark a whole program complete.
3. Compile the plan into stable todo/workboard leaves and requirements/acceptance/source references. Research streams are bounded parallel children with distinct ownership; synthesis and required review are downstream cards. Implementation is admitted only after its declared prerequisites are verified. Integration is an explicit card and target revision, followed by the declared acceptance checks. Keep all active waves under existing tool/provider/context and ownership limits.
4. Store exact artifact bodies through CAS and flush before accepting references. Persist the accepted plan reference, identity and current boundary using the runner's validated safe-checkpoint patterns. Reconstruct work and stage readiness from durable workboard/evidence records. A new runner must resolve the same continued objective explicitly; `handoffs/latest.json`, a prompt summary, or an unvalidated mission JSON file cannot reopen mutation admission.
5. Project the current stage, ready leaves, blockers, required evidence and artifact refs through the existing operational graph/turn-context path in both primary and brute-force loops. Compile required stage reviews and integration acceptance into existing completion constraints/verifier requirements. Use typed exact-version receipts rather than ordinary completed-card status where independent verification is required.

## Intended files and ownership seams

The implemented ownership boundaries are listed below; repository acceptance and delivery are recorded at the end of this workorder.

| Area | Intended files | Boundary |
|---|---|---|
| Strict schema and pure compiler | `packages/schemas/src/feature-workflow.ts`; `packages/orchestrator/src/featureWorkflow.ts`; package export barrels | Reuse existing todo/workboard/source/claim vocabulary; validate plan IDs, dependencies and accepted artifact lineage. No execution loop here. |
| Native tool and host binding | `packages/orchestrator/src/agenticRunner.ts`; `featureWorkflowRunnerBoundary.ts`; `featureWorkflowToolBoundary.ts` | Advertised schema, parsed arguments, profile checks, evidence attachment and actual run-path integration. No duplicate direct execution path. |
| Durable checkpoint and phase projection | `packages/orchestrator/src/featureWorkflow.ts`; existing runner checkpoint, workboard and operational-world projection hooks | Accepted plan reference and receipt correlation; recover admission closed until identity and prerequisites validate. Reuse CAS/lifecycle durability rather than introducing an independent workflow database. |
| Gate and terminal authority | Existing `completionReadiness.ts` constraint interfaces and runner producers; workboard prerequisite/review transitions | Only declared workflow obligations; preserve ordinary tasks and the existing generic-mutation completion behavior. |
| Actual child execution and receipts | `packages/execution/src/feature-workflow-child.ts`; `tools/agent-tool.ts`; execution types; `packages/cli/src/tui/native-inprocess-agent.ts`, tool adapter, interactive callbacks and Telegram registry | Preserve actual child identity, host-owned scope, exact artifact inputs and accepted report bytes; use the existing child runner and native artifact reader. |
| Actionable results | `featureWorkflowPresentation.ts`; `terminalTaskReport.ts`; runner terminal commit | Keep concrete review/check/repair guidance in current model context and the evidence-bound final result. |
| Tests | `packages/orchestrator/tests/featureWorkflow.test.ts`; `packages/orchestrator/tests/feature-workflow-runner.test.ts`; execution and CLI native-child tests | Pure validation plus real `runner.run()` with mocked backend/tools, durable temporary state, restart and brute-force coverage. No live inference, browser, Telegram, or remote issue effects. |

Preserve compatibility with `missionArtifacts.ts`, `featurePlanner.ts`, `featureNode.ts`, `adversarialHandoffs.ts`, and `autoValidators.ts`. They provide reusable types or planning/formatting logic, but the inspected production runner does not invoke their mission/recursive-feature execution path. Do not wire a second recursive executor merely to make those exports appear used. Do not treat `updateAssertionResult(..., 'passing')`, a generated validator prompt, or a worker's handoff exit-code field as a runtime receipt.

## Acceptance scenarios — 12 required

1. **Production entry:** actual registered tool definitions expose the exact accepted schema; a mocked model selects the workflow and the real runner materializes stable phased cards, not just a pure-helper result.
2. **Plan validity:** unknown/duplicate identities, cycles, missing assertion ownership, unknown artifact slots, malformed refs and cross-epoch references are rejected. Repeating an accepted create/revise request does not duplicate work.
3. **Research to specification:** bounded independent research returns provide durable source/artifact references; failed or missing streams remain visible; the specification consumes accepted evidence and records unresolved questions.
4. **Versioned review:** a distinct reviewer reviews an exact artifact version; a worker cannot self-verify; a changed specification invalidates its old review. Missing or timed-out required review cannot pass by omission.
5. **Phase admission:** declared design/research dependencies block implementation mutations while permitting the bounded evidence operations needed to unblock them. Independent ready work can progress under existing scheduling limits.
6. **Implementation ownership:** parallel children receive exact card/epoch/owned-file and return contracts; an unrelated mutation cannot be admitted by naming a workflow role or reporting a completed phase.
7. **Integrated verification:** green child-local checks do not satisfy acceptance for a different combined revision; the integration card produces the target revision and declared acceptance executes against that state.
8. **Failure invalidation:** a subsequent mutation or failed declared verifier revokes the earlier pass; repair creates bounded remaining work and does not re-run accepted unaffected research/specification.
9. **No premature terminal success:** completed-but-unreviewed cards and model-authored success statements cannot satisfy explicitly required review/integration obligations; terminal output names the actual remaining blocker/evidence.
10. **Restart durability:** interrupt before/after operation claim, artifact flush, receipt acceptance and phase advancement; a fresh runner restores exact objective/epoch/plan refs and resumes unfinished work. Failed flush or malformed checkpoint closes dependent admission; ambiguous mutations are reconciled before replay.
11. **Steering and isolation:** additive steering preserves the program; explicit replacement archives and retires it once. Late results, repeated text, a newer run generation and unrelated latest-handoff content cannot revive the retired scope.
12. **Both loops and bounded context:** the complete synthetic research → revised spec → two implementations → integration failure → repair → acceptance pass → handoff scenario traverses the actual primary and brute-force paths. Compaction preserves current authority, open requirements and durable artifact references without injecting full old-stage bodies.

Completion evidence must identify the implemented files, focused test results, production test paths, restart fixtures and scoped commit(s). A test count alone is insufficient; all 12 scenarios must map to concrete assertions. Publishing, shared-branch merges, live acceptance environments and external messaging remain outside this tranche unless separately authorized by the user.

## Independent implementation review

The first controller draft exposed these additional acceptance checks. Production code and the named tests demonstrate each repair; final aggregate verification and Git delivery are recorded below.

- [x] **D1 — Actual child inputs:** validate each supplied CAS reference against the actual content and validate the aggregate artifact digest before dispatch, in addition to matching operation and terminal identities. The complete child request has a separate digest covering instructions and tool policy; these are different hash domains. A copied binding alone is insufficient.
- [x] **D2 — Receipt-before-board recovery:** a crash after accepting a durable result but before publishing workboard completion must reconcile that exact result on recovery; it must not replay completed work.
- [x] **D3 — Read-only child boundaries:** research, review and artifact-only authoring with no owned source paths must not acquire unrestricted mutation tools. Write-capable children need an explicit host-owned scope.
- [x] **D4 — Cross-instance generation fencing:** after another controller adopts or retires a program, a late result in an older controller instance cannot overwrite its durable selector. Check persisted authority, not only the old instance's memory.
- [x] **D5 — Ambiguous-operation recovery:** changing a pending workflow operation to interrupted cannot independently authorize replay of an ambiguous mutation. Existing interruption reconciliation remains the admission authority.
- [x] **D6 — Cross-epoch continuation:** a normal new runner task advances its epoch. Explicit native resume must record adoption of the exact prior checkpoint into the current identity without resetting the lifecycle epoch or rewriting historical receipts. Test both reused and fresh runners; unrelated sessions and retired scopes remain excluded.
- [x] **D7 — Durable findings and bounded research:** persist the exact child report and its findings, blockers and unresolved questions; restore the reason work needs changes. Completed bounded research may leave advisory questions for specification. Explicit blocked/partial status and blocking findings remain unsatisfied; unanswered advisory questions must not force invented answers.
- [x] **D8 — Context priority under pressure:** a maximum-length objective or many old artifacts cannot displace current identity, ready task IDs, required input references and open obligations. Allocate section budgets and prioritize the active frontier; test both loops with genuinely crowded context.
- [x] **D9 — Control-state ownership:** a declared source-file scope cannot grant a worker permission to edit the workflow's own selectors, CAS objects or workboard state, including custom state directories and symlink aliases. Those records remain host-owned.

Root review also requires a strict child report containing exact reviewed references, disposition, findings, blockers and unresolved questions. A real child terminal receipt proves execution identity; it does not by itself prove an approving review verdict.

### Parent context loss reproduced during acceptance

The first genuinely crowded parent-request fixture failed in both execution loops. The final context admission receipt recorded message compaction, and the ordinary system frame holding the current workflow was replaced by a generic capacity-compaction marker. Ready card IDs and exact artifact references disappeared; the brute-force path also lost the accepted plan identity. A bounded controller projection alone therefore did not satisfy D8.

The repair is in the runner's final request construction: reconstruct the current bounded workflow authority from the controller in a protected host context slot after ordinary history preparation, remove the foldable duplicate, and reject admission if the required authority cannot fit. The passing fixture inspects actual post-compaction backend messages in both loops: the admission receipt records compaction, the final request stays within a 16,000-token capacity, and the owning plan/run/epoch, ready specification task, exact research input and unresolved output/blocker requirements survive. Existing impossible-policy admission tests retain rejection instead of silently removing required authority.

## Acceptance evidence map

All twelve scenarios are reconciled against these concrete assertions and the final aggregate run; counts alone do not establish acceptance.

| Scenario | Concrete verification |
| --- | --- |
| 1 — Production entry | `feature-workflow-runner.test.ts`: native discovery through the real runner, strict schema in actual backend requests, model-selected create, and executable routing metadata stripped before tool schema validation. `feature-workflow-transport.test.ts` follows the schema through actual HTTP encoders. |
| 2 — Plan validity | `featureWorkflow.test.ts`: stable compilation, duplicate/unknown/cyclic/future references, missing acceptance, model-supplied pass flags and requirement retirement. Repeated accepted plans leave the workboard event count unchanged. |
| 3 — Research and specification | Core tests retain failed/partial child reports and concrete findings, preserve advisory research questions, and supply exact static source bytes. The real-runner arc carries accepted research into specification. |
| 4 — Versioned review | Core and both-loop runner tests reject self-review, require the exact reviewed versions, reopen the rejected specification, accept its new artifact, and require a fresh independent review. Contextual sources remain in the input set without becoming reviewed outputs. |
| 5 — Phase admission | Both-loop full arcs reach two concurrent ready children through the existing scheduler (`maxActiveChildren = 2`). Core tests accept disjoint ownership tickets and reject overlapping pending mutation scopes. |
| 6 — Implementation ownership | Real-runner tests reject early and unowned writes before execution. Core tests reject protected control paths and escaping/dangling symlink parents. Native-child tests replace a wider supplied contract with the host scope and exclude unsupported mutators. |
| 7 — Integrated verification | The synthetic verifier reads the combined two-slice source state. Actual runner dispatch rejects a different command before execution; controller tests require current matching command receipts and target revision. |
| 8 — Failure and repair | Both loops traverse observed acceptance failure, native scoped repair, reintegration and passing acceptance. Separate tests deliberately recheck a previously green state, fail without a source mutation, and revoke the old pass. Unaffected research remains accepted. |
| 9 — Terminal authority | Premature completion, self-review, missing reports and incorrect check commands leave the real runner incomplete. Terminal-report tests preserve the concrete blocker and next action without relying on a final model reply. |
| 10 — Restart | Core tests cover selector flush faults, malformed receipts, receipt-before-board recovery and exact adoption. Real-runner tests resume both fresh and reused runners; captured pending reads obtain fresh tickets, while pending mutations reject continuation before another inference request. |
| 11 — Steering | `feature-workflow-runner.test.ts` uses public steering input plus typed reconciliation for continuation, replacement and replacement during a child. The old scope is durably retired before epoch advance; late results do not restore its admission. |
| 12 — Complete arc and context | Both production loops run the revised-specification/two-slice/failure/repair/acceptance arc. Actual parent-pressure tests record message compaction and verify protected current plan/run/epoch, ready tasks, exact required references and unresolved obligations in final requests within 16,000 tokens. Core context tests retain current required references ahead of a maximum-length objective. `native-inprocess-agent-runner.test.ts` sends a 324 KB observation through the real child runner, observes context reduction, reopens the exact artifact through native `artifact_read`, then returns an accepted terminal report. |

The synthetic backends and tools produce local fixture effects and receipts; no live model, network service, Telegram delivery or publication is used to establish this repository acceptance.

## Final verification and delivery — 2026-09-05

| Package | Passed | Skipped | Passing suites |
| --- | ---: | ---: | ---: |
| Schemas | 248 | 0 | 15 |
| Execution | 1,763 | 3 | 161 |
| Orchestrator | 2,736 | 1 | 224 |
| CLI | 2,563 | 0 | 271 |
| Total | 7,310 | 4 | 671 |

The clean rebuild removed workspace build outputs and package TypeScript build-info files, then rebuilt every workspace package. A final `pnpm -r build` after the last source repair also passed. Reproduce the regressions with `pnpm --dir packages/<package> exec vitest run --maxWorkers=4 --minWorkers=1`, with `OMNIUS_SQLITE_TESTS=1` on the orchestrator run. All inference and Telegram transport stayed behind the repository's hermetic test boundary.

Additional integration repairs preserve the one-argument invocation of ordinary tools, propagate host invocation context only through an explicitly capable tool or admitted workflow, and forward the owning Stop signal into ordinary native children as well as workflow children. The regression first reproduced a lost signal at the AgentTool producer, then passed after its forwarding repair. `invocation-context-capability.test.ts`, `feature-workflow-child.test.ts`, and CLI adapter/native-child tests cover the actual producer and receiving boundary. The inference network inventory includes the shared native child backend constructors.

Implementation commit **3c71f668** is delivered to **origin/main**. Related native transport repair **26d4cbed**, tracked in [WO-45](../runtime-health-remediation/WO-45-native-ollama-tool-contract.md), is also delivered and included in the aggregate verification. The operator guide is [Long-horizon feature work](../../guides/long-horizon-feature-workflow.md).

Repository acceptance is complete. Publication, installed-package replacement and subsequent live Telegram/model acceptance remain with the user; these tests establish execution and recovery contracts with controlled fixtures, not live-model task performance.
