nawabari 0.12.2 → 0.14.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 (140) hide show
  1. package/README.md +70 -247
  2. package/dist/cli-command-registry.d.ts +17 -3
  3. package/dist/cli-command-registry.js +25 -10
  4. package/dist/cli-command-registry.js.map +1 -1
  5. package/dist/cli.d.ts +10 -0
  6. package/dist/cli.js +107 -8
  7. package/dist/cli.js.map +1 -1
  8. package/dist/contract.js +33 -1
  9. package/dist/contract.js.map +1 -1
  10. package/dist/control-repositories.d.ts +43 -0
  11. package/dist/control-repositories.js +187 -0
  12. package/dist/control-repositories.js.map +1 -0
  13. package/dist/control-server-lease.d.ts +34 -0
  14. package/dist/control-server-lease.js +303 -0
  15. package/dist/control-server-lease.js.map +1 -0
  16. package/dist/control-server-request-pool.d.ts +70 -0
  17. package/dist/control-server-request-pool.js +473 -0
  18. package/dist/control-server-request-pool.js.map +1 -0
  19. package/dist/control-server.d.ts +37 -0
  20. package/dist/control-server.js +334 -0
  21. package/dist/control-server.js.map +1 -0
  22. package/dist/control-web.d.ts +10 -0
  23. package/dist/control-web.js +236 -0
  24. package/dist/control-web.js.map +1 -0
  25. package/dist/domain/doctor.d.ts +10 -1
  26. package/dist/domain/doctor.js +12 -3
  27. package/dist/domain/doctor.js.map +1 -1
  28. package/dist/domain/filesystem-policy-decision.d.ts +42 -2
  29. package/dist/domain/filesystem-policy-decision.js +61 -22
  30. package/dist/domain/filesystem-policy-decision.js.map +1 -1
  31. package/dist/domain/filesystem-policy-evidence.d.ts +12 -1
  32. package/dist/domain/filesystem-policy-evidence.js +89 -1
  33. package/dist/domain/filesystem-policy-evidence.js.map +1 -1
  34. package/dist/domain/filesystem-policy.js +29 -51
  35. package/dist/domain/filesystem-policy.js.map +1 -1
  36. package/dist/domain/implementation-execution-scope-resolver.d.ts +31 -0
  37. package/dist/domain/implementation-execution-scope-resolver.js +135 -0
  38. package/dist/domain/implementation-execution-scope-resolver.js.map +1 -0
  39. package/dist/domain/repository-observation-service.d.ts +9 -0
  40. package/dist/domain/repository-observation-service.js +164 -0
  41. package/dist/domain/repository-observation-service.js.map +1 -0
  42. package/dist/domain/repository-runtime-coordination-collector.d.ts +12 -0
  43. package/dist/domain/repository-runtime-coordination-collector.js +23 -0
  44. package/dist/domain/repository-runtime-coordination-collector.js.map +1 -0
  45. package/dist/domain/repository-runtime-filesystem-collector.d.ts +37 -0
  46. package/dist/domain/repository-runtime-filesystem-collector.js +438 -0
  47. package/dist/domain/repository-runtime-filesystem-collector.js.map +1 -0
  48. package/dist/domain/repository-runtime-lifecycle-collector.d.ts +9 -0
  49. package/dist/domain/repository-runtime-lifecycle-collector.js +180 -0
  50. package/dist/domain/repository-runtime-lifecycle-collector.js.map +1 -0
  51. package/dist/domain/repository-runtime-process-collector.d.ts +15 -0
  52. package/dist/domain/repository-runtime-process-collector.js +198 -0
  53. package/dist/domain/repository-runtime-process-collector.js.map +1 -0
  54. package/dist/domain/repository-runtime-profile-collector.d.ts +19 -0
  55. package/dist/domain/repository-runtime-profile-collector.js +310 -0
  56. package/dist/domain/repository-runtime-profile-collector.js.map +1 -0
  57. package/dist/domain/sandbox-launcher.js +7 -1
  58. package/dist/domain/sandbox-launcher.js.map +1 -1
  59. package/dist/domain/session-actions.d.ts +85 -0
  60. package/dist/domain/session-actions.js +762 -0
  61. package/dist/domain/session-actions.js.map +1 -0
  62. package/dist/domain/session-backend.d.ts +20 -4
  63. package/dist/domain/session-backend.js +159 -41
  64. package/dist/domain/session-backend.js.map +1 -1
  65. package/dist/domain/session-console.d.ts +1 -0
  66. package/dist/domain/session-console.js +11 -1
  67. package/dist/domain/session-console.js.map +1 -1
  68. package/dist/domain/session.d.ts +14 -3
  69. package/dist/domain/session.js.map +1 -1
  70. package/dist/domain/worktree-file-operation.d.ts +7 -2
  71. package/dist/domain/worktree-file-operation.js +12 -12
  72. package/dist/domain/worktree-file-operation.js.map +1 -1
  73. package/dist/git.d.ts +35 -0
  74. package/dist/git.js +377 -0
  75. package/dist/git.js.map +1 -1
  76. package/dist/public-contract.d.ts +4 -2
  77. package/dist/public-contract.js +11 -2
  78. package/dist/public-contract.js.map +1 -1
  79. package/dist/registry/atomic.d.ts +8 -2
  80. package/dist/registry/atomic.js +8 -23
  81. package/dist/registry/atomic.js.map +1 -1
  82. package/dist/registry/errors.d.ts +1 -1
  83. package/dist/registry/errors.js +0 -8
  84. package/dist/registry/errors.js.map +1 -1
  85. package/dist/registry/repository-state-boundary.d.ts +50 -0
  86. package/dist/registry/repository-state-boundary.js +129 -0
  87. package/dist/registry/repository-state-boundary.js.map +1 -0
  88. package/dist/registry/runtime-records.d.ts +23 -10
  89. package/dist/registry/runtime-records.js +236 -8
  90. package/dist/registry/runtime-records.js.map +1 -1
  91. package/dist/registry/types.d.ts +0 -9
  92. package/dist/registry/types.js +0 -1
  93. package/dist/registry/types.js.map +1 -1
  94. package/dist/registry.d.ts +0 -1
  95. package/dist/registry.js +0 -1
  96. package/dist/registry.js.map +1 -1
  97. package/dist/resource-coordination-compatibility.d.ts +7 -0
  98. package/dist/resource-coordination-compatibility.js +250 -0
  99. package/dist/resource-coordination-compatibility.js.map +1 -0
  100. package/dist/resource-handoff.js +11 -4
  101. package/dist/resource-handoff.js.map +1 -1
  102. package/dist/session-lifecycle-actions.d.ts +29 -0
  103. package/dist/session-lifecycle-actions.js +37 -0
  104. package/dist/session-lifecycle-actions.js.map +1 -1
  105. package/dist/session-lifecycle-classification.d.ts +3 -3
  106. package/dist/session-lifecycle-classification.js.map +1 -1
  107. package/dist/session-parking.d.ts +12 -39
  108. package/dist/session-parking.js +34 -268
  109. package/dist/session-parking.js.map +1 -1
  110. package/dist/session-registry.d.ts +61 -20
  111. package/dist/session-registry.js +1231 -243
  112. package/dist/session-registry.js.map +1 -1
  113. package/dist/state/session/guards.d.ts +8 -0
  114. package/dist/state/session/guards.js +21 -1
  115. package/dist/state/session/guards.js.map +1 -1
  116. package/dist/state/session/machine.d.ts +81 -3
  117. package/dist/state/session/machine.js +176 -5
  118. package/dist/state/session/machine.js.map +1 -1
  119. package/dist/state/session/types.d.ts +48 -3
  120. package/dist/state/session/types.js +3 -0
  121. package/dist/state/session/types.js.map +1 -1
  122. package/dist/ui/repository-terminal.d.ts +1 -1
  123. package/dist/ui/repository-terminal.js +6 -4
  124. package/dist/ui/repository-terminal.js.map +1 -1
  125. package/dist/ui/session-actions.d.ts +2 -77
  126. package/dist/ui/session-actions.js +2 -710
  127. package/dist/ui/session-actions.js.map +1 -1
  128. package/dist/verification-executor.d.ts +46 -0
  129. package/dist/verification-executor.js +232 -0
  130. package/dist/verification-executor.js.map +1 -1
  131. package/dist/working-set.d.ts +11 -1
  132. package/dist/working-set.js +14 -0
  133. package/dist/working-set.js.map +1 -1
  134. package/dist/worktree-profile-cli.d.ts +32 -0
  135. package/dist/worktree-profile-cli.js +41 -4
  136. package/dist/worktree-profile-cli.js.map +1 -1
  137. package/package.json +10 -6
  138. package/dist/registry/store.d.ts +0 -38
  139. package/dist/registry/store.js +0 -156
  140. package/dist/registry/store.js.map +0 -1
