@6reduk/workspace-pipeline 0.1.0

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.
Files changed (157) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +78 -0
  3. package/docs/collaboration.md +59 -0
  4. package/docs/config-fields.md +65 -0
  5. package/docs/contracts.md +149 -0
  6. package/docs/doctor.md +165 -0
  7. package/docs/launch.md +50 -0
  8. package/docs/lifecycle-cli.md +141 -0
  9. package/docs/lifecycle.md +42 -0
  10. package/docs/migrations/unity.md +288 -0
  11. package/docs/native-provider-format.md +149 -0
  12. package/docs/provider-bundles.md +81 -0
  13. package/docs/provider-resources.md +37 -0
  14. package/docs/release.md +25 -0
  15. package/docs/remove.md +70 -0
  16. package/docs/repair.md +80 -0
  17. package/docs/repositories.md +209 -0
  18. package/docs/repository-manual-recovery.md +102 -0
  19. package/docs/repository-observations.md +29 -0
  20. package/docs/repository-recovery.md +204 -0
  21. package/docs/repository-retention.md +46 -0
  22. package/docs/repository-transport-budgets.md +26 -0
  23. package/docs/retention.md +237 -0
  24. package/docs/source.md +50 -0
  25. package/docs/switch.md +412 -0
  26. package/package.json +39 -0
  27. package/schemas/common.schema.json +251 -0
  28. package/schemas/inventory.schema.json +15 -0
  29. package/schemas/operation.schema.json +286 -0
  30. package/schemas/pipeline.schema.json +317 -0
  31. package/schemas/state.schema.json +302 -0
  32. package/schemas/workspace.schema.json +67 -0
  33. package/src/cli.js +7 -0
  34. package/src/commands/adopt.js +2 -0
  35. package/src/commands/bootstrap-recovery.js +90 -0
  36. package/src/commands/dispatch.js +394 -0
  37. package/src/commands/init.js +84 -0
  38. package/src/commands/launch.js +69 -0
  39. package/src/commands/migration-apply.js +53 -0
  40. package/src/commands/migration.js +50 -0
  41. package/src/commands/repositories.js +61 -0
  42. package/src/commands/repository-abandon.js +16 -0
  43. package/src/commands/repository-ancestors.js +21 -0
  44. package/src/commands/repository-locks.js +77 -0
  45. package/src/contracts/parse.js +57 -0
  46. package/src/contracts/semantic.js +240 -0
  47. package/src/contracts/validate.js +21 -0
  48. package/src/launch/grok.js +20 -0
  49. package/src/migrations/legacy-unity-begin.js +35 -0
  50. package/src/migrations/legacy-unity-compensate.js +82 -0
  51. package/src/migrations/legacy-unity-deactivate.js +60 -0
  52. package/src/migrations/legacy-unity-deactivation-resume-apply.js +62 -0
  53. package/src/migrations/legacy-unity-deactivation-resume.js +81 -0
  54. package/src/migrations/legacy-unity-finalize.js +88 -0
  55. package/src/migrations/legacy-unity-install-recovery.js +76 -0
  56. package/src/migrations/legacy-unity-install-resume.js +60 -0
  57. package/src/migrations/legacy-unity-install.js +88 -0
  58. package/src/migrations/legacy-unity-lease.js +136 -0
  59. package/src/migrations/legacy-unity-preflight.js +67 -0
  60. package/src/migrations/legacy-unity-preview.js +91 -0
  61. package/src/migrations/legacy-unity-resume-apply.js +39 -0
  62. package/src/migrations/legacy-unity-resume.js +41 -0
  63. package/src/migrations/legacy-unity-resumed-evidence.js +88 -0
  64. package/src/migrations/legacy-unity.js +99 -0
  65. package/src/operations/apply.js +576 -0
  66. package/src/operations/backup.js +94 -0
  67. package/src/operations/bootstrap-lock.js +87 -0
  68. package/src/operations/bootstrap-owner-retirement.js +121 -0
  69. package/src/operations/bundle-update.js +54 -0
  70. package/src/operations/config-fields.js +24 -0
  71. package/src/operations/continuation-lifecycle.js +77 -0
  72. package/src/operations/doctor.js +214 -0
  73. package/src/operations/history.js +170 -0
  74. package/src/operations/installer-identity.js +49 -0
  75. package/src/operations/journal.js +142 -0
  76. package/src/operations/lifecycle.js +133 -0
  77. package/src/operations/lineage-guard.js +20 -0
  78. package/src/operations/lock.js +109 -0
  79. package/src/operations/maintenance.js +62 -0
  80. package/src/operations/migration-pending.js +22 -0
  81. package/src/operations/ownership.js +122 -0
  82. package/src/operations/plan.js +278 -0
  83. package/src/operations/reconciliation.js +112 -0
  84. package/src/operations/recovery-lease.js +66 -0
  85. package/src/operations/remove.js +140 -0
  86. package/src/operations/repair.js +188 -0
  87. package/src/operations/repository-abandon.js +192 -0
  88. package/src/operations/repository-ancestors.js +158 -0
  89. package/src/operations/repository-apply.js +122 -0
  90. package/src/operations/repository-authorization.js +48 -0
  91. package/src/operations/repository-bootstrap-continuation.js +190 -0
  92. package/src/operations/repository-bootstrap-reconcile.js +106 -0
  93. package/src/operations/repository-bootstrap-recover.js +114 -0
  94. package/src/operations/repository-bootstrap.js +82 -0
  95. package/src/operations/repository-clone.js +63 -0
  96. package/src/operations/repository-history.js +108 -0
  97. package/src/operations/repository-inputs.js +41 -0
  98. package/src/operations/repository-journal.js +127 -0
  99. package/src/operations/repository-lock-reconcile.js +401 -0
  100. package/src/operations/repository-pending.js +29 -0
  101. package/src/operations/repository-reconcile.js +182 -0
  102. package/src/operations/repository-resumption-approvals.js +77 -0
  103. package/src/operations/repository-retention-apply.js +75 -0
  104. package/src/operations/repository-retention.js +137 -0
  105. package/src/operations/repository-workspace.js +78 -0
  106. package/src/operations/retention-apply.js +133 -0
  107. package/src/operations/retention-combined-scan.js +30 -0
  108. package/src/operations/retention-combined.js +41 -0
  109. package/src/operations/retention-policy.js +65 -0
  110. package/src/operations/retention-receipts.js +126 -0
  111. package/src/operations/retention-scan.js +86 -0
  112. package/src/operations/retention.js +56 -0
  113. package/src/operations/state.js +210 -0
  114. package/src/operations/switch-activate.js +64 -0
  115. package/src/operations/switch-backups.js +29 -0
  116. package/src/operations/switch-continuation-journal.js +94 -0
  117. package/src/operations/switch-continuation-pending.js +60 -0
  118. package/src/operations/switch-continuation-records.js +109 -0
  119. package/src/operations/switch-continuation-recovery.js +91 -0
  120. package/src/operations/switch-continuation-runtime.js +135 -0
  121. package/src/operations/switch-continuation-store.js +120 -0
  122. package/src/operations/switch-continuation.js +76 -0
  123. package/src/operations/switch-execute.js +68 -0
  124. package/src/operations/switch-inspect.js +45 -0
  125. package/src/operations/switch-journal-store.js +109 -0
  126. package/src/operations/switch-journal.js +71 -0
  127. package/src/operations/switch-lifecycle.js +72 -0
  128. package/src/operations/switch-pending.js +43 -0
  129. package/src/operations/switch-preflight.js +73 -0
  130. package/src/operations/switch-prepare.js +75 -0
  131. package/src/operations/switch-records.js +60 -0
  132. package/src/operations/switch-recovery-store.js +74 -0
  133. package/src/operations/switch.js +52 -0
  134. package/src/operations/toml-fields.js +133 -0
  135. package/src/providers/bundles.js +42 -0
  136. package/src/providers/common-entry.js +16 -0
  137. package/src/providers/grok.js +26 -0
  138. package/src/providers/interface.js +25 -0
  139. package/src/providers/kimi.js +26 -0
  140. package/src/providers/native.js +155 -0
  141. package/src/providers/registry.js +10 -0
  142. package/src/providers/shared.js +51 -0
  143. package/src/providers/source.js +30 -0
  144. package/src/source/git.js +303 -0
  145. package/src/source/inventory.js +87 -0
  146. package/src/source/repository-budget.js +18 -0
  147. package/src/source/snapshot.js +37 -0
  148. package/src/workspace/paths.js +54 -0
  149. package/src/workspace/profiles.js +8 -0
  150. package/src/workspace/repositories.js +57 -0
  151. package/src/workspace/repository-inventory.js +77 -0
  152. package/src/workspace/repository-observation.js +38 -0
  153. package/src/workspace/repository-preflight.js +129 -0
  154. package/src/workspace/repository-preview.js +196 -0
  155. package/src/workspace/repository-tree.js +57 -0
  156. package/src/workspace/reserved.js +11 -0
  157. package/src/workspace/resolve.js +53 -0
