Skip to content

Commit a04829f

Browse files
committed
feat: complete recoverable project adoption
Ultra initialization previously created only a scaffold for existing repositories, could leave migrated or corrupt authority ambiguous, and allowed some task writers to bypass baseline and change ownership. Context limits and hook presentation could also obstruct legitimate incident work instead of providing recoverable guidance. Complete the greenfield, brownfield, prior-version, and corrupt-state lifecycle in one route. Add schema 12 repository, scope, branch, worktree, evidence, classification, and gap-ledger authority; safe resume and migration routing; explicit ready-baseline replacement approval; backup-first restore and rebaseline; durable archive-journal recovery; incident break-glass with mandatory reconciliation; and advisory context budgets. Rework Ultra skills and baseline templates around Observed, Verified, Decided, and Unknown evidence. Keep memory and code graph external, preserve host-neutral English prompt surfaces, and keep Claude Code, Codex, OpenCode, and Kimi installation contracts aligned. Close task authority bypasses across direct create, PRD parse, expansion, and update paths. Tasks now require a healthy baseline or authorized active change, children inherit parent ownership, established ownership cannot detach or cross changes, and terminal-change tasks are immutable. Verification: uv run --with pytest npm run verify:release passed all state/MCP, orchestrator, specification, four-host installation, npm tarball, and 24 hook tests; npm audit reported 0 vulnerabilities. Skill Creator quick validation passed 19/19 skills, prompt-authoring tests passed 11/11, MCP fixtures passed 69/69, npm pack dry-run contained 215 entries, and final forward ownership audit passed. Recovery remains explicit and backup-first; no project state is overwritten without the documented confirmation token. Persistent memory and code graph remain intentional external-provider exclusions. The unrelated untracked AGENTS.md was not staged.
1 parent 1f6c4d7 commit a04829f

79 files changed

Lines changed: 4460 additions & 566 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 21 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,30 @@
1-
# Research Reports
1+
# Research Evidence
22

3-
This directory contains research reports generated by `/ultra-research` step-file architecture.
3+
Store durable research evidence here only when it is too detailed for the baseline
4+
specification. Baseline decisions and accepted behavior remain in `.ultra/specs/`.
45

5-
## Structure
6+
## When to create a report
67

7-
Each round generates a report with quality metadata:
8+
Create a report for external facts, repository investigations, experiments, runtime
9+
observations, or decision evidence that must remain inspectable. Use a descriptive
10+
file name and include the observation date when freshness matters.
811

9-
| Steps | Round | Report File |
10-
|-------|-------|-------------|
11-
| 00-05 | R0: Product Discovery | `product-discovery-{date}.md` |
12-
| 10-11 | R1: User & Scenario | `user-scenario-{date}.md` |
13-
| 20-22 | R2: Feature Definition | `feature-definition-{date}.md` |
14-
| 30-32 | R3: Architecture Design | `architecture-design-{date}.md` |
15-
| 40-41 | R4: Quality & Deployment | `quality-deployment-{date}.md` |
12+
## Report contract
1613

17-
## Report Format
14+
Record:
1815

19-
Each report includes quality tracking in header:
16+
- scope and the decision the evidence informs;
17+
- observed facts with source references and dates;
18+
- verification commands or runtime evidence;
19+
- accepted decisions and their owner;
20+
- unresolved unknowns and whether they block the baseline;
21+
- links to the product or architecture sections updated from the evidence.
2022