package/README.md CHANGED
@@ -2,303 +2,126 @@
2
2
  <img src="./docs/assets/readme/nawabari-hero.webp" alt="Nawabari — Git Worktree Isolation." width="100%">
3
3
  </p>
4
4
 
5
- <p align="center">
6
- <a href="https://github.com/yohn-jp/nawabari/actions/workflows/ci.yml"><img alt="CI" src="https://github.com/yohn-jp/nawabari/actions/workflows/ci.yml/badge.svg"></a>
7
- <a href="https://www.npmjs.com/package/nawabari"><img alt="npm" src="https://img.shields.io/npm/v/nawabari"></a>
8
- <a href="https://www.npmjs.com/package/nawabari"><img alt="Node" src="https://img.shields.io/node/v/nawabari"></a>
9
- <a href="./LICENSE"><img alt="License" src="https://img.shields.io/npm/l/nawabari"></a>
10
- </p>
11
-
12
5
  # Nawabari
13
6
 
14
- Nawabari is a local governance layer for parallel coding agents. It gives each agent session an owned Git worktree and branch, records which repository resources that session may use, and checks those boundaries before governed mutations.
15
-
16
- It is for teams and tools that need several agents to work in one repository without silently sharing a worktree, overwriting one another's files, or guessing whether a session is safe to close. Nawabari is local-first: the session registry, Git observations, and authorization decisions do not require GitHub, `gh`, a network connection, or a particular agent runtime.
17
-
18
- This README describes the current 0.10.x product model. It is an overview and navigation surface, not a copy of generated contracts or implementation history.
7
+ Nawabari is a machine-local runtime for coding-agent sessions. It binds each session to an owned Git worktree and
8
+ mutable branch, checks declared access and coordination boundaries, and supports protected execution on Linux.
9
+ Repository ownership remains independent for each local Git repository; a shared remote does not merge local authority.
19
10
 
20
- The canonical routine-use workflow is one machine-authority path for both people
21
- and agents:
11
+ Nawabari owns local execution and recovery, not task selection, semantic orchestration, or GitHub Issue/PR governance.
12
+ Local ownership operations do not require GitHub, `gh`, or a particular agent runtime. Explicit Git push/fetch operations
13
+ and caller programs may use the network.
22
14
 
23
- 1. Create a managed session with explicit initial claims.
24
- 2. Declare any required auxiliary repository-local state explicitly.
25
- 3. Inspect the session and its claims.
26
- 4. Run governed work and mutations through the claim and evidence surfaces.
27
- 5. Handle claim conflicts from machine-readable evidence and typed lifecycle actions.
28
- 6. Reconcile stale or inconsistent physical state through the canonical operation.
29
- 7. Close or discard according to the lifecycle authority.
30
- 8. Confirm convergence with `doctor` and garbage-collection observation.
15
+ The [accepted Target Architecture](docs/architecture/index.md) defines the design to which the product must converge.
16
+ The [implementation status](docs/architecture/implementation-status.md) distinguishes that target from the current code.
17
+ This documentation adoption does not implement parking, change claim enforcement, repair Control Server authentication,
18
+ add a singleton lease, or strengthen filesystem durability by itself.
31
19
 
