@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
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 6reduk
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,78 @@
1
+ # Workspace Pipeline CLI
2
+
3
+ `@6reduk/workspace-pipeline` — workspace-local pipeline delivery. Licensed under MIT.
4
+
5
+ **`--help`, read-only `doctor`, and `logs list/clean/policy` are implemented.**
6
+ Setup/update/repair/remove/switch/continue use compiled workspace-local adapters
7
+ for Codex, Claude, Kimi and Grok. No native plugin installation
8
+ or global activation is performed. Claude/Grok shared-entry and skill routing were
9
+ observed in disposable sessions. Kimi native verification is deferred; its
10
+ configuration renderer remains experimental. Real-project migration requires an
11
+ explicit preview and approval; installation is not blanket runtime certification.
12
+
13
+ Grok's Claude-import suppression requires the [scoped launch command](docs/launch.md).
14
+ File installation does not establish native session discovery or runtime isolation;
15
+ Kimi/Grok checks and known generic-skill discovery limits are documented in
16
+ [native component formats](docs/native-provider-format.md).
17
+ Claude/Grok can be supplied as a single [provider bundle](docs/provider-bundles.md):
18
+ separate native configurations, one full CLAUDE.md, and joint lifecycle. A source
19
+ may supply either member or both; the CLI never invents missing configurations.
20
+
21
+ ## Purpose
22
+
23
+ Configure a workspace using a standalone pipeline from a local or remote Git
24
+ repository's committed tree. Pipeline packages contain shared rules and provider
25
+ skills, agents, MCP declarations and entry instructions; no native plugin lifecycle
26
+ is required.
27
+
28
+ The CLI supports single-repository and multi-repository layouts with an
29
+ explicit documentation location. Each workspace owns its installed resources.
30
+ Package versions describe installation state, not the validity of project documents.
31
+
32
+ Provider discovery, isolation, model behavior and live MCP remain distinct checks;
33
+ successful file installation does not certify runtime behavior or task approval.
34
+
35
+ ## Development
36
+
37
+ Requires Node.js 22 or newer and npm. The contract layer uses locked Ajv and YAML
38
+ dependencies. See [contracts](docs/contracts.md) and [collaboration](docs/collaboration.md).
39
+
40
+ ```sh
41
+ npm ci --ignore-scripts
42
+ npm run check
43
+ npm test
44
+ node src/cli.js --help
45
+ node src/cli.js doctor --workspace /absolute/path/to/workspace --json
46
+ npm run pack:check
47
+ npm run test:packed:providers
48
+ ```
49
+
50
+ The executable name is `workspace-pipeline`. Doctor prints JSON: exit 0 means
51
+ observed configuration ready, 1 means not ready/incomplete, 2 means invocation or
52
+ transport error. Unsupported commands exit with code 2. On Windows use an absolute
53
+ path such as `C:\Projects\my-workspace`. See [doctor](docs/doctor.md) for limits.
54
+
55
+ For journal listing and explicit cleanup, see [retention](docs/retention.md).
56
+ Cleanup requires a saved, reviewed preview and a separate `--apply --preview`
57
+ invocation. It never deletes snapshots, backups, project files or provider configs.
58
+ Startup cleanup is disabled unless the user enables a local policy via
59
+ `logs policy set`; no numeric defaults are assumed. Internal setup/update honors
60
+ that policy; public setup/update uses the same coordinator. Policy commands only
61
+ write `.pipeline/retention.json`, never harness settings or project documents.
62
+ Repository init/adopt previews acquire the explicitly selected Git pipeline source;
63
+ remote access additionally requires `--network`. No command launches MCP or changes
64
+ credentials. Repository setup and provider activation are separate steps.
65
+ See [repository commands](docs/repositories.md), [recovery](docs/repository-recovery.md)
66
+ and [manual recovery boundaries](docs/repository-manual-recovery.md).
67
+ See [lifecycle CLI](docs/lifecycle-cli.md) for preview/apply and continuation
68
+ contracts, including current restrictions and private-preview handling.
69
+
70
+ ## Distribution boundary
71
+
72
+ The npm allowlist contains `src/`, `schemas/` and `docs/`, plus npm's standard package metadata,
73
+ README and license. Customer manifests, private pipeline definitions and credentials
74
+ do not belong in this repository or the published package.
75
+
76
+ Verification CI does not publish. The separately dispatched release workflow
77
+ builds a tested tarball; npm publication remains gated until bootstrap and trusted
78
+ publishing are configured. See [release procedure](docs/release.md).
@@ -0,0 +1,59 @@
1
+ # Collaboration contract
2
+
3
+ Scope: multiple harnesses may be configured in one workspace. This does not make
4
+ concurrent edits safe or create a distributed lock.
5
+
6
+ ## Task owner and handoff (CON-03)
7
+
8
+ One owner controls each active task/artifact scope. Record task ID, owner, files,
9
+ source revision/before hashes, current step, unresolved questions and handoff target
10
+ in the project's task artifacts, not in machine-local installer state.
11
+
12
+ Before an overlapping edit, the next agent reads that handoff, checks the before
13
+ revision/hashes and explicitly takes ownership. Conflicts stop the edit; old approvals
14
+ are not silently reused for changed subjects. Review independence must be disclosed.
15
+ Independent agents can work on disjoint scopes only with explicit ownership.
16
+
17
+ The CLI does not orchestrate agents or certify their compliance with these rules.
18
+ A task claim is advisory, not a lock preventing all harness writes.
19
+
20
+ ## Installer exclusion (CON-01/02)
21
+
22
+ The internal S5 coordinator acquires its lock through the caller: one exclusive
23
+ lock per canonical workspace. It rechecks before bytes and stops the remaining
24
+ operation plan on drift/failure. A second workspace remains independent. Abandoned
25
+ locks are preserved; neither age nor a recorded PID authorizes deletion.
26
+
27
+ Before update/remove/switch/repair, coordinate and stop sessions using the affected
28
+ configuration. The CLI cannot reliably discover every outside agent/editor or revoke
29
+ already loaded instructions. Synthetic Windows tests cover separate-process
30
+ exclusion, interrupted writes and read-only recovery. CLI lifecycle commands and
31
+ real harness behavior are not implemented/certified by those tests.
32
+
33
+ Recovery requires the exact transaction record and never resumes execution,
34
+ rolls back, clears a lock or guesses the latest transaction. A stop before recovery
35
+ publication may leave an orphan start journal; preserve it as inert evidence.
36
+ Interrupted replacement staging files are also preserved, not safe to delete by
37
+ glob. Pending-state resolution needs an explicit scoped lifecycle operation;
38
+ until that command exists, the workspace cannot be automatically repaired.
39
+
40
+ The prepared preview checks the inline recovery budget (2 MiB and 50k parser nodes)
41
+ and refuses oversized plans with `plan.recovery-budget` before returning a preview
42
+ for approval. Split work into smaller plans; source blob limits are not deployment
43
+ envelope limits. Apply still validates the actual serialized records before writes.
44
+
45
+ Journal appends check the current head and new record. Full history is checked at
46
+ terminal result, activation and recovery: older-prefix damage may be detected at
47
+ those later gates, never treated as a valid completed transaction. This bounded
48
+ detection latency and cooperative locking are not hostile-OS protection. Power
49
+ loss/directory durability, ACL behavior and non-Windows execution remain unverified.
50
+
51
+ ## Across developers and machines (CON-04)
52
+
53
+ Use branches/worktrees plus review and a shared task authority in Git or the selected
54
+ board. Each developer owns their local wrapper; shared documentation belongs in the
55
+ declared repository. Do not commit credentials, machine-local state or secret-bearing
56
+ backups.
57
+
58
+ A local workspace lock is not a distributed lock. Installer readiness, live harness
59
+ discovery, safe parallel operation and producer acceptance are separate claims.
@@ -0,0 +1,65 @@
1
+ # Owned configuration fields
2
+
3
+ S11 development: setup includes Codex, Claude, Kimi and Grok adapters.
4
+
5
+ Trusted adapters propose changes; this layer does not grant approval, install a
6
+ plugin, start a harness/MCP server or edit any global configuration.
7
+
8
+ ## JSON and TOML
9
+
10
+ JSON field requests retain their existing JSON-pointer ownership semantics.
11
+ Claude's root `.mcp.json` is restricted to individual named `/mcpServers/<name>`
12
+ entries. Whole-file replacement and taking over the entire server map are refused.
13
+ Kimi's `.kimi-code/mcp.json` has the same named-entry restriction. JSON output is
14
+ reserialized with two-space indentation and a final newline: foreign values are
15
+ preserved, but the original JSON whitespace is not promised.
16
+
17
+ Codex `.codex/config.toml` uses `toml-fields` requests. Only named `/agents/<name>`
18
+ and `/mcp_servers/<name>` entries are addressable. Reserved scalar agent settings,
19
+ model, auth, permissions and project trust are outside this editor's scope.
20
+ Format is selected by this exact destination, never by executable source code or
21
+ a heuristic based on the file's contents. Existing state kind `field` and hashes
22
+ remain format-independent; no document/pipeline semantic version gate is added.
23
+ Grok's exact `.grok/config.toml` destination also uses TOML, restricted to named
24
+ `/mcp_servers/<name>` entries. Its agents are separate Markdown files. Compatibility
25
+ flags are child-environment launch settings, not owned TOML edits.
26
+
27
+ An entry is owned as a whole object. Concurrent changes inside that object cause
28
+ a conflict, including extra fields; foreign sibling entries remain foreign.
29
+ Equal foreign values do not silently become owned. Exact explicit takeover still
30
+ requires the ordinary preview/apply approval and backup.
31
+
32
+ ## Preservation and limits
33
+
34
+ TOML is parsed as TOML 1.0 using pinned `toml-eslint-parser` 0.10.1. AST source
35
+ ranges select changed entries; unrelated text, comments and newline spelling are
36
+ not reserialized. Changed entries are rendered deterministically and reparsed;
37
+ full semantic comparison checks that foreign values stayed unchanged. Comments
38
+ outside the replaced key/value spans stay in place, even if the former section
39
+ was removed. Empty lines/implicit parent tables may remain after removal.
40
+
41
+ - 2 MiB input/output and bounded AST traversal (50000 nodes, depth 64).
42
+ - Owned values must be JSON-domain TOML values; null/dates/nonfinite/unsafe numbers
43
+ are refused. Foreign TOML values are preserved without conversion to JSON.
44
+ - Named entries may use dotted keys, quoted keys and ordinary nested sections.
45
+ - An inline ancestor such as `agents = { ... }` cannot be split while preserving
46
+ foreign source spans: a changing request returns `toml.inline-ancestor`.
47
+ - Array-of-table entries and scalar parents are not supported owned entries.
48
+ - Parser diagnostics expose stable codes, not excerpts that may contain secrets.
49
+
50
+ Planner, doctor, repair, removal, backup checking and field-only historical
51
+ projections use the same destination codec. Repair uses installed snapshot data,
52
+ not latest upstream. The transaction engine still binds the exact complete
53
+ before/after file bytes and stops on drift; field projections do not authorize
54
+ continuation of uncertain operations.
55
+
56
+ ## Evidence boundary
57
+
58
+ Unit tests cover text preservation and conflicts. Synthetic lifecycle tests cover
59
+ setup/update/doctor/repair/remove and original-value backup restoration. This does
60
+ not certify native runtime behavior, MCP startup or model-visible instruction
61
+ loading. All four compiled adapters are implemented; bounded native discovery
62
+ evidence and its limitations are recorded separately.
63
+
64
+ Parser source/API: [toml-eslint-parser](https://github.com/ota-meshi/toml-eslint-parser)
65
+ and [AST range specification](https://github.com/ota-meshi/toml-eslint-parser/blob/main/docs/AST.md).
@@ -0,0 +1,149 @@
1
+ # Contract layer (S1)
2
+
3
+ This is a library layer, not an operational installer. The executable still exposes
4
+ only help. No provider is ready. Source acquisition, physical containment and apply
5
+ are later stages.
6
+
7
+ ## Reading route
8
+
9
+ - Portable package: [pipeline schema](../schemas/pipeline.schema.json).
10
+ - Portable workspace: [workspace schema](../schemas/workspace.schema.json).
11
+ - Shared types: [common schema](../schemas/common.schema.json).
12
+ - Package file list: [inventory schema](../schemas/inventory.schema.json).
13
+ - Local deployment: [state schema](../schemas/state.schema.json).
14
+ - File-operation preview/receipt: [operation schema](../schemas/operation.schema.json).
15
+ - Agent coordination: [collaboration](collaboration.md).
16
+
17
+ The four portable schemas are the reviewed v1 definitions. They do not invoke remote
18
+ schema resolution. New local state/operation schemas are implementation subjects for
19
+ review; they are not project governance versions.
20
+
21
+ ## Parsing and validation
22
+
23
+ `parse(text, format)` accepts JSON or YAML 1.2 core representing JSON-domain data.
24
+ It rejects duplicate keys (including escaped JSON keys), multiple documents, explicit
25
+ tags, anchors/aliases, merge keys, non-string mapping keys, prototype-sensitive keys,
26
+ non-finite/unsafe integer numbers, input over 2 MiB, depth over 64 and over 50,000 nodes.
27
+ Explicit tags/aliases are deliberately unsupported on both keys and values, not
28
+ partially expanded. Node/depth limits count mapping keys as well as values.
29
+ Multiple documents produce parse.documents; parser syntax failures produce parse.syntax.
30
+ A leading BOM and CRLF are allowed. Callers loading bytes must decode UTF-8 strictly;
31
+ this API accepts text, not arbitrary byte buffers.
32
+
33
+ JSON syntax is first checked with JSON.parse; the YAML AST then checks keys before
34
+ conversion. Returned mappings have null prototypes. Errors expose stable codes,
35
+ not parser excerpts or source values. These are domain inputs, not a general-purpose
36
+ editor for existing harness settings: preserving foreign comments/format is S8/S11.
37
+
38
+ `validateStructure(kind, value)` uses local Ajv 2020-12 schemas without coercion,
39
+ default insertion or field removal. It does not mutate inputs. Strict type-placement
40
+ and required-placement lint checks are disabled for the reviewed conditional schemas;
41
+ schema validation itself is not disabled.
42
+ The common schema is registered for references only: common is not a public
43
+ document kind and validateStructure('common', ...) fails with schema.kind.
44
+
45
+ Implementation references: [YAML document API](https://eemeli.org/yaml/#documents),
46
+ [YAML parser options](https://eemeli.org/yaml/#parse-options),
47
+ [Ajv JSON Schema](https://ajv.js.org/json-schema.html).
48
+ Dependencies are exact-versioned with a lockfile; no package scripts run to parse data.
49
+
50
+ ## Semantic entry points
51
+
52
+ - `validateBundle(pipeline, workspace, adapters?)`: provider subset/capabilities,
53
+ required-null rejection, explicit layout versus named profile, reference IDs, clone
54
+ subdirectory, custom/default common entry selection and lexical package paths.
55
+ Pipeline-source subdirectory is checked both in bundles and stored snapshots;
56
+ dot means package root, other values follow portable-path rules.
57
+ Omitting adapters checks declarations only, never certifies a harness.
58
+ - `validateInventory(inventory, {inventoryPath, manifestPath})`: lowercase SHA-256,
59
+ self-entry, mandatory manifest, path/case collisions, trailing dot/space and cap.
60
+ 9,999 entries plus the inventory equals the 10,000-file cap.
61
+ - `renderEntry(text, layout)`: only repository.<id> and documentation substitutions;
62
+ unknown or malformed tokens fail, including extra braces adjacent to a token.
63
+ Ordinary single braces (for example JSON around a quoted token) remain literal.
64
+ No expressions are evaluated.
65
+ - `resolveEntryChange(...)`: pure ownership decision; foreign content conflicts
66
+ unless explicitly preserved/replaced. A merge must be prepared as a separately
67
+ reviewed desired result. S4/S8 must compute the supplied hashes from actual bytes.
68
+
69
+ Physical inventory equality, blob hashes and size totals are S2. Repository overlap,
70
+ canonical roots, reserved roots, symlink/reparse containment and resolved path budgets
71
+ are S3. These checks cannot be replaced by a structural PASS.
72
+
73
+ ## Adapter boundary
74
+
75
+ `src/providers/interface.js` declares five capabilities, including behavioural
76
+ compatibility-isolation (no artificial corresponding file). Non-null components imply
77
+ capabilities even if requires omits them. Required null components and empty providers
78
+ fail. An adapter has id/version/capabilities plus pure validate/plan methods.
79
+
80
+ Adapters are trusted CLI modules, never executable modules loaded from the pipeline.
81
+ The test double is only a contract fixture and produces no operations. S8/S11 must
82
+ verify native provider roots and actual discovery before enabling a real adapter.
83
+ Adapters validate their data before proposing operations; they do not perform writes.
84
+ Generic planning and ownership checks must inspect proposed operations in S4.
85
+
86
+ ## Local state
87
+
88
+ State contains canonical workspace, configuration status, independent runtime status,
89
+ active deployment or null, and pending plan digest or null. An active deployment
90
+ contains pipeline/version, frozen Git identity, snapshot/inventory digests, explicit
91
+ layout/providers, adapter versions and ownership records.
92
+
93
+ Manifest origin retains original absolute path/base/digest and resolved source.
94
+ A copied manifest is not a new resolution base. Local snapshot and backup paths live
95
+ under .pipeline/snapshots and .pipeline/backups. Rebind detection is S4.
96
+
97
+ Ownership is per file or JSON Pointer field; file/field and ancestor-field overlap
98
+ are rejected. Original existing values require a local backup reference. Hashes and
99
+ references are stored instead of secret-bearing before/after values. Backup protection,
100
+ actual existence and field serialization are later I/O checks.
101
+
102
+ Ready requires an active deployment and no pending operation. Not-installed requires
103
+ neither. Needs-reconciliation requires a pending plan digest; drift requires an
104
+ active deployment. Conflict and unsupported can describe a pre-installation
105
+ diagnostic and do not require an active deployment. Pending work never implies a
106
+ successful new deployment.
107
+
108
+ ## File plans, receipts and transitions
109
+
110
+ A plan binds workspace, command, before-state digest, frozen source, desired deployment
111
+ and ordered target operations. One target path appears once; field edits are combined
112
+ into a containing-file replacement with whole-file before/desired guards.
113
+ Create/replace/delete/edit-fields have explicit hash/null rules.
114
+
115
+ validateOperation(plan, previous?) and validateReceiptForPlan(receipt, plan, previous?)
116
+ require previous when beforeStateHash is non-null. The previous state must validate
117
+ and match the plan workspace and digest. With a null beforeStateHash, previous must
118
+ be omitted or null. validateTransition forwards its previous state to these guards.
119
+ Target owners must be shared or belong to the union of previous.active.providers
120
+ and desired.providers. This allows removal/restoration of a former provider while
121
+ rejecting unrelated owners, without weakening source-state binding.
122
+ Provider membership alone is not file-level write authority: S4/S5 still check exact
123
+ ownership, permitted targets and observed bytes before any write.
124
+
125
+ The current operation schema describes file operations only. Clone/move transaction
126
+ records needed by init/adopt must be added and tested in S7 before those commands can
127
+ be exposed; listing their names does not implement them.
128
+
129
+ A receipt binds the canonical digest of that exact plan and every ordered target's
130
+ ID and before/desired hashes. Status is completed, failed, uncertain or skipped.
131
+ Completed requires desired readback; failed requires unchanged before-state. After
132
+ the first non-completed operation, all following operations must be skipped.
133
+
134
+ `contractDigest` sorts object keys, retains array order and hashes UTF-8 JSON with
135
+ SHA-256. Use it only on validated JSON-domain data; it is not a general serializer.
136
+ Source file digests use exact bytes instead.
137
+ Numbers follow JSON serialization: -0 and 0 have the same canonical representation.
138
+ This is intentional normalization, not distinct domain identities; current validated
139
+ plan/state numeric fields do not depend on signed zero. String values remain distinct.
140
+
141
+ `validateTransition` checks previous-state digest, workspace identity and full
142
+ receipt coverage. Completion selects exactly the planned deployment; failure keeps
143
+ the previous active deployment and records needs-reconciliation + pending digest.
144
+ All installer transitions reset runtime to not-run. No document approval is touched.
145
+
146
+ These are consistency guards, not proof of execution or user authorization. S4/S5
147
+ must compute hashes from actual state, enforce approved preview and lock, execute
148
+ guarded writes, verify readback and persist the journal. A fabricated consistent
149
+ receipt is not runtime evidence.
package/docs/doctor.md ADDED
@@ -0,0 +1,165 @@
1
+ # Read-only installation inspection (S6 development)
2
+
3
+ The internal `inspectInstallation(workspace, {recoveryPath}?)` API is implemented.
4
+ The public CLI exposes it read-only:
5
+
6
+ `workspace-pipeline doctor --workspace <absolute-path> [--recovery <relative-record>] [--json]`
7
+
8
+ Output is JSON even without --json. Exit 0 means configuration ready, 1 not ready
9
+ or incomplete, 2 invalid invocation or output failure. This is not an install command.
10
+
11
+ `ready` means observed **configuration readiness**, never a running harness,
12
+ Unity/MCP connectivity, task approval, permission to update, or deletion authority.
13
+ It does not write state: the on-disk historical status remains untouched.
14
+
15
+ Checks use local state and the installed snapshot; the original Git source,
16
+ workspace manifest and preparation directory need not still exist. No network
17
+ lookup or new package execution occurs. Managed file hashes and JSON field values
18
+ are checked; foreign siblings are not owned. Output does not include config values.
19
+
20
+ The history inventory pairs journal/recovery directories by exact UUID, validates
21
+ record chains and reports unfinished, malformed and orphan entries. A completed
22
+ journal alone does not establish activation or valid backups. Doctor selects a
23
+ completed transaction through the state's activation binding, then runs recovery
24
+ validation. Legacy unanchored states use conservative desired-deployment matching;
25
+ all such matches must pass. Selection is never by timestamp. Historical validation
26
+ errors or incomplete history force transactionEvidence=fail even if the selected
27
+ current transaction itself validates. An explicit path cannot hide invalid history.
28
+
29
+ For completed transactions bound to the exact current deployment, doctor compares
30
+ field-owned JSON by owned values rather than claiming ownership of foreign
31
+ siblings or formatting. Both the historical desired bytes and current bytes must
32
+ contain every owned value with its recorded hash. File-owned targets, malformed
33
+ JSON and changed/missing owned values do not qualify. Projected paths are explicit
34
+ in `fieldProjections`, bound to the exact recovery record. Historical receipts,
35
+ hashes and current observed byte hashes are not rewritten.
36
+
37
+ Ordinary `inspectRecovery` remains exact-byte validation. Doctor explicitly opts
38
+ into `fieldOwnershipOnly`; its result declares `comparisonScope` and may report
39
+ `desired-owned-fields` instead of byte equality. This exception is never available
40
+ to pending/incomplete journals and does not grant continuation or cleanup authority.
41
+
42
+ Completed continuation evidence may resolve an exact older unfinished entry.
43
+ History retains the original status and hashes and adds `resolution: continued`
44
+ plus exact `resolvedBy` recovery paths. A missing/corrupt approval, journal, source
45
+ snapshot, backup or lineage prevents this resolution. Only the corresponding
46
+ `history.unfinished` diagnostic is removed; unrelated problems stay visible.
47
+
48
+ The `evidenceOnly` recovery inspection used here reports `completed-evidence`,
49
+ not `applied`: activation and current targets remain `not-verified`. This makes
50
+ historical linkage survive a later legitimate update without pretending old
51
+ bytes are still current. Doctor separately validates the active transaction and
52
+ current owned configuration. Resolved history remains protected from cleanup;
53
+ an old unfinished journal is never rewritten as completed.
54
+
55
+ For repeated interruptions, `resolvesChain` lists the exact validated ancestors;
56
+ each ancestor keeps its own original status and hash. Validation is iterative,
57
+ cycle-checked and capped at 32 continuation links. Invalid/missing earlier evidence
58
+ prevents descendant resolution. All chain members remain cleanup-protected.
59
+
60
+ State, targets and history are observed again to detect drift. A present lock,
61
+ unknown or unfinished history, corrupt snapshot, mismatched workspace, invalid
62
+ recovery or target drift prevents readiness. Runtime is always `not-run`.
63
+ Historical transactions are not compared against today's target bytes as though
64
+ each were the current installation.
65
+
66
+ ## Limits
67
+
68
+ S7 repository operations have separate pending markers and bootstrap/recovery
69
+ locks. Doctor reports their presence as `repository.pending`,
70
+ `repository.bootstrap-pending`, `repository.recovery-pending`, or
71
+ `repository.recovery-resume-pending`, with readiness
72
+ false, without clearing or interpreting malformed records as success. This is a
73
+ blocking observation, not full repository recovery verification.
74
+
75
+ Ordinary mutating commands cannot acquire/use a workspace lock while these markers
76
+ exist. Only the internal repository executor holding the real same-workspace
77
+ bootstrap capability may proceed with its own operation. Lifecycle CLI previews
78
+ also stop before source access. Read-only history listing remains available;
79
+ this does not imply that the new S7 namespaces are already covered by retention.
80
+
81
+ A recorded `not-installed` state with history requires matching completed removal
82
+ evidence. An activation binding selects the exact committed operation; all retained
83
+ completed history is still validated as historical evidence. Current removal
84
+ results, history, state and lock status are verified.
85
+ Successful absence is `status: not-installed`, `configuration: not-installed`,
86
+ `ready: false`; it does not claim an installed or runnable pipeline. Missing,
87
+ corrupt or unfinished evidence remains a reconciliation blocker. Original history
88
+ is not deleted or changed by this check.
89
+
90
+ New final states contain `activation` with relative recovery path, recovery hash
91
+ and completed journal sequence/hash. The reference is saved in the same checked
92
+ state write. Pending retains the prior reference. Doctor verifies that binding and
93
+ historical predecessor references; selecting a different recovery is an error.
94
+ Historical target bytes are not compared to today's configuration, but corrupt or
95
+ unfinished evidence remains a blocker. Predecessor cycles are rejected.
96
+
97
+ Old states without activation remain readable and conservative: all content-matching
98
+ records are checked against current results. No reference is synthesized on read.
99
+ The optional schemaVersion=1 field is backward-readable by the new CLI; older
100
+ strict readers reject extended states rather than ignoring an unknown field.
101
+ This is installation metadata, not a pipeline/document version requirement.
102
+
103
+ - Read-only observations are not an atomic filesystem snapshot; hostile same-user
104
+ races are outside the guarantee. Run with configuration writers stopped.
105
+ - History enumeration is bounded to 1000 entries per journal/transaction parent.
106
+ Exceeding the bound produces `history.limit`, not a partial healthy result.
107
+ - All inventory entries remain protected from cleanup. Retention/dependency
108
+ eligibility and cleanup commands are separate S6 work.
109
+ - Errors remain visible; doctor never repairs config, deletes evidence, clears
110
+ locks, renews approvals or silently selects an updated pipeline version.
111
+ - A missing state is `not-installed` only when metadata is absent; residual
112
+ metadata with no valid state remains incomplete, not a clean installation.
113
+ - Provider-specific discovery/global compatibility checks are later adapter work;
114
+ synthetic provider-double readiness is not live-provider certification.
115
+
116
+ ### Repository completion is not lock recovery
117
+
118
+ The internal S7 completion verifier can confirm the exact approved repository
119
+ result after its pending marker has moved into history. That result does not mean
120
+ the workspace is unlocked or a pipeline is installed. If the process exited
121
+ abruptly, both its sibling bootstrap lock and `.pipeline/lock` may remain.
122
+ Read-only confirmation preserves them; ordinary operations remain blocked.
123
+ Do not delete those directories to bypass recovery. The public stale-lock recovery
124
+ route is not implemented yet. Tests distinguish an exception (which runs cleanup)
125
+ from a child process exiting without running `finally`.
126
+
127
+ Internal `recoverRepositoryLocks` now supports the paired stopped-owner locks
128
+ around finalization, with explicit approval of the exact lock-reconciliation digest.
129
+ It preserves both original lock directories under
130
+ `.pipeline/repository-lock-recoveries/<digest>/`, together with the request and
131
+ completion receipt. It does not replay repository effects or install a pipeline.
132
+ If finalization was pending, that separate operation remains necessary. Any failure
133
+ after recovery starts retains its sibling recovery gate; supported continuation
134
+ is described below. This is not a public CLI command.
135
+
136
+ Internal `inspectRepositoryLockRecovery` reconstructs interruptions after the
137
+ recovery request is persisted: before any rename, after the workspace-lock rename,
138
+ after both renames, and after receipt creation with the gate retained. It requires
139
+ the original lock digest plus repository preview/reconciliation bindings and
140
+ rechecks the repository result. Duplicate/missing lock locations, corrupted
141
+ records and changed results are refused. This read-only report never authorizes
142
+ resume or gate removal, including when a receipt is present. Interruptions before
143
+ the request is persisted remain outside this route.
144
+
145
+ Internal `finishRepositoryLockRecovery` supports all four recorded interruption
146
+ states listed above. The recovery owner must be a stopped local process and
147
+ the exact fresh observation must be explicitly approved. A sibling
148
+ `.recovery-resume` guard excludes competing resumptions and ordinary operations.
149
+ Only still-original lock directories are moved, in workspace/bootstrap order.
150
+ A missing receipt is created once; an existing receipt is preserved. Subjects,
151
+ owners, expected locations and records are rechecked between steps. The old gate
152
+ is moved into the recovery archive, then the resumption guard and approval are
153
+ also retained there. No repository effect is repeated. If this
154
+ resumption is interrupted, its guard remains blocking; recursive recovery of that
155
+ new interruption and failures before request persistence are not implemented yet.
156
+
157
+ Internal `inspectRepositoryLockResumption` can read an interrupted or completed
158
+ resumption without changing it. Supply the original lock digest and the exact
159
+ approved recovery observation digest, together with the repository subjects.
160
+ It distinguishes an active resumption, an archived old gate with a resumption
161
+ still pending, and a fully archived resumption. It checks the approval/owner
162
+ bindings and current repository result; duplicate locations and corrupt records
163
+ are refused. A completed record is not permission to replay the operation.
164
+ This check is for the same original subject before subsequent lifecycle changes;
165
+ it does not project stale evidence over later finalization or repository edits.
package/docs/launch.md ADDED
@@ -0,0 +1,50 @@
1
+ # Scoped Grok launch (S11 development)
2
+
3
+ This command starts Grok from an already configured workspace with five Claude
4
+ compatibility switches set to false in the child environment: skills, rules, agents,
5
+ MCP and hooks. It does not install a pipeline. Configure Grok using the ordinary
6
+ manifest-driven setup preview/apply first; do not manually construct state.
7
+
8
+ Preview first (replace both absolute paths):
9
+
10
+ ```powershell
11
+ workspace-pipeline launch grok --workspace "C:\Work\example" --executable "C:\Tools\grok.exe"
12
+ ```
13
+
14
+ The default is read-only: it checks installation state and reports the intended
15
+ launch without starting Grok. Add `--execute` to start an interactive session.
16
+ An interactive terminal is required. For native diagnostic output, use
17
+ `--inspect --execute`; this passes only `inspect --json` to the executable.
18
+ Diagnostic success does not establish model-visible skills or task readiness.
19
+
20
+ ## Boundaries
21
+
22
+ - Supply a trusted, absolute native executable path. Windows requires `.exe`;
23
+ `.cmd`/`.bat` wrappers are not accepted. No shell or automatic PATH lookup is used.
24
+ - Arbitrary harness arguments are rejected. In particular, the command does not
25
+ forward working-directory, worktree, model, prompt or approval overrides.
26
+ - The existing account/profile environment is inherited. Only the five Claude
27
+ pipeline compatibility variables are replaced; parent variables and global
28
+ configuration files are unchanged. Environment secrets are not printed.
29
+ - Installation must be ready, include Grok and have no pending operation.
30
+ State is checked around inspection and again immediately before execution.
31
+ - Close pipeline configuration editors/updaters during launch. These checks do
32
+ not hold a lock for the session or prevent subsequent concurrent edits.
33
+ - This is not a sandbox or executable authenticity check. The selected program
34
+ runs with the user's permissions and can start configured MCP servers. Normal
35
+ workspace trust and action approvals remain the harness/user's responsibility.
36
+ - Native plugins and generic skill discovery are not disabled. Removing Grok's
37
+ owned files alone does not prove it cannot discover another provider's skills.
38
+ - Native 1.0.40 inspection verified disabled markers for Claude skills, rules and
39
+ ordinary MCP declarations. Claude agents, hooks and plugin MCP remained listed
40
+ without disabled markers. This does not prove execution, but complete runtime
41
+ suppression of those components is NOT_VERIFIED; five environment values are
42
+ not by themselves an isolation guarantee.
43
+ - Root CLAUDE.md remained visible in the tested scoped session. Bundled delivery
44
+ uses it intentionally as a full shared entry with conditional provider sections.
45
+ Standalone legacy delivery retains the neutral AGENTS.md route.
46
+ This does not certify other import surfaces or
47
+ the full interactive TUI launch path.
48
+
49
+ The child exit code is propagated (signals map to a nonzero exit). No pipeline
50
+ stage, human acceptance or runtime certification is inferred from that code.