@tomflow/chatloop-tools 0.9.64 → 0.9.70
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/node_modules/@tomflow/chatloop-context/README.md +296 -0
- package/node_modules/@tomflow/chatloop-context/bin/cli.mjs +48 -0
- package/node_modules/@tomflow/chatloop-context/capabilities/approval.mjs +151 -0
- package/node_modules/@tomflow/chatloop-context/capabilities/context.mjs +376 -0
- package/node_modules/@tomflow/chatloop-context/capabilities/document.mjs +290 -0
- package/node_modules/@tomflow/chatloop-context/capabilities/evidence.mjs +134 -0
- package/node_modules/@tomflow/chatloop-context/capabilities/presentation.mjs +82 -0
- package/node_modules/@tomflow/chatloop-context/capabilities/project.mjs +349 -0
- package/node_modules/@tomflow/chatloop-context/capabilities/sdk.mjs +72 -0
- package/node_modules/@tomflow/chatloop-context/capabilities/start.mjs +73 -0
- package/node_modules/@tomflow/chatloop-context/capabilities/task.mjs +507 -0
- package/node_modules/@tomflow/chatloop-context/capabilities.generated.mjs +11 -0
- package/node_modules/@tomflow/chatloop-context/docs/interfaces.md +261 -0
- package/node_modules/@tomflow/chatloop-context/docs/operator-and-migration.md +277 -0
- package/node_modules/@tomflow/chatloop-context/index.mjs +238 -0
- package/node_modules/@tomflow/chatloop-context/lib/api-log.mjs +86 -0
- package/node_modules/@tomflow/chatloop-context/lib/approval-policy.mjs +77 -0
- package/node_modules/@tomflow/chatloop-context/lib/capability-catalog.generated.json +2036 -0
- package/node_modules/@tomflow/chatloop-context/lib/capability-router.mjs +69 -0
- package/node_modules/@tomflow/chatloop-context/lib/cli-commands.mjs +338 -0
- package/node_modules/@tomflow/chatloop-context/lib/context-cli.mjs +298 -0
- package/node_modules/@tomflow/chatloop-context/lib/context-migration.mjs +286 -0
- package/node_modules/@tomflow/chatloop-context/lib/core/context.mjs +117 -0
- package/node_modules/@tomflow/chatloop-context/lib/core/evidence.mjs +51 -0
- package/node_modules/@tomflow/chatloop-context/lib/core/health.mjs +134 -0
- package/node_modules/@tomflow/chatloop-context/lib/core/migration.mjs +262 -0
- package/node_modules/@tomflow/chatloop-context/lib/core/project.mjs +246 -0
- package/node_modules/@tomflow/chatloop-context/lib/core/review.mjs +180 -0
- package/node_modules/@tomflow/chatloop-context/lib/core/run-cancel.mjs +68 -0
- package/node_modules/@tomflow/chatloop-context/lib/core/run-recovery.mjs +112 -0
- package/node_modules/@tomflow/chatloop-context/lib/core/run.mjs +367 -0
- package/node_modules/@tomflow/chatloop-context/lib/core/store.mjs +398 -0
- package/node_modules/@tomflow/chatloop-context/lib/core/task.mjs +264 -0
- package/node_modules/@tomflow/chatloop-context/lib/line-review.mjs +13 -0
- package/node_modules/@tomflow/chatloop-context/lib/methods.mjs +111 -0
- package/node_modules/@tomflow/chatloop-context/lib/operations.mjs +107 -0
- package/node_modules/@tomflow/chatloop-context/lib/orphan-operator.mjs +118 -0
- package/node_modules/@tomflow/chatloop-context/lib/process-inventory.mjs +20 -0
- package/node_modules/@tomflow/chatloop-context/lib/project-branch.mjs +316 -0
- package/node_modules/@tomflow/chatloop-context/lib/project-diagnostic.mjs +153 -0
- package/node_modules/@tomflow/chatloop-context/lib/project-guards.mjs +19 -0
- package/node_modules/@tomflow/chatloop-context/lib/project-store.mjs +117 -0
- package/node_modules/@tomflow/chatloop-context/lib/trusted-run.mjs +142 -0
- package/node_modules/@tomflow/chatloop-context/lib/workspace-operator.mjs +169 -0
- package/node_modules/@tomflow/chatloop-context/package.json +38 -0
- package/node_modules/@tomflow/chatloop-context/scripts/build-capabilities.mjs +114 -0
- package/node_modules/@tomflow/chatloop-extension/README.md +190 -0
- package/node_modules/@tomflow/chatloop-extension/actions.generated.mjs +13 -0
- package/node_modules/@tomflow/chatloop-extension/bin/cli.mjs +168 -0
- package/node_modules/@tomflow/chatloop-extension/bin/native-host.mjs +246 -0
- package/node_modules/@tomflow/chatloop-extension/capabilities/chat_dom.mjs +1 -0
- package/node_modules/@tomflow/chatloop-extension/capabilities/chat_screenshot.mjs +1 -0
- package/node_modules/@tomflow/chatloop-extension/capabilities/chat_text.mjs +1 -0
- package/node_modules/@tomflow/chatloop-extension/capabilities/clean.mjs +1 -0
- package/node_modules/@tomflow/chatloop-extension/capabilities/continue.mjs +1 -0
- package/node_modules/@tomflow/chatloop-extension/capabilities/entry_test.mjs +1 -0
- package/node_modules/@tomflow/chatloop-extension/capabilities/handoff.mjs +1 -0
- package/node_modules/@tomflow/chatloop-extension/capabilities/reload.mjs +1 -0
- package/node_modules/@tomflow/chatloop-extension/capabilities/session.mjs +1 -0
- package/node_modules/@tomflow/chatloop-extension/capabilities/start.mjs +1 -0
- package/node_modules/@tomflow/chatloop-extension/capabilities/status.mjs +1 -0
- package/node_modules/@tomflow/chatloop-extension/extension/actions/clean.js +123 -0
- package/node_modules/@tomflow/chatloop-extension/extension/actions/common.js +183 -0
- package/node_modules/@tomflow/chatloop-extension/extension/actions/continue.js +390 -0
- package/node_modules/@tomflow/chatloop-extension/extension/actions/dom.js +2 -0
- package/node_modules/@tomflow/chatloop-extension/extension/actions/entry_test.js +241 -0
- package/node_modules/@tomflow/chatloop-extension/extension/actions/handoff-scoped.js +143 -0
- package/node_modules/@tomflow/chatloop-extension/extension/actions/handoff.js +399 -0
- package/node_modules/@tomflow/chatloop-extension/extension/actions/index.js +2 -0
- package/node_modules/@tomflow/chatloop-extension/extension/actions/model-intent.js +60 -0
- package/node_modules/@tomflow/chatloop-extension/extension/actions/read-mode.js +9 -0
- package/node_modules/@tomflow/chatloop-extension/extension/actions/reload.js +20 -0
- package/node_modules/@tomflow/chatloop-extension/extension/actions/screenshot.js +77 -0
- package/node_modules/@tomflow/chatloop-extension/extension/actions/session.js +95 -0
- package/node_modules/@tomflow/chatloop-extension/extension/actions/start.js +329 -0
- package/node_modules/@tomflow/chatloop-extension/extension/actions/status.js +38 -0
- package/node_modules/@tomflow/chatloop-extension/extension/actions/text.js +2 -0
- package/node_modules/@tomflow/chatloop-extension/extension/background.js +33 -0
- package/node_modules/@tomflow/chatloop-extension/extension/clean.html +5 -0
- package/node_modules/@tomflow/chatloop-extension/extension/content.js +40 -0
- package/node_modules/@tomflow/chatloop-extension/extension/continue.html +9 -0
- package/node_modules/@tomflow/chatloop-extension/extension/dom.html +17 -0
- package/node_modules/@tomflow/chatloop-extension/extension/entry_test.html +6 -0
- package/node_modules/@tomflow/chatloop-extension/extension/handoff.html +9 -0
- package/node_modules/@tomflow/chatloop-extension/extension/loop/action-catalog.generated.js +2 -0
- package/node_modules/@tomflow/chatloop-extension/extension/loop/api-aspect.generated.js +275 -0
- package/node_modules/@tomflow/chatloop-extension/extension/loop/api-observation-queue.generated.js +84 -0
- package/node_modules/@tomflow/chatloop-extension/extension/loop/core.js +107 -0
- package/node_modules/@tomflow/chatloop-extension/extension/loop/index.js +36 -0
- package/node_modules/@tomflow/chatloop-extension/extension/loop/observer-approval.js +299 -0
- package/node_modules/@tomflow/chatloop-extension/extension/loop/observer-inspect.js +144 -0
- package/node_modules/@tomflow/chatloop-extension/extension/loop/observer-poll.js +172 -0
- package/node_modules/@tomflow/chatloop-extension/extension/loop/observer-recovery.js +109 -0
- package/node_modules/@tomflow/chatloop-extension/extension/loop/observer.js +211 -0
- package/node_modules/@tomflow/chatloop-extension/extension/loop/resource-maintenance.js +159 -0
- package/node_modules/@tomflow/chatloop-extension/extension/loop/resources.js +399 -0
- package/node_modules/@tomflow/chatloop-extension/extension/manifest.json +43 -0
- package/node_modules/@tomflow/chatloop-extension/extension/popup.html +25 -0
- package/node_modules/@tomflow/chatloop-extension/extension/popup.js +99 -0
- package/node_modules/@tomflow/chatloop-extension/extension/reload.html +17 -0
- package/node_modules/@tomflow/chatloop-extension/extension/screenshot.html +17 -0
- package/node_modules/@tomflow/chatloop-extension/extension/session.html +7 -0
- package/node_modules/@tomflow/chatloop-extension/extension/start.html +6 -0
- package/node_modules/@tomflow/chatloop-extension/extension/status.html +6 -0
- package/node_modules/@tomflow/chatloop-extension/extension/text.html +17 -0
- package/node_modules/@tomflow/chatloop-extension/extension/worker/action-result.js +136 -0
- package/node_modules/@tomflow/chatloop-extension/extension/worker/action-take.js +218 -0
- package/node_modules/@tomflow/chatloop-extension/extension/worker/admission.js +127 -0
- package/node_modules/@tomflow/chatloop-extension/extension/worker/adopt-prepare.js +296 -0
- package/node_modules/@tomflow/chatloop-extension/extension/worker/adopt-recovery.js +186 -0
- package/node_modules/@tomflow/chatloop-extension/extension/worker/adopt-result.js +126 -0
- package/node_modules/@tomflow/chatloop-extension/extension/worker/bootstrap.js +287 -0
- package/node_modules/@tomflow/chatloop-extension/extension/worker/manual.js +163 -0
- package/node_modules/@tomflow/chatloop-extension/extension/worker/readiness.js +345 -0
- package/node_modules/@tomflow/chatloop-extension/extension/worker/router.js +209 -0
- package/node_modules/@tomflow/chatloop-extension/extension/worker/scheduler.js +385 -0
- package/node_modules/@tomflow/chatloop-extension/extension/worker/session-control.js +75 -0
- package/node_modules/@tomflow/chatloop-extension/extension/worker/task-action-v2.js +278 -0
- package/node_modules/@tomflow/chatloop-extension/extension/worker/task-cancel-recovery-v2.js +52 -0
- package/node_modules/@tomflow/chatloop-extension/extension/worker/task-cancel-v2.js +93 -0
- package/node_modules/@tomflow/chatloop-extension/extension/worker/task-continue-recovery-v2.js +78 -0
- package/node_modules/@tomflow/chatloop-extension/extension/worker/task-handoff-recovery-v2.js +148 -0
- package/node_modules/@tomflow/chatloop-extension/extension/worker/task-handoff-v2.js +325 -0
- package/node_modules/@tomflow/chatloop-extension/extension/worker/task-hold-recovery-v2.js +109 -0
- package/node_modules/@tomflow/chatloop-extension/extension/worker/task-intent-dispatch-v2.js +220 -0
- package/node_modules/@tomflow/chatloop-extension/extension/worker/task-intent-v2.js +106 -0
- package/node_modules/@tomflow/chatloop-extension/extension/worker/task-owner-resolver.js +110 -0
- package/node_modules/@tomflow/chatloop-extension/extension/worker/task-recover-v2.js +209 -0
- package/node_modules/@tomflow/chatloop-extension/extension/worker/task-routes-v2.js +357 -0
- package/node_modules/@tomflow/chatloop-extension/extension/worker/task-run-store.js +400 -0
- package/node_modules/@tomflow/chatloop-extension/extension/worker/task-scheduler.js +78 -0
- package/node_modules/@tomflow/chatloop-extension/extension/worker/task-start-v2.js +361 -0
- package/node_modules/@tomflow/chatloop-extension/extension/worker/task-terminal-v2.js +235 -0
- package/node_modules/@tomflow/chatloop-extension/extension/worker/turn-failure.js +197 -0
- package/node_modules/@tomflow/chatloop-extension/extension/worker/turn-finished.js +205 -0
- package/node_modules/@tomflow/chatloop-extension/index.mjs +78 -0
- package/node_modules/@tomflow/chatloop-extension/lib/action-routing.mjs +19 -0
- package/node_modules/@tomflow/chatloop-extension/lib/api-observation-queue.mjs +82 -0
- package/node_modules/@tomflow/chatloop-extension/lib/bridge.mjs +378 -0
- package/node_modules/@tomflow/chatloop-extension/lib/browser-launch.mjs +89 -0
- package/node_modules/@tomflow/chatloop-extension/lib/context-binding.mjs +45 -0
- package/node_modules/@tomflow/chatloop-extension/lib/context-ipc.mjs +122 -0
- package/node_modules/@tomflow/chatloop-extension/lib/owner-evidence.mjs +75 -0
- package/node_modules/@tomflow/chatloop-extension/lib/owner-kernel-lock.mjs +106 -0
- package/node_modules/@tomflow/chatloop-extension/lib/owner-ledger.mjs +316 -0
- package/node_modules/@tomflow/chatloop-extension/lib/owner-locked-write.mjs +30 -0
- package/node_modules/@tomflow/chatloop-extension/lib/scoped-cancel-v2.mjs +190 -0
- package/node_modules/@tomflow/chatloop-extension/lib/scoped-continue-v2.mjs +214 -0
- package/node_modules/@tomflow/chatloop-extension/lib/scoped-handoff-v2.mjs +338 -0
- package/node_modules/@tomflow/chatloop-extension/lib/scoped-native-control.mjs +398 -0
- package/node_modules/@tomflow/chatloop-extension/lib/scoped-recovery-v2.mjs +234 -0
- package/node_modules/@tomflow/chatloop-extension/lib/scoped-retire-v2.mjs +70 -0
- package/node_modules/@tomflow/chatloop-extension/lib/scoped-terminal-v2.mjs +143 -0
- package/node_modules/@tomflow/chatloop-extension/lib/session-file.mjs +228 -0
- package/node_modules/@tomflow/chatloop-extension/package.json +36 -0
- package/node_modules/@tomflow/chatloop-extension/scripts/build-actions.mjs +138 -0
- package/node_modules/@tomflow/chatloop-trace/README.md +118 -0
- package/node_modules/@tomflow/chatloop-trace/events/context.api.mjs +23 -0
- package/node_modules/@tomflow/chatloop-trace/events/typed.api.call.mjs +22 -0
- package/node_modules/@tomflow/chatloop-trace/events.generated.mjs +4 -0
- package/node_modules/@tomflow/chatloop-trace/index.mjs +59 -0
- package/node_modules/@tomflow/chatloop-trace/lib/api-aspect.mjs +273 -0
- package/node_modules/@tomflow/chatloop-trace/lib/trace-reader.mjs +308 -0
- package/node_modules/@tomflow/chatloop-trace/lib/trace-retention.mjs +140 -0
- package/node_modules/@tomflow/chatloop-trace/lib/trace.mjs +236 -0
- package/node_modules/@tomflow/chatloop-trace/package.json +28 -0
- package/node_modules/@tomflow/chatloop-trace/scripts/build-events.mjs +68 -0
- package/node_modules/ps-list/index.d.ts +76 -0
- package/node_modules/ps-list/index.js +366 -0
- package/node_modules/ps-list/license +9 -0
- package/node_modules/ps-list/package.json +44 -0
- package/node_modules/ps-list/readme.md +56 -0
- package/node_modules/ps-list/vendor/fastlist-0.3.0-x64.exe +0 -0
- package/node_modules/ps-list/vendor/fastlist-0.3.0-x86.exe +0 -0
- package/package.json +12 -4
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
# Context npm package — actual interface, consumer and dependency map
|
|
2
|
+
|
|
3
|
+
> Applies to the **source** version declared in [`../package.json`](../package.json), not a fixed historical release.
|
|
4
|
+
> The connected MCP may still be running an earlier installed release.
|
|
5
|
+
> This document describes source contracts, not production cutover approval.
|
|
6
|
+
|
|
7
|
+
## 1. Only two package entrypoints
|
|
8
|
+
|
|
9
|
+
| Physical path | npm entry | API classification | Access |
|
|
10
|
+
| --- | --- | --- | --- |
|
|
11
|
+
| `index.mjs` | `exports["."]` | Only module surface: Public SDK, pinned MCP adapter, trusted runtime and reviewed operator | `import {...} from '@tomflow/chatloop-context'` |
|
|
12
|
+
| `bin/cli.mjs` | `bin.chatloop-context` | Only executable surface | `chatloop-context <command>` from installed npm bin |
|
|
13
|
+
|
|
14
|
+
No `exports["./*"]`; all `lib/**` files are private source modules.
|
|
15
|
+
The two entrypoints are **forms of access**. Trust and authority remain
|
|
16
|
+
explicitly **separate** (import or CLI execution does not grant permission).
|
|
17
|
+
|
|
18
|
+
## 2. Exact JavaScript exports from index.mjs
|
|
19
|
+
|
|
20
|
+
| Export | Returns / exposes | Provider implementation | Consumed by |
|
|
21
|
+
| --- | --- | --- | --- |
|
|
22
|
+
| `CONTEXT_CONTRACT` | method contract ID | `lib/methods.mjs` | Tools MCP gateway / SDK |
|
|
23
|
+
| `CONTEXT_PACKAGE_VERSION` | installed package version | `lib/methods.mjs` | Tools CLI result verification |
|
|
24
|
+
| `requestContext(args)` | authorized operation result | `lib/operations.mjs` → `lib/core/store.mjs` | Public SDK, CLI |
|
|
25
|
+
| `contextGateway` | namespace: `tools`, `validate`, `allowedProjects`, `cliPath` | `lib/methods.mjs`, `index.mjs` | Tools `lib/context-gateway.mjs`, `lib/context-control-run.mjs` |
|
|
26
|
+
| `loadTrustedRuntime()` | namespace: `execute(command,args,native)` | `lib/trusted-run.mjs` → private Core | Tools signed Native adapter |
|
|
27
|
+
| `loadLocalOperator()` | only `runLocalCliCommand()` | `lib/cli-commands.mjs` (other operator utilities private to root composition) | Context CLI only |
|
|
28
|
+
| `subscribeContextApiLog(listener)` | non-authoritative callback / unsubscribe | `lib/api-log.mjs` unified Proxy cut | Tools SDK root → Supervisor Trace Writer |
|
|
29
|
+
|
|
30
|
+
**Important:** `loadTrustedRuntime` and `loadLocalOperator` are callable
|
|
31
|
+
only by trusted adapters in the intended architecture, but JavaScript imports
|
|
32
|
+
**are not an OS security boundary**. Real authorization comes from signed
|
|
33
|
+
messages, same-UID boundaries, native session state, project grants, SQLite
|
|
34
|
+
access control, TTY reviews and Core's CAS/receipt checks.
|
|
35
|
+
|
|
36
|
+
## 2.1 Build-time capability composition
|
|
37
|
+
|
|
38
|
+
`capabilities/<group>.mjs` owns the unique business method descriptors,
|
|
39
|
+
full Schema and execution route; `scripts/build-capabilities.mjs` generates
|
|
40
|
+
a static import manifest and a JSON method catalog. The root SDK composes
|
|
41
|
+
a generic capability router, rather than a per-method `switch`. API
|
|
42
|
+
documentation no longer parses implementation source. All original Core
|
|
43
|
+
CAS, authorization and receipt rules remain authoritative. Independent
|
|
44
|
+
new module routes are read-only and receive scoped read ports; new writers
|
|
45
|
+
require an explicitly reviewed transaction/receipt boundary.
|
|
46
|
+
No new runtime plugin loader, CLI entry or MCP service is introduced.
|
|
47
|
+
|
|
48
|
+
## 3. Public business API and MCP exposure
|
|
49
|
+
|
|
50
|
+
The generated capability catalog served through `lib/methods.mjs` contains **34** current methods; redundant and legacy operations are removed outright. Each method is available through one of
|
|
51
|
+
exactly **two MCP tools**:
|
|
52
|
+
|
|
53
|
+
- **Read:** `chat_loop_context_get` — discovery, Project/Task,
|
|
54
|
+
document/evidence/history, authority, checkpoint and receipt reads.
|
|
55
|
+
- **Write:** `chat_loop_context_mutate` — guarded Project/Task,
|
|
56
|
+
R/P issue/approval, evidence, Start lease, Context patch and checkpoint.
|
|
57
|
+
|
|
58
|
+
`project.list` and `task.list` have one bounded page response shape,
|
|
59
|
+
including when `limit` is omitted (`limit=30`). No legacy array API exists.
|
|
60
|
+
|
|
61
|
+
Exact IDs, modes, input schemas and dispatch routes are owned by
|
|
62
|
+
`capabilities/<group>.mjs` and compiled into the package Method Catalog.
|
|
63
|
+
Call `sdk.methods.list` and `sdk.methods.describe` for the installed SDK
|
|
64
|
+
contract; this prose document is not a parallel API schema authority.
|
|
65
|
+
|
|
66
|
+
Ordinary MCP **never exposes** `permit.consume`, `run.bind.initial`,
|
|
67
|
+
`run.fence`, `run.bind.handoff` or other private Run/Permit actions.
|
|
68
|
+
|
|
69
|
+
### Task creation vs. legacy review-only restrictions
|
|
70
|
+
|
|
71
|
+
Public `task.create` creates a DRAFT task without accepting `context.executionPermission` (`TASK_CREATE_REVIEW_SCOPE_FORBIDDEN`). Stage 01/02 review-round restrictions belong to the Workflow and R/P approval flow, not permanent Task execution scope. This change **does not grant execution**: Stage 03 still requires effective R/P approvals and independent authorization for any filesystem, installation or browser operation. Existing Task records carrying review-only/unknown `executionPermission` are not silently migrated or made executable; `start.reserve`, Native START permit and initial run bind remain fail-closed. A clearly requested review-only engagement should finish at its authorized review scope, without manufacturing a future implementation/Start permission.
|
|
72
|
+
|
|
73
|
+
### Local operator: correct an incorrectly permanent review-only Task
|
|
74
|
+
|
|
75
|
+
`chatloop-context task correct-review-scope <projectId> <taskId> <taskRevision> <approvalRevision> <storeEpoch> <expectedPermission> <operatorEvidenceRef> <writeRequestId>`
|
|
76
|
+
|
|
77
|
+
This is an **independent local operator** action, not an SDK/MCP method
|
|
78
|
+
or a model-executable task mutation. It requires the existing
|
|
79
|
+
`CHAT_LOOP_CONTEXT_ADMIN_ENABLE=1`, exact allowed Project, a real
|
|
80
|
+
interactive TTY confirmation bound to the Task, both revisions, epoch,
|
|
81
|
+
old permission and original-intent evidence reference. Operator must
|
|
82
|
+
independently inspect the original user request and R/P before consenting.
|
|
83
|
+
A normal non-interactive MCP process is rejected. Reconcile an uncertain
|
|
84
|
+
write only with `task scope-correction-receipt <projectId> <storeEpoch> <writeRequestId>`;
|
|
85
|
+
do not repeat the mutation with a new ID.
|
|
86
|
+
|
|
87
|
+
Core rejects mismatched CAS, unapproved or pending R/P, project drift,
|
|
88
|
+
any prior Start lease or permit, active/pending Run, unresolved effects,
|
|
89
|
+
an unknown permission value, or a second correction. It preserves
|
|
90
|
+
original R/P and approved hashes, Project and read-only Workspace bounds,
|
|
91
|
+
Task identity and original objective, and records a durable audit note.
|
|
92
|
+
The receipt `SCOPE_CORRECTED_NOT_OPERATION_AUTHORIZED` **does not authorize**
|
|
93
|
+
installation, download, temporary writes, packing, repository access,
|
|
94
|
+
browser sending or Stage 04; those are independently checked against
|
|
95
|
+
the approved Pn and actual user/operator authorization. The current
|
|
96
|
+
production version may not contain this source-only operator command
|
|
97
|
+
until the Context release is installed and verified.
|
|
98
|
+
|
|
99
|
+
## 4. Provider → consumer matrix (actual source paths)
|
|
100
|
+
|
|
101
|
+
| Provider | API / action consumed | Actual consumer | Boundary and result |
|
|
102
|
+
| --- | --- | --- | --- |
|
|
103
|
+
| Context index — `contextGateway` | `tools, validate, allowedProjects, cliPath` | `packages/local-tools/lib/context-gateway.mjs` | Registers two MCP tools, validates args, spawns pinned executable without shell |
|
|
104
|
+
| Context CLI | `request --json` | Tools `lib/context-gateway.mjs` | One JSON request and one contract-versioned receipt per short-lived process |
|
|
105
|
+
| Context index — `contextGateway` | `allowedProjects` | Tools `lib/context-control-run.mjs` | Verifies Native Project ACL before trusted runtime is opened |
|
|
106
|
+
| Context index — `loadTrustedRuntime` | `execute(command,args,native)` | Tools `lib/context-control-run.mjs` | Signed, session-bound Supervisor IPC; Core Run/Permit CAS |
|
|
107
|
+
| Context CLI | `admin <action>` | Reviewed local operator | Single executable; private `lib/context-cli.mjs` interpreter is not an npm SDK API |
|
|
108
|
+
| Context MCP: Project | `project.authority/open/resolve/material.*` | Project Skill | Project binding, material identity, rules and authority |
|
|
109
|
+
| Context MCP: Review | `document.*`, `approval.*` | Workflow Stage 02/07 | Document issue and approval facts; user-turn capture is external |
|
|
110
|
+
| Context MCP: Task/Context | `task.open`, `context.resume/history/request.status` | Workflow Stage 03–06 | Recovery, checkpoint and UNKNOWN-safe action planning |
|
|
111
|
+
| Context MCP: Tools authorized Provider | `project.authority`, `task.list/open` | Tools `providers/context.mjs` and `lib/context-gateway.mjs` | No legacy Registry API or second business writer |
|
|
112
|
+
| Context CLI | `project init/register/bind`, `task fence-orphan` and others | Local reviewed operator | Filesystem/path, SourceUnit, TTY and durable evidence gates |
|
|
113
|
+
| Context CLI/package | packaged `index.mjs`, `bin/cli.mjs`, `lib/core/**` | Tools release/bundle | Exact file fingerprint verification; no npm subpath |
|
|
114
|
+
|
|
115
|
+
All 34 public operations and the Gateway/Trusted/Operator entrypoints pass the `lib/api-log.mjs` Context adapter backed by the **single public AOP implementation** exported from `@tomflow/chatloop-trace`; domain code does not implement logging. Tools maps payload-free events to Trace v2 fixed `event=context.api` and `api={name,surface,mode}`. Each call has its own `callId=spanId`; `traceId` is inherited from the verified correlation parent when available, otherwise equals `callId`. The SDK does not write a second log database. API observations never replace the SQLite CAS receipt.
|
|
116
|
+
|
|
117
|
+
The authoritative SQLite state owner is **Context Core**; Tools is an
|
|
118
|
+
adapter and Supervisor, not another Context database writer. The Chrome
|
|
119
|
+
Worker/Native is responsible for real Session Owner and browser actions.
|
|
120
|
+
|
|
121
|
+
### Private execution chain (not an MCP method)
|
|
122
|
+
|
|
123
|
+
`Extension Worker → Browser Native Host (context-control) → signed
|
|
124
|
+
context-ipc.mjs → Tools Supervisor (context-control-run.mjs) →
|
|
125
|
+
loadTrustedRuntime() → Context Core → one Project SQLite`.
|
|
126
|
+
|
|
127
|
+
The Tools private handler passes a signed-IPC-verified Native projection into the Context trusted domain facade, which validates project binding, phase, RunRef and CAS. The private handler supports: `permit.consume`,
|
|
128
|
+
`run.bind.initial`, `run.fence`, `run.bind.handoff`,
|
|
129
|
+
`run.restore-same-owner`, `run.fence.terminal`,
|
|
130
|
+
`run.credential.rotate`, `run.fence.cancel`, `run.terminalStatus`,
|
|
131
|
+
`run.reopenStatus`, `run.snapshot`.
|
|
132
|
+
|
|
133
|
+
`run.fence.cancel` is a Native/Worker-only, exact-Session idle Adopt cancellation transaction. It revokes the current writable Run credential, seals permits, records `CANCELLED_NOT_DELIVERED`, and never manufactures Task `DONE` or a `deliveryRef`. A matching Native BLOCKED Owner and verified private `session` Action request are prerequisites; after the Context receipt, Native checks the terminal marker again before allowing the `CANCELLED` Session CAS. Ordinary Context MCP clients cannot invoke this private command. An interrupted or unknown receipt stays BLOCKED pending original-request reconciliation; it is not permission to retry or clear the Owner.
|
|
134
|
+
|
|
135
|
+
The new private V2 `permit.consume(kind:RECOVER_HANDOFF)` and
|
|
136
|
+
`run.restore-fenced-handoff` share the existing Task SQLite/receipt
|
|
137
|
+
transactions, not the V1 `RESERVED` restore. The permit is only
|
|
138
|
+
consumable while the exact Native Owner is `BLOCKED`, and the
|
|
139
|
+
transaction checks the original pending attempt, pinned checkpoint,
|
|
140
|
+
successor generation/RunRef, existing USED Handoff permit, current
|
|
141
|
+
approved R/P, zero unresolved effects, unique unused recovery permit,
|
|
142
|
+
CAS and fresh credential before rebinding the original generation.
|
|
143
|
+
The original Extension `session` Action now has a source-only
|
|
144
|
+
`recover-handoff` route through the Native BLOCKED Owner, Worker
|
|
145
|
+
`NOT_SENT` evidence and the signed Tools Supervisor IPC. The original
|
|
146
|
+
private recovery request generates one credential; a lost ACK must
|
|
147
|
+
reconcile the same request's USED permit, Context binding and Native
|
|
148
|
+
CAS, not mint a second permit. **None of this is run, packaged,
|
|
149
|
+
published or E2E-accepted**; a Context method alone never authorizes
|
|
150
|
+
a browser send or proves that the installed Writer was restored.
|
|
151
|
+
|
|
152
|
+
The existing V1 `run.restore-same-owner` is not a V2 Handoff
|
|
153
|
+
recovery contract: it requires the old Native `RESERVED` phase.
|
|
154
|
+
Its Context transaction independently rejects any already delivered,
|
|
155
|
+
cancelled or unresolved-effect Task before rebinding a Writer, even
|
|
156
|
+
when the original Checkpoint and single-use CONTINUE permit match.
|
|
157
|
+
It also requires the pending Handoff to target exactly the same
|
|
158
|
+
Session's next generation and RunRef; a same-attempt receipt alone
|
|
159
|
+
cannot redirect recovery to a different successor.
|
|
160
|
+
|
|
161
|
+
The Browser Native Host now permits the Worker-used `run.reopenStatus`
|
|
162
|
+
through the same signed private IPC path; it is not a public MCP method.
|
|
163
|
+
For first-Start recovery, `run.terminalStatus` accepts the private
|
|
164
|
+
`startRecoveryLeaseRef` only for a generation-zero Native BLOCKED pointer
|
|
165
|
+
without an active Chat. It returns `UNBOUND_NO_PERMIT` only when the exact
|
|
166
|
+
fresh lease is the sole valid reservation, no prior permit was consumed,
|
|
167
|
+
no writer/unknown effect exists, and current approvals remain valid.
|
|
168
|
+
`start.reserve` rejects a previously consumed initial permit and removes
|
|
169
|
+
expired unused initial leases transactionally; the read-only proof does not
|
|
170
|
+
grant a permit, bind a writer, or replace a Session.
|
|
171
|
+
|
|
172
|
+
For V2 Handoff, the same trusted `run.terminalStatus` accepts
|
|
173
|
+
`expectedHandoffAttemptId` with the independently checked Native
|
|
174
|
+
`PENDING` Owner, or with its exact positive-revision `BLOCKED` Owner
|
|
175
|
+
after the original pre-SEND_BEGIN Native abort fence. This remains a
|
|
176
|
+
read-only proof, never a Start recovery lease or a Writer recovery.
|
|
177
|
+
Context compares the signed original attempt to `pending_attempt`
|
|
178
|
+
inside the SQLite read snapshot and exposes only
|
|
179
|
+
`pendingAttemptMatches: boolean` rather than an ID or credential.
|
|
180
|
+
Native requires this match and the original USED Handoff Permit to
|
|
181
|
+
authorize `send-check` while PENDING, or to confirm the revoked
|
|
182
|
+
`handoff-abort-fence-read-v2` receipt once BLOCKED. No probe permits
|
|
183
|
+
replaying a SEND_BEGIN-unknown effect or reviving Context Writer.
|
|
184
|
+
|
|
185
|
+
## 5. Context → external dependencies (reverse direction)
|
|
186
|
+
|
|
187
|
+
| External owner / dependency | Context call, file or mechanism | Source | Coupling and scope |
|
|
188
|
+
| --- | --- | --- | --- |
|
|
189
|
+
| **Node built-ins** (not an npm dependency) | `node:sqlite`, `node:crypto`, `node:fs`, `node:path`, `node:os`, `node:child_process`, `node:readline/promises`, `node:module/url` | `lib/core/store.mjs`, migration, admin, orphan etc. | SQLite/file security, transactions, hashes, backups, TTY, system checks |
|
|
190
|
+
| **Extension API (declared npm dependency)** | `verifyOrphanOwnerIdle({oldRunRef,projectId})` | `lib/orphan-operator.mjs` → `@tomflow/chatloop-extension` | Official provider verifies its own Native Session and live Extension IDLE, returning bounded evidence |
|
|
191
|
+
| **Process provider (declared npm dependency)** | `psList({all:false})` | `lib/process-inventory.mjs` → `ps-list` | Observable known MCP processes only; snapshots do not authorize migration cutover |
|
|
192
|
+
| **Context Store** | Project-local `context.sqlite` via `lib/project-store.mjs` | `lib/operations.mjs`, `lib/core/store.mjs` | Authoritative State + receipt; **not** a cross-module API |
|
|
193
|
+
|
|
194
|
+
`packages/context/package.json` declares exactly two runtime dependencies:
|
|
195
|
+
`ps-list` for bounded process observation, and
|
|
196
|
+
`@tomflow/chatloop-extension` for its official Owner evidence API.
|
|
197
|
+
All remaining file/SQLite/crypto APIs are provided by Node. This is an
|
|
198
|
+
explicit Provider→Consumer edge: Context no longer constructs the
|
|
199
|
+
Extension install path or reads the Extension-owned Session file directly.
|
|
200
|
+
A process snapshot is never equivalent to a durable stop/fence receipt.
|
|
201
|
+
The migration functions no longer accept a caller-supplied `knownWriters`
|
|
202
|
+
bypass; privileged operator and persistent-state checks remain mandatory.
|
|
203
|
+
|
|
204
|
+
## 6. Core source ownership (one transaction authority)
|
|
205
|
+
|
|
206
|
+
| File | Responsibility |
|
|
207
|
+
| --- | --- |
|
|
208
|
+
| `lib/core/store.mjs` | Open/verify single SQLite DB, schema, WAL, mode, shared auth/CAS/receipt/transaction context |
|
|
209
|
+
| `lib/core/health.mjs` | Store diagnostics, terminal/reopen status, latest checkpoint |
|
|
210
|
+
| `lib/core/migration.mjs` | SourceUnit classification/reconciliation/cutover transactions |
|
|
211
|
+
| `lib/core/project.mjs` | Project identity, authority, Material versions and writes |
|
|
212
|
+
| `lib/core/task.mjs` | Task status, revision and lifecycle |
|
|
213
|
+
| `lib/core/review.mjs` | R/P documents, presentation evidence and approvals |
|
|
214
|
+
| `lib/core/evidence.mjs` | Task evidence references |
|
|
215
|
+
| `lib/core/context.mjs` | Context history, request receipt, UNKNOWN handling, checkpoints and resume |
|
|
216
|
+
| `lib/core/run.mjs` | Lease, Permit, credential, bind/fence/handoff/orphan controls |
|
|
217
|
+
|
|
218
|
+
The root `index.mjs` injects domain factories into Store API ports. `store.mjs`
|
|
219
|
+
assembles them using a **single shared SQLite handle**. Implementation modules
|
|
220
|
+
never import each other; no extra database, service, Owner controller, or
|
|
221
|
+
independent commit/receipt writer is created.
|
|
222
|
+
|
|
223
|
+
## 7. Final-version decisions and exclusions
|
|
224
|
+
|
|
225
|
+
- **No subpath exports or compatibility forwarding modules**; direct
|
|
226
|
+
imports of `lib/*` across npm package boundaries are prohibited.
|
|
227
|
+
- The identical `context.open` alias is gone; `project.open` is the
|
|
228
|
+
single bounded Project summary. No raw `project.get` / `task.get`
|
|
229
|
+
projection is published; consumers use `project.open` / `task.open`.
|
|
230
|
+
- Migration and SourceUnit safeguards remain private to Operator/Core;
|
|
231
|
+
they do **not** create legacy public MCP methods or compatibility aliases.
|
|
232
|
+
- The package exports **no** Extension/Trace/Tools private implementation
|
|
233
|
+
path; Native/Tools import **only `@tomflow/chatloop-context`**.
|
|
234
|
+
- No npm publish, production migration, Chrome E2E or Owner change is
|
|
235
|
+
implied by this source refactor.
|
|
236
|
+
|
|
237
|
+
## 8. Removed/unneeded exports
|
|
238
|
+
|
|
239
|
+
The root Local Operator namespace contains **one** CLI entry function (`runLocalCliCommand`); all other operator functions are private to root composition. The root Trusted Runtime namespace is now **one** `execute` method (was raw Core / path resolver / credential generator). The CLI `project reconcile-receipt` duplicate command is removed; use `project migration-receipt`.
|
|
240
|
+
|
|
241
|
+
The redundant `chatloop-tools context` command is removed; operators must use the single `chatloop-context admin <action>` entry instead. This does not change Store approval, TTY or migration guards.
|
|
242
|
+
|
|
243
|
+
## 9. Enforced implementation boundary (source-level)
|
|
244
|
+
|
|
245
|
+
```text
|
|
246
|
+
@tomflow/chatloop-context
|
|
247
|
+
index.mjs [only npm SDK import entry + API composition]
|
|
248
|
+
|-- Business SDK tier -> Core / project-store / operations
|
|
249
|
+
|-- Trusted tier -> Run/Permit API (signed IPC caller)
|
|
250
|
+
+-- Operator tier -> migration / workspace / cli-commands
|
|
251
|
+
bin/cli.mjs [only npm executable entry]
|
|
252
|
+
+-- index.mjs -> loadLocalOperator().runLocalCliCommand()
|
|
253
|
+
lib/** [private modules, named injected capability contracts]
|
|
254
|
+
+-- Node built-ins / explicitly declared external providers only
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
- Forbidden: `lib/a.mjs` importing `lib/b.mjs`, reverse-importing the npm root from private modules, and `bin/cli.mjs` bypassing the root SDK to import private modules.
|
|
258
|
+
- Allowed: the sole root `index.mjs` loads implementations and injects named capability functions into each module exactly once, with lazy SDK, Trusted and Operator tiers.
|
|
259
|
+
- SQLite ownership: `core/store.mjs` creates the only Store handle and coordinates transaction/CAS/receipt authority. The domain factories receive one shared connection, not separate writers.
|
|
260
|
+
- Security: direct import or dependency injection never grants ACL, operator TTY, Native Owner, signed IPC, or write access.
|
|
261
|
+
- Regression: `test/module-boundary.test.mjs` enforces both npm entrypoints, bans private-module imports, and verifies assembled capability counts and absence of raw SQLite exports. Context/Tools/Native integration tests protect behavior. Node 20 retains catalog discovery without loading SQLite.
|
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
# Context local operator, Legacy and migration procedures (historical reference)
|
|
2
|
+
|
|
3
|
+
This preserves the previous detailed operator/migration procedures. For the current SDK entry,
|
|
4
|
+
Node/runtime requirements, API discovery and up-to-date contract links, begin with [README](../README.md).
|
|
5
|
+
Do not treat older version examples, readiness labels or production-blocked statements below as
|
|
6
|
+
current deployment facts; verify the live connected SDK and SourceUnit authority.
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
Independent Context SDK. Method Catalog supports Node >=20; CLI/Core require Node >=24. Chat Loop Tools and other explicitly
|
|
10
|
+
authorized local adapters use the same versioned Method Catalog and SQLite Core.
|
|
11
|
+
This package is not a Chrome controller, HTTP service or background process.
|
|
12
|
+
|
|
13
|
+
## Project data (target layout, not a production cutover)
|
|
14
|
+
|
|
15
|
+
Each explicitly registered project has one SQLite source of truth:
|
|
16
|
+
~/.chat-loop/context/<projectId>/context.sqlite
|
|
17
|
+
|
|
18
|
+
Optional artifacts/ and backups/ live beside it; no competing project.json,
|
|
19
|
+
current.md, history.md or handoff.md. The user's source repository and AGENTS.md
|
|
20
|
+
are NOT managed or modified by Context. A project may reference authorized
|
|
21
|
+
Workspace roots via Project.sharedContext.workspaceRefs.
|
|
22
|
+
|
|
23
|
+
## SDK method disclosure
|
|
24
|
+
|
|
25
|
+
Use:
|
|
26
|
+
chatloop-context methods list --json
|
|
27
|
+
chatloop-context methods describe project.open
|
|
28
|
+
|
|
29
|
+
Both use lib/methods.mjs, the same catalog that generates ChatGPT MCP inputSchema.
|
|
30
|
+
No hidden run.bind/fence/permit controls are exposed as ordinary SDK methods.
|
|
31
|
+
|
|
32
|
+
Example after an approved pinned installation (future release, not yet published):
|
|
33
|
+
npx --yes --offline --package=@tomflow/chatloop-context@0.1.0 chatloop-context methods list --json
|
|
34
|
+
|
|
35
|
+
Requests take one bounded JSON object from stdin and emit one JSON object on
|
|
36
|
+
stdout. Never place credentials or sensitive project bodies in CLI args or logs:
|
|
37
|
+
echo '{"operation":"sdk.methods.list","group":"project"}' | chatloop-context request --json
|
|
38
|
+
|
|
39
|
+
A trusted local adapter supplies CHAT_LOOP_CONTEXT_ALLOWED_PROJECTS and, if
|
|
40
|
+
needed, CHAT_LOOP_CONTEXT_ROOT (default ~/.chat-loop/context) or an explicit
|
|
41
|
+
CHAT_LOOP_CONTEXT_DB solely for existing legacy Store compatibility.
|
|
42
|
+
The comma-separated Project grant is parsed atomically: invalid, empty or
|
|
43
|
+
duplicate IDs reject the whole grant, including in MCP and Native adapters.
|
|
44
|
+
Use project.list/task.list with limit (1–100) and cursor for bounded pages;
|
|
45
|
+
omitting both keeps the legacy array return. A page is not a cross-request
|
|
46
|
+
snapshot; verify revisions when resuming after concurrent writes.
|
|
47
|
+
|
|
48
|
+
## Reviewed Project registration and Workspace ownership (local operator)
|
|
49
|
+
|
|
50
|
+
The local operator must explicitly enable admin scope, choose the permitted
|
|
51
|
+
Project IDs, and use an **interactive terminal**. The user-reviewed entry
|
|
52
|
+
validates real canonical directories and prompts for an exact action+scope
|
|
53
|
+
confirmation BEFORE creating a Store:
|
|
54
|
+
|
|
55
|
+
CHAT_LOOP_CONTEXT_ADMIN_ENABLE=1 \
|
|
56
|
+
CHAT_LOOP_CONTEXT_ALLOWED_PROJECTS=demo \
|
|
57
|
+
chatloop-context project register demo "Demo project" /confirmed/workspace
|
|
58
|
+
|
|
59
|
+
Additional Workspace roots may be supplied to `register` (up to 16).
|
|
60
|
+
Registration uses a global per-Context-root lock, rejects symlink roots,
|
|
61
|
+
nested/overlapping roots and previously claimed roots, and atomically renames
|
|
62
|
+
a newly staged per-Project SQLite. An existing Project is never overwritten.
|
|
63
|
+
|
|
64
|
+
To replace the **whole** Workspace set on an existing Project, first call
|
|
65
|
+
`project.open` and read its projectRevision and storeEpoch, then explicitly
|
|
66
|
+
run the local operator command (with the same admin grant and TTY confirmation):
|
|
67
|
+
|
|
68
|
+
chatloop-context project bind demo <revision> <storeEpoch> <writeRequestId> /root/a /root/b
|
|
69
|
+
chatloop-context project bind demo <revision> <storeEpoch> <writeRequestId> --clear
|
|
70
|
+
|
|
71
|
+
The second command explicitly clears every Workspace binding. A bind checks
|
|
72
|
+
the original Project identity, CAS revision/epoch, global Project ownership,
|
|
73
|
+
path stability, active execution/Handoff writer fences, then writes one durable
|
|
74
|
+
Core receipt. If the CLI result is lost, use the **same** request ID for a
|
|
75
|
+
read-only operator lookup, never repeat the mutation with a different ID:
|
|
76
|
+
|
|
77
|
+
chatloop-context project receipt demo <storeEpoch> <writeRequestId>
|
|
78
|
+
|
|
79
|
+
The older `project init` remains an explicit *local-admin* compatibility
|
|
80
|
+
command for already approved automated setup; it does **not** itself collect
|
|
81
|
+
a real user-review prompt and must not be offered as the normal first-use flow.
|
|
82
|
+
None of these commands are exposed as ordinary model Context MCP mutations.
|
|
83
|
+
A local TTY/OS-UID operator approval is not cryptographic ChatGPT user
|
|
84
|
+
authentication. Without explicit user authorization, do not infer independent
|
|
85
|
+
approval or claim a completed in-Chat self-service onboarding. For a user-
|
|
86
|
+
delegated Agent migration, label the operator `USER_DELEGATED_AGENT` and retain
|
|
87
|
+
the exact verified source/backup/revision evidence; never describe this as an
|
|
88
|
+
independent human or platform-authenticated approval. None of these operations
|
|
89
|
+
grant Chrome Owner or migrate an existing Legacy Store by themselves.
|
|
90
|
+
|
|
91
|
+
## Offline shared Store extraction (diagnostic ONLY, not a cutover)
|
|
92
|
+
|
|
93
|
+
Before a cutover, use the **read-only** source integrity audit with an explicitly
|
|
94
|
+
granted Project and a verified old Store epoch:
|
|
95
|
+
|
|
96
|
+
CHAT_LOOP_CONTEXT_ALLOWED_PROJECTS=demo \
|
|
97
|
+
chatloop-context project audit-sources demo /private/old/shared.sqlite <sourceEpoch>
|
|
98
|
+
|
|
99
|
+
To inspect a Registry task document that changed since shadow scan, point to
|
|
100
|
+
a verified private Recovery Archive copy of the **original** document:
|
|
101
|
+
|
|
102
|
+
chatloop-context project inspect-reference demo /private/old/shared.sqlite \
|
|
103
|
+
<sourceEpoch> <sourceUnitId> <taskId> /private/archive/task-document.md
|
|
104
|
+
|
|
105
|
+
This is a read-only two-version evidence check: exact Registry SHA and
|
|
106
|
+
task identity, archived document SHA, current document SHA, and a bounded
|
|
107
|
+
insertions-only vs changed-content comparison. It outputs a review-required
|
|
108
|
+
receipt (not a stored approval); `canActivate` and `canExecute` remain false.
|
|
109
|
+
Never rewrite the old Registry to suppress drift.
|
|
110
|
+
|
|
111
|
+
**Reviewed local reconciliation (not SourceUnit activation):** after independently
|
|
112
|
+
reviewing the exact original archive, current document, Project scope and old
|
|
113
|
+
writers, a local terminal operator may run:
|
|
114
|
+
|
|
115
|
+
CHAT_LOOP_CONTEXT_ADMIN_ENABLE=1 CHAT_LOOP_CONTEXT_ALLOWED_PROJECTS=demo \
|
|
116
|
+
chatloop-context project reconcile-reference demo /private/old/shared.sqlite \
|
|
117
|
+
<epoch> <sourceUnitId> <migrationRevision> <taskId> <originalArchiveFile> \
|
|
118
|
+
<currentDocSha256> <operatorReviewRef> <writeRequestId>
|
|
119
|
+
|
|
120
|
+
A real TTY is required and the exact source/old/new hashes and review reference
|
|
121
|
+
must be confirmed. Only insertions-only Task document drift is admitted; other
|
|
122
|
+
content changes need separate review. The Core uses epoch, migration revision
|
|
123
|
+
and durable request receipts, keeps original and current SHA plus original
|
|
124
|
+
archive locator in the SourceUnit, leaves the Registry file unchanged and
|
|
125
|
+
keeps the SourceUnit in SHADOW_RO. It cannot create R/P approvals or Browser
|
|
126
|
+
Owner, or assert the independent old-writer / user-authentication gates.
|
|
127
|
+
For an uncertain result, **query** with the same ID, never resubmit with a new ID:
|
|
128
|
+
|
|
129
|
+
chatloop-context project migration-receipt demo /private/old/shared.sqlite \
|
|
130
|
+
<epoch> <writeRequestId>
|
|
131
|
+
|
|
132
|
+
This interface is a local-operator entry; a TTY under one OS UID is not
|
|
133
|
+
proof of platform-authenticated ChatGPT user approval. By default an autonomous
|
|
134
|
+
agent MUST NOT infer an independent operator decision. When the user expressly
|
|
135
|
+
delegates the precise migration scope in the current conversation, the agent
|
|
136
|
+
may operate the existing TTY path as a **disclosed user-delegated local agent**,
|
|
137
|
+
with exact SourceUnit/hash/revision checks and an immutable private delegation
|
|
138
|
+
audit record. Record `USER_DELEGATED_AGENT`, never `INDEPENDENT_HUMAN` or
|
|
139
|
+
platform-authenticated consent. This delegation does not approve R/P or Owner.
|
|
140
|
+
The audit reads source bytes and Registry-linked Task documents, checks exact
|
|
141
|
+
Project Material hash/path coverage, and distinguishes a changed Registry
|
|
142
|
+
file from drift in a linked task document. Its CLI receipt also includes
|
|
143
|
+
`supportedWriterObservation: {status,pids}` from the same bounded process
|
|
144
|
+
inventory used by `activate` (PID only; never argv). `MATCHED` reports a known
|
|
145
|
+
writer still running; `NO_SUPPORTED_PROCESS_MATCH` is **not proof** that all
|
|
146
|
+
legacy writers were independently fenced, and `UNVERIFIED` means the process
|
|
147
|
+
scan itself failed. It reports mixed CURRENT items still requiring human
|
|
148
|
+
classification, without revealing historical document bodies or treating a
|
|
149
|
+
recovered user Turn as fresh approval. Its `BLOCKED` status intentionally
|
|
150
|
+
includes independent old-writer fencing and release/E2E gates that a local
|
|
151
|
+
file scan cannot prove. It never creates a Store or modifies SourceUnits,
|
|
152
|
+
revisions, permissions, Owner or approvals.
|
|
153
|
+
|
|
154
|
+
**Mixed CURRENT EvidenceOnly classification (local operator only):** when
|
|
155
|
+
the complete, exact historical Markdown bytes are already stored as a
|
|
156
|
+
`LEGACY_UNVERIFIED` Project Material under the canonical source path/hash,
|
|
157
|
+
the operator may explicitly classify a mixed source as historical evidence
|
|
158
|
+
without promoting ANY text to a current Project/Task/R/P fact:
|
|
159
|
+
|
|
160
|
+
CHAT_LOOP_CONTEXT_ADMIN_ENABLE=1 CHAT_LOOP_CONTEXT_ALLOWED_PROJECTS=demo \
|
|
161
|
+
chatloop-context project classify-evidence demo /private/old/shared.sqlite \
|
|
162
|
+
<epoch> <sourceUnitId> <migrationRevision> <sourceSha256> \
|
|
163
|
+
<operatorReviewRef> <writeRequestId>
|
|
164
|
+
|
|
165
|
+
The preflight verifies the physical SourceUnit and the complete stored body,
|
|
166
|
+
and requires exact interactive terminal confirmation. Only the Core's
|
|
167
|
+
`migrationClassify` mutates the SourceUnit manifest with
|
|
168
|
+
`taskContexts=[]`, `projectSharedContext={}` and a reference to the
|
|
169
|
+
entire original content as EvidenceOnly/UNKNOWN; the Unit stays SHADOW_RO.
|
|
170
|
+
This is an intentional human-reviewed historical *disposition*, not a
|
|
171
|
+
claim that the historical statements are current or approved. It does not
|
|
172
|
+
activate a Store, release an old writer, or authorize Chrome Owner.
|
|
173
|
+
For an unknown result use `project migration-receipt` with original epoch and
|
|
174
|
+
writeRequestId. Local TTY is not ChatGPT platform user authentication.
|
|
175
|
+
|
|
176
|
+
An older single SQLite may contain several Projects. Never copy or rename it
|
|
177
|
+
directly into the active per-Project location: doing so leaks unrelated data,
|
|
178
|
+
reuses the old epoch and risks reviving stale runs. The local operator can
|
|
179
|
+
first inspect the legacy Store read-only to obtain the **exact** source
|
|
180
|
+
`storeEpoch` and target `projectRevision`, then, on a separate private
|
|
181
|
+
target root and with explicit real TTY confirmation, use:
|
|
182
|
+
|
|
183
|
+
CHAT_LOOP_CONTEXT_ROOT=/private/review-target \\
|
|
184
|
+
CHAT_LOOP_CONTEXT_ALLOWED_PROJECTS=demo \\
|
|
185
|
+
CHAT_LOOP_CONTEXT_ADMIN_ENABLE=1 \\
|
|
186
|
+
chatloop-context project stage-diagnostic demo /private/old/shared.sqlite <sourceEpoch> <projectRevision>
|
|
187
|
+
|
|
188
|
+
This action reads the source through a SQLite online snapshot, selects ONLY
|
|
189
|
+
the named Project and its scoped rows, retains their exact Task/Material/
|
|
190
|
+
SourceUnit history and old-epoch receipts, then strips runnable leases,
|
|
191
|
+
permits and writer credentials. It vacuums foreign Project content from the
|
|
192
|
+
new database and checks the physical row counts, integrity and ownership
|
|
193
|
+
before atomically publishing the result. A private `migration-diagnostic.json`
|
|
194
|
+
receipt names the old/new epochs and counts but is **not** a second active
|
|
195
|
+
Context authority or a retained full-Store backup.
|
|
196
|
+
|
|
197
|
+
The resulting Project is always `DIAGNOSTIC_ONLY`, with a new epoch,
|
|
198
|
+
`canExecute=false` and `approvalsRevalidated=false`. Old receipts cannot
|
|
199
|
+
replay under the new epoch. No SourceUnit becomes `MANAGED_RW`, and no
|
|
200
|
+
Task/Run, browser Owner or previously observed R/P approval gains authority.
|
|
201
|
+
The source is left untouched. An invalid SourceUnit, unexpected schema,
|
|
202
|
+
stale revision, missing operator approval or existing target fails closed;
|
|
203
|
+
incomplete staging is removed. This command is not exposed through MCP.
|
|
204
|
+
|
|
205
|
+
## Reviewed single-Project release (local operator, not MCP)
|
|
206
|
+
|
|
207
|
+
A diagnostic branch is **never** promoted. A separate terminal-only release
|
|
208
|
+
works exclusively with an already reviewed legacy SQLite containing **exactly
|
|
209
|
+
one Project**. The existing `project audit-sources` must show source hashes,
|
|
210
|
+
reference checks, mixed evidence and bodies reviewed, and every SourceUnit
|
|
211
|
+
must already be `MANAGED_RW`. All known Gateway writers must be stopped, any
|
|
212
|
+
unknown legacy clients independently fenced, and all running Task leases/
|
|
213
|
+
permits/UNKNOWN effects reconciled before sealing. If any requirement fails,
|
|
214
|
+
do not run these commands.
|
|
215
|
+
|
|
216
|
+
With `CHAT_LOOP_CONTEXT_ADMIN_ENABLE=1` and a single explicit Project grant,
|
|
217
|
+
and **without** `CHAT_LOOP_CONTEXT_DB`, the local operator first confirms
|
|
218
|
+
the exact source Epoch/revision, backup path and output receipt in a real TTY:
|
|
219
|
+
|
|
220
|
+
chatloop-context project seal-source <projectId> <sourceDb> <epoch> \
|
|
221
|
+
<projectRevision> <privateBackup.sqlite> <privateSeal.json>
|
|
222
|
+
|
|
223
|
+
Sealing makes a fresh private SQLite online backup, verifies the source again
|
|
224
|
+
under an exclusive write transaction, and durably sets the single old Store
|
|
225
|
+
to `CUTOVER_FENCED`. The old Store then rejects ordinary and internal writes
|
|
226
|
+
even when the old Epoch is supplied. This is **not** SourceUnit approval and
|
|
227
|
+
does not restore any Browser Owner. If the command reports UNKNOWN, inspect
|
|
228
|
+
the old Store mode and original private receipt; never remove the fence or
|
|
229
|
+
retry with a new Project/backup path.
|
|
230
|
+
|
|
231
|
+
Only when the seal receipt and its SHA-256 are independently verified, the
|
|
232
|
+
operator may separately confirm:
|
|
233
|
+
|
|
234
|
+
chatloop-context project publish-managed <projectId> <sourceDb> <epoch> \
|
|
235
|
+
<projectRevision> <privateSeal.json> <sealSha256>
|
|
236
|
+
|
|
237
|
+
Publication accepts only a sealed, **single-Project** source, exact backup
|
|
238
|
+
hash, unchanged logical source hash, all reviewed SourceUnits and no known
|
|
239
|
+
live MCP writer. It creates a new-Epoch `ACTIVE` single-Project SQLite under
|
|
240
|
+
the canonical Context root, with an atomic directory rename, zero foreign
|
|
241
|
+
projects, zero runnable permits/leases and **zero inherited R/P approvals or
|
|
242
|
+
run credentials**. The original old Store stays `CUTOVER_FENCED`; no dual
|
|
243
|
+
write. The published Project can use Context business writes, but its old
|
|
244
|
+
approvals are untrusted: Workspace binding and **fresh** R/P presentation,
|
|
245
|
+
confirmation, Native Owner and Chrome E2E must each be validated separately.
|
|
246
|
+
The response deliberately sets `canExecute:false`.
|
|
247
|
+
|
|
248
|
+
If publication fails after sealing, preserve the sealed source, existing
|
|
249
|
+
private backup and seal receipt for offline recovery; never copy/rename a
|
|
250
|
+
`DIAGNOSTIC_ONLY` Store into production or flip `storeMode` directly.
|
|
251
|
+
The CLI rejects non-TTY callers and the module is not exposed via ordinary
|
|
252
|
+
MCP. Same-UID local terminal confirmation alone is **not** proof of an
|
|
253
|
+
independent ChatGPT user authorization. Exception: a current explicit user
|
|
254
|
+
instruction can delegate a specific Project cutover to an Agent, which may
|
|
255
|
+
operate the local TTY as `USER_DELEGATED_AGENT` after recording the source
|
|
256
|
+
identities, hashes, revisions, physical writer fence, backup and restoration
|
|
257
|
+
evidence. The resulting review is delegated, **not independently human-verified**.
|
|
258
|
+
Do not weaken the actual Core CAS, offline backup, old-writer check, Legacy
|
|
259
|
+
fence, R/P approval, UNKNOWN-send or browser Owner guards.
|
|
260
|
+
|
|
261
|
+
**Production remains BLOCKED** until the physical source hashes, mixed
|
|
262
|
+
CURRENT ownership, old writers and true operator approval have been reviewed,
|
|
263
|
+
old app/Native/Registry clients fenced, fresh backup plus recovery tested and
|
|
264
|
+
the release/real Chrome E2E gates passed. See P0-02 in
|
|
265
|
+
`docs/CONTEXT.md`(现行)及 `git show 5ec21b33e9e4:docs/research/chat-loop-context-cli-architecture-20261109.md`(历史).
|
|
266
|
+
|
|
267
|
+
## Safety
|
|
268
|
+
|
|
269
|
+
Writes use expectedStoreEpoch, revision CAS and durable writeRequestId.
|
|
270
|
+
Unknown results must be checked with the SAME request ID; never blindly
|
|
271
|
+
resubmit with another ID. Active-run holder controls live outside ordinary
|
|
272
|
+
MCP/CLI mutations in the restricted Worker→Native adapter. An SDK business
|
|
273
|
+
checkpoint never grants Browser Owner. One OS UID is not per-Chat isolation.
|
|
274
|
+
|
|
275
|
+
No serve, Socket, HTTP API, second Tunnel or per-project daemon. The real
|
|
276
|
+
legacy Context and UNKNOWN Chrome Owner remain unchanged until explicit
|
|
277
|
+
migration and recovery approval.
|