32
- Nawabari governs operations routed through Nawabari. A normal governed session is an ownership and authorization boundary, not an operating-system or filesystem sandbox. A process with ambient filesystem permissions can still edit another worktree directly.
20
+ ## Install and discover
33
21
 
34
- ## Install
35
-
36
- Node.js 24 or newer is required.
22
+ Use Node.js 24 or newer.
37
23
 
38
24
  ```bash
39
25
  npm install -g nawabari
40
26
  nawabari --version
41
- git nawabari --help
42
- ```
43
-
44
- The package installs both `nawabari` and `git-nawabari`; `git nawabari ...` works as Git's external subcommand.
45
-
46
- ## Canonical routine-use workflow
47
-
48
- Run from the repository's integration worktree. The following bootstrap uses the
49
- same public option shape as the packed routine-use certification. Omit the
50
- auxiliary declaration when the session needs no declared repository-local state;
51
- do not replace it with an arbitrary host path.
52
-
53
- ```bash
54
27
  nawabari capabilities --json
55
- nawabari doctor --json
56
-
57
- auxiliary_state='{"source":{"kind":"repository-local","path":".codegraph/ignored"},"target":{"kind":"managed-worktree","path":".codegraph/ignored"},"mode":"copy","durability":"durable"}'
58
- created=$(git nawabari session create \
59
- --branch feature/example \
60
- --resource README.md --mode write \
61
- --auxiliary-state "$auxiliary_state" \
62
- --json)
63
- session_id=$(printf '%s' "$created" | jq -r .session_id)
64
- worktree=$(printf '%s' "$created" | jq -r .worktree)
65
-
66
- (cd "$worktree" && git nawabari session show --session "$session_id" --json)
67
- (cd "$worktree" && git nawabari session claims --session "$session_id" --json)
68
- (cd "$worktree" && git nawabari session inspect --session "$session_id" --schema-version 2 --json)
69
-
70
- (cd "$worktree" && git nawabari session claim --session "$session_id" --resource contract-lifecycle.txt --mode exclusive-write --json)
71
- (cd "$worktree" && git nawabari authorize --session "$session_id" --operation source-write --resource contract-lifecycle.txt --json)
72
- (cd "$worktree" && "$EDITOR" contract-lifecycle.txt)
73
- (cd "$worktree" && git nawabari evidence snapshot --session "$session_id" --json)
74
- (cd "$worktree" && git nawabari checkpoint --session "$session_id" --json)
75
- (cd "$worktree" && git nawabari commit --session "$session_id" --message "Exercise governed lifecycle" --resource contract-lifecycle.txt --json)
76
- (cd "$worktree" && git nawabari push --session "$session_id" --remote origin --branch feature/example --resource contract-lifecycle.txt --create-upstream --json)
28
+ git nawabari session create --help --json
77
29
  ```
78
30
 
79
- `session create` provisions the new worktree under `<repository-parent>/.nawabari/worktrees` by default (discoverable via `status --json` as `managed_worktree_root`). Nawabari creates that managed subdirectory on first default placement. New exact `--worktree` paths must be under the reported root; an absolute path directly under the repository parent remains accepted for compatibility with older callers and persisted sessions.
80
-
81
- The initial-claim grammar is `--resource <path-or-glob> --mode <read|write|exclusive-write>` and the pair may be repeated. Each resource is paired with its own mode. The parser also permits zero pairs for backward compatibility, but the canonical routine path declares at least one initial claim. Initial claims are committed atomically with the new session, worktree, and branch. A conflict returns a machine-readable failure such as `RESOURCE_CLAIM_CONFLICT` and does not leave a partially established session or claim set.
31
+ The package installs `nawabari` and `git-nawabari`; Git discovers the latter as `git nawabari`.
32
+ Use installed help and capabilities for exact supported commands, schemas, options, and failure codes.
33
+ Package version, persisted schema version, claim schema version, and public contract identity are distinct.
82
34
 
83
- Resource-claim enforcement is disabled by default for a new session: `commit`/`push` authorization does not require the session to hold a resource claim for its own session-owned operations. Pass `--enforce-claims` to `session create` to opt that session into the previous claim-authorization behavior, including `MISSING_RESOURCE_CLAIM`/`INSUFFICIENT_CLAIM_MODE` denials and existing claim-mode compatibility rules. Worktree ownership, branch ownership, and `RESOURCE_CLAIM_CONFLICT` protection against another session's active claim remain enforced either way.
35
+ ## Local session workflow
84
36
 
85
- The packed auxiliary-state declaration above is the bounded `copy` form: a `repository-local` source is copied to a `managed-worktree` target with `durability: durable`. It is an explicit, repeatable, allowlisted capability. It does not discover ignored state, project process-local sockets/PID files/logs, shadow Git-tracked paths, or expose arbitrary host filesystem paths. Auxiliary-state projection is separate from `SessionRuntimeProjection`: the former copies declared repository-local durable state for a managed worktree; the latter describes explicit runtime material and filesystem visibility for protected execution. Auxiliary state does not change the runtime projection.
86
-
87
- The create operation is atomic, but a caller must treat an uncertain result carefully. If JSON reports `REGISTRY_DURABILITY_UNCERTAIN`, re-read the reported session and claims before retrying. If the exact original declaration is already present, follow `bootstrap_retry.next_action: inspect-established-session` and inspect that `session_id`; if another declaration owns the worktree or branch, follow `bootstrap_retry.next_action: inspect-blocking-session`. Nawabari never silently adopts an existing owner. A retry is appropriate only after the authoritative state proves that the requested bootstrap was not established.
88
-
89
- `--all-claimed` is an explicit resource selector. It resolves safely observed Git-changed paths covered by qualifying claims; it does not bypass claim authorization. Use repeated `--resource <path>` when an explicit path list is preferable.
90
-
91
- After reviewing and integrating the session branch through the caller's normal local Git/provider process:
37
+ From the repository's integration worktree, create a session and retain the returned identity and worktree path.
38
+ The default session does not require resource claims for otherwise-valid session-owned operations.
39
+ Worktree/branch ownership, applicable scope restrictions, and conflicts with another session's claims remain enforced.
92
40
 