21-
```markdown
22-
# Round {N}: {Round Name}
23+
Keep inference distinct from observation. Link to external provider content instead of
24+
copying memory, code-graph payloads, or large source material into Ultra.
2325

24-
> **Confidence**: 92%
25-
> **Steps completed**: {list}
26-
> **Completed**: {date}
26+
## Completion
2727

28-
## Key Findings
29-
[3-5 bullet points]
30-
31-
## Decisions Made
32-
[Choices and rationale]
33-
34-
## Open Questions
35-
[What remains uncertain]
36-
```
37-
38-
## Quality Gate
39-
40-
- Each step uses [C] Continue user gate — user confirms before proceeding
41-
- Per-step SUCCESS METRICS and FAILURE MODES enforce output quality
42-
- Step 99 (Synthesis) validates field-level completeness of all spec files
43-
44-
## Research Distillate
45-
46-
After all steps complete, `step-99-synthesis` generates:
47-
- `.ultra/specs/research-distillate.md` — Token-efficient summary (<2000 tokens) for `/ultra-plan` consumption
48-
49-
## Integration
50-
51-
- Reports are referenced in `specs/` for technology decisions
52-
- Research distillate is the primary input for `/ultra-plan`
53-
- Quality summary displayed at end of `/ultra-research`
28+
Update the affected baseline specification, include the report in `baseline.record`
29+
evidence when material, and record unresolved work in the authoritative gap ledger.
30+
Do not create a condensed duplicate of the baseline.

.ultra-template/specs/discovery.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,16 @@ Separate blocking unknowns from questions that are outside the accepted scope.
3636
|---|---|---|---|
3737
| | | | |
3838

39+
## Baseline Gaps
40+
41+
Reference the authoritative gap ids recorded in `.ultra/state.db`. Use one of
42+
`baseline_blocker`, `documentation_drift`, `known_defect`, `technical_debt`,
43+
`unknown`, or `future_change`.
44+
45+
| Gap id | Category | Status | Evidence reference | Owner |
46+
|---|---|---|---|---|
47+
| | | | | |
48+
3949
## Current Behavior Notes
4050

4151
For an existing project, describe only behavior confirmed from source, tests, runtime,

CHANGELOG.md

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,57 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
## [0.13.0] — 2026-07-18
11+
12+
### Added
13+
14+
- Added schema 12 repository snapshots, branch and dirty-worktree evidence,
15+
classification metadata, and a categorized baseline gap ledger with explicit
16+
blocker, ownership, acceptance, and resolution state.
17+
- Added safe `task.init_project` resume semantics, bounded monorepo scope
18+
detection, projection-only import routing, explicit migrated-baseline
19+
replacement, and backup-first recovery for old state databases.
20+
- Added explicit corrupt-state restore and rebaseline commands that quarantine
21+
the original database, WAL, SHM, and task projection and restore every moved
22+
artifact when recovery fails.
23+
- Added approved incident break-glass records and mandatory post-incident
24+
baseline reconciliation gaps, plus durable archive-journal crash recovery.
25+
26+
### Changed
27+
28+
- Made `ultra-init` the single route for empty repositories, existing
29+
codebases, healthy installations, incomplete adoptions, prior Ultra state,
30+
and corrupt databases. Existing application and baseline files are preserved;
31+
resume installs only missing current scaffold assets.
32+
- New ordinary changes now require a healthy ready baseline. Already-active
33+
work remains executable with visible drift warnings, while convergence still
34+
requires current approved authority.
35+
- Ready-baseline replacement now requires durable owner identity and rationale;
36+
a bare `replace_ready` boolean is rejected and cannot erase provenance.
37+
- Reworked baseline templates and host-neutral Skills around
38+
`Observed`/`Verified`/`Decided`/`Unknown` evidence, characterization results,
39+
owner approval, and one deterministic next action.
40+
41+
### Fixed
42+
43+
- Prevented prior-version projects from being treated as approved after a
44+
schema upgrade; compatibility baselines remain `migrated/adopting` until an
45+
evidence-backed brownfield replacement is approved.
46+
- Made status and doctor report old or corrupt state as structured recovery
47+
guidance, retain pre-migration backup paths on failure, and close failed
48+
database handles safely.
49+
- Prevented maintenance CLI telemetry from opening corrupt authority before
50+
evidence-preserving recovery checks, and made task creation enforce the same
51+
baseline boundary as change creation.
52+
- Closed bulk-parse and task-expansion task-creation bypasses; persisted PRD
53+
tasks now carry their active change id, and expanded children inherit the
54+
parent task's authorized change ownership.
55+
- Rejected task writes against missing or terminal changes even when the
56+
baseline is healthy, and enforced parent-child change ownership for generic
57+
task creation and reassignment paths.
58+
- Fixed installed npm tarballs so direct `ultra-tools task init-project` calls
59+
can locate the packaged scaffold outside a source checkout.
60+
1061
## [0.12.1] — 2026-07-18
1162

