opencode-agent-orchestration-kit 1.0.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/CODEOWNERS +1 -0
- package/.github/ISSUE_TEMPLATE/bug_report.yml +65 -0
- package/.github/ISSUE_TEMPLATE/config.yml +11 -0
- package/.github/ISSUE_TEMPLATE/documentation.yml +22 -0
- package/.github/ISSUE_TEMPLATE/feature_request.yml +43 -0
- package/.github/PULL_REQUEST_TEMPLATE.md +25 -0
- package/.github/workflows/check.yml +47 -0
- package/CODE_OF_CONDUCT.md +24 -0
- package/CONTRIBUTING.md +52 -0
- package/LICENSE +201 -0
- package/NOTICE.md +23 -0
- package/README.md +806 -0
- package/SECURITY.md +17 -0
- package/docker/open-design/.env.example +6 -0
- package/docker/open-design/Dockerfile +50 -0
- package/docker/open-design/docker-compose.yml +18 -0
- package/docker/open-design/opencode-od/agents/od-worker.md +22 -0
- package/docker/open-design/opencode-od/opencode.json +24 -0
- package/docs/agents.md +21 -0
- package/docs/commands.md +16 -0
- package/docs/configuration.md +30 -0
- package/docs/docker-open-design.md +42 -0
- package/docs/impeccable.md +18 -0
- package/docs/installation.md +176 -0
- package/docs/models.md +17 -0
- package/docs/open-design.md +25 -0
- package/docs/quickstart.md +74 -0
- package/docs/releases/v1.0.10.md +46 -0
- package/docs/releases/v1.0.14.md +39 -0
- package/docs/releases/v1.0.27.md +66 -0
- package/docs/security.md +8 -0
- package/docs/superpowers/plans/2026-07-20-safe-installation-lifecycle.md +779 -0
- package/docs/superpowers/plans/2026-07-20-version-identity-and-releases.md +590 -0
- package/docs/superpowers/specs/2026-07-20-safe-installation-lifecycle-design.md +1350 -0
- package/docs/superpowers/specs/2026-07-20-version-identity-and-releases-design.md +557 -0
- package/docs/superpowers.md +34 -0
- package/docs/synology.md +30 -0
- package/docs/troubleshooting.md +54 -0
- package/docs/workflows.md +44 -0
- package/doctor.sh +5 -0
- package/env.example +15 -0
- package/install.sh +5 -0
- package/opencode/AGENTS.md +104 -0
- package/opencode/agents/debugger.md +41 -0
- package/opencode/agents/designer.md +93 -0
- package/opencode/agents/developer.md +180 -0
- package/opencode/agents/evaluator.md +35 -0
- package/opencode/agents/evolver.md +31 -0
- package/opencode/agents/lead.md +251 -0
- package/opencode/agents/researcher.md +76 -0
- package/opencode/agents/review_api.md +34 -0
- package/opencode/agents/review_coordinator.md +111 -0
- package/opencode/agents/review_quality.md +35 -0
- package/opencode/agents/review_security.md +35 -0
- package/opencode/agents/review_tests.md +37 -0
- package/opencode/agents/reviewer.md +116 -0
- package/opencode/agents/scoper.md +75 -0
- package/opencode/agents/specifier.md +116 -0
- package/opencode/commands/code-simplify.md +36 -0
- package/opencode/commands/design.md +27 -0
- package/opencode/commands/evolve.md +165 -0
- package/opencode/commands/feature.md +67 -0
- package/opencode/commands/implement.md +11 -0
- package/opencode/commands/init.md +34 -0
- package/opencode/commands/loop.md +145 -0
- package/opencode/commands/mvp-spec.md +20 -0
- package/opencode/commands/plan.md +74 -0
- package/opencode/commands/research.md +12 -0
- package/opencode/commands/review-orchestrated.md +47 -0
- package/opencode/commands/review-preflight.md +26 -0
- package/opencode/commands/review.md +18 -0
- package/opencode/commands/scope.md +36 -0
- package/opencode/commands/spec.md +12 -0
- package/opencode/commands/test.md +40 -0
- package/opencode/docs/ai/evolution/README.md +135 -0
- package/opencode/docs/ai/evolution/benchmarks/manual-scenarios.md +123 -0
- package/opencode/docs/ai/evolution/benchmarks/router-scenarios.jsonl +8 -0
- package/opencode/docs/ai/evolution/evolution_history.md +83 -0
- package/opencode/docs/ai/evolution/mechanisms.jsonl +7 -0
- package/opencode/docs/ai/evolution/rejected_mechanisms.jsonl +2 -0
- package/opencode/docs/ai/evolution/runs/README.md +15 -0
- package/opencode/docs/ai/evolution/runs/iteration-001-sidecar/analysis/overview.md +12 -0
- package/opencode/docs/ai/evolution/runs/iteration-001-sidecar/change_evaluation.json +108 -0
- package/opencode/docs/ai/evolution/runs/iteration-001-sidecar/change_manifest.json +52 -0
- package/opencode/docs/ai/evolution/runs/iteration-001-sidecar/evaluation.md +19 -0
- package/opencode/docs/ai/evolution/runs/iteration-001-sidecar/post_evaluation.md +12 -0
- package/opencode/docs/ai/evolution/runs/iteration-002-feature-flow-fix/analysis/overview.md +7 -0
- package/opencode/docs/ai/evolution/runs/iteration-002-feature-flow-fix/change_evaluation.json +31 -0
- package/opencode/docs/ai/evolution/runs/iteration-002-feature-flow-fix/evaluation.md +19 -0
- package/opencode/docs/ai/evolution/runs/iteration-003-agent-readable-harness/analysis/overview.md +13 -0
- package/opencode/docs/ai/evolution/runs/iteration-003-agent-readable-harness/change_evaluation.json +66 -0
- package/opencode/docs/ai/evolution/runs/iteration-003-agent-readable-harness/change_manifest.json +82 -0
- package/opencode/docs/ai/evolution/runs/iteration-003-agent-readable-harness/evaluation.md +20 -0
- package/opencode/docs/ai/evolution/runs/iteration-004-orchestration-audit/analysis/detail/ahe-run-lifecycle-validator.md +40 -0
- package/opencode/docs/ai/evolution/runs/iteration-004-orchestration-audit/analysis/detail/evolve-evaluation-only-contract.md +15 -0
- package/opencode/docs/ai/evolution/runs/iteration-004-orchestration-audit/analysis/detail/open-design-tool-contract.md +14 -0
- package/opencode/docs/ai/evolution/runs/iteration-004-orchestration-audit/analysis/detail/slash-command-contract-coverage.md +40 -0
- package/opencode/docs/ai/evolution/runs/iteration-004-orchestration-audit/analysis/overview.md +17 -0
- package/opencode/docs/ai/evolution/runs/iteration-004-orchestration-audit/analysis/pre_apply_approval.md +15 -0
- package/opencode/docs/ai/evolution/runs/iteration-004-orchestration-audit/change_evaluation.json +252 -0
- package/opencode/docs/ai/evolution/runs/iteration-004-orchestration-audit/change_manifest.json +210 -0
- package/opencode/docs/ai/evolution/runs/iteration-004-orchestration-audit/evaluation.md +25 -0
- package/opencode/docs/ai/evolution/runs/iteration-004-orchestration-audit/post_apply_evaluation.md +15 -0
- package/opencode/docs/ai/evolution/runs/iteration-004-orchestration-audit/post_manifest_evaluation.md +14 -0
- package/opencode/docs/ai/evolution/runs/iteration-004-orchestration-audit/pre_apply_evaluation.md +15 -0
- package/opencode/docs/ai/evolution/runs/iteration-005-harness-orchestration-audit/analysis/overview.md +13 -0
- package/opencode/docs/ai/evolution/runs/iteration-005-harness-orchestration-audit/change_evaluation.json +14 -0
- package/opencode/docs/ai/evolution/runs/iteration-005-harness-orchestration-audit/change_manifest.json +30 -0
- package/opencode/docs/ai/evolution/runs/iteration-005-harness-orchestration-audit/evaluation.md +25 -0
- package/opencode/docs/ai/evolution/runs/iteration-006-lead-delegation-audit/analysis/overview.md +13 -0
- package/opencode/docs/ai/evolution/runs/iteration-006-lead-delegation-audit/change_evaluation.json +14 -0
- package/opencode/docs/ai/evolution/runs/iteration-006-lead-delegation-audit/change_manifest.json +29 -0
- package/opencode/docs/ai/evolution/runs/iteration-006-lead-delegation-audit/evaluation.md +18 -0
- package/opencode/docs/ai/evolution/runs/iteration-007-agent-skills-integration/analysis/overview.md +13 -0
- package/opencode/docs/ai/evolution/runs/iteration-007-agent-skills-integration/change_evaluation.json +14 -0
- package/opencode/docs/ai/evolution/runs/iteration-007-agent-skills-integration/change_manifest.json +34 -0
- package/opencode/docs/ai/evolution/runs/iteration-007-agent-skills-integration/evaluation.md +17 -0
- package/opencode/docs/ai/evolution/runs/iteration-008-lead-readonly-shell-permissions/analysis/overview.md +13 -0
- package/opencode/docs/ai/evolution/runs/iteration-008-lead-readonly-shell-permissions/change_evaluation.json +12 -0
- package/opencode/docs/ai/evolution/runs/iteration-008-lead-readonly-shell-permissions/change_manifest.json +28 -0
- package/opencode/docs/ai/evolution/runs/iteration-008-lead-readonly-shell-permissions/evaluation.md +17 -0
- package/opencode/docs/ai/evolution/runs/iteration-009-lead-developer-ownership-loop/analysis/overview.md +9 -0
- package/opencode/docs/ai/evolution/runs/iteration-009-lead-developer-ownership-loop/change_evaluation.json +14 -0
- package/opencode/docs/ai/evolution/runs/iteration-009-lead-developer-ownership-loop/change_manifest.json +31 -0
- package/opencode/docs/ai/evolution/runs/iteration-009-lead-developer-ownership-loop/evaluation.md +18 -0
- package/opencode/docs/ai/evolution/runs/iteration-010-token-plugin-sidebar-content/analysis/overview.md +12 -0
- package/opencode/docs/ai/evolution/runs/iteration-010-token-plugin-sidebar-content/change_evaluation.json +14 -0
- package/opencode/docs/ai/evolution/runs/iteration-010-token-plugin-sidebar-content/change_manifest.json +31 -0
- package/opencode/docs/ai/evolution/runs/iteration-010-token-plugin-sidebar-content/evaluation.md +17 -0
- package/opencode/docs/ai/evolution/runs/iteration-011-lead-cd-which-permissions/analysis/overview.md +10 -0
- package/opencode/docs/ai/evolution/runs/iteration-011-lead-cd-which-permissions/change_evaluation.json +14 -0
- package/opencode/docs/ai/evolution/runs/iteration-011-lead-cd-which-permissions/change_manifest.json +30 -0
- package/opencode/docs/ai/evolution/runs/iteration-011-lead-cd-which-permissions/evaluation.md +17 -0
- package/opencode/docs/ai/evolution/runs/iteration-012-lead-shell-allowlist-boundaries/analysis/overview.md +25 -0
- package/opencode/docs/ai/evolution/runs/iteration-012-lead-shell-allowlist-boundaries/change_evaluation.json +28 -0
- package/opencode/docs/ai/evolution/runs/iteration-012-lead-shell-allowlist-boundaries/change_manifest.json +31 -0
- package/opencode/docs/ai/evolution/runs/iteration-012-lead-shell-allowlist-boundaries/evaluation.md +22 -0
- package/opencode/docs/ai/evolution/runs/iteration-013-doc-gardening-mechanical-checks/analysis/overview.md +27 -0
- package/opencode/docs/ai/evolution/runs/iteration-013-doc-gardening-mechanical-checks/change_evaluation.json +32 -0
- package/opencode/docs/ai/evolution/runs/iteration-013-doc-gardening-mechanical-checks/change_manifest.json +49 -0
- package/opencode/docs/ai/evolution/runs/iteration-013-doc-gardening-mechanical-checks/evaluation.md +92 -0
- package/opencode/docs/ai/evolution/runs/iteration-014-harness-baseline/analysis/detail/token-vs-semantic.md +31 -0
- package/opencode/docs/ai/evolution/runs/iteration-014-harness-baseline/analysis/overview.md +14 -0
- package/opencode/docs/ai/evolution/runs/iteration-014-harness-baseline/evaluation.md +36 -0
- package/opencode/docs/ai/evolution/runs/iteration-015-semantic-checker/analysis/overview.md +13 -0
- package/opencode/docs/ai/evolution/runs/iteration-015-semantic-checker/change_evaluation.json +31 -0
- package/opencode/docs/ai/evolution/runs/iteration-015-semantic-checker/change_manifest.json +47 -0
- package/opencode/docs/ai/evolution/runs/iteration-015-semantic-checker/evaluation.md +27 -0
- package/opencode/docs/ai/evolution/runs/iteration-016-contract-prompt-alignment/analysis/overview.md +32 -0
- package/opencode/docs/ai/evolution/runs/iteration-016-contract-prompt-alignment/change_evaluation.json +31 -0
- package/opencode/docs/ai/evolution/runs/iteration-016-contract-prompt-alignment/change_manifest.json +35 -0
- package/opencode/docs/ai/evolution/runs/iteration-016-contract-prompt-alignment/evaluation.md +31 -0
- package/opencode/docs/ai/evolution/runs/iteration-017-ahe-cycle/analysis/detail/pattern-1-feature-sidecar-false-positive.md +51 -0
- package/opencode/docs/ai/evolution/runs/iteration-017-ahe-cycle/analysis/detail/pattern-2-checker-time-budget.md +52 -0
- package/opencode/docs/ai/evolution/runs/iteration-017-ahe-cycle/analysis/overview.md +99 -0
- package/opencode/docs/ai/evolution/runs/iteration-017-ahe-cycle/change_evaluation.json +61 -0
- package/opencode/docs/ai/evolution/runs/iteration-017-ahe-cycle/change_manifest.json +61 -0
- package/opencode/docs/ai/evolution/runs/iteration-017-ahe-cycle/evaluation.md +448 -0
- package/opencode/docs/ai/evolution/runs/iteration-018-free-message-routing-audit/analysis/detail/intake-gray-zone.md +65 -0
- package/opencode/docs/ai/evolution/runs/iteration-018-free-message-routing-audit/analysis/overview.md +172 -0
- package/opencode/docs/ai/evolution/runs/iteration-018-free-message-routing-audit/evaluation.md +226 -0
- package/opencode/docs/ai/evolution/runs/iteration-019-handoff-routing-audit/analysis/detail/plan-only-gray-zone.md +62 -0
- package/opencode/docs/ai/evolution/runs/iteration-019-handoff-routing-audit/analysis/overview.md +167 -0
- package/opencode/docs/ai/evolution/runs/iteration-019-handoff-routing-audit/evaluation.md +163 -0
- package/opencode/docs/ai/evolution/runs/iteration-020-loop-engineering-command/analysis/overview.md +42 -0
- package/opencode/docs/ai/evolution/runs/iteration-020-loop-engineering-command/change_evaluation.json +46 -0
- package/opencode/docs/ai/evolution/runs/iteration-020-loop-engineering-command/change_manifest.json +57 -0
- package/opencode/docs/ai/evolution/runs/iteration-020-loop-engineering-command/evaluation.md +48 -0
- package/opencode/docs/ai/evolution/runs/iteration-021/analysis/detail/contract-vs-runtime-gap.md +163 -0
- package/opencode/docs/ai/evolution/runs/iteration-021/analysis/detail/evidence-collection-blocker.md +134 -0
- package/opencode/docs/ai/evolution/runs/iteration-021/analysis/overview.md +111 -0
- package/opencode/docs/ai/evolution/runs/iteration-021/change_evaluation.json +52 -0
- package/opencode/docs/ai/evolution/runs/iteration-021/change_manifest.json +50 -0
- package/opencode/docs/ai/evolution/runs/iteration-021/evaluation.md +46 -0
- package/opencode/docs/ai/evolution/runs/iteration-021/manifest-justification.md +48 -0
- package/opencode/docs/ai/evolution/session-sources.md +91 -0
- package/opencode/docs/ai/harness/README.md +32 -0
- package/opencode/docs/ai/harness/agents.md +148 -0
- package/opencode/docs/ai/harness/checks.md +119 -0
- package/opencode/docs/ai/harness/commands.md +391 -0
- package/opencode/docs/ai/harness/evidence.md +85 -0
- package/opencode/docs/ai/harness/init-detection-rules.md +160 -0
- package/opencode/docs/ai/harness/orchestrated-review.md +131 -0
- package/opencode/docs/ai/harness/skill-metadata-schema.md +198 -0
- package/opencode/docs/ai/harness/skill-resolution.md +202 -0
- package/opencode/docs/ai/harness/skill_registry.json +443 -0
- package/opencode/docs/ai/harness/skill_registry.md +43 -0
- package/opencode/docs/ai/project-context-template.md +53 -0
- package/opencode/opencode.json +38 -0
- package/opencode/package-lock.json +1717 -0
- package/opencode/package.json +11 -0
- package/opencode/plugins/token-tree-usage.tsx +206 -0
- package/opencode/references/performance-checklist.md +153 -0
- package/opencode/references/security-checklist.md +134 -0
- package/opencode/references/testing-patterns.md +236 -0
- package/opencode/scripts/check-harness.mjs +1572 -0
- package/opencode/scripts/check-harness.test.mjs +820 -0
- package/opencode/scripts/collect-session-evidence.mjs +612 -0
- package/opencode/scripts/collect-session-evidence.test.mjs +443 -0
- package/opencode/scripts/preflight-audit.mjs +497 -0
- package/opencode/scripts/preflight-audit.test.mjs +363 -0
- package/opencode/scripts/project-capability-snapshot.mjs +407 -0
- package/opencode/scripts/project-capability-snapshot.test.mjs +382 -0
- package/opencode/scripts/review-orchestrated-prepare.mjs +547 -0
- package/opencode/scripts/review-orchestrated-prepare.test.mjs +516 -0
- package/opencode/scripts/skill-resolver.mjs +585 -0
- package/opencode/scripts/skill-resolver.test.mjs +781 -0
- package/opencode/scripts/update-skill-registry.mjs +380 -0
- package/opencode/skills/api-and-interface-design/SKILL.md +315 -0
- package/opencode/skills/autonomous-loops/SKILL.md +312 -0
- package/opencode/skills/code-review-and-quality/SKILL.md +365 -0
- package/opencode/skills/code-simplification/SKILL.md +345 -0
- package/opencode/skills/context-engineering/SKILL.md +252 -0
- package/opencode/skills/debugging-and-error-recovery/SKILL.md +316 -0
- package/opencode/skills/documentation-and-adrs/SKILL.md +298 -0
- package/opencode/skills/doubt-driven-development/SKILL.md +168 -0
- package/opencode/skills/iterative-retrieval/SKILL.md +232 -0
- package/opencode/skills/open-design/SKILL.md +123 -0
- package/opencode/skills/performance-optimization/SKILL.md +365 -0
- package/opencode/skills/security-and-hardening/SKILL.md +369 -0
- package/opencode/skills/source-driven-development/SKILL.md +210 -0
- package/opencode/skills/test-driven-development/SKILL.md +406 -0
- package/opencode/skills/using-agent-skills/SKILL.md +194 -0
- package/opencode/skills/verification-loop/SKILL.md +162 -0
- package/opencode/tools/open_design.ts +361 -0
- package/opencode/tui.json +5 -0
- package/package.json +20 -0
- package/rollback.sh +5 -0
- package/scripts/check.sh +184 -0
- package/scripts/install-smoke.sh +111 -0
- package/scripts/manage-installation.mjs +1498 -0
- package/scripts/manage-installation.test.mjs +1936 -0
- package/scripts/version.mjs +197 -0
- package/scripts/version.test.mjs +195 -0
- package/uninstall.sh +5 -0
- package/upgrade.sh +5 -0
|
@@ -0,0 +1,1350 @@
|
|
|
1
|
+
# Safe Installation Lifecycle Design
|
|
2
|
+
|
|
3
|
+
## Status
|
|
4
|
+
|
|
5
|
+
Revised design awaiting explicit approval before implementation planning.
|
|
6
|
+
|
|
7
|
+
## Problem
|
|
8
|
+
|
|
9
|
+
The current installer copies directory contents directly into an OpenCode
|
|
10
|
+
configuration. It preserves a small set of existing root files, but it
|
|
11
|
+
overwrites colliding files under managed directories. The uninstaller relies on
|
|
12
|
+
a manually maintained list, deletes listed files even after user modification,
|
|
13
|
+
and leaves most currently shipped files behind.
|
|
14
|
+
|
|
15
|
+
The measured baseline is:
|
|
16
|
+
|
|
17
|
+
- a pre-existing `agents/lead.md` is overwritten during install;
|
|
18
|
+
- a subsequently modified owned file is deleted during uninstall;
|
|
19
|
+
- the shipped payload contains 185 files while the uninstall list contains 30;
|
|
20
|
+
- 155 shipped files remain after uninstall;
|
|
21
|
+
- neither install nor uninstall supports `--dry-run`;
|
|
22
|
+
- there is no upgrade, doctor, ownership manifest, or rollback mechanism.
|
|
23
|
+
|
|
24
|
+
## Goals
|
|
25
|
+
|
|
26
|
+
1. Track which files the kit owns without claiming unrelated user files.
|
|
27
|
+
2. Make every mutation plan inspectable before it is applied.
|
|
28
|
+
3. Prevent an upgrade from writing anything when a blocking conflict or
|
|
29
|
+
unexplained drift exists on managed files.
|
|
30
|
+
4. Preserve user modifications during uninstall.
|
|
31
|
+
5. Support clean install, managed upgrade, diagnosis, uninstall, and one-step
|
|
32
|
+
rollback with synthetic, reproducible tests.
|
|
33
|
+
6. Detect interrupted, corrupt, or concurrent operations mechanically.
|
|
34
|
+
7. Keep the implementation local, dependency-free, auditable, and portable
|
|
35
|
+
across supported macOS and Linux environments.
|
|
36
|
+
|
|
37
|
+
## Non-goals
|
|
38
|
+
|
|
39
|
+
- A general-purpose package manager or remote control plane.
|
|
40
|
+
- The future `oak` CLI proposed for roadmap Slice 3.2.
|
|
41
|
+
- Canonical kit version identity, release-note binding, or migrations keyed by
|
|
42
|
+
kit version; those belong to Slice 1.3.
|
|
43
|
+
- A full compatibility matrix or Windows support declaration; those belong to
|
|
44
|
+
Slice 1.4.
|
|
45
|
+
- Multiple rollback generations, automatic background repair, or automatic
|
|
46
|
+
synchronization.
|
|
47
|
+
- Automatic merging of user configuration files.
|
|
48
|
+
|
|
49
|
+
## Chosen approach
|
|
50
|
+
|
|
51
|
+
Use one dependency-free Node.js engine at `scripts/manage-installation.mjs`.
|
|
52
|
+
Small shell wrappers keep the current repository interface and expose one
|
|
53
|
+
operation each:
|
|
54
|
+
|
|
55
|
+
```text
|
|
56
|
+
install.sh [--dry-run] [--force] [--target PATH]
|
|
57
|
+
upgrade.sh [--dry-run] [--target PATH]
|
|
58
|
+
doctor.sh [--accept-preserved PATH] [--target PATH]
|
|
59
|
+
uninstall.sh [--dry-run] [--yes] [--target PATH]
|
|
60
|
+
rollback.sh [--dry-run] [--target PATH]
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
The wrappers contain no ownership or mutation logic. They resolve the repository
|
|
64
|
+
root and invoke the Node engine with the corresponding command.
|
|
65
|
+
|
|
66
|
+
Target resolution is identical for every wrapper: explicit `--target PATH`
|
|
67
|
+
wins, otherwise use a non-empty `OPENCODE_CONFIG_DIR`, otherwise use
|
|
68
|
+
`$HOME/.config/opencode`. The command fails if the selected environment value
|
|
69
|
+
is empty or if `HOME` is unavailable when needed. Shell-style `~` expansion is
|
|
70
|
+
not performed on argument values.
|
|
71
|
+
|
|
72
|
+
Extending the current Bash implementation was rejected because manifest parsing,
|
|
73
|
+
hashing, journaling, recovery, and deterministic tests would be duplicated and
|
|
74
|
+
fragile. A committed static payload manifest was rejected because it would
|
|
75
|
+
duplicate the source tree and introduce another drift surface before Slice 1.3
|
|
76
|
+
defines canonical version identity.
|
|
77
|
+
|
|
78
|
+
## Source payload
|
|
79
|
+
|
|
80
|
+
The source payload is the regular files and executable modes below `opencode/`.
|
|
81
|
+
The engine walks that directory without following symlinks and builds a sorted
|
|
82
|
+
inventory of normalized POSIX-style relative paths. A symlink file or symlink
|
|
83
|
+
directory anywhere in the source inventory is rejected; the walk never follows
|
|
84
|
+
it.
|
|
85
|
+
|
|
86
|
+
`.oak` is a reserved namespace and can never be part of the source payload or
|
|
87
|
+
the files managed by the kit. Source inventory rejects `.oak` and every
|
|
88
|
+
descendant path before normalization can admit it, whether the source entry is
|
|
89
|
+
a regular file, directory, symlink, or an equivalent normalized spelling.
|
|
90
|
+
|
|
91
|
+
Each source entry contains:
|
|
92
|
+
|
|
93
|
+
```json
|
|
94
|
+
{
|
|
95
|
+
"path": "agents/lead.md",
|
|
96
|
+
"sha256": "hex digest",
|
|
97
|
+
"mode": 420
|
|
98
|
+
}
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
Paths must be relative, normalized, non-empty, and contain neither `..` nor a
|
|
102
|
+
platform root. Duplicate normalized paths are invalid. A persisted source mode
|
|
103
|
+
is exactly `stat.mode & 0o777`, represented as an integer from `0o000` through
|
|
104
|
+
`0o777`. Executable bits are preserved; the engine must not normalize all
|
|
105
|
+
payload files to `0644`.
|
|
106
|
+
|
|
107
|
+
## Target state layout
|
|
108
|
+
|
|
109
|
+
Managed state lives below the selected target:
|
|
110
|
+
|
|
111
|
+
```text
|
|
112
|
+
TARGET/.oak/
|
|
113
|
+
manifest.json
|
|
114
|
+
lock.json
|
|
115
|
+
transaction.json
|
|
116
|
+
rollback/
|
|
117
|
+
transaction.json
|
|
118
|
+
files/
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
`manifest.json` is active ownership state. `transaction.json` exists only while
|
|
122
|
+
an operation is in progress or needs recovery. `rollback/` stores exactly one
|
|
123
|
+
committed rollback point. Transient `rollback.next/` and `rollback.previous/`
|
|
124
|
+
directories may exist only while durably replacing that point or recovering the
|
|
125
|
+
replacement. Uninstall may leave `.oak/` behind so that the most recent
|
|
126
|
+
uninstall can be rolled back.
|
|
127
|
+
|
|
128
|
+
Structured `.oak/` metadata does not intentionally store credentials,
|
|
129
|
+
environment values, tokens, prompts, logs, transcripts, unrelated
|
|
130
|
+
configuration, or absolute machine-local paths. Rollback backups are different:
|
|
131
|
+
they contain the exact previous bytes of overwritten or removed managed files.
|
|
132
|
+
Those bytes may include credentials or private configuration and must be treated
|
|
133
|
+
as potentially sensitive.
|
|
134
|
+
|
|
135
|
+
Required permissions are:
|
|
136
|
+
|
|
137
|
+
```text
|
|
138
|
+
.oak/ 0700
|
|
139
|
+
manifest.json 0600
|
|
140
|
+
lock.json 0600
|
|
141
|
+
transaction.json 0600
|
|
142
|
+
rollback/ 0700
|
|
143
|
+
rollback/transaction.json 0600
|
|
144
|
+
rollback/files/* 0600
|
|
145
|
+
state temporary files 0600
|
|
146
|
+
transient rollback directories 0700
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
State directories and files are created with restrictive permissions before
|
|
150
|
+
any sensitive bytes are written; they are not created permissively and fixed
|
|
151
|
+
afterward. Backup contents are never printed. Errors, logs, and summaries may
|
|
152
|
+
name a relative managed path and operation but never include backed-up bytes.
|
|
153
|
+
Backups remain inside the selected target's `.oak/` state and are never copied
|
|
154
|
+
to the repository, external logs, or another target.
|
|
155
|
+
|
|
156
|
+
Public leak scanning applies to repository files and the public diff. It does
|
|
157
|
+
not scan or publish the contents of temporary targets created locally to test
|
|
158
|
+
rollback, because those targets may intentionally contain synthetic or exact
|
|
159
|
+
backup bytes and are deleted by the bounded test cleanup.
|
|
160
|
+
|
|
161
|
+
## Ownership manifest
|
|
162
|
+
|
|
163
|
+
The manifest has `schema_version: 1` and is validated strictly before use:
|
|
164
|
+
|
|
165
|
+
```json
|
|
166
|
+
{
|
|
167
|
+
"schema_version": 1,
|
|
168
|
+
"manager": "opencode-agent-orchestration-kit",
|
|
169
|
+
"payload_sha256": "digest of the sorted source inventory",
|
|
170
|
+
"created_at": "ISO-8601 timestamp",
|
|
171
|
+
"updated_at": "ISO-8601 timestamp",
|
|
172
|
+
"last_transaction_id": "opaque local id",
|
|
173
|
+
"owned_files": [
|
|
174
|
+
{
|
|
175
|
+
"path": "agents/lead.md",
|
|
176
|
+
"sha256": "digest of installed bytes",
|
|
177
|
+
"mode": 420
|
|
178
|
+
}
|
|
179
|
+
],
|
|
180
|
+
"preserved_files": [
|
|
181
|
+
{
|
|
182
|
+
"path": "opencode.json",
|
|
183
|
+
"observed_sha256": "digest of user bytes at the last operation",
|
|
184
|
+
"observed_mode": 420,
|
|
185
|
+
"source_sha256": "source payload digest at the last operation",
|
|
186
|
+
"source_mode": 420,
|
|
187
|
+
"reason": "preexisting-user-file",
|
|
188
|
+
"merge_acknowledgement": {
|
|
189
|
+
"target_sha256": "digest of the acknowledged target bytes",
|
|
190
|
+
"target_mode": 420,
|
|
191
|
+
"source_sha256": "digest of the acknowledged source bytes",
|
|
192
|
+
"source_mode": 420,
|
|
193
|
+
"acknowledged_at": "ISO-8601 timestamp"
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
]
|
|
197
|
+
}
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
`owned_files` contains only files written by the kit or safely adopted during
|
|
201
|
+
initial install because their bytes and mode already matched the source.
|
|
202
|
+
`preserved_files` records only paths that overlapped the source when deliberately
|
|
203
|
+
left under user ownership. An entry may remain briefly after a later source
|
|
204
|
+
removal solely as obsolete-preserved metadata awaiting upgrade cleanup. It
|
|
205
|
+
stores the prior observed user state and prior observed source state so a later
|
|
206
|
+
scan can distinguish which side changed. It does not inventory arbitrary files
|
|
207
|
+
or `node_modules`.
|
|
208
|
+
|
|
209
|
+
The validator rejects unknown schema versions, duplicate paths, invalid hashes,
|
|
210
|
+
invalid modes outside integer `0o000` through `0o777`, traversal paths, absolute
|
|
211
|
+
paths, overlap between owned and preserved paths, and unsorted entries. It
|
|
212
|
+
validates `observed_sha256`, `observed_mode`, `source_sha256`, and `source_mode`
|
|
213
|
+
for every preserved entry. Neither `owned_files` nor `preserved_files` may
|
|
214
|
+
contain `.oak` or a descendant of `.oak`. Preserved reasons are explicit state:
|
|
215
|
+
`preexisting-user-file` or `preexisting-exact-match`; unknown values fail
|
|
216
|
+
validation. `reason` is stable provenance and never records merge status.
|
|
217
|
+
|
|
218
|
+
`merge_acknowledgement` is either `null` or a complete object with four valid
|
|
219
|
+
hash/mode fields and an ISO-8601 `acknowledged_at` timestamp. Initial
|
|
220
|
+
preservation sets it to `null`. Acknowledgement creates or replaces it with the
|
|
221
|
+
exact accepted tuple and a timestamp from injectable `clock()`, while leaving
|
|
222
|
+
`reason` unchanged. Partial objects, invalid hashes, invalid modes, invalid
|
|
223
|
+
timestamps, or unknown fields are invalid. The `accept-preserved` transaction
|
|
224
|
+
validator additionally requires the next manifest's baselines to equal the new
|
|
225
|
+
acknowledgement tuple and its reason to equal the previous reason. A later
|
|
226
|
+
valid manifest may retain that object as historical while its baselines evolve
|
|
227
|
+
under the separately allowed policies. The entry remains preserved and
|
|
228
|
+
user-owned.
|
|
229
|
+
|
|
230
|
+
## File classifications
|
|
231
|
+
|
|
232
|
+
Planning compares source inventory, the validated manifest, and current target
|
|
233
|
+
state. Every path present in the source or ownership manifest is classified as
|
|
234
|
+
one of:
|
|
235
|
+
|
|
236
|
+
- `owned-unchanged`: target hash and mode match the manifest;
|
|
237
|
+
- `owned-modified`: target exists but differs from the manifest;
|
|
238
|
+
- `owned-missing`: manifest owns the path but the target is absent;
|
|
239
|
+
- `preserved-user`: a source-overlapping path deliberately not owned;
|
|
240
|
+
- `unowned-match`: an existing path exactly matches the source and can be
|
|
241
|
+
adopted without writing;
|
|
242
|
+
- `unowned-conflict`: an existing source-overlapping path differs;
|
|
243
|
+
- `new`: source path is absent and unowned;
|
|
244
|
+
- `obsolete-unchanged`: owned path is absent from the new source and still
|
|
245
|
+
matches the manifest;
|
|
246
|
+
- `obsolete-modified`: obsolete owned path differs from the manifest;
|
|
247
|
+
- `obsolete-preserved-present`: a path remains in `preserved_files`, is absent
|
|
248
|
+
from the current source, and still exists in the target;
|
|
249
|
+
- `obsolete-preserved-missing`: a path remains in `preserved_files`, is absent
|
|
250
|
+
from both the current source and target.
|
|
251
|
+
|
|
252
|
+
Arbitrary target files that overlap neither a source path nor an ownership
|
|
253
|
+
manifest entry are user-owned and never included in a mutation plan.
|
|
254
|
+
|
|
255
|
+
For a `preserved-user` entry, planning compares current target bytes/mode with
|
|
256
|
+
`observed_sha256`/`observed_mode`, and current source bytes/mode with
|
|
257
|
+
`source_sha256`/`source_mode`. It distinguishes:
|
|
258
|
+
|
|
259
|
+
- user unchanged + source unchanged: stable preserved state;
|
|
260
|
+
- user changed + source unchanged: known user-owned evolution;
|
|
261
|
+
- user unchanged + source changed: manual merge pending;
|
|
262
|
+
- user changed + source changed: manual merge pending on both sides;
|
|
263
|
+
- preserved path missing: actionable missing preserved state.
|
|
264
|
+
|
|
265
|
+
The last state applies only while the source still contains the path. When the
|
|
266
|
+
source no longer contains it, the entry is `obsolete-preserved-present` or
|
|
267
|
+
`obsolete-preserved-missing`; there is no current source baseline to merge or
|
|
268
|
+
acknowledge.
|
|
269
|
+
|
|
270
|
+
A source-changed preserved entry remains merge-pending until target bytes and
|
|
271
|
+
mode exactly match the current source or the user explicitly acknowledges the
|
|
272
|
+
current customized merge through the administrative operation below. The
|
|
273
|
+
manager never guesses that an arbitrary custom edit completed a merge. Ordinary
|
|
274
|
+
doctor is read-only and never refreshes either baseline. A real upgrade that
|
|
275
|
+
already has payload or ownership work to commit may refresh the observed user
|
|
276
|
+
baseline when only the user changed, and may refresh both baselines when target
|
|
277
|
+
and current source match exactly. A no-op upgrade never creates an implicit
|
|
278
|
+
manifest-only transaction merely to refresh preserved baselines.
|
|
279
|
+
|
|
280
|
+
An acknowledgement record is current only when its four hash/mode values match
|
|
281
|
+
the current target/source tuple and the stored baselines. It is historical when
|
|
282
|
+
either current side later changes, and it may remain as audit history. No
|
|
283
|
+
acknowledgement, a current acknowledgement, and a historical acknowledgement
|
|
284
|
+
are distinct reportable states. Health and merge classification derive from
|
|
285
|
+
current state versus the baselines, never merely from the object's presence.
|
|
286
|
+
|
|
287
|
+
## Obsolete preserved paths
|
|
288
|
+
|
|
289
|
+
An obsolete preserved path remains user-owned and is never treated as owned,
|
|
290
|
+
deleted, modified, backed up, recreated, or merged. It creates no journaled
|
|
291
|
+
filesystem operation. Before cleanup, ordinary doctor reports that the kit no
|
|
292
|
+
longer distributes the path and returns exit `1` because ownership metadata
|
|
293
|
+
cleanup is pending; it does not report owned drift or offer
|
|
294
|
+
`--accept-preserved` without a current source file.
|
|
295
|
+
|
|
296
|
+
A real upgrade removes each obsolete entry from `preserved_files`, does not add
|
|
297
|
+
it to `owned_files`, and represents the decision only between
|
|
298
|
+
`previous_manifest` and `next_manifest`, using a logical `preserve` plan entry
|
|
299
|
+
with plan reason `source-removed`; that reason is not written as preserved-file
|
|
300
|
+
provenance. This is real ownership work, so one or more obsolete preserved
|
|
301
|
+
entries are sufficient for a manifest-only upgrade even when no payload file
|
|
302
|
+
changes. That exception does not authorize a transaction whose only purpose is
|
|
303
|
+
to refresh an unacknowledged preserved baseline.
|
|
304
|
+
|
|
305
|
+
Rollback of this manifest-only upgrade restores the previous preserved entry
|
|
306
|
+
and its metadata without deleting a present user file or recreating a missing
|
|
307
|
+
one.
|
|
308
|
+
|
|
309
|
+
## Acknowledging a preserved manual merge
|
|
310
|
+
|
|
311
|
+
The single interface for recognizing a completed manual merge is:
|
|
312
|
+
|
|
313
|
+
```text
|
|
314
|
+
doctor --accept-preserved PATH [--target PATH]
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
This is an explicit administrative mutation mode of the existing diagnostic
|
|
318
|
+
wrapper; ordinary `doctor` remains read-only. A separate wrapper is unnecessary,
|
|
319
|
+
and coupling acknowledgement to `upgrade` would make an ordinary upgrade carry
|
|
320
|
+
unrelated user authorization.
|
|
321
|
+
|
|
322
|
+
The argument is exactly one normalized manifest-relative path. Globs,
|
|
323
|
+
directories, repeated options, broad patterns, and paths containing control
|
|
324
|
+
characters that cannot be represented safely on one line are rejected. The
|
|
325
|
+
target and current source must both exist as safe regular files. The command
|
|
326
|
+
displays classification, full hashes, modes, and one canonical authorization
|
|
327
|
+
line:
|
|
328
|
+
|
|
329
|
+
```text
|
|
330
|
+
ACK-PRESERVED <path> <target-sha256> <target-mode-octal> <source-sha256> <source-mode-octal>
|
|
331
|
+
```
|
|
332
|
+
|
|
333
|
+
Hashes are the full 64 lowercase hexadecimal characters. Modes are exactly four
|
|
334
|
+
octal digits from `0000` through `0777`. Single ASCII spaces separate fields;
|
|
335
|
+
all other characters, including additional spaces, are significant. The
|
|
336
|
+
command reads one line from stdin and removes only its terminating newline. The
|
|
337
|
+
result must equal the displayed line byte-for-byte. `yes`, `y`, a path alone,
|
|
338
|
+
partial or truncated fields, omitted modes, a tuple from another invocation, or
|
|
339
|
+
any other mismatch is not authorization.
|
|
340
|
+
|
|
341
|
+
The deterministic flow is:
|
|
342
|
+
|
|
343
|
+
1. Validate invocation, target, manifest, normalized `PATH`, and that the path
|
|
344
|
+
belongs to `preserved_files` and is not obsolete-preserved.
|
|
345
|
+
2. Safely read current target/source hashes and modes, display their
|
|
346
|
+
classification and the exact canonical line, and read one stdin line.
|
|
347
|
+
3. Return exit `1` without persistent mutation for EOF, cancellation, malformed
|
|
348
|
+
input, or any non-exact line.
|
|
349
|
+
4. Build the complete initial plan only after exact confirmation. Block on
|
|
350
|
+
`owned-modified`, `owned-missing`, `unowned-conflict`,
|
|
351
|
+
`obsolete-modified`, corrupt or active transaction state, live or stale
|
|
352
|
+
lock, unsafe symlink, structural path error, or any conflict that prevents a
|
|
353
|
+
reliable rollback point. Unrelated non-blocking warnings on other preserved
|
|
354
|
+
paths may continue.
|
|
355
|
+
5. Acquire the exclusive lock, then recompute the source, target, complete
|
|
356
|
+
tuple, fingerprint, and global plan. Any change from the confirmed tuple or
|
|
357
|
+
initial fingerprint returns exit `1` before persistent transaction state.
|
|
358
|
+
6. Create a manifest-only `accept-preserved` transaction. Update both stored
|
|
359
|
+
baselines and create or replace `merge_acknowledgement` with the exact tuple
|
|
360
|
+
plus `acknowledged_at` from injectable `clock()`. Keep `reason` unchanged.
|
|
361
|
+
7. Commit through the ordinary journal, manifest, rollback-point, durability,
|
|
362
|
+
and commit-boundary protocol.
|
|
363
|
+
|
|
364
|
+
TTY is not required. Explicit stdin works identically in interactive and
|
|
365
|
+
non-interactive environments; being attached to a terminal never implies
|
|
366
|
+
acceptance. Tests provide the public canonical line through stdin and need no
|
|
367
|
+
private flag.
|
|
368
|
+
|
|
369
|
+
Exit `0` means acknowledgement committed. Exit `1` covers cancellation, EOF,
|
|
370
|
+
malformed or mismatched confirmation, post-confirmation tuple/fingerprint
|
|
371
|
+
change, a safe actionable global blocker, or another non-corrupt warning that
|
|
372
|
+
prevents apply. Exit `2` covers invalid invocation, non-normalized or
|
|
373
|
+
non-preserved or obsolete-preserved path, missing/non-regular target or source,
|
|
374
|
+
corrupt manifest or transaction state, unsafe symlink, structural collision, or
|
|
375
|
+
a filesystem error that prevents safe analysis or apply. Every exit `1` before
|
|
376
|
+
commit leaves zero persistent mutation except
|
|
377
|
+
durable cleanup of bootstrap directories created by that invocation.
|
|
378
|
+
|
|
379
|
+
Target and source need not match each other. Acceptance grants no authorization
|
|
380
|
+
for future states, modifies no file bytes or modes, never changes ownership,
|
|
381
|
+
and never adds the path to `owned_files`. After acceptance, an unchanged tuple
|
|
382
|
+
is stable and compatible with ordinary doctor exit `0`; a later target-only
|
|
383
|
+
change is user-only evolution, a later source-only change is merge-pending, and
|
|
384
|
+
changes on both sides are merge-pending on both sides. Rollback restores the
|
|
385
|
+
prior baselines and prior acknowledgement object or `null`, keeps `reason`, and
|
|
386
|
+
does not touch the preserved file.
|
|
387
|
+
|
|
388
|
+
## Blocking conflicts and non-blocking warnings
|
|
389
|
+
|
|
390
|
+
Upgrade performs no managed-file or persistent-state mutation when any blocking
|
|
391
|
+
conflict exists:
|
|
392
|
+
|
|
393
|
+
- `owned-modified`;
|
|
394
|
+
- `owned-missing`;
|
|
395
|
+
- `unowned-conflict`;
|
|
396
|
+
- `obsolete-modified`;
|
|
397
|
+
- invalid manifest or corrupt state;
|
|
398
|
+
- unresolved transaction;
|
|
399
|
+
- live lock;
|
|
400
|
+
- stale lock during an ordinary mutation;
|
|
401
|
+
- unsafe source, target, or state symlink;
|
|
402
|
+
- file/directory collision or invalid parent path;
|
|
403
|
+
- fingerprint change after lock acquisition.
|
|
404
|
+
|
|
405
|
+
These conditions are non-blocking warnings and may coexist with safe unrelated
|
|
406
|
+
upgrade operations:
|
|
407
|
+
|
|
408
|
+
- any `preserved-user` path;
|
|
409
|
+
- a preserved file modified by its user;
|
|
410
|
+
- changed source payload for a preserved file;
|
|
411
|
+
- a missing preserved path whose source still exists;
|
|
412
|
+
- an obsolete preserved path awaiting ownership-metadata cleanup;
|
|
413
|
+
- protected configuration awaiting manual merge;
|
|
414
|
+
- an absent optional integration.
|
|
415
|
+
|
|
416
|
+
Warnings never authorize modification of the warned path. A warning may make
|
|
417
|
+
doctor exit `1` as defined below without converting it into an upgrade blocker.
|
|
418
|
+
|
|
419
|
+
## Protected root files
|
|
420
|
+
|
|
421
|
+
To preserve compatibility with installations over an existing OpenCode config,
|
|
422
|
+
these pre-existing root paths remain user-owned by default:
|
|
423
|
+
|
|
424
|
+
```text
|
|
425
|
+
AGENTS.md
|
|
426
|
+
opencode.json
|
|
427
|
+
tui.json
|
|
428
|
+
package.json
|
|
429
|
+
package-lock.json
|
|
430
|
+
```
|
|
431
|
+
|
|
432
|
+
If one exists before initial installation and differs from the source, install
|
|
433
|
+
records it as `preserved-user`, leaves it untouched, and prints a merge warning.
|
|
434
|
+
During initial install only, an exact byte-and-mode match may be adopted as
|
|
435
|
+
owned without rewriting it. `--force` may overwrite a differing protected root
|
|
436
|
+
file only during initial install. The flag is explicit overwrite authorization,
|
|
437
|
+
and rollback bytes must be durable before replacement.
|
|
438
|
+
|
|
439
|
+
`--force` is not accepted by upgrade, uninstall, doctor, or rollback.
|
|
440
|
+
|
|
441
|
+
## Operation plans
|
|
442
|
+
|
|
443
|
+
Mutating commands first produce a complete in-memory logical plan. Each plan
|
|
444
|
+
entry has a kind (`add`, `adopt`, `update`, `remove`, `preserve`), path, before
|
|
445
|
+
state, after state, and reason. Plans are sorted by path and include a
|
|
446
|
+
fingerprint of all observed source, manifest, and target inputs.
|
|
447
|
+
|
|
448
|
+
Logical decisions and journaled filesystem operations are distinct. `add`,
|
|
449
|
+
`update`, and `remove` mutate managed filesystem bytes and may appear in the
|
|
450
|
+
transaction journal. `adopt` and `preserve` change only ownership metadata in
|
|
451
|
+
`previous_manifest` and the complete next manifest; they never appear in the
|
|
452
|
+
journal `operations` array and never have a backup.
|
|
453
|
+
|
|
454
|
+
During initial install, `adopt` claims an existing regular file only when its
|
|
455
|
+
bytes and mode exactly match the source. It does not rewrite the file and adds
|
|
456
|
+
it to `owned_files`. Rollback of an adoption reverts ownership by restoring the
|
|
457
|
+
previous manifest; it does not remove or modify the pre-existing file.
|
|
458
|
+
|
|
459
|
+
`preserve` always leaves a path user-owned and performs no file write. Initial
|
|
460
|
+
preservation records it in `preserved_files`; obsolete cleanup with reason
|
|
461
|
+
`source-removed` omits the entry from the next manifest while preserving the
|
|
462
|
+
user path. Rollback restores the previous manifest without removing, recreating,
|
|
463
|
+
or modifying the preserved file. Manual merge acknowledgement is also a
|
|
464
|
+
`preserve` metadata decision, not a managed-file mutation.
|
|
465
|
+
|
|
466
|
+
`--dry-run` renders the plan and exits without creating the target, `.oak/`, a
|
|
467
|
+
lock, a manifest, a backup, or any other file. Dry-run is an advisory preview;
|
|
468
|
+
it is strongly recommended but is not a persisted approval and is not required
|
|
469
|
+
before apply. No preview token is introduced in this slice.
|
|
470
|
+
|
|
471
|
+
A real invocation computes an initial in-memory plan, acquires the target lock,
|
|
472
|
+
and recomputes the plan under that lock. It aborts if the post-lock fingerprint
|
|
473
|
+
differs from the same invocation's pre-lock fingerprint. This check prevents a
|
|
474
|
+
race inside one invocation; it does not connect a previous dry-run process to a
|
|
475
|
+
later apply process.
|
|
476
|
+
|
|
477
|
+
Human-readable output must state counts and list every conflict or preserved
|
|
478
|
+
path. Tests call exported planning functions and assert the structured plan
|
|
479
|
+
directly; no public `--json` option is introduced in this slice.
|
|
480
|
+
|
|
481
|
+
## Install
|
|
482
|
+
|
|
483
|
+
Initial install supports a clean or pre-existing target.
|
|
484
|
+
|
|
485
|
+
1. Inventory the source and target without writing.
|
|
486
|
+
2. Preserve differing protected root files.
|
|
487
|
+
3. Adopt exact source matches.
|
|
488
|
+
4. Plan additions for absent source paths.
|
|
489
|
+
5. Treat any other unowned collision as a conflict and abort before writes.
|
|
490
|
+
6. With explicit `--force`, permit initial-install collisions after capturing
|
|
491
|
+
their original bytes for rollback. The flag itself is the explicit
|
|
492
|
+
authorization; a prior dry-run is recommended and documented but not
|
|
493
|
+
mechanically required.
|
|
494
|
+
7. Apply the plan and create schema-1 ownership state.
|
|
495
|
+
|
|
496
|
+
A legacy installation without `.oak/manifest.json` is treated as an initial
|
|
497
|
+
install, not as an upgrade. Exact matches can be adopted. Differing managed
|
|
498
|
+
paths remain conflicts and require manual resolution or explicit initial
|
|
499
|
+
`--force`. This is the safe migration path for releases predating the manifest.
|
|
500
|
+
|
|
501
|
+
## Upgrade
|
|
502
|
+
|
|
503
|
+
Upgrade requires a valid active manifest.
|
|
504
|
+
|
|
505
|
+
It may:
|
|
506
|
+
|
|
507
|
+
- add new source paths;
|
|
508
|
+
- update `owned-unchanged` paths;
|
|
509
|
+
- remove `obsolete-unchanged` paths;
|
|
510
|
+
- remove obsolete preserved entries from ownership tracking without touching
|
|
511
|
+
their target paths;
|
|
512
|
+
- refresh the manifest and payload digest.
|
|
513
|
+
|
|
514
|
+
Upgrade never claims an unowned path solely because its bytes happen to match.
|
|
515
|
+
When a path is new in the source, absent from the previous manifest, already
|
|
516
|
+
exists in the target, and matches the new source exactly in bytes and mode, it
|
|
517
|
+
remains user-owned. Upgrade records it as `preserved-user` with reason
|
|
518
|
+
`preexisting-exact-match`, does not rewrite it, emits a warning, and continues
|
|
519
|
+
other safe operations. If its source changes later, the preserved-file merge
|
|
520
|
+
policy applies.
|
|
521
|
+
|
|
522
|
+
A `preserved-user` path always remains user-owned during upgrade. Upgrade never
|
|
523
|
+
overwrites or auto-adopts it, even if the current bytes later match the shipped
|
|
524
|
+
source. A user-only change is informational and may refresh the observed user
|
|
525
|
+
baseline only when an independently requested, non-empty upgrade commits. A
|
|
526
|
+
source change produces a manual-merge warning and keeps the prior baselines
|
|
527
|
+
until target and source match exactly during such a real upgrade or the user
|
|
528
|
+
runs `doctor --accept-preserved PATH`. Neither case blocks unrelated safe
|
|
529
|
+
upgrade operations. A missing preserved path whose source still exists remains
|
|
530
|
+
a non-blocking warning and is not recreated; a missing path whose source was
|
|
531
|
+
removed follows obsolete-preserved cleanup instead.
|
|
532
|
+
|
|
533
|
+
It must abort the entire operation before any write if it finds:
|
|
534
|
+
|
|
535
|
+
- `owned-modified`;
|
|
536
|
+
- `owned-missing`;
|
|
537
|
+
- `unowned-conflict`;
|
|
538
|
+
- `obsolete-modified`;
|
|
539
|
+
- invalid or corrupt state;
|
|
540
|
+
- any other blocker in Blocking conflicts and non-blocking warnings.
|
|
541
|
+
|
|
542
|
+
Upgrade deliberately has no partial-success or force mode.
|
|
543
|
+
|
|
544
|
+
## Target bootstrap and lock acquisition
|
|
545
|
+
|
|
546
|
+
Lock creation must not weaken the no-write guarantee for an initially invalid
|
|
547
|
+
plan:
|
|
548
|
+
|
|
549
|
+
1. Compute the complete initial plan in memory without creating the target,
|
|
550
|
+
`.oak/`, lock, journal, or backups.
|
|
551
|
+
2. If that plan contains a blocking conflict, abort with zero filesystem
|
|
552
|
+
mutation.
|
|
553
|
+
3. For a potentially valid apply, create the target and `.oak/` only when
|
|
554
|
+
absent, with their required modes, and record internal booleans equivalent to
|
|
555
|
+
`target_created_by_invocation` and `oak_created_by_invocation`.
|
|
556
|
+
4. Generate the transaction ID, acquire the lock through exclusive publication
|
|
557
|
+
with that ID, and recompute the entire plan while holding it.
|
|
558
|
+
5. If the fingerprint changed or the post-lock plan now contains a blocker,
|
|
559
|
+
remove and durably unlink the invocation's lock. Remove `.oak/` only when
|
|
560
|
+
`oak_created_by_invocation` is true and it remains empty. Remove the target
|
|
561
|
+
only when `target_created_by_invocation` is true and it remains empty.
|
|
562
|
+
6. Cleanup never removes a directory that predated the invocation.
|
|
563
|
+
7. Do not create transaction state, rollback state, or backups until the
|
|
564
|
+
post-lock plan is valid.
|
|
565
|
+
|
|
566
|
+
Creating and then fully cleaning invocation-owned bootstrap directories is not
|
|
567
|
+
a managed-file mutation. The observable final state after a post-lock abort must
|
|
568
|
+
match the pre-invocation state byte-for-byte. Bootstrap cleanup is durable:
|
|
569
|
+
after removing `.oak/`, fsync the target directory; after removing an
|
|
570
|
+
invocation-created target, fsync its parent directory. A controlled failure
|
|
571
|
+
between `rmdir` and parent-directory fsync must finish or retry that durability
|
|
572
|
+
step before surfacing the abort. The internal created-by-invocation flags are
|
|
573
|
+
never inferred for pre-existing directories.
|
|
574
|
+
|
|
575
|
+
## Doctor
|
|
576
|
+
|
|
577
|
+
Ordinary doctor is read-only and reports:
|
|
578
|
+
|
|
579
|
+
- manifest presence, schema, and structural validity;
|
|
580
|
+
- source payload validity;
|
|
581
|
+
- counts and paths by file classification;
|
|
582
|
+
- active, stale, or malformed lock state;
|
|
583
|
+
- interrupted transaction state;
|
|
584
|
+
- rollback availability;
|
|
585
|
+
- preserved configuration requiring manual merge;
|
|
586
|
+
- obsolete preserved entries awaiting ownership-metadata cleanup.
|
|
587
|
+
|
|
588
|
+
Exit codes:
|
|
589
|
+
|
|
590
|
+
- `0`: healthy managed installation with valid manifest and source, no blocking
|
|
591
|
+
drift, no newly pending merge, and preserved files in a known stable state.
|
|
592
|
+
A committed rollback point may be available. A deliberately preserved file
|
|
593
|
+
is compatible with exit `0`; user-only changes with unchanged source are
|
|
594
|
+
informational and remain user-owned.
|
|
595
|
+
- `1`: actionable but safely diagnosable state, including a missing preserved
|
|
596
|
+
file whose source still exists, changed source for a preserved file, both
|
|
597
|
+
user and source changed, manual merge pending, obsolete preserved metadata,
|
|
598
|
+
stale lock, recoverable interrupted transaction, missing or modified owned
|
|
599
|
+
file, or rollback conflict.
|
|
600
|
+
- `2`: invalid invocation, corrupt JSON, unknown schema, unsafe path or symlink,
|
|
601
|
+
serious file/directory collision, unrecoverable state, or filesystem error
|
|
602
|
+
that prevents safe analysis.
|
|
603
|
+
|
|
604
|
+
Ordinary doctor never repairs, deletes, or refreshes state. The explicitly
|
|
605
|
+
confirmed `--accept-preserved` administrative mode has the narrow manifest-only
|
|
606
|
+
mutation semantics defined above and no other repair authority.
|
|
607
|
+
|
|
608
|
+
## Uninstall
|
|
609
|
+
|
|
610
|
+
Uninstall requires a valid manifest and plans before prompting.
|
|
611
|
+
|
|
612
|
+
- Remove only `owned-unchanged` files.
|
|
613
|
+
- Preserve and report `owned-modified`, `owned-missing`, all `preserved-user`
|
|
614
|
+
entries, and all unrelated user files.
|
|
615
|
+
- Remove directories only when they are empty after file operations.
|
|
616
|
+
- Record a rollback transaction and remove the active manifest only after the
|
|
617
|
+
planned removals succeed.
|
|
618
|
+
- Leave `.oak/rollback/` so the uninstall can be restored.
|
|
619
|
+
|
|
620
|
+
User modifications are never deleted, including with `--yes`. `--yes` skips the
|
|
621
|
+
interactive confirmation but changes no ownership rule.
|
|
622
|
+
|
|
623
|
+
## Rollback
|
|
624
|
+
|
|
625
|
+
Rollback has two explicit modes selected from current state.
|
|
626
|
+
|
|
627
|
+
### Committed-operation rollback
|
|
628
|
+
|
|
629
|
+
When there is no active `planned`, `applying`, or `rolling-back` transaction,
|
|
630
|
+
only the latest committed install, upgrade, uninstall, or `accept-preserved`
|
|
631
|
+
transaction is rollbackable.
|
|
632
|
+
|
|
633
|
+
Rollback first verifies that current manifest presence matches the committed
|
|
634
|
+
transaction's `next_manifest`, and, when present, that its canonical digest
|
|
635
|
+
matches `next_manifest_sha256`. It also verifies that every journaled `add`,
|
|
636
|
+
`update`, or `remove` path still matches its committed after-state. Any presence,
|
|
637
|
+
digest, or managed-filesystem mismatch aborts before writes and lists the
|
|
638
|
+
conflict. Logical `adopt` and `preserve` decisions are reverted through the
|
|
639
|
+
manifest and do not impose byte/mode preconditions on their user-owned or
|
|
640
|
+
pre-existing files because rollback will not mutate those files.
|
|
641
|
+
|
|
642
|
+
When safe, rollback:
|
|
643
|
+
|
|
644
|
+
- restores replaced or removed bytes and modes;
|
|
645
|
+
- removes files added by the transaction;
|
|
646
|
+
- restores the previous active manifest or removes the newly created manifest;
|
|
647
|
+
- marks the transaction `rolled-back`;
|
|
648
|
+
- retains no second rollback generation.
|
|
649
|
+
|
|
650
|
+
`rollback --dry-run` is read-only and shows the exact inverse plan.
|
|
651
|
+
|
|
652
|
+
### Interrupted-operation recovery
|
|
653
|
+
|
|
654
|
+
When `transaction.json` is `planned`, `applying`, or `rolling-back`, `rollback`
|
|
655
|
+
performs or resumes recovery of that active transaction instead of consuming
|
|
656
|
+
the latest committed rollback point. It uses the journal's forward and inverse
|
|
657
|
+
completed-operation indexes and durable before backups:
|
|
658
|
+
|
|
659
|
+
- `planned|applying + none` first transitions durably to `rolling-back +
|
|
660
|
+
interrupted-forward`; an existing `rolling-back` journal must already have a
|
|
661
|
+
valid explicit origin;
|
|
662
|
+
|
|
663
|
+
- forward-completed operations not yet inverse-completed must still match their
|
|
664
|
+
recorded after-state;
|
|
665
|
+
- inverse-completed operations must match their recorded before-state;
|
|
666
|
+
- uncompleted operations must still match their recorded before-state;
|
|
667
|
+
- before a forward manifest write, current presence and digest must match
|
|
668
|
+
`previous_manifest`; after a forward-completed write they must match
|
|
669
|
+
`next_manifest` until its inverse completes; after the inverse they must again
|
|
670
|
+
match `previous_manifest`. Each comparison verifies expected absence as well
|
|
671
|
+
as a present canonical digest;
|
|
672
|
+
- any mismatch aborts recovery before further mutation and reports the path;
|
|
673
|
+
- safe recovery inverses only completed operations and restores the previous
|
|
674
|
+
manifest state;
|
|
675
|
+
- the active journal is atomically marked `rolled-back` and removed after the
|
|
676
|
+
restored state is durable;
|
|
677
|
+
- the earlier committed rollback point, if any, remains available and is not
|
|
678
|
+
replaced or consumed.
|
|
679
|
+
|
|
680
|
+
Recovery is blocked by a live lock. If the journal exists and its recorded PID
|
|
681
|
+
is no longer alive, rollback may atomically replace the stale lock with a
|
|
682
|
+
recovery lock. `rollback --dry-run` reports the recovery plan without replacing
|
|
683
|
+
the stale lock or writing any state.
|
|
684
|
+
|
|
685
|
+
## Transaction journal schema
|
|
686
|
+
|
|
687
|
+
Active and committed transaction records use `schema_version: 1` and a minimum
|
|
688
|
+
shape equivalent to:
|
|
689
|
+
|
|
690
|
+
```json
|
|
691
|
+
{
|
|
692
|
+
"schema_version": 1,
|
|
693
|
+
"transaction_id": "opaque-id",
|
|
694
|
+
"command": "install",
|
|
695
|
+
"status": "planned",
|
|
696
|
+
"rollback_origin": "none",
|
|
697
|
+
"created_at": "ISO-8601 timestamp",
|
|
698
|
+
"source_payload_sha256": "hex digest",
|
|
699
|
+
"previous_manifest": null,
|
|
700
|
+
"next_manifest": {
|
|
701
|
+
"schema_version": 1,
|
|
702
|
+
"manager": "opencode-agent-orchestration-kit",
|
|
703
|
+
"payload_sha256": "hex digest",
|
|
704
|
+
"created_at": "ISO-8601 timestamp",
|
|
705
|
+
"updated_at": "ISO-8601 timestamp",
|
|
706
|
+
"last_transaction_id": "opaque-id",
|
|
707
|
+
"owned_files": [
|
|
708
|
+
{
|
|
709
|
+
"path": "agents/lead.md",
|
|
710
|
+
"sha256": "hex digest",
|
|
711
|
+
"mode": 420
|
|
712
|
+
}
|
|
713
|
+
],
|
|
714
|
+
"preserved_files": []
|
|
715
|
+
},
|
|
716
|
+
"previous_manifest_sha256": null,
|
|
717
|
+
"next_manifest_sha256": "hex digest",
|
|
718
|
+
"lock": {
|
|
719
|
+
"transaction_id": "opaque-id",
|
|
720
|
+
"pid": 1234,
|
|
721
|
+
"command": "install",
|
|
722
|
+
"created_at": "ISO-8601 timestamp"
|
|
723
|
+
},
|
|
724
|
+
"operations": [
|
|
725
|
+
{
|
|
726
|
+
"index": 0,
|
|
727
|
+
"kind": "update",
|
|
728
|
+
"path": "agents/lead.md",
|
|
729
|
+
"before_sha256": "hex digest",
|
|
730
|
+
"before_mode": 420,
|
|
731
|
+
"after_sha256": "hex digest",
|
|
732
|
+
"after_mode": 420,
|
|
733
|
+
"backup_path": "files/000000"
|
|
734
|
+
}
|
|
735
|
+
],
|
|
736
|
+
"completed_operation_indexes": [],
|
|
737
|
+
"rollback_completed_operation_indexes": [],
|
|
738
|
+
"manifest_write_completed": false,
|
|
739
|
+
"rollback_manifest_write_completed": false
|
|
740
|
+
}
|
|
741
|
+
```
|
|
742
|
+
|
|
743
|
+
`previous_manifest` and `next_manifest` are each either a complete valid
|
|
744
|
+
manifest object or `null`; `{}` never represents absence. Presence and digest
|
|
745
|
+
are inseparable: an object requires its matching SHA-256 digest, and `null`
|
|
746
|
+
requires a null digest. The validator rejects an object with a null digest,
|
|
747
|
+
null with a non-null digest, an empty or incomplete object, a digest mismatch,
|
|
748
|
+
and any command-specific presence pair other than:
|
|
749
|
+
|
|
750
|
+
| Transaction command | Previous | Next |
|
|
751
|
+
| --- | --- | --- |
|
|
752
|
+
| `install` | `null` | valid manifest |
|
|
753
|
+
| `upgrade` | valid manifest | valid manifest |
|
|
754
|
+
| `accept-preserved` | valid manifest | valid manifest |
|
|
755
|
+
| `uninstall` | valid manifest | `null` |
|
|
756
|
+
|
|
757
|
+
Both manifests may never be null. Rollback and recovery retain the original
|
|
758
|
+
command and presence pair. Rollback of install removes `manifest.json` and
|
|
759
|
+
restores expected absence; rollback of uninstall restores the previous
|
|
760
|
+
manifest; rollback of upgrade or acknowledgement restores the previous
|
|
761
|
+
manifest. Presence is part of state validation: a present manifest when absence
|
|
762
|
+
is expected, or an absent manifest when presence is expected, is a blocking
|
|
763
|
+
conflict even before digest comparison.
|
|
764
|
+
|
|
765
|
+
Manifest bytes have one canonical representation used for writing, digesting,
|
|
766
|
+
and validation: object keys sorted lexicographically at every level, schema
|
|
767
|
+
arrays sorted by their defined path order, no insignificant whitespace, UTF-8
|
|
768
|
+
without BOM, and exactly one final LF byte. The SHA-256 covers those exact
|
|
769
|
+
bytes. No alternate serialization or digest representation is permitted.
|
|
770
|
+
|
|
771
|
+
The nested `lock` object is the durable snapshot of the lock holder that last
|
|
772
|
+
published journal progress. Its `transaction_id` must equal the top-level
|
|
773
|
+
transaction ID. Allowed transaction `command` values are `install`, `upgrade`,
|
|
774
|
+
`uninstall`, and `accept-preserved`;
|
|
775
|
+
rollback retains the original command and changes transaction status rather
|
|
776
|
+
than pretending to be a new forward operation. A lock may additionally record
|
|
777
|
+
`rollback` as its command because that field identifies the process holding the
|
|
778
|
+
lock, not the transaction being inverted.
|
|
779
|
+
|
|
780
|
+
`rollback_origin` is mandatory and has exactly three values: `none`,
|
|
781
|
+
`interrupted-forward`, and `committed-operation`. It is never inferred solely
|
|
782
|
+
from `status`. Allowed status/origin transitions are:
|
|
783
|
+
|
|
784
|
+
```text
|
|
785
|
+
planned + none -> applying + none
|
|
786
|
+
planned + none -> rolling-back + interrupted-forward
|
|
787
|
+
applying + none -> committed + none
|
|
788
|
+
applying + none -> rolling-back + interrupted-forward
|
|
789
|
+
committed + none -> rolling-back + committed-operation
|
|
790
|
+
rolling-back + interrupted-forward -> rolled-back + interrupted-forward
|
|
791
|
+
rolling-back + committed-operation -> rolled-back + committed-operation
|
|
792
|
+
```
|
|
793
|
+
|
|
794
|
+
`committed` is the stored status of
|
|
795
|
+
`.oak/rollback/transaction.json`. `planned`, `applying`, and `rolling-back` are
|
|
796
|
+
active-journal states. `rolled-back` is terminal and may exist only briefly
|
|
797
|
+
while its durable active journal is being cleaned. No other transition or
|
|
798
|
+
status/origin combination is valid. A forward recovery explicitly changes
|
|
799
|
+
`planned|applying + none` to `rolling-back + interrupted-forward`. Copying a
|
|
800
|
+
committed transaction to the active journal explicitly changes `committed +
|
|
801
|
+
none` to `rolling-back + committed-operation`. `rolled-back` retains the origin
|
|
802
|
+
of the inversion that just completed.
|
|
803
|
+
|
|
804
|
+
The journal `operations` array contains only managed-filesystem mutations and
|
|
805
|
+
permits exactly `add`, `update`, and `remove`. `backup_path` is nullable and has
|
|
806
|
+
this strict shape:
|
|
807
|
+
|
|
808
|
+
| `kind` | Before state | After state | `backup_path` |
|
|
809
|
+
| --- | --- | --- | --- |
|
|
810
|
+
| `add` | hash and mode both `null` | hash and mode required | `null` |
|
|
811
|
+
| `update` | hash and mode required | hash and mode required | required |
|
|
812
|
+
| `remove` | hash and mode required | hash and mode both `null` | required |
|
|
813
|
+
|
|
814
|
+
For example, a valid add operation is:
|
|
815
|
+
|
|
816
|
+
```json
|
|
817
|
+
{
|
|
818
|
+
"index": 0,
|
|
819
|
+
"kind": "add",
|
|
820
|
+
"path": "agents/example.md",
|
|
821
|
+
"before_sha256": null,
|
|
822
|
+
"before_mode": null,
|
|
823
|
+
"after_sha256": "hex digest",
|
|
824
|
+
"after_mode": 420,
|
|
825
|
+
"backup_path": null
|
|
826
|
+
}
|
|
827
|
+
```
|
|
828
|
+
|
|
829
|
+
An `add` rollback removes the file only while it matches the recorded
|
|
830
|
+
after-state. An `update` rollback restores its durable before-bytes and mode. A
|
|
831
|
+
`remove` rollback restores its durable before-bytes and mode. `adopt`,
|
|
832
|
+
`preserve`, unknown kinds, a backup on `add`, or a missing backup on `update` or
|
|
833
|
+
`remove` are invalid journal state.
|
|
834
|
+
|
|
835
|
+
The validator checks the schema version; allowed commands, status/origin states
|
|
836
|
+
and transitions; lock transaction-ID equality and well-formed
|
|
837
|
+
PID/timestamp/command fields; unique, consecutive operation indexes; normalized
|
|
838
|
+
managed paths; safe relative backup paths; hashes; modes; completed indexes
|
|
839
|
+
that refer to real operations; and the strict operation table above. Hash and
|
|
840
|
+
mode are a pair: neither may be null while the other is present. Operation paths
|
|
841
|
+
must not be `.oak` or a descendant. Forward `completed_operation_indexes` and
|
|
842
|
+
`rollback_completed_operation_indexes` must each contain unique valid indexes;
|
|
843
|
+
rollback progress may include only forward-completed operations and must be
|
|
844
|
+
consistent with `rolling-back` or `rolled-back` status.
|
|
845
|
+
`rollback_manifest_write_completed` may be true only in those rollback statuses
|
|
846
|
+
and only after the forward manifest write was completed.
|
|
847
|
+
|
|
848
|
+
Every non-null `backup_path` is a normalized relative path below `files/`; it
|
|
849
|
+
must never be absolute, escape its permitted root, contain `.oak` as a path
|
|
850
|
+
component, name a symlink, or represent a managed target path. Resolution is
|
|
851
|
+
defined only by the validated status/origin pair:
|
|
852
|
+
|
|
853
|
+
| Journal state | Permitted backup root |
|
|
854
|
+
| --- | --- |
|
|
855
|
+
| `planned|applying + none` | `.oak/rollback.next/` |
|
|
856
|
+
| `committed + none` | `.oak/rollback/` |
|
|
857
|
+
| `rolling-back|rolled-back + interrupted-forward` | `.oak/rollback.next/` |
|
|
858
|
+
| `rolling-back|rolled-back + committed-operation` | `.oak/rollback/` |
|
|
859
|
+
|
|
860
|
+
In particular, `rolling-back` alone never selects a backup root. Recovery fails
|
|
861
|
+
closed before mutation when origin, status, backup presence, storage location,
|
|
862
|
+
or path validation disagree. No redundant backup-root field is introduced.
|
|
863
|
+
|
|
864
|
+
### Manifest-only transactions
|
|
865
|
+
|
|
866
|
+
A transaction may have `"operations": []` when it changes only manifest state.
|
|
867
|
+
This includes initial adoption, preservation records, explicit manual-merge
|
|
868
|
+
acknowledgement, a permitted preserved baseline refresh during a real upgrade,
|
|
869
|
+
obsolete preserved metadata cleanup, and a payload-digest change with no
|
|
870
|
+
managed-file mutation. The empty operations array does not bypass transaction
|
|
871
|
+
safety: the operation still requires a lock,
|
|
872
|
+
complete plan fingerprint, durable journal with complete `previous_manifest`
|
|
873
|
+
and `next_manifest` presence values, durable manifest publication or removal,
|
|
874
|
+
rollback point, and the same commit boundary as a filesystem transaction. No
|
|
875
|
+
per-file backup is created. Rollback validates current manifest presence and
|
|
876
|
+
digest, then restores only the previous manifest state; it never mutates adopted
|
|
877
|
+
or preserved file bytes or modes.
|
|
878
|
+
|
|
879
|
+
After successful commit, `.oak/transaction.json` no longer exists. Its committed
|
|
880
|
+
form is installed at `.oak/rollback/transaction.json`, with backup bytes under
|
|
881
|
+
`.oak/rollback/files/`. A new point is first made durable under
|
|
882
|
+
`.oak/rollback.next/`, which remains intact as the interrupted-forward recovery
|
|
883
|
+
root until the commit boundary. The previous point is retained as
|
|
884
|
+
`.oak/rollback.previous/`; the candidate is durably materialized separately at
|
|
885
|
+
`.oak/rollback/` without consuming `rollback.next`. The active journal makes
|
|
886
|
+
that candidate non-committed until the journal is durably removed. Only after
|
|
887
|
+
that removal may `rollback.next` and `rollback.previous` be cleaned. Failure
|
|
888
|
+
before the boundary uses `rollback.next` for forward recovery, discards the
|
|
889
|
+
uncommitted candidate, and restores or retains `rollback.previous` as the prior
|
|
890
|
+
committed point. The protocol must never declare an operation committed with no
|
|
891
|
+
usable rollback point. Transient next/previous directories are resolved by
|
|
892
|
+
recovery and do not create additional user-visible rollback generations.
|
|
893
|
+
|
|
894
|
+
If a crash occurs after commit but before redundant `rollback.previous/` or
|
|
895
|
+
`rollback.next/` cleanup, `rollback/` remains the sole active point and the
|
|
896
|
+
transient directories are non-active cleanup residue. Doctor reports them as
|
|
897
|
+
actionable exit `1`. A later mutation may remove them only after acquiring the
|
|
898
|
+
lock, validating the active rollback point, and reaching a blocker-free
|
|
899
|
+
post-lock plan; it never selects either residue for user rollback or recovery
|
|
900
|
+
when no active journal exists.
|
|
901
|
+
|
|
902
|
+
## Transaction and interruption recovery
|
|
903
|
+
|
|
904
|
+
Every real mutation follows this sequence:
|
|
905
|
+
|
|
906
|
+
1. Acquire an exclusive target lock.
|
|
907
|
+
2. Recompute and validate the plan.
|
|
908
|
+
3. Capture all before-bytes needed for rollback.
|
|
909
|
+
4. Atomically write and durably publish a `planned + none` transaction journal.
|
|
910
|
+
5. Atomically change the journal to `applying` and durably publish that state.
|
|
911
|
+
6. Apply each file using the durable write/remove protocols below and durably
|
|
912
|
+
record each completed operation index.
|
|
913
|
+
7. Atomically and durably publish `next_manifest`, or durably unlink
|
|
914
|
+
`manifest.json` when next is null, and then durably record
|
|
915
|
+
`manifest_write_completed: true`.
|
|
916
|
+
8. Keep the forward-recovery backups intact under `rollback.next/`. Move the
|
|
917
|
+
prior committed point to `rollback.previous/`, durably materialize the new
|
|
918
|
+
candidate at `rollback/` with a journal in state `committed + none`, and
|
|
919
|
+
fsync `.oak/` after each directory transition. While the active journal
|
|
920
|
+
exists, this `rollback/` candidate is not user-rollbackable.
|
|
921
|
+
9. After the new committed journal and backups are durable at `rollback/`,
|
|
922
|
+
durably remove the active journal. This removal is the commit boundary. Any
|
|
923
|
+
failure before it remains an interrupted operation and retains
|
|
924
|
+
`rollback.previous/` plus the active journal needed for recovery.
|
|
925
|
+
10. After commit, durably remove the now-redundant `rollback.previous/` and
|
|
926
|
+
`rollback.next/`. A crash here leaves only cleanup residue and does not
|
|
927
|
+
change which point is active.
|
|
928
|
+
11. Durably remove the lock and release the operation.
|
|
929
|
+
|
|
930
|
+
Writing or replacing any regular managed file uses:
|
|
931
|
+
|
|
932
|
+
```text
|
|
933
|
+
create a same-directory temporary file with restrictive initial permissions
|
|
934
|
+
write all bytes
|
|
935
|
+
fsync the temporary file
|
|
936
|
+
apply the intended source mode
|
|
937
|
+
atomically rename to the destination
|
|
938
|
+
fsync the parent directory
|
|
939
|
+
```
|
|
940
|
+
|
|
941
|
+
Removing a managed file uses:
|
|
942
|
+
|
|
943
|
+
```text
|
|
944
|
+
make its rollback backup bytes and mode durable
|
|
945
|
+
unlink the managed file
|
|
946
|
+
fsync the parent directory
|
|
947
|
+
```
|
|
948
|
+
|
|
949
|
+
Manifest, journal, rollback metadata, and ordinary state replacements use a
|
|
950
|
+
same-directory `0600` temporary file, complete write, file `fsync`, atomic
|
|
951
|
+
rename, and `fsync` of the corresponding `.oak/` directory. State directories
|
|
952
|
+
are `0700`. Initial lock acquisition additionally requires exclusive
|
|
953
|
+
publication: the implementation may use a same-directory durable temporary plus
|
|
954
|
+
an atomic no-replace primitive such as same-filesystem link publication when a
|
|
955
|
+
portable no-replace rename is unavailable. Lock removal also fsyncs `.oak/`.
|
|
956
|
+
|
|
957
|
+
Directory `fsync` behavior is encapsulated in one internal helper. It retries
|
|
958
|
+
interruptions and handles macOS/Linux-specific open or sync limitations
|
|
959
|
+
explicitly; it must not silently downgrade a failed required directory sync to
|
|
960
|
+
success. A filesystem that cannot provide the required durability causes the
|
|
961
|
+
operation to fail closed and remain recoverable.
|
|
962
|
+
|
|
963
|
+
No operation is declared committed until managed files, required manifest
|
|
964
|
+
publication or removal, final journal, new rollback point, and all relevant
|
|
965
|
+
parent directory entries are durable under this protocol.
|
|
966
|
+
|
|
967
|
+
The journal records forward and inverse progress separately. A controlled
|
|
968
|
+
failure transitions the active journal from `planned|applying + none` to
|
|
969
|
+
`rolling-back + interrupted-forward`, resolves backups only below
|
|
970
|
+
`.oak/rollback.next/`, durably records each inverse operation, then transitions
|
|
971
|
+
to `rolled-back + interrupted-forward`. An abrupt exit may leave
|
|
972
|
+
`transaction.json` in `planned`, `applying`, or either valid `rolling-back`
|
|
973
|
+
origin; rollback resumes the transition deterministically from its recorded
|
|
974
|
+
indexes and origin. All other mutating commands refuse to run until recovery
|
|
975
|
+
completes. Doctor reports the exact state.
|
|
976
|
+
|
|
977
|
+
Committed-operation rollback acquires a lock whose `transaction_id` equals the
|
|
978
|
+
committed transaction ID and whose command is `rollback`. It then copies the
|
|
979
|
+
committed journal into active `transaction.json`, changes its status to
|
|
980
|
+
`rolling-back`, changes `rollback_origin` from `none` to
|
|
981
|
+
`committed-operation`, and replaces its nested `lock` snapshot with the exact
|
|
982
|
+
current rollback lock fields, all while retaining the committed point. It
|
|
983
|
+
resolves backups only below `.oak/rollback/` and removes that committed point
|
|
984
|
+
only after every inverse operation and manifest restoration are durable and the
|
|
985
|
+
active journal reaches `rolled-back + committed-operation`. Interrupted forward
|
|
986
|
+
recovery uses the existing active journal, resolves only
|
|
987
|
+
`.oak/rollback.next/` backups, and never consumes the earlier committed rollback
|
|
988
|
+
point.
|
|
989
|
+
|
|
990
|
+
The engine exposes an internal failpoint callback to tests so interruption can
|
|
991
|
+
be simulated without production-only environment flags or undocumented CLI
|
|
992
|
+
options.
|
|
993
|
+
|
|
994
|
+
For deterministic tests, the engine also accepts internal injectable
|
|
995
|
+
dependencies equivalent to `clock()`, `transactionId()`, and `pidProbe()`.
|
|
996
|
+
These, together with `failpoint()`, are module-level dependencies or function
|
|
997
|
+
arguments, never public CLI options or secret environment flags. A filesystem
|
|
998
|
+
adapter may be introduced only if required to simulate low-level write or fsync
|
|
999
|
+
failures; the default implementation always uses the real filesystem path.
|
|
1000
|
+
|
|
1001
|
+
## Concurrency
|
|
1002
|
+
|
|
1003
|
+
The engine creates `.oak/lock.json` using exclusive creation. The lock records
|
|
1004
|
+
transaction ID, PID, command, and timestamp. PID liveness is conservative
|
|
1005
|
+
because operating systems can reuse PIDs: if the recorded PID appears alive,
|
|
1006
|
+
the engine blocks and does not try to infer whether it is the same process.
|
|
1007
|
+
The PID probe treats success as apparently alive, `ESRCH` as not alive, and
|
|
1008
|
+
`EPERM` as potentially alive and therefore blocking. Any other probe error is
|
|
1009
|
+
reported conservatively and fails closed rather than declaring the PID dead.
|
|
1010
|
+
Doctor reports that ambiguity. Ordinary install, upgrade, and uninstall never
|
|
1011
|
+
remove an existing live or stale lock.
|
|
1012
|
+
|
|
1013
|
+
A dead-PID lock is reported as stale. Recovery rollback may replace it only when
|
|
1014
|
+
an interrupted transaction also exists, the recorded PID does not appear alive,
|
|
1015
|
+
the lock and journal have the same transaction ID, and replacement is atomic
|
|
1016
|
+
and durable. Before the first replacement, every nested journal lock field must
|
|
1017
|
+
exactly equal the stale lock. A replacement lock keeps that transaction ID, uses
|
|
1018
|
+
the recovery PID/timestamp and command `rollback`, and is the only permitted
|
|
1019
|
+
successor mismatch while the nested snapshot is being updated. The engine must
|
|
1020
|
+
durably replace the nested journal lock snapshot before applying or recording
|
|
1021
|
+
another inverse operation. A crash between lock replacement and that journal
|
|
1022
|
+
update remains recognizable by the shared transaction ID plus the successor's
|
|
1023
|
+
`rollback` command, so another dead-PID recovery may repeat the same handoff.
|
|
1024
|
+
Any different mismatch fails closed. A stale lock without a matching
|
|
1025
|
+
interrupted transaction remains a blocking condition for mutations and
|
|
1026
|
+
requires manual investigation rather than an aggressive unlock heuristic.
|
|
1027
|
+
|
|
1028
|
+
Dry-run and ordinary doctor create no lock. `doctor --accept-preserved` is a
|
|
1029
|
+
real manifest mutation and follows the same exclusive lock, rescan, fingerprint,
|
|
1030
|
+
journal, and durability rules as every other apply. A concurrent read-only
|
|
1031
|
+
preview cannot authorize stale writes.
|
|
1032
|
+
|
|
1033
|
+
## Filesystem safety
|
|
1034
|
+
|
|
1035
|
+
- Resolve and validate the explicit target before mutation. Convert target,
|
|
1036
|
+
repository root, and source payload root to normalized absolute paths, resolve
|
|
1037
|
+
existing components without following an unsafe symlink, and apply the
|
|
1038
|
+
filesystem's case-sensitivity rules when they can be determined safely.
|
|
1039
|
+
- Reject `/`, an empty or safely unresolvable target, and every equality,
|
|
1040
|
+
ancestor, or descendant relationship between target and either repository
|
|
1041
|
+
root or source payload root. Thus the target cannot contain either root and
|
|
1042
|
+
cannot be contained by either root. Normalized `.`/`..`, case-equivalent, and
|
|
1043
|
+
symlink-mediated spellings do not bypass this rule.
|
|
1044
|
+
- Never recursively delete a caller-supplied broad path.
|
|
1045
|
+
- Reject source symlink files, source symlink directories, any symlink component
|
|
1046
|
+
in a managed target path, any symlink below `.oak/`, and any symlink used as
|
|
1047
|
+
rollback storage. Source inventory and target validation do not follow
|
|
1048
|
+
symlinks.
|
|
1049
|
+
- Use only normalized manifest-relative paths joined beneath the validated
|
|
1050
|
+
target.
|
|
1051
|
+
- Reserve `.oak` and all descendants exclusively for installation-manager
|
|
1052
|
+
state. Reject that namespace in source inventory, `owned_files`,
|
|
1053
|
+
`preserved_files`, logical plan paths, journal operation paths, and any
|
|
1054
|
+
backup path that attempts to represent a managed `.oak` path.
|
|
1055
|
+
- Remove only explicitly planned files and proven-empty directories.
|
|
1056
|
+
- Install, upgrade, recovery, and rollback restore both exact bytes and persisted
|
|
1057
|
+
mode. Internal `.oak` modes always follow the restrictive state policy rather
|
|
1058
|
+
than source modes.
|
|
1059
|
+
|
|
1060
|
+
These structural collisions fail closed before managed mutation and cannot be
|
|
1061
|
+
resolved with `--force`:
|
|
1062
|
+
|
|
1063
|
+
- source file where target is a directory;
|
|
1064
|
+
- source directory where target is a regular file;
|
|
1065
|
+
- regular-file parent in a managed target path;
|
|
1066
|
+
- `.oak` as a regular file or symlink;
|
|
1067
|
+
- rollback storage as a symlink;
|
|
1068
|
+
- manifest or lock path as a directory;
|
|
1069
|
+
- any other invalid parent path or file/directory type mismatch.
|
|
1070
|
+
|
|
1071
|
+
`--force` is limited to initial install and authorizes replacement only of a
|
|
1072
|
+
regular file at a normalized path beneath the validated target, with no symlink
|
|
1073
|
+
in the path or its managed ancestors, and only after the previous bytes and mode
|
|
1074
|
+
are durable. It cannot replace a directory, traverse a symlink, repair a
|
|
1075
|
+
manifest, bypass a live or stale lock, ignore an active transaction, overwrite
|
|
1076
|
+
`.oak`, run during upgrade, delete user-modified files during uninstall, resolve
|
|
1077
|
+
path traversal, or omit rollback backup creation.
|
|
1078
|
+
|
|
1079
|
+
## Tests
|
|
1080
|
+
|
|
1081
|
+
Create `scripts/manage-installation.test.mjs`. Tests use temporary source and
|
|
1082
|
+
target directories and import the engine rather than shelling out except for a
|
|
1083
|
+
small wrapper contract set.
|
|
1084
|
+
|
|
1085
|
+
Required scenarios:
|
|
1086
|
+
|
|
1087
|
+
1. Clean install dry-run performs zero writes.
|
|
1088
|
+
2. Clean install creates owned files and a valid sorted manifest.
|
|
1089
|
+
3. Existing protected configuration is preserved and recorded.
|
|
1090
|
+
4. Existing unrelated user files remain untouched.
|
|
1091
|
+
5. Unowned managed collision aborts with no target or state changes.
|
|
1092
|
+
6. Initial `--force` captures rollback bytes before replacement.
|
|
1093
|
+
7. Exact existing matches are adopted without rewriting during initial install.
|
|
1094
|
+
8. Upgrade fixture adds, updates, and removes expected files.
|
|
1095
|
+
9. Modified owned file aborts the complete upgrade with byte-for-byte unchanged
|
|
1096
|
+
target and state.
|
|
1097
|
+
10. Modified obsolete file aborts upgrade.
|
|
1098
|
+
11. Uninstall removes unchanged owned files and preserves modified/user files.
|
|
1099
|
+
12. Rollback restores install, upgrade, and uninstall.
|
|
1100
|
+
13. Post-operation user modification blocks rollback.
|
|
1101
|
+
14. Invalid schema, malformed JSON, duplicate paths, traversal paths, and bad
|
|
1102
|
+
hashes fail closed.
|
|
1103
|
+
15. Simulated interruption leaves recoverable journal state.
|
|
1104
|
+
16. Recovery rollback restores the pre-operation state.
|
|
1105
|
+
17. Live lock rejects a second mutation.
|
|
1106
|
+
18. Stale lock and corrupt transaction are reported without mutation.
|
|
1107
|
+
19. Source and target symlink traversal are rejected.
|
|
1108
|
+
20. Wrapper help, unknown arguments, target precedence, and exit codes remain
|
|
1109
|
+
deterministic.
|
|
1110
|
+
21. Stable preserved protected file permits doctor exit `0`.
|
|
1111
|
+
22. Source-only change for a protected file produces a merge warning.
|
|
1112
|
+
23. User and source changes on the same protected file produce merge pending.
|
|
1113
|
+
24. New upgrade source path with identical pre-existing target bytes/mode stays
|
|
1114
|
+
user-owned as `preexisting-exact-match`.
|
|
1115
|
+
25. Source-file/target-directory collision fails without mutation.
|
|
1116
|
+
26. Source-directory/target-file collision fails without mutation.
|
|
1117
|
+
27. `.oak` as a regular file fails closed.
|
|
1118
|
+
28. `.oak` as a symlink fails closed.
|
|
1119
|
+
29. Failure between rename and parent-directory fsync remains recoverable.
|
|
1120
|
+
30. Failure while installing a new rollback point preserves the previous point.
|
|
1121
|
+
31. Bootstrap cleanup never removes a pre-existing target.
|
|
1122
|
+
32. Bootstrap cleanup removes an empty target created by the invocation.
|
|
1123
|
+
33. Initial install preserves executable modes.
|
|
1124
|
+
34. Upgrade preserves executable modes.
|
|
1125
|
+
35. Rollback restores executable modes.
|
|
1126
|
+
36. `--force` rejects directory replacement.
|
|
1127
|
+
37. `--force` rejects symlink replacement or traversal.
|
|
1128
|
+
38. Backups, state files, state temporaries, and state directories have the
|
|
1129
|
+
required restrictive permissions.
|
|
1130
|
+
39. An apparently live PID blocks conservatively.
|
|
1131
|
+
40. Journal with invalid completed indexes fails closed.
|
|
1132
|
+
41. Missing protected preserved file whose source still exists produces doctor
|
|
1133
|
+
exit `1` without recreation.
|
|
1134
|
+
42. Stable preserved file is not a blocking conflict.
|
|
1135
|
+
43. Failure before journal creation leaves zero persistent state.
|
|
1136
|
+
44. Failure after journal creation produces a deterministic recovery plan.
|
|
1137
|
+
45. Interrupted recovery rollback does not consume the prior committed rollback
|
|
1138
|
+
point.
|
|
1139
|
+
46. Invalid or out-of-range persisted modes fail closed.
|
|
1140
|
+
47. Error and summary output never includes sentinel bytes stored in a sensitive
|
|
1141
|
+
rollback backup.
|
|
1142
|
+
48. A failure injected after bootstrap `rmdir` but before parent-directory
|
|
1143
|
+
`fsync` completes or retries the required sync and leaves the same durable
|
|
1144
|
+
zero state as before invocation.
|
|
1145
|
+
49. An unknown journal status or an invalid status transition fails closed
|
|
1146
|
+
without changing target, manifest, journal, or rollback state.
|
|
1147
|
+
50. Recovery from `rolling-back` resumes only the remaining inverse operations,
|
|
1148
|
+
reaches `rolled-back` deterministically, and retains the earlier committed
|
|
1149
|
+
rollback point for an interrupted forward operation.
|
|
1150
|
+
51. Committed rollback writes a `rollback` lock and matching active-journal lock
|
|
1151
|
+
snapshot with the committed transaction ID; interruption before or after
|
|
1152
|
+
holder-snapshot refresh remains resumable, while any unrelated ID or holder
|
|
1153
|
+
mismatch fails closed.
|
|
1154
|
+
52. Acknowledging a manual merge updates both preserved baselines and its
|
|
1155
|
+
acknowledgement metadata without changing reason, bytes, modes, or user
|
|
1156
|
+
ownership.
|
|
1157
|
+
53. Manual-merge acknowledgement aborts if the target changes after the
|
|
1158
|
+
confirmed plan.
|
|
1159
|
+
54. Manual-merge acknowledgement aborts if the source changes after the
|
|
1160
|
+
confirmed plan.
|
|
1161
|
+
55. Acknowledgement of a path absent from `preserved_files` fails closed.
|
|
1162
|
+
56. A source change after acknowledgement creates merge-pending state again.
|
|
1163
|
+
57. A user change after acknowledgement is classified as user-only evolution.
|
|
1164
|
+
58. Interrupted-forward recovery resolves backups only below
|
|
1165
|
+
`.oak/rollback.next/`.
|
|
1166
|
+
59. Committed-operation rollback resolves backups only below `.oak/rollback/`.
|
|
1167
|
+
60. An inconsistent status, rollback origin, backup root, or backup path fails
|
|
1168
|
+
closed.
|
|
1169
|
+
61. `.oak` as any source-payload entry is rejected.
|
|
1170
|
+
62. `.oak` in manifest-owned paths is rejected.
|
|
1171
|
+
63. A target equal to the repository root is rejected.
|
|
1172
|
+
64. A target that is an ancestor of the repository root is rejected.
|
|
1173
|
+
65. A target that is a descendant of the repository root is rejected.
|
|
1174
|
+
66. A target equal to, an ancestor of, or a descendant of the source payload is
|
|
1175
|
+
rejected.
|
|
1176
|
+
67. A dangerous target relationship expressed through `..` normalization is
|
|
1177
|
+
rejected.
|
|
1178
|
+
68. `adopt` changes ownership without rewriting the existing file.
|
|
1179
|
+
69. Rollback of adoption restores ownership without deleting or modifying the
|
|
1180
|
+
adopted file.
|
|
1181
|
+
70. `preserve` creates no mutable journal operation or backup.
|
|
1182
|
+
71. Rollback of preservation restores manifest state without changing file
|
|
1183
|
+
bytes or mode.
|
|
1184
|
+
72. A journal operation with `kind: adopt` is rejected.
|
|
1185
|
+
73. A journal operation with `kind: preserve` is rejected.
|
|
1186
|
+
74. An `add` operation with a non-null backup is rejected.
|
|
1187
|
+
75. An `update` operation without a valid backup is rejected.
|
|
1188
|
+
76. A `remove` operation without a valid backup is rejected.
|
|
1189
|
+
77. A manifest-only transaction can commit and rollback correctly with an empty
|
|
1190
|
+
operations array.
|
|
1191
|
+
78. Manual-merge acknowledgement is a rollbackable manifest-only transaction.
|
|
1192
|
+
79. `EPERM` from the PID probe blocks conservatively.
|
|
1193
|
+
80. Ordinary doctor reports a user-only preserved change without updating its
|
|
1194
|
+
baseline.
|
|
1195
|
+
81. A source payload entry at `.oak/manifest.json` is rejected independently of
|
|
1196
|
+
whether `.oak` was materialized as a directory, file, or symlink.
|
|
1197
|
+
82. A target relationship hidden through an existing symlink is rejected
|
|
1198
|
+
without following the unsafe path for mutation.
|
|
1199
|
+
83. Reserved `.oak` paths in `preserved_files`, logical plans, journal
|
|
1200
|
+
operations, or backup paths are rejected.
|
|
1201
|
+
84. A case-equivalent dangerous target relationship is rejected on a filesystem
|
|
1202
|
+
where case-insensitivity can be determined safely.
|
|
1203
|
+
85. An `add` operation with non-null before-state is rejected.
|
|
1204
|
+
86. A `remove` operation with non-null after-state is rejected.
|
|
1205
|
+
87. An `update` with an incomplete before-state or after-state pair is rejected.
|
|
1206
|
+
88. Any operation with a hash present but mode absent, or mode present but hash
|
|
1207
|
+
absent, is rejected.
|
|
1208
|
+
89. An unknown journal operation kind is rejected.
|
|
1209
|
+
90. `doctor --accept-preserved PATH` rejects path-only authorization that does
|
|
1210
|
+
not exactly match the displayed canonical ACK line.
|
|
1211
|
+
91. Manual-merge acknowledgement rejects confirmation containing any target or
|
|
1212
|
+
source hash/mode value different from the planned tuple.
|
|
1213
|
+
92. A no-op upgrade leaves the manifest and all preserved baselines byte-for-byte
|
|
1214
|
+
unchanged.
|
|
1215
|
+
93. A crash after commit but before `rollback.next/` and
|
|
1216
|
+
`rollback.previous/` cleanup leaves `rollback/` as the sole active point;
|
|
1217
|
+
doctor returns `1`, and neither residue is selected for rollback or
|
|
1218
|
+
interrupted recovery.
|
|
1219
|
+
94. A PID-probe error other than `ESRCH` or `EPERM` is reported conservatively
|
|
1220
|
+
and fails closed without stale-lock replacement.
|
|
1221
|
+
95. An initial-install journal uses `previous_manifest: null`, a valid complete
|
|
1222
|
+
next manifest, and matching null/non-null digests.
|
|
1223
|
+
96. An uninstall journal uses a valid previous manifest and
|
|
1224
|
+
`next_manifest: null` with a null next digest.
|
|
1225
|
+
97. A manifest object paired with a null digest fails validation.
|
|
1226
|
+
98. A null manifest paired with a non-null digest fails validation.
|
|
1227
|
+
99. Rollback of install removes the active manifest and restores expected
|
|
1228
|
+
absence.
|
|
1229
|
+
100. Rollback of uninstall restores the prior manifest.
|
|
1230
|
+
101. Recovery detects a present manifest when the journal expects absence.
|
|
1231
|
+
102. Recovery detects an absent manifest when the journal expects presence.
|
|
1232
|
+
103. A preserved path removed from the source but present in the target is
|
|
1233
|
+
classified `obsolete-preserved-present`.
|
|
1234
|
+
104. A preserved path absent from both source and target is classified
|
|
1235
|
+
`obsolete-preserved-missing`.
|
|
1236
|
+
105. Upgrade removes obsolete preserved metadata without touching a present
|
|
1237
|
+
user file.
|
|
1238
|
+
106. Upgrade removes obsolete preserved metadata without recreating a missing
|
|
1239
|
+
user file.
|
|
1240
|
+
107. Rollback of that manifest-only upgrade restores the preserved entry without
|
|
1241
|
+
changing or recreating user bytes.
|
|
1242
|
+
108. Ordinary doctor reports obsolete preserved metadata with exit `1` before
|
|
1243
|
+
cleanup and does not offer acknowledgement.
|
|
1244
|
+
109. Obsolete preserved cleanup permits a manifest-only upgrade when no other
|
|
1245
|
+
payload or ownership work exists.
|
|
1246
|
+
110. `--accept-preserved` requires the complete canonical ACK line.
|
|
1247
|
+
111. Confirmation `yes` is rejected with exit `1` and no persistent mutation.
|
|
1248
|
+
112. Path-only confirmation is rejected with exit `1` and no persistent
|
|
1249
|
+
mutation.
|
|
1250
|
+
113. A truncated hash in the confirmation line is rejected.
|
|
1251
|
+
114. EOF before a valid line cancels with exit `1` and zero persistent mutation.
|
|
1252
|
+
115. Exact confirmation works through non-interactive stdin without private
|
|
1253
|
+
flags.
|
|
1254
|
+
116. A tuple or fingerprint change after lock acquisition aborts with exit `1`.
|
|
1255
|
+
117. A path absent from `preserved_files` returns exit `2`.
|
|
1256
|
+
118. Unrelated owned drift blocks acknowledgement without changing state.
|
|
1257
|
+
119. A non-blocking warning on another preserved file does not block
|
|
1258
|
+
acknowledgement.
|
|
1259
|
+
120. Acknowledging a merge leaves the original preservation `reason` unchanged.
|
|
1260
|
+
121. Acknowledging a merge creates a complete `merge_acknowledgement` matching
|
|
1261
|
+
the committed baselines.
|
|
1262
|
+
122. `merge_acknowledgement.acknowledged_at` uses the injectable clock.
|
|
1263
|
+
123. Rollback restores the previous acknowledgement object or `null`.
|
|
1264
|
+
124. A partial acknowledgement object fails manifest validation.
|
|
1265
|
+
125. A new acknowledgement whose hashes or modes differ from the
|
|
1266
|
+
`accept-preserved` next-manifest baselines fails transaction validation.
|
|
1267
|
+
126. A later source change leaves the acknowledgement historical and creates
|
|
1268
|
+
merge-pending state.
|
|
1269
|
+
127. A later target change leaves the acknowledgement historical and is
|
|
1270
|
+
classified as user-only evolution.
|
|
1271
|
+
128. Canonical manifest serialization produces identical bytes and digest for
|
|
1272
|
+
writing and validation.
|
|
1273
|
+
129. An empty object is invalid and never represents an absent manifest.
|
|
1274
|
+
130. A transaction with both previous and next manifests null is rejected.
|
|
1275
|
+
131. Committed-operation rollback rejects current manifest presence when the
|
|
1276
|
+
committed next state expects absence, and rejects absence when it expects
|
|
1277
|
+
presence, before any inverse write.
|
|
1278
|
+
132. Committed-operation rollback rejects a present current manifest whose
|
|
1279
|
+
canonical digest differs from `next_manifest_sha256`.
|
|
1280
|
+
133. Interrupted recovery rejects a present manifest with the wrong canonical
|
|
1281
|
+
digest for its recorded previous, next, or inverse-completed phase.
|
|
1282
|
+
134. An upgrade journal accepts only valid complete previous and next manifests
|
|
1283
|
+
with matching non-null digests.
|
|
1284
|
+
135. An `accept-preserved` journal accepts only valid complete previous and next
|
|
1285
|
+
manifests with matching non-null digests.
|
|
1286
|
+
136. Each transaction command rejects every presence pair other than its
|
|
1287
|
+
declared install, upgrade, accept-preserved, or uninstall combination.
|
|
1288
|
+
|
|
1289
|
+
Update `unit-and-script-tests` so both `scripts/*.test.mjs` and
|
|
1290
|
+
`opencode/scripts/*.test.mjs` execute in CI.
|
|
1291
|
+
|
|
1292
|
+
Extend `scripts/install-smoke.sh` to exercise, in a clean temporary target:
|
|
1293
|
+
|
|
1294
|
+
```text
|
|
1295
|
+
install -> doctor -> upgrade --dry-run -> uninstall -> rollback -> doctor
|
|
1296
|
+
```
|
|
1297
|
+
|
|
1298
|
+
The final doctor must confirm that rollback restored the managed installation,
|
|
1299
|
+
and the installed plugin import must continue to pass.
|
|
1300
|
+
|
|
1301
|
+
## Documentation
|
|
1302
|
+
|
|
1303
|
+
Update `README.md` and `docs/installation.md` with:
|
|
1304
|
+
|
|
1305
|
+
- command examples and dry-run-first workflow;
|
|
1306
|
+
- manifest ownership semantics;
|
|
1307
|
+
- protected configuration behavior;
|
|
1308
|
+
- legacy migration limitation;
|
|
1309
|
+
- conflict resolution guidance;
|
|
1310
|
+
- uninstall preservation rules;
|
|
1311
|
+
- single-generation rollback limitation;
|
|
1312
|
+
- recovery steps for interrupted state.
|
|
1313
|
+
|
|
1314
|
+
Update `CONTRIBUTING.md` only if its validation checklist needs to name the new
|
|
1315
|
+
manager tests. Update `scripts/check.sh` to require the engine, wrappers, tests,
|
|
1316
|
+
and executable modes.
|
|
1317
|
+
|
|
1318
|
+
## Validation and evidence
|
|
1319
|
+
|
|
1320
|
+
Required before closure:
|
|
1321
|
+
|
|
1322
|
+
- focused RED/GREEN manager tests;
|
|
1323
|
+
- all manager scenarios above;
|
|
1324
|
+
- `npm run check`;
|
|
1325
|
+
- `npm run check:release`;
|
|
1326
|
+
- `bash -n` for every shell wrapper;
|
|
1327
|
+
- clean temporary installation lifecycle smoke;
|
|
1328
|
+
- negative conflict proof showing no write occurred;
|
|
1329
|
+
- `git diff --check`;
|
|
1330
|
+
- public leak scan;
|
|
1331
|
+
- independent spec, implementation, and final diff review.
|
|
1332
|
+
|
|
1333
|
+
Evidence must distinguish automated tests, static checks, temporary live smoke,
|
|
1334
|
+
manual review, and anything not run. No routing behavior changes, so transcript
|
|
1335
|
+
replay is not required.
|
|
1336
|
+
|
|
1337
|
+
## Public/private boundary
|
|
1338
|
+
|
|
1339
|
+
All implementation belongs to the public repository. No private OpenCode
|
|
1340
|
+
configuration, provider, MCP, credential, endpoint, session, transcript,
|
|
1341
|
+
machine-local path, or user-installed skill registry is copied or referenced.
|
|
1342
|
+
Private memory state remains outside the public repository and this design.
|
|
1343
|
+
|
|
1344
|
+
## Rollback of this development slice
|
|
1345
|
+
|
|
1346
|
+
The Slice 1.2 diff can be reverted by its explicit public file list. It must not
|
|
1347
|
+
discard the already approved but uncommitted Slice 1.1 changes in shared files
|
|
1348
|
+
such as `package.json`, `README.md`, `CONTRIBUTING.md`, or
|
|
1349
|
+
`scripts/install-smoke.sh`. No commit, push, tag, or release is part of this
|
|
1350
|
+
slice unless separately requested.
|