93
41
  ```bash
94
- git nawabari session inspect --session "$session_id" --json
95
- git nawabari session close --session "$session_id" --json
42
+ nawabari session create --branch feature/example --json
43
+ nawabari session show --session "$session_id" --json
44
+ nawabari session inspect --session "$session_id" --schema-version 2 --json
96
45
  ```
97
46
 
98
- Close is conservative. Unintegrated commits, dirty worktrees, ambiguous Git state, and ownership mismatches remain blocked. For a squash or rebase merge, pass an exact local `--integrated-revision <rev>` so Nawabari can independently re-verify the content.
99
-
100
- If the lifecycle result exposes a recoverable blocker, follow its typed `next_action`/`next_actions` entry. `reconcile-physical-state` is the non-mutating observation action (its command is `doctor`). Its explicit apply action is `reconcile-physical-state-apply`, and its exact command is:
47
+ Set `session_id` and the working directory from the create result; do not use another session's worktree.
48
+ For explicit claim enforcement, declare it at creation:
101
49
 
102
50
  ```bash
103
- git nawabari session reconcile --session "$owner_session_id" --apply --json
51
+ nawabari session create --branch feature/claimed --enforce-claims \
52
+ --resource README.md --mode write --json
104
53
  ```
105
54
 
106
- The session ID must be the blocking owner reported by the machine result. A successful apply returns `operation: "reconcile-apply"`, `action.action_id: "reconcile-physical-state-apply"`, and a completed outcome; the owner is terminalized and its claims are released only when the existing lifecycle and physical-state evidence authorizes that transition. Retry the blocked claim only after this result succeeds.
107
-
108
- After every session reaches its terminal lifecycle result, confirm convergence from
109
- the repository integration worktree:
55
+ Commit and push are explicit governed operations with concrete resources. On claim-enforced sessions, their required
56
+ claim strength is discovered from the operation contract. Integration/review decisions remain caller-owned.
57
+ After integration, inspect and close. A blocked close does not authorize discard.
110
58
 