1263
### Fixed
@@ -490,7 +541,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
490541
skill manifest, CLI protocol + mapping table; 5 spec validators.
491542
- **Phase 0 — skeleton**: multi-runtime installer scaffolding.
492543

493-
[Unreleased]: https://github.com/rocky2431/ultra-builder-pro-cli/compare/v0.12.1...HEAD
544+
[Unreleased]: https://github.com/rocky2431/ultra-builder-pro-cli/compare/v0.13.0...HEAD
545+
[0.13.0]: https://github.com/rocky2431/ultra-builder-pro-cli/compare/v0.12.1...v0.13.0
494546
[0.12.1]: https://github.com/rocky2431/ultra-builder-pro-cli/compare/v0.12.0...v0.12.1
495547
[0.12.0]: https://github.com/rocky2431/ultra-builder-pro-cli/compare/v0.11.0...v0.12.0
496548
[0.11.0]: https://github.com/rocky2431/ultra-builder-pro-cli/compare/v0.10.0...v0.11.0

README.md

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ authoritative `.ultra/state.db`.
88

99
<div align="center">
1010

11-
[![Version](https://img.shields.io/badge/version-0.12.1-blue)](./CHANGELOG.md)
11+
[![Version](https://img.shields.io/badge/version-0.13.0-blue)](./CHANGELOG.md)
1212
[![Tests](https://img.shields.io/badge/tests-passing-brightgreen)](#verification)
1313
[![License: MIT](https://img.shields.io/badge/license-MIT-green)](./LICENSE)
1414
[![Node](https://img.shields.io/badge/node-%E2%89%A522-informational)](./package.json)
@@ -44,9 +44,10 @@ authoritative `.ultra/state.db`.
4444
Incident changes additionally require a five-section `diagnosis.md` covering
4545
reproduction, hypotheses, root cause, regression test, and recovery.
4646
- **Adopts existing repositories without pretending they are new.** `ultra-init`
47-
auto-detects greenfield versus brownfield work. Brownfield adoption records
48-
current specifications, repository/runtime evidence, known-red verification,
49-
unknowns, and explicit approval without rewriting application code.
47+
classifies greenfield, brownfield, and monorepo scope. Brownfield adoption records
48+
current specifications, repository/runtime evidence, worktree snapshot, known-red
49+
verification, categorized gaps, unknowns, and explicit approval without rewriting
50+
application code. v4.4 and v4.5 projection-only projects have backup-first imports.
5051
- **Keeps external context external.** Memory and code-graph providers retain
5152
their own content; Ultra stores only provider/project/revision/status metadata
5253
references in a compiled change context.
@@ -89,10 +90,10 @@ for per-runtime capabilities.
8990
Start with `ultra-init` in both new and existing projects. An empty project opens
9091
a `draft` greenfield baseline. An existing codebase opens an `adopting`
9192
brownfield baseline; inspect current behavior, call `baseline.record`, then
92-
approve it through `baseline.converge` before normal planning or delivery. An
93-
urgent active fix may continue while adoption or context-size warnings are
94-
visible. `change.converge` requires approved adoption, while normal HEAD/spec drift
95-
from that change is declared and health-checked atomically by `change.archive`.
93+
approve it through `baseline.converge` before normal planning or delivery. Existing
94+
active work may continue while adoption drift is visible. A new incident requires an
95+
explicit break-glass approver and leaves a blocking reconciliation gap at archive;
96+
new ordinary work always requires a healthy ready baseline.
9697

9798
## Three-layer architecture
9899

@@ -133,9 +134,13 @@ Full details in [`docs/RUNTIME-COMPAT-MATRIX.md`](./docs/RUNTIME-COMPAT-MATRIX.m
133134
## Typical workflow
134135

135136
```bash
136-
# 1. Initialize a new project or adopt an existing repository automatically
137+
# 1. Bootstrap project state (the ultra-init skill completes adoption and approval)
137138
ultra-tools task init-project --project-name myapp --mode auto
138139

140+
# Projection-only projects from prior releases use one backup-first import:
141+
ultra-tools migrate --from=4.4 --to=4.5 --source-dir .
142+
ultra-tools migrate --from=4.5 --to=12.0 --source-dir .
143+
139144
# 2. Record and converge the greenfield/brownfield baseline, then turn accepted
140145
# behavior into a task graph (normally driven by ultra-init/research/plan)
141146

@@ -208,6 +213,17 @@ Individual suites: `test:state`, `test:orch`, `test:spec`, `test:rest`.
208213
the recorded install provenance with current asset hashes and validates the
209214
host-specific hook, MCP, plugin, and runtime-manifest entry points. Reinstall
210215
only after preserving the degraded report as evidence.
216+
- **Projection tasks exist but state.db has no tasks**: run the exact v4.4 or v4.5
217+
`ultra-tools migrate` command returned by MCP, verify the backup and imported counts,
218+
then run `ultra-init` to replace the compatibility row with a reviewed brownfield
219+
baseline.
220+
- **Old or corrupt state.db**: `ultra-tools system doctor` is read-only;
221+
`ultra-tools system doctor --repair` upgrades supported schemas with two backup
222+
checkpoints. A corrupt database is never overwritten automatically. After explicit
223+
owner approval, restore a verified managed copy with
224+
`ultra-tools system restore --backup <path> --confirm REPLACE_CORRUPT_ULTRA_STATE`,
225+
or preserve the corrupt DB and legacy projection before rebuilding authority with
226+
`ultra-tools system rebaseline --project-name <name> --confirm REBASELINE_CORRUPT_ULTRA_STATE`.
211227
- **Legacy Ultra memory data remains on disk**: inspect first with
212228
`ultra-tools legacy-memory inspect`, archive with
213229
`ultra-tools legacy-memory archive`, then prune only with the explicit

adapters/_shared/handbook.cjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,12 @@ function renderHandbook(runtime) {
6060
`- Collaboration boundary: ${value.collaboration}. The current host remains primary and owns final verification.`,
6161
`- Coordination boundary: ${value.coordination}.`,
6262
'- Authority: `.ultra/state.db` is the only durable Ultra authority for baselines, changes, tasks, sessions, events, incidents, projection state, telemetry, and review evidence. Generated JSON and Markdown are projections or workflow artifacts.',
63-
'- Baseline boundary: `task.init_project` detects greenfield or brownfield work; `baseline.start`, `baseline.record`, and `baseline.converge` adopt the project without rewriting application code. An incomplete baseline is advisory during active work but blocks change convergence; normal HEAD or tracked-spec drift from that change is reconciled and health-checked atomically at archive.',
63+
'- Baseline boundary: `task.init_project` classifies greenfield or brownfield work and records repository scope. Projection-only prior state uses the exact supported backup-first import returned by the authority check; migrated compatibility rows require explicit brownfield re-adoption. `baseline.record` owns evidence, verification, repository snapshot, and the gap ledger; `baseline.converge` requires explicit owner approval. New ordinary changes require a healthy ready baseline. Existing active work may continue with warnings, but baseline readiness blocks change convergence; normal drift reconciliation is health-checked atomically at archive. Only an explicitly approved incident break-glass may start without baseline readiness, and its archive creates a blocking reconciliation gap.',
6464
'- Context Spine boundary: `change.context` compiles role/gate readiness, required references, a fresh-context budget, public seam, verification command, and one next action. File, token, and context-share budgets are advisory attention signals, not refusal gates. Hooks inject only the DB-derived `change.breadcrumb`; missing required evidence or stale execution context must be recompiled.',
6565
'- Specification learning boundary: stable implementation discoveries use approval-gated propose/approve-or-reject/apply transitions. Unresolved learning blocks convergence; review requires independent specification-fidelity and engineering-standards evidence.',
6666
'- Memory and graph boundary: Ultra Builder Pro does not capture prompts, transcripts, observations, summaries, cross-session memory, or code-graph content. Separately installed providers own that data; Ultra may store only their metadata references in a change context manifest.',
6767
'- Hook boundary: Ultra hooks observe workflow/change lifecycle only. Health/context may run when `.ultra/state.db` exists; advisory warnings never reject work, and an incomplete workflow never traps session stop. Direct projection protection remains authoritative; compact and subagent recovery stays active-workflow scoped. Generic command blocking and post-edit policy stay in user or repository governance.',
68-
'- Installation boundary: `ubp --doctor` is the read-only authority for installed asset provenance, content hashes, and host entry-point wiring; `system.doctor` remains scoped to project state and workflow recovery.',
68+
'- Installation boundary: `ubp --doctor` is the read-only authority for installed asset provenance, content hashes, and host entry-point wiring. Project `system.doctor` diagnoses state and performs only authorized backup-first schema, projection, session, and archive-journal recovery; it never approves a baseline.',
6969
'- Agent boundary: the bundled review and debugging agents are bounded workers. They use the current checkout and parent-supplied context, do not own private persistent state, and never replace the primary agent.',
7070
'- Package boundary: only the twelve Ultra workflows, four internal review-rule skills, host-specific collaboration companions, and the minimal host bootstrap belong to this plugin. General browser, deployment, discovery, and framework skills must be installed from their owners.',
7171
END_MARKER,

adapters/tests/codex.test.cjs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const { spawnSync } = require('node:child_process');
99
const yaml = require('js-yaml');
1010
const { Client } = require('@modelcontextprotocol/sdk/client/index.js');
1111
const { StdioClientTransport } = require('@modelcontextprotocol/sdk/client/stdio.js');
12+
const { initStateDb, closeStateDb } = require('../../mcp-server/lib/state-db.cjs');
1213

1314
const codex = require('../codex.js');
1415
const { parse: parseFrontmatter } = require('../_shared/frontmatter.cjs');
@@ -263,6 +264,13 @@ test('bundled plugin MCP runs outside the source checkout and keeps state in the
263264
let client;
264265
try {
265266
install(layout);
267+
const seededState = initStateDb(path.join(projectDir, '.ultra', 'state.db'));
268+
seededState.db.prepare(
269+
`INSERT INTO baselines
270+
(id, project_name, mode, status, approved_by, approval_note, converged_at)
271+
VALUES ('test-baseline', 'codex-bundle', 'greenfield', 'ready', 'test', 'smoke fixture', ?)`,
272+
).run(new Date().toISOString());
273+
closeStateDb(seededState.db);
266274
const mcp = JSON.parse(fs.readFileSync(path.join(layout.pluginRoot, '.mcp.json'), 'utf8'));
267275
const server = mcp.mcpServers['ultra-builder-pro'];
268276
const env = { ...process.env };

commands/ultra-init.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
description: Initialize a new project or adopt an existing repository into authoritative Ultra baseline state
3-
argument-hint: "[name] [type] [stack] [auto|greenfield|brownfield]"
3+
argument-hint: "[name] [type] [stack] [auto|greenfield|brownfield] [--scope <path>]"
44
workflow-ref: "@skills/ultra-init/SKILL.md"
55
---
66

docs/AGENT-CONTEXT.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,10 @@ necessary context when they do not.
7878
role, gate, readiness, blockers, and one next action. They must not inject intent
7979
bodies, transcripts, external memory, or graph payloads. Missing references,
8080
digest drift, HEAD drift, or a missing execution seam blocks readiness. Context
81-
size and an incomplete baseline are advisory during an active bounded change;
82-
baseline adoption becomes a hard gate at convergence; revision and tracked-spec
83-
integrity are reconciled and rechecked atomically at archive.
81+
size and baseline drift are advisory for a change that is already active. New ordinary
82+
work requires a healthy baseline. Only an explicitly approved incident break-glass may
83+
start without it; incident archive records a blocking reconciliation gap. Revision and
84+
tracked-spec integrity are reconciled and rechecked atomically for ordinary archive.
8485

8586
Stable discoveries use `change.learning_propose`; they reach the baseline only
8687
through approve/reject/apply transitions in `change.learning_resolve`. Unresolved

0 commit comments

Comments
 (0)