@@ -0,0 +1,141 @@
1
+ # Lifecycle CLI routing — development scope
2
+
3
+ The generic dispatcher routes `setup`, `update`, `repair`, `remove`, `switch` and `continue` through
4
+ the native operation APIs and their coordinators. The packaged entrypoint supplies
5
+ compiled Codex, Claude, Kimi and Grok adapters. S11 review and native Kimi/Grok
6
+ verification remain open; use disposable workspaces for these additions.
7
+ For Grok Claude-import suppression use the [scoped launcher](launch.md), not a
8
+ direct harness invocation. File readiness does not certify runtime isolation.
9
+
10
+ Tests supply a trusted registry directly to `runCli`. There is no argv flag,
11
+ environment-selected module, or pipeline-supplied executable adapter loader.
12
+ Direct library calls without a registry still fail with `cli.providers-unavailable`.
13
+ CLI assembly supplies built-in adapters, never package code.
14
+
15
+ ## Preview and apply contract
16
+
17
+ Once a trusted registry is provided by the CLI assembly:
18
+
19
+ ```text
20
+ workspace-pipeline setup --workspace <absolute-wrapper> [--manifest <absolute-file>] [--network]
21
+ workspace-pipeline update --workspace <absolute-wrapper> [--manifest <absolute-file>] [--network]
22
+ workspace-pipeline setup --workspace <absolute-wrapper> --apply --preview <absolute-json-file>
23
+ workspace-pipeline update --workspace <absolute-wrapper> --apply --preview <absolute-json-file>
24
+ ```
25
+
26
+ Preview returns the complete prepared JSON on stdout. It may acquire a Git
27
+ source into temporary storage outside the wrapper, but does not write provider
28
+ configuration. Network acquisition requires explicit `--network`. When manifest
29
+ is omitted, setup uses the standard workspace manifest; update uses the recorded
30
+ manifest origin. Relocation does not silently rebind it. The separate source
31
+ rebind workflow is not exposed by these commands yet.
32
+
33
+ Save prepared JSON privately, inspect its operations and then explicitly invoke
34
+ `--apply --preview`. It may contain configuration secrets and absolute local
35
+ paths; do not commit it or send it to shared logs. Apply does not accept
36
+ `--manifest` or `--network`, acquire a fresh source, or substitute a new preview.
37
+ Missing/stale staged data is an error, not permission to download replacements.
38
+
39
+ Apply binds the verb and exact wrapper before lock acquisition, then invokes
40
+ existing locked approval, registry, ownership, history, snapshot and drift checks.
41
+ `--apply` authorizes only that saved prepared subject; no approval is inferred
42
+ from preview generation. Existing local opt-in retention is handled by the
43
+ internal lifecycle coordinator, not a second cleanup pass in the dispatcher.
44
+
45
+ ## Output and failures
46
+
47
+ - stdout: one prepared JSON or operation result.
48
+ - stderr during apply: structured journal/recovery locations and operation events.
49
+ - exit 0: preview created, or observed configuration ready with successful lock
50
+ release and reporting. It never certifies harness/MCP runtime.
51
+ - exit 1: lifecycle failure/incomplete result, including a wrong verb or wrapper
52
+ in the prepared package. Read the operation result, not just the exit code.
53
+ - exit 2: invalid invocation, unavailable adapters, input/transport failure.
54
+
55
+ If stdout fails after a successful apply, exit 2 does not undo that apply.
56
+ Operation events and `doctor` distinguish actual configuration state from output
57
+ delivery. Errors expose stable codes, not raw exception messages or argv secrets.
58
+ No force unlock, rollback, retry or global configuration mutation is performed.
59
+
60
+ ## Offline repair and removal
61
+
62
+ These routes have the same trusted-registry restriction as setup/update:
63
+
64
+ ```text
65
+ workspace-pipeline repair --workspace <absolute-wrapper>
66
+ workspace-pipeline remove --workspace <absolute-wrapper> [--providers codex] [--bundles claude-grok]
67
+ workspace-pipeline repair --workspace <absolute-wrapper> --apply --preview <absolute-json-file>
68
+ workspace-pipeline remove --workspace <absolute-wrapper> --apply --preview <absolute-json-file>
69
+ ```
70
+
71
+ Repair reconstructs only the approved installed snapshot, not the newest source.
72
+ Removal preserves other installed providers and shared files while needed; full
73
+ removal restores taken-over content and removes only owned scope. Missing/corrupt
74
+ snapshots, backups, unresolved history or conflicting user edits fail closed.
75
+ Neither route reads the original manifest or downloads from Git. `--manifest`
76
+ and `--network` are rejected. `--providers` and `--bundles` are remove-preview-only;
77
+ omitting both previews all installed providers and bundles. Use actual installed
78
+ bundle IDs; selecting a bundle member via `--providers` fails with
79
+ `remove.bundle-required`. The saved subject fixes the actual selection, so apply
80
+ cannot override it. See [removal](remove.md) and [bundle delivery](provider-bundles.md).
81
+
82
+ The maintenance coordinator validates exact command/workspace and record before
83
+ locking, checks history under lock and calls native approval/replay. It reports
84
+ journal/recovery locations early and preserves partial evidence on failure.
85
+ Successful full removal returns `not-installed` with exit 0, not `ready`; runtime
86
+ is still unverified. A failed output delivery cannot roll back successful work.
87
+
88
+ Automatic retention remains setup/update-only at this stage; maintenance does
89
+ not silently clean history or use removal approval as cleanup permission.
90
+ Interrupted-operation continuation has a separate exact approval boundary below.
91
+
92
+ ## Switching pipeline
93
+
94
+ With the same trusted built-in registry restriction:
95
+
96
+ ```text
97
+ workspace-pipeline switch --workspace <absolute-wrapper> --manifest <absolute-incoming-manifest> [--network]
98
+ workspace-pipeline switch --workspace <absolute-wrapper> --apply --preview <absolute-json-file>
99
+ ```
100
+
101
+ The incoming manifest is mandatory for preview. Preparation stages and validates
102
+ the incoming Git package before removal; it does not change workspace files.
103
+ Apply accepts only the saved prepared subject, not manifest/network overrides.
104
+ Under the workspace lock it persists recovery, marks the operation pending,
105
+ executes `remove-old` then `install-new`, and activates only after both phases
106
+ and final targets are checked. Completed phases alone do not mean activation.
107
+
108
+ Events identify journal/recovery locations and phase progress. An interruption
109
+ between phases leaves the actual state `needs-reconciliation` and the old active
110
+ identity; an operation result of `failed` does not imply unchanged files.
111
+ Re-running switch is not an implicit retry or recovery command. There is no
112
+ automatic rollback, source reacquisition, or retention cleanup in this route.
113
+ Use read-only doctor/history to inspect retained state. Continuation eligibility
114
+ is narrower than arbitrary failure recovery, as described below.
115
+
116
+ ## Continuing an interrupted operation
117
+
118
+ ```text
119
+ workspace-pipeline continue --workspace <absolute-wrapper> --recovery .pipeline/transactions/<run-id>/recovery.json
120
+ workspace-pipeline continue --workspace <absolute-wrapper> --apply --preview <absolute-json-file>
121
+ ```
122
+
123
+ The registry restriction still applies. Select an exact workspace-relative recovery
124
+ record, never the newest filename or timestamp. Preview is read-only and private;
125
+ it may contain desired configuration bytes. Apply accepts no recovery/source/network
126
+ override and reconstructs the saved proposal under lock before any target writes.
127
+
128
+ This creates a new journal and recovery record. Old records are preserved; desired
129
+ bytes are read back, not written again, and before bytes require the new approval.
130
+ Conflicting bytes, stale pending state, corrupt ancestry or changed evidence reject
131
+ continuation. Removal may end in not-installed; success is not runtime certification.
132
+ Reporter failures retain evidence and never trigger rollback or automatic retry.
133
+
134
+ The native eligibility rules remain authoritative: general operations require a
135
+ valid pending record without conflicts. Switch accepts an uncertain target or a
136
+ verified open/completed journal still selected by pending state. At a clean
137
+ boundary, `uncertain: null` means no ambiguous write: only unrecorded operations
138
+ and phase checks remain. Completed outcomes are not replayed. After both recorded
139
+ phase checks, an empty remainder permits separately checked activation, not an
140
+ inferred phase success. Failed/corrupt journals and changed targets fail closed.
141
+ No source download, global setting change, force unlock or retention cleanup occurs.
@@ -0,0 +1,42 @@
1
+ # Setup/update coordination (S6 development)
2
+
3
+ Internal APIs only; public CLI routing and real provider adapters remain pending.
4
+
5
+ `prepareLifecycle(input, registry)` prepares an explicit setup or update command.
6
+ It can acquire a Git source into temporary storage outside the workspace, but
7
+ does not edit provider configuration or approve its own output. A wrong verb for
8
+ the current installation is rejected. Incomplete history blocks preparation.
9
+
10
+ `applyLifecycle(input, registry, {report, retention})` takes the exact prepared plan and a
11
+ separate approval, acquires the workspace lock, rechecks state/history and invokes
12
+ native apply. Callers must coordinate stopped configuration consumers; neither an
13
+ approval nor this lock proves that outside harness sessions have stopped.
14
+
15
+ The registry and reporter are trusted caller code, never loaded from the pipeline
16
+ source. Reporter events contain paths and status, not credential-bearing contents.
17
+ CLI wiring must provide a reporter to actually print early events.
18
+
19
+ Journal location events: `planned` (no creation claim), `created` (directory exists),
20
+ `initialized` (start record checked). They include absolute path and run ID.
21
+ Recovery location events: `created-unverified`, then `verified` after readback;
22
+ before creation its intended path is labelled `not-created`.
23
+
24
+ The final result preserves the last observed location statuses, including failure
25
+ after journal creation but before recovery. A failure before journal allocation
26
+ reports null journal/recovery. A forced kill cannot guarantee a final message.
27
+ Reporter failure during execution stops it; partially written evidence is retained.
28
+ Failure to emit the final result does not rewrite an already successful operation:
29
+ `outputError` is separate. Lock release failure is likewise separately reported.
30
+ No rollback, cleanup, force-unlock or retry is implied by a failure report.
31
+
32
+ The optional `retention` argument is a separately approved exact cleanup preview,
33
+ not an implicit setup permission. It runs under the same lock after read-only
34
+ main preflight and before the new journal is created. A failed cleanup/report
35
+ prevents setup/update from starting; its own result stays in `result.cleanup`.
36
+ Main preflight is repeated afterwards. See [retention](retention.md) for limits;
37
+ an explicitly enabled local automatic policy is also supported. Manual startup
38
+ cleanup plus automatic policy is rejected. Public setup/update routing remains pending.
39
+
40
+ Repeated update with unchanged desired deployment remains valid: doctor verifies
41
+ every matching recovery record, and recovery distinguishes completed no-op state
42
+ from before-state using the completed journal, not equality of state bytes alone.
@@ -0,0 +1,288 @@
1
+ # Legacy Unity migration — internal synthetic implementation
2
+
3
+ S10 is in progress. CLI preview, inspection and explicit apply are available for
4
+ synthetic testing; independent review and real deployment approval remain pending.
5
+
6
+ ## CLI preparation and inspection
7
+
8
+ `workspace-pipeline migration unity preview --workspace <absolute-wrapper> --manifest <absolute-manifest>`
9
+ prepares the complete proposal, staging committed Git source outside the wrapper.
10
+ Add `--network` only to permit remote acquisition. Keep the JSON private: it can
11
+ contain full config bytes. The command does not disable plugins or install files.
12
+
13
+ `workspace-pipeline migration unity inspect --workspace <absolute-wrapper> --recovery <relative-record> --phase <phase>`
14
+ inspects one explicit saved migration without writes or source acquisition.
15
+ Phases: `deactivation`, `installation`, `recovery`, `closeout`, `compensation`.
16
+ Each selects the corresponding narrow internal planner described below. Unknown
17
+ phases, path escapes, duplicate flags and `--apply` are rejected. Exit 0 means a
18
+ proposal was prepared, NOT installation readiness or approval. Blocked proposals
19
+ return nonzero. To authorize exactly a saved proposal, use the separate command:
20
+
21
+ `workspace-pipeline migration unity apply --workspace <absolute-wrapper> --preview <absolute-preview-file>`
22
+
23
+ This verb is explicit authorization of the saved installer-bound envelope. It
24
+ accepts no source/network/phase overrides. Initial migration runs deactivation,
25
+ installation and validated closeout under its lock. Recovery/compensation previews
26
+ execute only their selected bounded operation; a phase result may still require a
27
+ fresh closeout preview and approval. Exit 0 means completed or legacy-restored;
28
+ exit 1 means needs-reconciliation, exit 2 means rejected/error (writes may have
29
+ occurred before an I/O failure). Inspect the reported recovery/log paths; never
30
+ infer rollback from nonzero exit. Stop harness sessions/config editors before apply.
31
+ Private records remain under .pipeline/migrations; do not delete active recovery
32
+ evidence. No automatic cleanup or publication occurs.
33
+
34
+ CLI output now wraps the inner proposal in `installer-bound-migration-preview`.
35
+ Its installer identity hashes `package.json`, `src/` and `schemas/`, independently
36
+ of installation directory. Verify this envelope before future apply; changed
37
+ installer payload requires a new preview. This does not version-pin project docs,
38
+ the harness or model. Docs/tests are excluded from this executable-payload identity.
39
+ It is not a publisher signature, a hash of tar compression bytes, or verification
40
+ of installed dependency contents. `npm run test:packed:identity` tests identity
41
+ through an offline tarball install and rejects a changed installed payload.
42
+ prepareLegacyUnityOptOut is a pure byte transformer, not a writer or approval.
43
+ It disables only unity-sdd-pipeline@unity-sdd in the supplied local Codex/Claude
44
+ configuration. Other bytes are preserved. Missing/ambiguous activation and active
45
+ inline TOML ancestors fail closed. No global settings are accepted implicitly.
46
+
47
+ The coordinator binds the wrapper, exact before/after bytes and approved source;
48
+ the public CLI additionally binds the installer payload. Prefetch and conflict
49
+ checks precede legacy deactivation.
50
+ Existing AGENTS.md/CLAUDE.md require explicit takeover and private backups.
51
+ Global caches, game and docs remain outside scope. Old .unity-sdd markers are not
52
+ ownership. The transformer alone is neither a migration nor recovery mechanism.
53
+ Interrupted operations need observed-state reconciliation under the CLI lock and
54
+ fresh continuation/compensation approval, never blind rollback. Users must stop
55
+ active harness sessions. Do not deploy until the complete route is reviewed.
56
+
57
+ The configuration-only deactivation record includes both complete before/after
58
+ payloads and hashes. Treat it as private: foreign settings may contain credentials.
59
+ Validation rebuilds the narrow transformations instead of trusting caller hashes.
60
+ Inspection classifies each current target as before, after, unchanged-disabled or
61
+ conflict. It never establishes ownership, authorizes restoration, or writes files.
62
+ An independently edited file equal to after bytes is not proof of our execution.
63
+ This record has no wrapper/source/approval binding; it is an internal component,
64
+ not a complete apply preview. The outer coordinator must supply those bindings.
65
+
66
+ Read-only preflight now acquires a committed Git source into external preparation
67
+ storage, verifies its inventory and Unity identity, and binds the wrapper plus six
68
+ legacy entry/config/marker file hashes. Rechecking uses staged bytes without Git
69
+ or network. Existing .pipeline metadata, missing legacy files, changed wrapper
70
+ bytes and changed package bytes block this preparation route. No target writes,
71
+ entry takeovers, journal or approval are implemented by this preflight. Its digest
72
+ is integrity evidence, not authority; native registry/layout validation and a full
73
+ apply transaction are supplied by the internal routes below. This inner preflight
74
+ does not bind the installer; the public CLI envelope binds its executable payload,
75
+ not the tarball bytes, as described above.
76
+
77
+ prepareLegacyUnityPreview now renders the compiled Codex/Claude adapters and
78
+ shared entry against the verified source and workspace manifest. Only AGENTS.md
79
+ and CLAUDE.md receive proposed exact-byte takeovers; other foreign collisions
80
+ still fail closed. Original entry bytes are retained in the private proposal and
81
+ the setup plan declares their native backup paths. No backup file is written yet.
82
+
83
+ The embedded setup preview uses virtual post-deactivation observations. It is
84
+ NOT independently applicable to the current wrapper and must never be submitted
85
+ directly to generic apply. The outer migration requires both ordered phases under
86
+ one approval and appropriate recovery semantics. It also binds original target
87
+ observations and checks the manifest again after rendering. The internal coordinator
88
+ below handles deactivation, native installation and same-process finalization.
89
+
90
+ verifyLegacyUnityPreview binds explicit caller approval to the whole proposal,
91
+ checks the selected wrapper and current manifest, verifies staged package bytes
92
+ and reconstructs every proposed edit with compiled adapters. Changed instructions,
93
+ paths or phase order are rejected even if a caller recomputes the outer digest.
94
+ This verification performs no acquisition, writes or locking, and must be repeated
95
+ under the eventual transaction guard before writes. It is not an execution capability.
96
+
97
+ Integration constraint: ordinary setup recovery represents one installation and
98
+ cannot truthfully cover a preceding legacy deactivation. Do not manufacture an
99
+ old active deployment or record deactivation as init/repair. The final coordinator
100
+ must persist both phases and gate all normal lifecycle writers while migration is
101
+ incomplete; native doctor/history/continuation must understand the resulting record
102
+ before any ready activation is allowed. CLI apply delegates to these checked routes.
103
+
104
+ Pending guard implemented: presence of `.pipeline/migration-operation.json`
105
+ blocks ordinary workspace locks and existing repository/lifecycle entry guards.
106
+ It is checked again when a held lock is used, including repository-operation locks.
107
+ Empty, malformed, directory and link markers are not parsed as permission to proceed.
108
+ History reports incomplete; doctor reports needs-reconciliation, ready=false.
109
+ No marker is deleted or auto-repaired. Migration-specific recovery/execution
110
+ capabilities were initially unavailable; the internal begin/deactivate route below
111
+ now supplies one. Do not create the marker manually in real workspaces. This guard
112
+ alone does not perform migration.
113
+
114
+ ## Internal begin and first-phase execution
115
+
116
+ beginLegacyUnityMigration validates the full approved preview before locking and
117
+ again under a process-local migration lock. It first writes a pending marker,
118
+ then the private recovery record containing original bytes and approval binding.
119
+ Only after both readbacks does it seal the capability. JSON cannot recreate the
120
+ capability. Changed/missing marker or changed recovery invalidates it. Ordinary
121
+ and repository-operation locks cannot bypass it. The caller must release the
122
+ returned lock; failure does not delete recovery evidence or restore targets.
123
+
124
+ The returned internal deactivate method writes exact Codex and Claude opt-outs
125
+ with per-target intent/outcome records under the migration's deactivation directory.
126
+ An error stops the remainder. A write followed by an error is uncertain, not
127
+ silently successful. A repeated call is not an automatic retry. Final history
128
+ readback audits the fixed phase journal. Instructions, skills and game files are
129
+ not written in this phase. Result remains needs-reconciliation after success:
130
+ the second phase must run separately through the same authenticated capability.
131
+
132
+ ## Internal second-phase installation
133
+
134
+ The returned install method requires the complete, hash-linked deactivation journal
135
+ and exact disabled configuration bytes. Disabled settings alone are not execution
136
+ evidence. It delegates installation to native apply, including re-rendering, checked
137
+ writes, instruction takeover backups, native transaction recovery and activation.
138
+ The full preview approval supplies the subordinate installation authorization;
139
+ it is not a new inferred human decision. Source snapshot and Git object preparation
140
+ must remain outside the wrapper and present for verification.
141
+
142
+ An installation locator binds the native journal/recovery to the outer migration
143
+ and deactivation result. A second call is not an implicit retry. An interruption
144
+ preserves recovery and leaves ordinary lifecycle operations blocked. Even when
145
+ native apply returns ready, the outer result is needs-reconciliation: the pending
146
+ marker stays in place and doctor must not report readiness until finalization.
147
+
148
+ ## Internal same-process finalization
149
+
150
+ The returned finalize method requires a completed first-phase journal, exact native
151
+ prepared-plan/approval bindings and a successful native recovery inspection of the
152
+ current installation. Legacy binding files must remain unchanged. It writes an
153
+ exclusive completion record, repeats the checks and removes only the exact pending
154
+ marker. Recovery, original backups and journals are retained. Removing the marker
155
+ invalidates the migration write capability; the caller must release the lock before
156
+ ordinary doctor can report readiness. Readiness covers configuration, not runtime.
157
+
158
+ Interruption before marker removal leaves the workspace blocked. An existing
159
+ completion record is not permission to retry or delete the marker manually.
160
+ Supported restart and compensation routes are described below; they require fresh
161
+ approval and do not themselves authorize a real-workspace deployment.
162
+
163
+ ## Read-only restart closeout preview
164
+
165
+ prepareLegacyUnityCloseoutResume accepts an exact persisted migration recovery
166
+ path, verifies marker/recovery/preview bindings and both installed phases, and
167
+ returns a digest-bound proposal. If a matching completion record already exists,
168
+ only marker removal is proposed; otherwise completion creation precedes removal.
169
+ Conflicting completion evidence or incomplete installation is rejected. No lock,
170
+ write, network acquisition, lease or implicit approval is issued (executable=false).
171
+ This preview covers only the installed-phase restart case. For partial deactivation,
172
+ see "Partial deactivation inspection"; for interrupted installation, see "Interrupted
173
+ installation preview"; for bounded restoration, see "Explicit pre-install
174
+ compensation". Approved closeout execution is described next.
175
+
176
+ ## Approved restart closeout execution
177
+
178
+ applyLegacyUnityCloseoutResume requires fresh approval of the exact closeout
179
+ preview digest. It reconstructs the proposal before acquiring a new process-local
180
+ migration lease, checks again under the workspace lock, and saves a separate
181
+ authorization record. It creates completion only when proposed, verifies the
182
+ result and authorization, and removes the exact marker. Old completion records
183
+ are preserved. The lock is released on success or error; no error triggers rollback.
184
+ If interruption creates completion, the previous preview is stale: inspect again
185
+ and approve the new remaining-operation preview. Tests currently exercise fresh
186
+ leases after releasing the former lock, not termination of a live harness process.
187
+ CLI apply can invoke this writer only with its saved installer-bound proposal.
188
+
189
+ ## Partial deactivation inspection
190
+
191
+ prepareLegacyUnityDeactivationResume reads the persisted migration and validates
192
+ the bounded first-phase journal prefix (start, intents, outcomes, phase check).
193
+ It compares current files with exact before/after bytes and preserves failed or
194
+ uncertain history. A desired hash without an intent is not attributed to this
195
+ migration; completed evidence followed by before bytes is a conflict, not retry.
196
+ Foreign config bytes block the proposal, while unrelated target drift is rejected.
197
+ The result proposes write-disabled or confirm-observed actions without executing
198
+ them. It rejects the native installation locator/state: partial installation needs
199
+ its own recovery route. This is not an executable continuation or compensation.
200
+
201
+ applyLegacyUnityDeactivationResume is the internal approved writer for that
202
+ proposal. It reconstructs the preview, acquires a fresh migration lease/lock and
203
+ writes a separate digest-selected attempt journal. It checks surrounding targets
204
+ and original evidence before each operation. Observed disabled bytes are confirmed;
205
+ remaining exact before bytes can be changed to disabled. Errors preserve uncertainty
206
+ and stop execution; original failed/uncertain records remain untouched. Replaying
207
+ the same attempt cannot overwrite its journal. Both success and failure keep the
208
+ migration blocker. phase-observed alone is not permission to advance to installation
209
+ or remove the marker: the evidence verification below is mandatory.
210
+
211
+ ## Resumed-phase evidence at the installation gate
212
+
213
+ The installation/finalization phase verifier now recognizes exactly one completed
214
+ deactivation-resume attempt. It reconstructs the two narrow operations from the
215
+ original before/after contract and observed hashes; checks approval, original
216
+ journal prefix, unchanged observations, classifications and the six new records;
217
+ and verifies record membership/hashes again. Incomplete, tampered or multiple
218
+ attempts block the gate. No latest-by-time selection or historical PASS rewrite.
219
+ This only supplies phase evidence to existing installation validation; passing
220
+ this verifier does not create a write capability. The restart route below requires
221
+ a separate fresh approval.
222
+
223
+ ## Fresh installation after recovered deactivation
224
+
225
+ prepareLegacyUnityInstallResume binds the persisted migration, completed phase
226
+ evidence, current target hashes, prepared snapshot and original native setup plan.
227
+ It rejects an existing installation locator or state rather than retrying a started
228
+ installation. applyLegacyUnityInstallResume reconstructs that preview, requires
229
+ its exact approval, acquires a new process-local lease and rechecks under lock.
230
+ It saves a separate authorization record and delegates to native installation.
231
+ Result remains needs-reconciliation until separately approved closeout. Recovery
232
+ of an interrupted native installation is not implemented by this route.
233
+
234
+ ## Interrupted installation preview
235
+
236
+ An initial setup interrupted after its native recovery record is persisted but
237
+ before pending state is published can be continued with a new approved recovery
238
+ preview. This requires absent state, validated snapshot/backups, an intact original
239
+ journal with no target intents/outcomes and all targets/dependencies still at their
240
+ original bytes. It creates a separate transaction; it never fabricates the missing
241
+ pending state or rewrites historical evidence. Existing-state updates do not gain
242
+ this pre-pending route.
243
+
244
+ Earlier interruptions with an installation locator but missing/incomplete native
245
+ journal or recovery record remain blocked: there is insufficient validated native
246
+ evidence for this continuation. Do not remove the marker manually. Repeated failed
247
+ continuations remain unsupported as described below.
248
+
249
+ prepareLegacyUnityInstallRecovery wraps the existing native prepareContinuation,
250
+ without a separate target-writing algorithm. It binds migration/marker, completed
251
+ first-phase evidence, installation locator and exact original prepared setup to
252
+ the selected native recovery. Legacy binding files are checked separately from
253
+ native-owned targets. The native planner proposes verify-readback for observed
254
+ desired bytes and write-desired for remaining before bytes; conflicts fail closed.
255
+ The result requires new approval, stays executable=false and never clears the
256
+ migration blocker or rewrites an old outcome.
257
+
258
+ applyLegacyUnityInstallRecovery reconstructs a newly approved preview, acquires a
259
+ fresh migration lease and uses native applyContinuation. A separate authorization
260
+ and exclusive continuation locator bind the new native recovery to this migration.
261
+ Closeout checks the exact authorized continuation and its native lineage to the
262
+ original interrupted setup before accepting the new activation. It does not use
263
+ an unrelated ready state or overwrite original recovery. The migration blocker
264
+ remains until separately approved closeout. An interrupted continuation remains
265
+ blocked; repeating it is rejected. Multi-continuation selection/recovery is pending.
266
+
267
+ ## Explicit pre-install compensation
268
+
269
+ prepareLegacyUnityCompensation and applyLegacyUnityCompensation cover only the
270
+ original deactivation attempt before native installation or resumed deactivation.
271
+ Existing native preparation/state or resumed-attempt records block this narrow
272
+ route. A new digest-bound approval authorizes restoration of the two exact original
273
+ local configuration files and marker removal after complete verification. It never
274
+ changes shared caches, global settings, instructions, game files or documentation.
275
+
276
+ Separate compensation intent/outcome records preserve the original history. An
277
+ error stops writes and retains the marker; no implicit retry/rollback follows.
278
+ Success returns legacy-restored, not ready for the new pipeline. Migration evidence
279
+ and .pipeline metadata remain; this is not metadata cleanup or authorization for
280
+ another setup. Compensation after installation/resumed attempts and recovery of
281
+ an interrupted compensation remain unsupported.
282
+
283
+ These writers and CLI apply remain development-preview functionality.
284
+ Real application requires a separately approved real-wrapper preview. Only the
285
+ bounded resume and pre-install compensation routes described above are supported.
286
+ Repeated interrupted recovery attempts, multiple installation continuations and
287
+ post-install compensation remain unsupported; do not clear the marker to bypass
288
+ these limitations.
@@ -0,0 +1,149 @@
1
+ # Native source components (S8 / S11 implementation)
2
+
3
+ These are trusted CLI adapters, not native harness plugins. They consume verified
4
+ Git files through the existing manifest component paths; source code is never
5
+ loaded as a CLI adapter. Development dispatch includes Codex, Claude, Kimi and Grok.
6
+ Harness discovery, packaged lifecycle and pilot readiness remain
7
+ separate checks.
8
+
9
+ ## Skills
10
+
11
+ All four providers accept a directory of `<name>/SKILL.md` files. Each file has YAML
12
+ frontmatter containing exactly `name` and `description`, and a nonempty body.
13
+ Directory and declared name must match. Supporting files remain in the snapshot.
14
+ Names are lowercase ASCII letters/digits/hyphens, beginning with a letter, up to
15
+ 63 characters; `constructor`, `prototype` and `default` are not accepted.
16
+
17
+ The CLI generates a small native skill in `.agents/skills/` (Codex) or
18
+ `.claude/skills/` (Claude). It retains the name/description and directs the agent
19
+ to read the complete source skill in the installed snapshot. Relative links are
20
+ resolved from that source file. This avoids rewriting the canonical procedure
21
+ and its links. Package authors must ensure those source-relative links resolve.
22
+ An existing foreign skill is an ownership conflict, not silently overwritten.
23
+ Names are not automatically changed: references in the pipeline keep working.
24
+ Authors should use a pipeline-specific prefix. User/global harness precedence
25
+ is not certified by file installation or these adapters.
26
+
27
+ ## Agents
28
+
29
+ Codex: a flat directory of `<name>.toml`, with exactly three string assignments:
30
+ `name`, `description`, `developer_instructions`. The adapter registers named
31
+ roles in `.codex/config.toml`, pointing to local `.codex/agents/<name>.toml`.
32
+ Generated role files contain only `developer_instructions`, with source routing
33
+ followed by the original instruction text. No model or permission is selected.
34
+ The reserved scalar role name `enabled` is also rejected.
35
+
36
+ Claude: a flat directory of `<name>.md`, with exactly `name` and `description` in
37
+ YAML frontmatter and a nonempty instruction body. The generated
38
+ `.claude/agents/<name>.md` routes to the source. Optional harness-specific models,
39
+ tools, hooks and permission fields are currently unsupported and rejected, not
40
+ dropped silently. A null agents component explicitly means no packaged agents.
41
+
42
+ ## MCP
43
+
44
+ Each non-null MCP component points to JSON with exactly `mcpServers`, a nonempty
45
+ map of named servers. Supported server shapes:
46
+
47
+ - `type: stdio`, `command`, optional string-array `args` and string-map `env`.
48
+ - `type: http`, `url` with HTTP(S), no userinfo or fragment.
49
+
50
+ Unknown fields/transports fail closed. There is no secret resolution, OAuth,
51
+ trust grant or server execution in rendering. Environment values are literal
52
+ configuration data; do not place secrets in public sources. Automatic startup
53
+ later remains harness behavior, and users must trust the pipeline supplier.
54
+
55
+ Codex receives individual `/mcp_servers/<name>` TOML fields; Claude receives
56
+ individual `/mcpServers/<name>` fields in wrapper `.mcp.json`. Other servers and
57
+ user settings retain existing ownership rules. Runtime availability is not
58
+ inferred from configuration presence.
59
+
60
+ ## Entry and shared ownership
61
+
62
+ For a declared Claude/Grok bundle, [bundle rules](provider-bundles.md) take priority:
63
+ one full source-authored CLAUDE.md and joint lifecycle. The following neutral-entry
64
+ behavior is retained only for standalone sources without bundle declarations.
65
+
66
+ Claude and Grok share a provider-neutral `CLAUDE.md`: it imports `@AGENTS.md` and
67
+ explicitly instructs the reader to read AGENTS.md, without relying on import
68
+ syntax support in Grok. It contains no direct Claude-specific route. Normal
69
+ foreign-file conflict checks apply. Codex uses common `AGENTS.md`. Non-null provider
70
+ entry components are conditional routes from AGENTS.md; follow only the route for
71
+ the current harness. These links do not enable a provider.
72
+ The common entry lists available source routes independently of the selected
73
+ installation subset so removing one provider does not invalidate its remaining
74
+ owner's reconstruction. AGENTS.md remains until the last provider is removed.
75
+ CLAUDE.md has one shared owner but only two consumers: Claude and Grok. Removing
76
+ either retains it while the other remains; removing its final consumer restores
77
+ the original file or removes the created file, even if Codex remains installed.
78
+
79
+ An update migrates the old managed Claude-owned entry only after checking its
80
+ recorded bytes; original backup lineage is preserved. Edited or foreign files
81
+ remain conflicts, not implicitly authorized replacements. Installed version-1
82
+ adapter output can still be replayed for repair/removal before updating. Adapter
83
+ versions describe CLI rendering, never the validity of project documents.
84
+
85
+ Source contracts are intentionally bounded. `compatibility-isolation` is not a
86
+ claimed capability here. Legacy plugins/global imports require separate migration
87
+ and native checks; they are not disabled by these renderers.
88
+
89
+ ## Official format references
90
+
91
+ - [Codex skills](https://learn.chatgpt.com/docs/build-skills)
92
+ - [Codex named agent/config reference](https://learn.chatgpt.com/docs/config-file/config-reference)
93
+ - [Claude subagents](https://code.claude.com/docs/en/sub-agents)
94
+ - [Claude MCP scopes](https://code.claude.com/docs/en/mcp)
95
+
96
+ Consulted 2026-09-20/21. Native-version observations and limitations are recorded
97
+ in the S8 provider-discovery artifact; current docs alone do not certify installed
98
+ harness behavior.
99
+
100
+ ## S11 development: Kimi and Grok components
101
+
102
+ These renderers are registered in the development CLI for configuration delivery.
103
+ Select providers in the workspace manifest, then use normal preview/apply setup.
104
+ Native discovery, trust and runtime isolation are separate from file installation.
105
+
106
+ Both use the same strict skill frontmatter and immutable routing described above:
107
+ Kimi writes `.kimi-code/skills/<name>/SKILL.md`; Grok writes
108
+ `.grok/skills/<name>/SKILL.md`. Agents accept the same restricted Markdown source
109
+ shape as Claude and use their respective `agents/<name>.md` directories. Kimi
110
+ rejects `agent`, `coder`, `explore`, `plan`; Grok rejects `general-purpose`,
111
+ `explore`, `plan`, to prevent unintended built-in replacement. No roles are
112
+ invented when the package declares `agents: null`.
113
+
114
+ Canonical MCP JSON is translated to named fields in `.kimi-code/mcp.json`
115
+ (`/mcpServers/<name>`) and `.grok/config.toml` (`/mcp_servers/<name>`). Canonical
116
+ `type` is omitted from these native entries. Only those entries are owned:
117
+ whole-file replacement and unrelated configuration fields are refused. Existing
118
+ foreign entries are conflicts or preserved, never silently adopted.
119
+
120
+ Both use the common AGENTS.md provider route. No Kimi SYSTEM.md, Grok system
121
+ prompt override, authentication, trust or model settings are generated.
122
+
123
+ ### Discovery and launch limitations
124
+
125
+ Kimi and Grok can discover generic `.agents` skills. Removing one provider's
126
+ owned routes therefore does not prove that harness can no longer discover a
127
+ pipeline still installed for another provider. Installer ownership isolation and
128
+ native discovery are distinct checks.
129
+
130
+ Grok's child-environment helper sets five Claude compatibility switches to false:
131
+ skills, rules, agents, MCP and hooks. It changes only the child environment,
132
+ including removal of conflicting Windows key spellings. It does not switch
133
+ accounts, rewrite global configuration, grant trust or suppress native plugins.
134
+ The development CLI exposes a guarded [launch command](launch.md). Ordinary direct `grok` launch is
135
+ not certified by component rendering; local TOML presence is insufficient proof
136
+ of effective compatibility settings. Diagnostic plugin inventory can retain a
137
+ plugin even when its imported skill is disabled.
138
+
139
+ In the tested Grok 1.0.40 session, root CLAUDE.md was still read with all five
140
+ flags false. The common entry deliberately accommodates this behavior. It does
141
+ not prove suppression of duplicate agents, hooks or plugin MCP. Those runtime
142
+ checks remain separate; shared instructions do not imply full Claude compatibility.
143
+
144
+ Source and native inspect probes support development decisions; session-visible
145
+ discovery, trust behavior and execution remain separately tested requirements.
146
+ References: [Kimi skills](https://www.kimi.com/code/docs/en/kimi-code-cli/customization/skills.html),
147
+ [Kimi agents](https://www.kimi.com/code/docs/en/kimi-code-cli/customization/agents.html),
148
+ [Grok agents](https://docs.x.ai/build/features/subagents),
149
+ [Grok MCP](https://docs.x.ai/build/features/mcp-servers).