111
59
  ```bash
112
- git nawabari gc --dry-run --json
113
- git nawabari doctor --json
114
- ```
115
-
116
- ## Authority model
117
-
118
- Each boundary has one job and one local authority. README summarizes the product contract; executable code and machine-readable projections remain authoritative for exact schemas, transitions, and failure vocabularies.
119
-
120
- | Boundary | What it answers | Typical commands |
121
- | ---------------------- | -------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------- |
122
- | Session lifecycle | Which session owns a worktree/branch and whether it can safely progress or terminate | `session create`, `session inspect`, `session close` |
123
- | Resource Claims | Which session may access a canonical repository resource and at what mode | `session claim`, `session claims`, `session update`, `session release` |
124
- | Mutation authorization | Whether a concrete operation has sufficient claims and no conflicting owner | `guard`, `authorize`, `commit`, `push` |
125
- | Repository evidence | What Git can observe about revisions, paths, changes, ancestry, and bounded diffs | `checkpoint`, `evidence snapshot`, `diff` |
126
- | Auxiliary state | Whether explicitly declared durable repository-local state may be copied into the managed worktree | `session create --auxiliary-state`, `capabilities` |
127
- | Reconciliation/cleanup | Whether observed physical state permits a lifecycle recovery or cleanup action | `session inspect`, `session reconcile`, `doctor`, `gc` |
128
- | Protected execution | Whether a command runs inside the opt-in Linux process/filesystem boundary | `session run`, `session exec`, `session shell`, `doctor` |
129
-
130
- Claims are not task labels and do not encode GitHub or agent semantics. `write` permits ordinary path changes; `exclusive-write` is required for finalizing operations such as commit and push. Conflicting or ambiguous claims fail closed.
131
-
132
- The default governance path does not install hooks and does not prevent direct filesystem writes outside Nawabari. Its guarantee is that Nawabari-routed operations consult authoritative session, Git, and claim state before mutation.
133
-
134
- Nawabari's authority ends at local session ownership, claims, Git evidence, and the lifecycle of the managed worktree and branch. Task meaning, Issue/PR state, review decisions, and provider/GitHub state remain outside that authority.
135
-
136
- ### Claim conflict and physical recovery
137
-
138
- `RESOURCE_CLAIM_CONFLICT` does not always mean stale state. A healthy owner is reported with `ownerState: "active"`; the certified contention path exposes `inspect-blocking-session` and `wait-for-conflicting-claim-release` safe actions without a reconciliation `nextAction`. Inspect the owner and wait for the legitimate claim release; do not remove another session's claim.
139
-
140
- For a stale or inconsistent owner, the machine result instead carries physical and lifecycle evidence such as `ownerPhysicalState: "prunable-missing"`, `ownerLifecycleState: "stale-inconsistent"`, and the typed `nextAction.actionId: "reconcile-physical-state"`. Inspect it first:
141
-
142
- ```bash
143
- git nawabari session inspect --session "$owner_session_id" --schema-version 2 --json
144
- ```
145
-
146
- Then use the explicit apply operation shown above and retry the original claim after it completes. Age or a missing path alone is not destructive authority. The packed test removes a worktree only as external fault injection; supported recovery does not involve editing the session registry manually or deleting a raw Git worktree.
147
-
148
- ## Session and resource lifecycle
149
-
150
- The normal path is:
151
-
152
- ```text
153
- session create (explicit initial claims)
154
- ↓
155
- inspect session/claims → claim/authorize → checkpoint → commit or push
156
- ↓ ↓
157
- inspect readiness integrate the branch
158
- ↓ ↓
159
- session close or discard ←─────────────────────────┘
160
- ↓
161
- doctor + gc --dry-run convergence check
162
- ```
163
-
164
- If work is not integrated, `session inspect` reports bounded blockers and safe next actions. Discard is never an implicit fallback for close or garbage collection.
165
-
166
- The Session lifecycle is backed by the executable XState authority in 0.10.x and exposed through public state, contract, and manifest projections. Consumers use those projections rather than internal machine nodes or actor objects.
167
-
168
- ### Claims
169
-
170
- Claims are canonical repository-relative resource records attached to a session. Supported modes are `read`, `write`, and `exclusive-write`. The canonical routine path establishes its first claim during `session create`; later additions, transitions, and releases use the existing claim surfaces.
171
-
172
- ```bash
173
- git nawabari session claim --session "$session_id" --resource src/example.ts --mode exclusive-write --json
174
- git nawabari session claims --session "$session_id" --json
175
- git nawabari session update --session "$session_id" --resource src/example.ts --mode exclusive-write --resource test/example.test.ts --mode write --if-generation 1 --json
176
- git nawabari session release --session "$session_id" --all --force --json
177
- ```
178
-
179
- Resource aliases are discoverable through help. Use `--help --json` rather than copying option metadata into an integration.
180
-
181
- Claim modes are cumulative. The canonical operation requirements are derived from the operation authorization policy and are shown by `session claim --help`:
182
-
183
- - `read`: no governed operation
184
- - `write`: `source-write`, `stage`
185
- - `exclusive-write`: `source-write`, `stage`, `commit`, `branch-mutation`, `push`, `cleanup`
186
-
187
- The policy requires `exclusive-write` for operations that finalize or remove shared state. This mapping is documentation of the executable authority, not a second claim policy; integrations should discover the current values from help or the machine contract.
188
-
189
- ### Inspect, close, discard, and garbage collection
190
-
191
- `session inspect` is read-only and uses the same close/cleanup evidence as `session close`. Use `--schema-version 2` when consuming the single-authority lifecycle and action projection.
192
-
193
- ```bash
194
- git nawabari session inspect --session "$session_id" --json
195
- git nawabari session discard --session "$session_id" --preview --json
196
- ```
197
-
198
- `session discard` requires an explicit session ID and may destroy unintegrated commits and uncommitted work in that session's worktree. Preview reports bounded destructive scope without mutation. Actual discard revalidates repository, worktree, branch, `HEAD`, and registry ownership before destructive steps.
199
-
200
- When the caller intentionally abandons the session, apply that explicit
201
- decision with `git nawabari session discard --session "$session_id" --json`.
202
- Discard is not an automatic fallback for a blocked close.
203
-
204
- `gc --dry-run` reports stale candidates and blockers. `gc --apply` only cleans candidates passing the same safety checks; elapsed age alone is diagnostic suspicion, not destructive authority. `doctor` reports prerequisite and reconciliation state without silently repairing ownership. Use the typed lifecycle action and explicit `session reconcile` operation for supported stale/inconsistent-owner recovery; `doctor` does not silently repair it.
205
-
206
- ## Governed Git work
207
-
208
- `guard` and `authorize` are separate read-only boundaries:
209
-
210
- - `guard` without an operation verifies the current physical worktree, branch, and session ownership/context. It does not evaluate resource claims.
211
- - `authorize` evaluates a named operation against concrete resources, using the canonical operation policy and active claims. It does not grant or persist claims.
212
- - `guard --operation <name> --resource <path>` remains a compatibility convenience for the combined claim-aware check. Use `authorize` when the operation decision itself is the intended boundary.
213
-
214
- The operation vocabulary is discoverable from the CLI and includes `source-write`, `stage`, `commit`, `branch-mutation`, `push`, and `cleanup`.
215
-
216
- `checkpoint` and `evidence snapshot` describe Git-observable facts only. They do not infer task meaning, Issue ownership, or review status. `diff` requires explicit concrete paths and bounds optional patch output.
217
-
218
- ```bash
219
- git nawabari commit --session "$session_id" --message "Update example" --resource src/example.ts --json
220
- git nawabari commit --session "$session_id" --message "Update example" --all-claimed --json
221
- git nawabari push --session "$session_id" --remote origin --branch feature/example --all-claimed --json
60
+ nawabari session close --session "$session_id" --json
61
+ nawabari gc --dry-run --json
62
+ nawabari doctor --json
222
63
  ```
223
64
 
224
- ## Optional protected execution
225
-
226
- Protected execution is an opt-in Linux-only mode beneath the existing Nawabari session and claim authority. It does not create a second session identity and does not turn ordinary `session create` work into a sandbox.
65
+ See [current CLI workflows](docs/reference/cli-workflows.md) for bounded working sets, auxiliary state, claims,
66
+ Git mutation, explicit discard, reconciliation, and bootstrap retry. Target park/resume semantics are documented in
67
+ [session lifecycle](docs/architecture/session-lifecycle.md), not advertised here as implemented commands.
227
68
 
228
- ```bash
229
- git nawabari session run --session "$session_id" --runtime-policy strict -- node worker.js
230
- git nawabari session exec --session "$session_id" -- npm test
231
- git nawabari session shell --session "$session_id" --runtime-policy compatibility
232
- ```
69
+ ## Execution guarantees
233
70
 
234
- The `--` terminator is mandatory. The command is passed as argv and is not interpreted by a shell. The canonical profile gives the child a private root, `/tmp`, `/proc`, HOME, and cache state, mounts only the owned worktree read-write, and does not expose sibling worktrees or Nawabari control paths. Network mode is explicitly `inherited`, not isolated. Required Linux capabilities fail closed when unavailable; optional Landlock and cgroups v2 provide defense in depth when available.
235
-
236
- Protected execution defaults to the strict `development` runtime profile. Only declared Node, Git, and the deterministic `ls` baseline utility are projected through `/nawabari/bin`; `/usr`, `/bin`, `/nix/store`, the host home, and local user-tool directories are not implicitly visible. pnpm is an explicit opt-in development requirement. Compatibility is available only through the explicit `--runtime-policy compatibility` option.
71
+ An ordinary session is an ownership boundary, not automatic OS isolation. Direct edits by a host process with ambient
72
+ permissions remain outside the mediated-operation guarantee.
73
+ Protected execution requires the selected Linux sandbox and explicit runtime material. Managed execution additionally
74
+ uses durable execution ownership, launch admission, and owned process/cgroup evidence. These are separate capabilities;
75
+ a generic sandbox-ready result does not prove managed-runtime readiness.
237
76
 
238
77
  ```bash
239
- git nawabari doctor --json
78
+ nawabari session run --session "$session_id" --runtime-policy strict -- node worker.js
240
79
  ```
241
80
 
242
- See [Standalone Linux compatibility](docs/standalone-linux-compatibility.md) for platform-specific details.
243
-
244
- ## CLI and machine-readable discovery
81
+ Strict execution does not silently fall back to host PATH, HOME, broad mounts, or compatibility mode.
82
+ Network mode remains `inherited`; filesystem isolation does not imply isolation from host loopback services.
83
+ See [runtime/process](docs/architecture/runtime-process.md), [runtime reference](docs/reference/runtime-projection.md),
84
+ and [security policy](SECURITY.md) before interpreting a capability or isolation claim.
245
85
 
246
- The installed CLI is the primary integration surface. Discover its contract rather than hard-coding presentation output:
86
+ ## Optional local Control Server
247
87
 
248
88
  ```bash
249
- nawabari capabilities --json
250
- nawabari --version --json
251
- nawabari session create --help --json
252
- nawabari session inspect --help --json
253
- nawabari session reconcile --help --json
254
- nawabari commit --help --json
89
+ nawabari server
90
+ nawabari server --port 47472
255
91
  ```
256
92
 
257
- `capabilities --json` works without a Git repository. The top-level contract is `nawabari.standalone-execution.v1`, schema version `1`; Resource Claim meaning is separately versioned as `nawabari.resource-claims.v2`. Package version alone is not a compatibility decision. The capability projection publishes the initial-claim grammar and retry vocabulary, auxiliary-state contract, lifecycle action IDs, and the `session reconcile --session <id> --apply` apply arguments used above.
258
-
259
- JSON mode emits one bounded document on stdout. Consumers should use machine-readable fields and stable codes rather than parse human-oriented text.
260
-
261
- The command surface includes Session lifecycle, Resource Claims, authorization/evidence, governed Git commit/push, reconciliation/discovery, and protected execution. Use `--help --json` and `capabilities --json` for the authoritative inventory. Human-readable guidance and agent integrations use these same command and action identifiers; there is no separate human or agent workflow.
93
+ The current foreground server binds only `127.0.0.1`, defaults to port `47471`, and serves known repositories through one
94
+ browser endpoint. CLI and TUI work without it. Stop it with Ctrl-C or SIGTERM.
262
95
 
263
- `src/cli-command-registry.ts` is the single canonical authority for that surface: every command/option name is a `CommandId`/`OptionId` literal type derived directly from the registry data (not hand-typed), and `--help`, `capabilities`, and the executable dispatcher's own accepted-flag parsing all read that same data. There is no second command or option table to keep in sync.
96
+ **Current limitation:** the implementation audited for this adoption bootstraps its control token into the unauthenticated
97
+ root document. With inherited host networking, this is not an isolation boundary against untrusted local/protected
98
+ processes. Do not treat concurrent untrusted workloads and this server as a securely separated operator interface.
99
+ The accepted target requires trusted-host-only credential delivery; that repair remains implementation work.
100
+ Different ports also do not currently enforce the accepted machine/user singleton requirement.
264
101
 
265
- ## Stable package exports
102
+ The [control-surfaces contract](docs/architecture/control-surfaces.md) defines authentication, lifecycle, discovery,
103
+ concurrency, and projection boundaries without turning this optional server into a remote control plane.
266
104
 
267
- Node consumers can use public projections without spawning the CLI:
105
+ ## Public Node projections
268
106
 
269
107
  ```js
270
- import {
271
- availableNawabariCommands,
272
- classifyNawabariState,
273
- getNawabariSessionStateSnapshot,
274
- nawabariTransitionDecision,
275
- } from "nawabari/state";
276
-
108
+ import { getNawabariSessionStateSnapshot } from "nawabari/state";
277
109
  import { nawabariMachineContract } from "nawabari/contract";
278
-
279
- import { generateNawabariProductStateManifest, serializeNawabariProductStateManifest } from "nawabari/manifest";
110
+ import { generateNawabariProductStateManifest } from "nawabari/manifest";
280
111
  ```
281
112
 
282
- `nawabari/state` provides transport-neutral lifecycle projection and read-only observation of an existing session. `nawabari/contract` provides the installed machine-contract projection. `nawabari/manifest` provides the deterministic Product State Manifest projection.
283
-
284
- These exports do not grant mutation authority and do not expose raw XState machines, actor references, internal state-node IDs, private context, or `dist/` deep imports. Mutations still go through authoritative runtime paths. See [XState state architecture](docs/architecture/xstate-state-architecture.md).
285
-
286
- ## Further reading
113
+ These exports expose read/classification/contract projections, not mutation permission or raw XState actors.
114
+ Do not deep-import private `dist` modules as a supported API.
287
115
 
288
- - [XState state architecture](docs/architecture/xstate-state-architecture.md): lifecycle authority, public projections, and integration boundaries.
289
- - [Standalone Linux compatibility](docs/standalone-linux-compatibility.md): protected-execution compatibility and conformance details.
290
- - [Release notes](docs/releases/): version-specific changes and migration context.
291
- - [Contributing](CONTRIBUTING.md): development workflow and repository conventions.
292
- - [Security policy](SECURITY.md): vulnerability reporting.
116
+ ## Documentation and development
293
117
 
294
- ## Development
118
+ Start with the [documentation map](docs/index.md), [contribution workflow](CONTRIBUTING.md), and
119
+ [release history](docs/releases/). Development uses the exact `packageManager` declaration in `package.json`.
295
120
 
296
121
  ```bash
297
122
  pnpm install --frozen-lockfile
298
- pnpm run format:check
299
- pnpm run lint
300
- pnpm run typecheck
301
- pnpm test
123
+ pnpm run verify
302
124
  ```
303
125
 
304
- `pnpm run verify` runs the complete repository validation, including package and workflow checks.
126
+ Verification includes package and environment-dependent proofs. A missing sandbox, runtime material, or delegated cgroup
127
+ is not a successful security test. See the [proof matrix](docs/architecture/verification-provenance.md).
@@ -126,7 +126,7 @@ declare const REGISTRY_DATA: readonly [{
126
126
  name: "--enforce-claims";
127
127
  description: string;
128
128
  } & CliHelpOptionSpec];
129
- readonly notes: readonly ["All create options are optional. Use status --json to discover managed_worktree_root.", "--worktree and --worktree-root cannot be combined.", "--profile-parameter requires --profile; ambiguous unqualified profile ids are rejected.", "Initial claims are provisioned atomically with the session; each --resource must be immediately followed by its own --mode, and zero pairs remains backward compatible.", "Resource-claim enforcement is disabled by default; pass --enforce-claims to require claims for commit/push authorization on this session. Worktree and branch ownership, and claim conflicts against other sessions, remain enforced regardless.", "Providing one bounded working-set artifact requires the other; both are validated before worktree ownership is established.", "A claim conflict returns blocking-owner evidence. A durability-uncertain result is retry-safe only after re-reading the reported registry state; an existing owner is never silently adopted.", "Without an override, Nawabari creates the safe managed root <repository-parent>/.nawabari/worktrees on first use. Existing absolute worktree paths directly under the repository parent remain accepted for compatibility."];
129
+ readonly notes: readonly ["All create options are optional. Use status --json to discover managed_worktree_root.", "--worktree and --worktree-root cannot be combined.", "--profile-parameter requires --profile; ambiguous unqualified profile ids are rejected.", "Initial claims are provisioned atomically with the session; each --resource must be immediately followed by its own --mode, and zero pairs remains backward compatible.", "Resource-claim enforcement is disabled by default; pass --enforce-claims to require claims for commit/push authorization on this session. Worktree and branch ownership, and claim conflicts against other sessions, remain enforced regardless.", "Providing one bounded working-set artifact requires the other; both are validated before worktree ownership is established.", "Both JSON artifact formats and field semantics are documented in README Working-set artifacts; session show --json exposes working_set.revision for expansion.", "A claim conflict returns blocking-owner evidence. A durability-uncertain result is retry-safe only after re-reading the reported registry state; an existing owner is never silently adopted.", "Without an override, Nawabari creates the safe managed root <repository-parent>/.nawabari/worktrees on first use. Existing absolute worktree paths directly under the repository parent remain accepted for compatibility."];
130
130
  }, {
131
131
  readonly name: "session id";
132
132
  readonly summary: "Resolve the current session identity";
@@ -246,7 +246,7 @@ declare const REGISTRY_DATA: readonly [{
246
246
  name: "--unresolved";
247
247
  description: string;
248
248
  } & CliHelpOptionSpec];
249
- readonly notes: readonly ["The current working-set revision is a mandatory CAS token; stale requests are rejected without mutation.", "READONLY is evaluated independently. Mutation classes also require the existing session claim authority.", "The execution-scope artifact must match the session's established provenance; it cannot widen Inari maximum authority."];
249
+ readonly notes: readonly ["The current working-set revision is a mandatory CAS token; stale requests are rejected without mutation.", "READONLY is evaluated independently. Mutation classes also require the existing session claim authority.", "The execution-scope artifact must match the session's established provenance; it cannot widen Inari maximum authority.", "Inspect session show --json working_set.revision and history; use the same bootstrap execution-scope JSON. See README Working-set artifacts."];
250
250
  }, {
251
251
  readonly name: "session reconcile";
252
252
  readonly summary: "Apply bounded lifecycle reconciliation for one selected session";
@@ -317,7 +317,7 @@ declare const REGISTRY_DATA: readonly [{
317
317
  } & {
318
318
  readonly value: "<action-id>";
319
319
  readonly required: true;
320
- readonly values: readonly ["retain-session", "supply-exact-integrated-revision", "retry-close-with-bounded-integration-fetch", "discard-session", "reconcile-physical-state"];
320
+ readonly values: readonly import("./domain/session-actions.js").SessionActionId[];
321
321
  }, {
322
322
  name: "--token";
323
323
  description: string;
@@ -345,6 +345,20 @@ declare const REGISTRY_DATA: readonly [{
345
345
  readonly usage: "nawabari ui";
346
346
  readonly options: readonly [];
347
347
  readonly notes: readonly ["The UI reads one canonical repository runtime snapshot at startup and on refresh; it never mutates registry, Git, or filesystem state.", "Non-interactive callers receive one bounded projection and may combine this command with --json."];
348
+ }, {
349
+ readonly name: "server";
350
+ readonly summary: "Run the machine-local control server and built-in Web UI";
351
+ readonly usage: "nawabari server [--port <port>]";
352
+ readonly options: readonly [{
353
+ name: "--port";
354
+ description: string;
355
+ } & {
356
+ readonly value: "<port>";
357
+ readonly default: "47471";
358
+ readonly minimum: 1;
359
+ readonly maximum: 65535;
360
+ }];
361
+ readonly notes: readonly ["Runs in the foreground and binds 127.0.0.1 only; the bind address is not configurable. An occupied port fails.", "Serves every locally known Nawabari repository through one listener; each repository keeps its own backend authority.", "API requests require the ephemeral startup token header; the token rotates on restart and is never printed."];
348
362
  }, {
349
363
  readonly name: "session coordination preview";
350
364
  readonly summary: "Preview bounded coordination between two sessions";
@@ -1,4 +1,5 @@
1
1
  import { DEFAULT_SESSION_LIST_LIMIT, MAX_SESSION_LIST_LIMIT } from "./domain/session.js";
2
+ import { SESSION_ACTION_IDS } from "./domain/session-actions.js";
2
3
  import { claimModeOperationRequirements, OPERATION_VOCABULARY } from "./operation-authorization.js";
3
4
  import { EVIDENCE_MAX_DIFF_BYTES, EVIDENCE_MAX_DIFF_HUNKS } from "./repository-evidence.js";
4
5
  const CLI_NAME = "nawabari";
@@ -64,10 +65,10 @@ const REGISTRY_DATA = [
64
65
  repeatable: true,
65
66
  }),
66
67
  option("--auxiliary-state", "JSON repository-local auxiliary-state declaration to materialize in the managed worktree; repeatable", { value: "<json>", repeatable: true }),
67
- option("--execution-scope-file", "Bounded JSON execution-scope artifact file for governed bootstrap", {
68
+ option("--execution-scope-file", "Version 1 implementation-execution-scope JSON; see README Working-set artifacts", {
68
69
  value: "<path>",
69
70
  }),
70
- option("--candidate-working-set-file", "Bounded JSON candidate-working-set artifact file for governed bootstrap", { value: "<path>" }),
71
+ option("--candidate-working-set-file", "Schema version 1 candidate-working-set JSON; see README Working-set artifacts", { value: "<path>" }),
71
72
  option("--enforce-claims", "Opt this session into resource-claim enforcement; without it, operation authorization does not require resource claims for session-owned operations"),
72
73
  ],
73
74
  notes: [
@@ -77,6 +78,7 @@ const REGISTRY_DATA = [
77
78
  "Initial claims are provisioned atomically with the session; each --resource must be immediately followed by its own --mode, and zero pairs remains backward compatible.",
78
79
  "Resource-claim enforcement is disabled by default; pass --enforce-claims to require claims for commit/push authorization on this session. Worktree and branch ownership, and claim conflicts against other sessions, remain enforced regardless.",
79
80
  "Providing one bounded working-set artifact requires the other; both are validated before worktree ownership is established.",
81
+ "Both JSON artifact formats and field semantics are documented in README Working-set artifacts; session show --json exposes working_set.revision for expansion.",
80
82
  "A claim conflict returns blocking-owner evidence. A durability-uncertain result is retry-safe only after re-reading the reported registry state; an existing owner is never silently adopted.",
81
83
  "Without an override, Nawabari creates the safe managed root <repository-parent>/.nawabari/worktrees on first use. Existing absolute worktree paths directly under the repository parent remain accepted for compatibility.",
82
84
  ],
@@ -168,6 +170,7 @@ const REGISTRY_DATA = [
168
170
  "The current working-set revision is a mandatory CAS token; stale requests are rejected without mutation.",
169
171
  "READONLY is evaluated independently. Mutation classes also require the existing session claim authority.",
170
172
  "The execution-scope artifact must match the session's established provenance; it cannot widen Inari maximum authority.",
173
+ "Inspect session show --json working_set.revision and history; use the same bootstrap execution-scope JSON. See README Working-set artifacts.",
171
174
  ],
172
175
  },
173
176
  {
@@ -230,16 +233,10 @@ const REGISTRY_DATA = [
230
233
  usage: `${CLI_NAME} session action --session <id> --action <action-id> --token <json> [--confirm --preview <json>] [--operation-id <id>]`,
231
234
  options: [
232
235
  option("--session", "Explicit session identity; never inferred", { value: "<id>", required: true }),
233
- option("--action", "Typed action ID from the current diagnostic next_actions", {
236
+ option("--action", "Typed action ID from the current lifecycle action projection", {
234
237
  value: "<action-id>",
235
238
  required: true,
236
- values: [
237
- "retain-session",
238
- "supply-exact-integrated-revision",
239
- "retry-close-with-bounded-integration-fetch",
240
- "discard-session",
241
- "reconcile-physical-state",
242
- ],
239
+ values: SESSION_ACTION_IDS,
243
240
  }),
244
241
  option("--token", "JSON action token returned by the current UI snapshot", { value: "<json>", required: true }),
245
242
  option("--confirm", "Explicit intent for actions that require confirmation"),
@@ -262,6 +259,24 @@ const REGISTRY_DATA = [
262
259
  "Non-interactive callers receive one bounded projection and may combine this command with --json.",
263
260
  ],
264
261
  },
262
+ {
263
+ name: "server",
264
+ summary: "Run the machine-local control server and built-in Web UI",
265
+ usage: `${CLI_NAME} server [--port <port>]`,
266
+ options: [
267
+ option("--port", "Local TCP port on 127.0.0.1", {
268
+ value: "<port>",
269
+ default: "47471",
270
+ minimum: 1,
271
+ maximum: 65535,
272
+ }),
273
+ ],
274
+ notes: [
275
+ "Runs in the foreground and binds 127.0.0.1 only; the bind address is not configurable. An occupied port fails.",
276
+ "Serves every locally known Nawabari repository through one listener; each repository keeps its own backend authority.",
277
+ "API requests require the ephemeral startup token header; the token rotates on restart and is never printed.",
278
+ ],
279
+ },
265
280
  {
266
281
  name: "session coordination preview",
267
282
  summary: "Preview bounded coordination between two sessions",