@tiangong-lca/cli 0.1.0 → 0.1.2

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 (159) hide show
  1. package/README.md +58 -6
  2. package/dist/src/batch.d.ts +6 -0
  3. package/dist/src/batch.js +6 -0
  4. package/dist/src/batch.js.map +1 -0
  5. package/dist/src/cli.d.ts +161 -0
  6. package/dist/src/cli.js +130 -0
  7. package/dist/src/cli.js.map +1 -1
  8. package/dist/src/command-spec.d.ts +90 -0
  9. package/dist/src/command-spec.js +400 -0
  10. package/dist/src/command-spec.js.map +1 -0
  11. package/dist/src/lib/artifacts.d.ts +9 -0
  12. package/dist/src/lib/auth-identity-receipt.d.ts +160 -0
  13. package/dist/src/lib/auth-identity-receipt.js +634 -0
  14. package/dist/src/lib/auth-identity-receipt.js.map +1 -0
  15. package/dist/src/lib/batch/attempt-recovery.d.ts +12 -0
  16. package/dist/src/lib/batch/attempt-recovery.js +183 -0
  17. package/dist/src/lib/batch/attempt-recovery.js.map +1 -0
  18. package/dist/src/lib/batch/canonical-contracts.d.ts +21 -0
  19. package/dist/src/lib/batch/canonical-contracts.js +180 -0
  20. package/dist/src/lib/batch/canonical-contracts.js.map +1 -0
  21. package/dist/src/lib/batch/engine.d.ts +2 -0
  22. package/dist/src/lib/batch/engine.js +294 -0
  23. package/dist/src/lib/batch/engine.js.map +1 -0
  24. package/dist/src/lib/batch/errors.d.ts +51 -0
  25. package/dist/src/lib/batch/errors.js +81 -0
  26. package/dist/src/lib/batch/errors.js.map +1 -0
  27. package/dist/src/lib/batch/item-projection.d.ts +10 -0
  28. package/dist/src/lib/batch/item-projection.js +118 -0
  29. package/dist/src/lib/batch/item-projection.js.map +1 -0
  30. package/dist/src/lib/batch/run-lock.d.ts +4 -0
  31. package/dist/src/lib/batch/run-lock.js +155 -0
  32. package/dist/src/lib/batch/run-lock.js.map +1 -0
  33. package/dist/src/lib/batch/scheduler-runtime.d.ts +29 -0
  34. package/dist/src/lib/batch/scheduler-runtime.js +114 -0
  35. package/dist/src/lib/batch/scheduler-runtime.js.map +1 -0
  36. package/dist/src/lib/batch/types.d.ts +183 -0
  37. package/dist/src/lib/batch/types.js +2 -0
  38. package/dist/src/lib/batch/types.js.map +1 -0
  39. package/dist/src/lib/dataset-author.d.ts +39 -0
  40. package/dist/src/lib/dataset-bilingual.d.ts +165 -0
  41. package/dist/src/lib/dataset-classification.d.ts +279 -0
  42. package/dist/src/lib/dataset-command.d.ts +53 -0
  43. package/dist/src/lib/dataset-contract.d.ts +82 -0
  44. package/dist/src/lib/dataset-curation-queue.d.ts +219 -0
  45. package/dist/src/lib/dataset-evidence-search.d.ts +134 -0
  46. package/dist/src/lib/dataset-import-lca.d.ts +136 -0
  47. package/dist/src/lib/dataset-local.d.ts +23 -0
  48. package/dist/src/lib/dataset-maintenance-alias-request.d.ts +12 -0
  49. package/dist/src/lib/dataset-maintenance-alias-rewrite.d.ts +111 -0
  50. package/dist/src/lib/dataset-maintenance-apply.d.ts +458 -0
  51. package/dist/src/lib/dataset-maintenance-clear-account.d.ts +161 -0
  52. package/dist/src/lib/dataset-maintenance-contract.d.ts +317 -0
  53. package/dist/src/lib/dataset-maintenance-derivatives.d.ts +48 -0
  54. package/dist/src/lib/dataset-maintenance-flow-identity-approval-claim.d.ts +50 -0
  55. package/dist/src/lib/dataset-maintenance-flow-identity-capture.d.ts +110 -0
  56. package/dist/src/lib/dataset-maintenance-flow-identity-command.d.ts +15 -0
  57. package/dist/src/lib/dataset-maintenance-flow-identity-contract.d.ts +387 -0
  58. package/dist/src/lib/dataset-maintenance-flow-identity-execution-contract.d.ts +456 -0
  59. package/dist/src/lib/dataset-maintenance-flow-identity-freeze.d.ts +99 -0
  60. package/dist/src/lib/dataset-maintenance-flow-identity-plan.d.ts +85 -0
  61. package/dist/src/lib/dataset-maintenance-flow-identity-recovery.d.ts +268 -0
  62. package/dist/src/lib/dataset-maintenance-flow-identity-run.d.ts +123 -0
  63. package/dist/src/lib/dataset-maintenance-flow-identity-seal.d.ts +50 -0
  64. package/dist/src/lib/dataset-maintenance-flow-identity-verify.d.ts +85 -0
  65. package/dist/src/lib/dataset-maintenance-flow-identity-wire.d.ts +32 -0
  66. package/dist/src/lib/dataset-maintenance-pagination.d.ts +58 -0
  67. package/dist/src/lib/dataset-maintenance-plan.d.ts +40 -0
  68. package/dist/src/lib/dataset-maintenance-protected-artifacts.d.ts +16 -0
  69. package/dist/src/lib/dataset-maintenance-protected-before.d.ts +71 -0
  70. package/dist/src/lib/dataset-maintenance-protected-contract.d.ts +385 -0
  71. package/dist/src/lib/dataset-maintenance-protected-freeze.d.ts +148 -0
  72. package/dist/src/lib/dataset-maintenance-protected-preparation.d.ts +76 -0
  73. package/dist/src/lib/dataset-maintenance-protected-run.d.ts +252 -0
  74. package/dist/src/lib/dataset-maintenance-protected-seal.d.ts +93 -0
  75. package/dist/src/lib/dataset-maintenance-protected-toolchain.d.ts +31 -0
  76. package/dist/src/lib/dataset-maintenance-protected-verify.d.ts +99 -0
  77. package/dist/src/lib/dataset-maintenance-remote.d.ts +212 -0
  78. package/dist/src/lib/dataset-maintenance-support-validation.d.ts +18 -0
  79. package/dist/src/lib/dataset-maintenance-verify.d.ts +102 -0
  80. package/dist/src/lib/dataset-patch.d.ts +193 -0
  81. package/dist/src/lib/dataset-references-rewrite.d.ts +77 -0
  82. package/dist/src/lib/dataset-remote-refresh.d.ts +64 -0
  83. package/dist/src/lib/dataset-remote-verify.d.ts +168 -0
  84. package/dist/src/lib/dataset-save-draft-run.d.ts +283 -0
  85. package/dist/src/lib/dataset-save-draft-run.js +54 -21
  86. package/dist/src/lib/dataset-save-draft-run.js.map +1 -1
  87. package/dist/src/lib/dataset-source-upload-attachments.d.ts +109 -0
  88. package/dist/src/lib/dataset-validate.d.ts +62 -0
  89. package/dist/src/lib/dotenv.d.ts +6 -0
  90. package/dist/src/lib/env.d.ts +59 -0
  91. package/dist/src/lib/errors.d.ts +18 -0
  92. package/dist/src/lib/flow-build-alias-map.d.ts +80 -0
  93. package/dist/src/lib/flow-fetch-rows.d.ts +70 -0
  94. package/dist/src/lib/flow-get.d.ts +35 -0
  95. package/dist/src/lib/flow-governance.d.ts +22 -0
  96. package/dist/src/lib/flow-list.d.ts +57 -0
  97. package/dist/src/lib/flow-materialize-decisions.d.ts +67 -0
  98. package/dist/src/lib/flow-payload-validation.d.ts +32 -0
  99. package/dist/src/lib/flow-publish-reviewed-data.d.ts +262 -0
  100. package/dist/src/lib/flow-publish-version.d.ts +193 -0
  101. package/dist/src/lib/flow-qa.d.ts +289 -0
  102. package/dist/src/lib/flow-read.d.ts +70 -0
  103. package/dist/src/lib/flow-regen-product.d.ts +431 -0
  104. package/dist/src/lib/flow-remediate.d.ts +133 -0
  105. package/dist/src/lib/http.d.ts +25 -0
  106. package/dist/src/lib/http.js.map +1 -1
  107. package/dist/src/lib/identity-preflight.d.ts +235 -0
  108. package/dist/src/lib/io.d.ts +2 -0
  109. package/dist/src/lib/kb-search.d.ts +23 -0
  110. package/dist/src/lib/lca-release.d.ts +105 -0
  111. package/dist/src/lib/lifecyclemodel-auto-build.d.ts +223 -0
  112. package/dist/src/lib/lifecyclemodel-bundle-save.d.ts +71 -0
  113. package/dist/src/lib/lifecyclemodel-graph.d.ts +91 -0
  114. package/dist/src/lib/lifecyclemodel-orchestrate.d.ts +349 -0
  115. package/dist/src/lib/lifecyclemodel-publish-build.d.ts +77 -0
  116. package/dist/src/lib/lifecyclemodel-publish-resulting-process.d.ts +27 -0
  117. package/dist/src/lib/lifecyclemodel-qa.d.ts +206 -0
  118. package/dist/src/lib/lifecyclemodel-resulting-process.d.ts +204 -0
  119. package/dist/src/lib/lifecyclemodel-save-draft-run.d.ts +96 -0
  120. package/dist/src/lib/lifecyclemodel-validate-build.d.ts +78 -0
  121. package/dist/src/lib/llm.d.ts +51 -0
  122. package/dist/src/lib/package-version.d.ts +3 -0
  123. package/dist/src/lib/process-auto-build.d.ts +168 -0
  124. package/dist/src/lib/process-batch-build.d.ts +97 -0
  125. package/dist/src/lib/process-dedup-review.d.ts +253 -0
  126. package/dist/src/lib/process-flow-build-plan.d.ts +108 -0
  127. package/dist/src/lib/process-get.d.ts +26 -0
  128. package/dist/src/lib/process-list.d.ts +87 -0
  129. package/dist/src/lib/process-payload-validation.d.ts +27 -0
  130. package/dist/src/lib/process-publish-build.d.ts +148 -0
  131. package/dist/src/lib/process-qa.d.ts +243 -0
  132. package/dist/src/lib/process-refresh-references.d.ts +179 -0
  133. package/dist/src/lib/process-required-fields.d.ts +142 -0
  134. package/dist/src/lib/process-resume-build.d.ts +77 -0
  135. package/dist/src/lib/process-save-draft-run.d.ts +72 -0
  136. package/dist/src/lib/process-save-draft.d.ts +53 -0
  137. package/dist/src/lib/process-scope-statistics.d.ts +210 -0
  138. package/dist/src/lib/process-verify-rows.d.ts +71 -0
  139. package/dist/src/lib/publish.d.ts +219 -0
  140. package/dist/src/lib/remote.d.ts +19 -0
  141. package/dist/src/lib/run.d.ts +60 -0
  142. package/dist/src/lib/runtime-rulesets.d.ts +29 -0
  143. package/dist/src/lib/state-lock.d.ts +25 -0
  144. package/dist/src/lib/state-lock.js +23 -1
  145. package/dist/src/lib/state-lock.js.map +1 -1
  146. package/dist/src/lib/supabase-client.d.ts +47 -0
  147. package/dist/src/lib/supabase-data-api-contract.d.ts +304 -0
  148. package/dist/src/lib/supabase-data-api-replay.d.ts +74 -0
  149. package/dist/src/lib/supabase-json-ordered-write.d.ts +65 -0
  150. package/dist/src/lib/supabase-rest.d.ts +26 -0
  151. package/dist/src/lib/supabase-session.d.ts +115 -0
  152. package/dist/src/lib/tidas-languages.d.ts +3 -0
  153. package/dist/src/lib/tidas-sdk-package-validator.d.ts +111 -0
  154. package/dist/src/lib/tidas-sdk-validation.d.ts +42 -0
  155. package/dist/src/lib/unstructured.d.ts +32 -0
  156. package/dist/src/lib/user-api-key.d.ts +16 -0
  157. package/dist/src/lib/validation.d.ts +82 -0
  158. package/dist/src/main.d.ts +4 -0
  159. package/package.json +17 -3
package/README.md CHANGED
@@ -19,23 +19,40 @@ checkPaths:
19
19
  - bin/**
20
20
  - src/cli.ts
21
21
  - src/main.ts
22
+ - src/batch.ts
23
+ - src/command-spec.ts
24
+ - src/lib/auth-identity-receipt.ts
22
25
  - src/lib/lca-release.ts
26
+ - scripts/run-auth-identity-production-case.ts
27
+ - test/auth-identity*.test.ts
23
28
  - test/lca-release*.test.ts
24
- lastReviewedAt: 2026-08-25
25
- lastReviewedCommit: 9078fe123e5909b680f27af1af1d2018bcd02826
26
- lastReviewedNote: 'Reviewed for Issue #226: the public package guide identifies the 0.1.0 pnpm/TypeScript 7 compatibility release while the tarball remains package-manager neutral.'
29
+ lastReviewedAt: 2026-08-26
30
+ lastReviewedCommit: b9a99011fcc1d7388355e66649113ac5d4a7a9c8
31
+ lastReviewedNote: 'Reviewed for Issue #237: identifies 0.1.2 as the release-only package identity for the bounded pnpm 11.24 public API while runtime, exports, dependencies, and release behavior stay fixed.'
27
32
  ---
28
33
 
29
34
  # TianGong LCA CLI
30
35
 
31
- Package: `@tiangong-lca/cli` Executable: `tiangong-lca` Current package version: `0.1.0` Node: `24.x`
36
+ Package: `@tiangong-lca/cli` Executable: `tiangong-lca` Current package version: `0.1.2` Node: `24.19.0`
32
37
 
33
- Repository development is single-track on pnpm `11.23.0` and TypeScript `7.0.2`. The published package remains a clean, package-manager-neutral consumer artifact: it contains runtime files only, not pnpm, TypeScript, Oxlint, tests, source-only tooling, or repository lockfiles.
38
+ Repository development is single-track on pnpm `11.24.0` and TypeScript `7.0.2`. The published package remains a clean, package-manager-neutral consumer artifact: it contains runtime files only, not pnpm, TypeScript, Oxlint, tests, source-only tooling, or repository lockfiles.
34
39
 
35
40
  Review note, 2026-08-25: Issue #224 migrates repository development and release automation to the sole root `pnpm-workspace.yaml` / `pnpm-lock.yaml`, TypeScript 7.0.2, and type-aware Oxlint on Node 24. The feature change deliberately keeps version 0.0.33. A separate release-only PR should prepare 0.1.0 after the toolchain change merges and its full package/coverage/release gates pass.
36
41
 
37
42
  Review note, 2026-08-25: Issue #226 publishes that 0.1.0 compatibility boundary after merged PR #225. Version metadata and public release evidence advance to 0.1.0; the runtime JavaScript/assets surface, command behavior, Node 24 runtime, pnpm/TypeScript 7 development baseline, native pnpm Trusted Publishing/provenance, and exact released-commit workspace handoff remain unchanged from the reviewed feature delivery.
38
43
 
44
+ Review note, 2026-08-25: Issue #228 implements `auth identity-receipt` as a bounded read-only current-user proof. It checks expected project intent before session work, verifies the live user through `/auth/v1/user`, allows one auth-refresh replay after 401/403, and emits an exact-key canonical receipt without API keys, tokens, full email addresses, session paths, or credential-derived fingerprints. Production callers must pass both expected assertions and accept only `assertions.mode="intent-bound"`.
45
+
46
+ Review note, 2026-08-25: Issue #230 publishes the merged identity receipt as `@tiangong-lca/cli@0.1.1`. Runtime logic and published dependencies remain unchanged; the sole pnpm lock changes only for exact dev-only `sigstore@5.0.0`. Local metadata, engines, and every workflow converge on Node 24.19.0. Release automation asserts actual platform/architecture across the reusable four-platform pre-tag matrix and provides `pnpm release:verify-published` for cryptographic Fulcio/CT/Rekor provenance, registry signatures, actual tarball integrity, isolated user/global package-manager configuration, exact pnpm 11.23.0, and credential-free bin/ESM/CJS consumer proof.
47
+
48
+ Review note, 2026-08-26: Issue #232 adds two supported typed library subpaths without changing version `0.1.1`: `@tiangong-lca/cli/command-spec` owns the byte-compatible `tiangong-foundry.command-spec.v1` authority and shell-free execution adapters, while `@tiangong-lca/cli/batch` owns identity/content/policy-bound scheduling, resource-aware exclusive keys, explicit mutation readback recovery, and host-safe run-directory locks. Claim-time identity drift—including a throwing identity getter—is a stable item failure/event and every already-started worker is drained before return. Any escaping infrastructure callback error records one fatal cause, immediately closes new claims, drains only already-claimed workers, and rejects after all worker promises settle. A blocked resource stays unclaimed and consumes no worker while a later free resource may run; per-resource FIFO cursors and a private minimum-ready heap keep ordinary scheduling near `O(n log k)` rather than repeatedly scanning all pending items. Run-lock PID/host/timestamp ownership is derived internally and cannot be supplied by callers. Every public timer-backed timeout, poll, or retry delay is bounded by Node's `2_147_483_647ms` maximum. The package root remains unsupported and publication requires a later release-only delivery.
49
+
50
+ Review note, 2026-08-26: Issue #233 changes only the internal shape of the batch subpath. `src/batch.ts` is now a 62-line facade over bounded, acyclic modules for types, errors/contracts, locking, projection, scheduler runtime, attempts/recovery, and the engine. Executable budgets keep the facade below 400 lines and every internal module below 800 while locking exact public export identities, declarations, errors, event/result bytes, packed consumers, and dataset dogfood. Package version, dependencies, pnpm-only TypeScript 7 development, and runtime behavior are unchanged.
51
+
52
+ Review note, 2026-08-26: Issue #236 changes only the repository and clean-consumer package-manager requirement from exact pnpm 11.23.0 to 11.24.0. The sole root lock requires no byte change under pnpm 11.24.0; Node 24.19.0, TypeScript 7.0.2, package version 0.1.1, public commands and exports, dependencies, tags, provenance, and publication remain unchanged, with no npm/Yarn fallback.
53
+
54
+ Review note, 2026-08-26: Issue #237 releases the already reviewed bounded CommandSpec/batch runtime and pnpm 11.24 toolchain as `@tiangong-lca/cli@0.1.2`. The release changes only package metadata and four live CLI-version fixtures; runtime files, public subpaths and object identities, dependencies, the sole lock, Node 24.19.0, TypeScript 7.0.2, package-manager-neutral consumers, and automated provenance path remain unchanged.
55
+
39
56
  Review note, 2026-07-12: `dataset maintenance plan/apply/verify` provides current-user RLS-scoped exact-row maintenance with immutable plans, explicit approval, per-action logs, platform audit correlation, and independent readback. `merge-support-aliases` now runs only in `target_mode=owner_draft`: source/target support and all changed rows stay private `state_code=0`; publication is a separate future workflow.
40
57
 
41
58
  Review note, 2026-07-13: maintenance scans now prove exact-count pagination even when PostgREST returns fewer rows than the requested `--page-size`. An incomplete or inconsistent scan fails before artifacts, approval, or mutation; under stable filtered membership/order the proof represents a complete ordered multi-request traversal, not one transaction-level/MVCC snapshot.
@@ -87,6 +104,16 @@ pnpm build
87
104
  node ./bin/tiangong-lca.js --help
88
105
  ```
89
106
 
107
+ ## Typed library subpaths
108
+
109
+ The package exposes only these supported module APIs in addition to the executable launcher subpath:
110
+
111
+ - `@tiangong-lca/cli/command-spec` parses, creates, artifact-binds, and executes exact `tiangong-foundry.command-spec.v1` objects. `display` is diagnostic only; executable plus argv and binding bytes/SHA-256 form the canonical authority. Sync and async execution always use `shell:false`; async callers may inject resolver, clock, sleep, spawn, timeout, and abort adapters. `timeoutMs` must fit Node's maximum timer delay.
112
+ - `@tiangong-lca/cli/batch` runs bounded generic work with an overall run contract and a required per-item `{ item_id, content_sha256, policy_sha256 }` contract. Every identity/content/policy/resource projection is validated before work starts and rechecked before resumed acceptance or a fresh claim. Identity changes or getter failures emit `item_identity_drift` with `BatchItemIdentityDriftError`, execute zero attempts, and do not let the batch return before other in-flight items drain. An escaping scheduler/event/stop callback records the first infrastructure error, closes further claims, awaits all worker settlements, then rejects. Input order, truthful resource-aware claim order, completion order, pause/stop behavior, awaited monotonic events, and exception isolation are explicit. Optional exclusive keys serialize only matching resources; a blocked key remains unclaimed and consumes no worker while later free keys may use the public ceiling of 64 workers. Per-resource FIFO queues expose only their head through an ordered binary min-heap, giving near `O(n log k)` ready scheduling for `k` resources.
113
+ - Mutation batches reject automatic retry. A consumed or ambiguous mutation can continue only through an explicitly supplied readback-recovery callback; resume requires exact run and item contracts, and each resumed or rejected result participates in stop decisions before fresh claims. Retry/backoff values must be non-negative safe integers within Node's timer limit. Exclusive keys must be runtime strings. `withBatchRunLock` gives one canonical run directory one cross-process lock domain, permits reentrancy only from a still-live scope owned by the current holder, keeps the top-level promise pending until detached nested scopes drain, rejects completed-context reentry into a later owner, preserves live or foreign-host locks, and stale-recovers only a same-host dead PID. Public lock callers cannot set PID, host, or ownership time; timeout/poll values are non-negative safe integers within Node's timer limit.
114
+
115
+ The packed ESM, CJS dynamic-import, and TypeScript consumers exercise both public subpaths and generated declarations. Deep imports and `import '@tiangong-lca/cli'` remain unsupported.
116
+
90
117
  ## Env
91
118
 
92
119
  Remote commands require:
@@ -112,6 +139,31 @@ TIANGONG_LCA_DISABLE_SESSION_CACHE=false
112
139
  TIANGONG_LCA_FORCE_REAUTH=false
113
140
  ```
114
141
 
142
+ ## Auth Identity Receipt
143
+
144
+ Use the identity receipt before a production-backed case or any later owner-draft write gate:
145
+
146
+ ```text
147
+ tiangong-lca auth identity-receipt --expected-project-ref <project-ref> --expected-user-id <user-id> --json
148
+ ```
149
+
150
+ The command performs no dataset write. It exchanges the normal user API key for a session, checks the canonical Supabase project, and makes a bounded live `GET /auth/v1/user`. A cached token that receives `401` or `403` may be refreshed and retried exactly once; all other transport or response failures are terminal. A valid production guard requires:
151
+
152
+ - `schema` exactly `tiangong-lca.auth-identity-receipt.v1`;
153
+ - `status: "passed"`, `operation: "current-user-read"`, and `remote_write_mode: "read-only"`;
154
+ - exact expected project/user values with `assertions.mode: "intent-bound"` and `requested_count: 2`;
155
+ - a fresh capture time and a valid recomputed `receipt_scope_sha256`.
156
+
157
+ Calling without expectations is allowed for discovery but produces `assertions.mode: "observed"`; it is not an authorization guard. The safe display email is masked and must not be used as the account key. The receipt deliberately excludes credentials, full email, session-file details, raw response metadata, and all credential/token/path-derived fingerprints.
158
+
159
+ For the explicitly authorized local production read case from a validated repository checkout, invoke the narrow TypeScript runner with a new private output directory:
160
+
161
+ ```text
162
+ pnpm case:auth-identity:production -- --env-file <data-foundry-ignored-.env> --expected-project-ref <project-ref> --expected-user-id <user-id> --out-dir <new-private-case-directory>
163
+ ```
164
+
165
+ The runner reads only `TIANGONG_LCA_API_BASE_URL`, `TIANGONG_LCA_SUPABASE_PUBLISHABLE_KEY`, and `TIANGONG_LCA_TEST_API_KEY`; the last is mapped to the child process's standard API-key variable. It does not accept an alternate CLI path. The pnpm command first performs a clean TS7 build without the production env. Its plain-Node runner then single-reads source/config/lock and the freshly generated `dist/src/**/*.js`, hashes the source tree, runner, runtime, exact entrypoint, and pnpm lock, and copies those exact built buffers into a private snapshot before exposing the key. It forces reauthentication with session cache disabled, runs only the built snapshot from an exclusively created clean directory with an argv array and `shell:false`, cleans the snapshot before publishing success artifacts, and persists only the parsed receipt and case manifest. POSIX creates the case directory as `0700` and files as `0600`; Windows inherits ACLs from the caller-selected parent, so use a user-restricted parent because mode bits are not an ACL guarantee. The runner never stores raw child stdout/stderr and is intentionally not wired to CI secrets. This receipt is locally hash-verifiable, not server-signed attestation.
166
+
115
167
  ## LCI/LCIA Data Release
116
168
 
117
169
  The `release` command family is the authenticated transport used by the standalone release control plane. It does not introduce a TIDAS schema variant: result packages reuse the existing Process exchange structure for LCI and the existing Process LCIA result fields, with a LifecycleModel referencing the resulting Process.
@@ -419,7 +471,7 @@ For `process build-plan` and `flow build-plan`, canonical payloads embedded in t
419
471
 
420
472
  For `process save-draft`, canonical process payloads are validated locally with `ProcessSchema` before any `--commit` write. Schema-invalid rows remain in `outputs/save-draft-rpc/failures.jsonl` instead of being persisted. Batch import callers should pass `--target-user-id`; the CLI then verifies the current auth session and any visible draft owner before writing, while downstream readback verification still proves the final owner and payload.
421
473
 
422
- For `dataset save-draft --execution-contract`, the JSON contract uses schema `dataset-save-draft-execution-contract.v1` and supplies `execution_id`, `project_ref`, an exact owner (`user_id`, lowercase `email`, `state_code: 0`), and ordered actions. Each action binds `action_id`, `desired_sha256`, `expected_operation` (`insert` or `save_draft`), table/id/version, `before_sha256`, and earlier `dependency_action_ids`. Contract mode requires `--commit`; account-local Unit Group or Flow Property support rows additionally require `--allow-account-local-support`. `--max-parallel` defaults to 1 and is capped at 8. When it is greater than 1, every action through the highest referenced dependency remains serial; only the later table/id/version-unique suffix may overlap. The exact owner token is renewed and checked before each DML dispatch. Attempts and outcomes are stored under the platform user-state directory (`$XDG_STATE_HOME/tiangong-lca-cli` when configured), not beside the contract or report. Any prior terminal or unresolved attempt is read back or retained without re-dispatch; exit status is nonzero unless every action has exact terminal success.
474
+ For `dataset save-draft --execution-contract`, the JSON contract uses schema `dataset-save-draft-execution-contract.v1` and supplies `execution_id`, `project_ref`, an exact owner (`user_id`, lowercase `email`, `state_code: 0`), and ordered actions. Each action binds `action_id`, `desired_sha256`, `expected_operation` (`insert` or `save_draft`), table/id/version, `before_sha256`, and earlier `dependency_action_ids`. Contract mode requires `--commit`; account-local Unit Group or Flow Property support rows additionally require `--allow-account-local-support`. `--max-parallel` defaults to 1 and is capped at 8. Every action through the highest referenced dependency remains on the existing serial path; only the later table/id/version-unique suffix delegates claims and fatal-stop coordination to the public batch engine. `executeAction` still exclusively owns PREPARED evidence, exact before-state checks, token renewal, dispatch, durable attempts, readback, and no-replay decisions, so report bytes and input ordering do not change. Attempts and outcomes are stored under the platform user-state directory (`$XDG_STATE_HOME/tiangong-lca-cli` when configured), not beside the contract or report. Any prior terminal or unresolved attempt is read back or retained without re-dispatch; exit status is nonzero unless every action has exact terminal success.
423
475
 
424
476
  For `dataset maintenance apply`, explicitly passing `--max-parallel 1..8` opts into the destructive flow-convergence profile. It accepts only a non-empty, unique-target, flow delete-only plan whose current and projected reference impacts are both zero. Before dispatch it completes a fresh SELECT-only scan of every process visible to the owner session and rejects any inbound edge. For a separately governed all-process check, pair `--global-inbound-proof /absolute/proof.json` with `--approve-global-inbound-proof <sha256>`; the proof must be fresh, SELECT-only, complete, zero-inbound, and bound to the exact project, actor, plan, and ordered target set, and it is validated before the live scan is skipped. The CLI never runs raw SQL. Each action writes append-only `PREPARED` and `DISPATCHED` evidence before its protected owner-session RPC, then records `COMMITTED` only after exact absent readback. An ambiguous action is read back, marked `UNKNOWN`, and never replayed automatically; independent actions continue. Omit `--max-parallel` to retain ordinary maintenance apply behavior.
425
477
 
@@ -0,0 +1,6 @@
1
+ export { assertBatchContractMatches, assertBatchItemContractMatches, canonicalBatchJson, createBatchContract, createBatchItemContract, parseBatchContract, parseBatchItemContract, sha256BatchBytes, sha256BatchJson, } from './lib/batch/canonical-contracts.js';
2
+ export { runBoundedBatch } from './lib/batch/engine.js';
3
+ export { BatchContractError, BatchItemIdentityDriftError, BatchItemProjectionDriftError, BatchItemResourceDriftError, BatchItemResumeContractError, BatchMutationReplayError, BatchMutationRetryError, BatchRunLockIdentityConflictError, BatchRunLockTimeoutError, } from './lib/batch/errors.js';
4
+ export { batchRunLockPath, batchRunLockStatePath, withBatchRunLock } from './lib/batch/run-lock.js';
5
+ export { MAX_BATCH_CONCURRENCY } from './lib/batch/types.js';
6
+ export type { BatchAttemptedResumeItem, BatchClock, BatchCompletedResumeItem, BatchContract, BatchEvent, BatchEventType, BatchExclusiveKeyContext, BatchExecutionContext, BatchItemContract, BatchItemFailedResult, BatchItemResult, BatchItemResultStatus, BatchItemSucceededResult, BatchItemSuccessStatus, BatchJsonObject, BatchJsonPrimitive, BatchJsonValue, BatchMode, BatchMutationRecoveryContext, BatchMutationRecoveryResult, BatchPauseContext, BatchRecoverySource, BatchResumeItem, BatchResumeState, BatchRetryContext, BatchRetryPolicy, BatchRunLockOptions, BatchRunLockReceipt, BatchRunResult, BatchSleep, BatchStatus, BatchStopContext, CreateBatchContractOptions, CreateBatchItemContractOptions, RunBoundedBatchOptions, } from './lib/batch/types.js';
@@ -0,0 +1,6 @@
1
+ export { assertBatchContractMatches, assertBatchItemContractMatches, canonicalBatchJson, createBatchContract, createBatchItemContract, parseBatchContract, parseBatchItemContract, sha256BatchBytes, sha256BatchJson, } from './lib/batch/canonical-contracts.js';
2
+ export { runBoundedBatch } from './lib/batch/engine.js';
3
+ export { BatchContractError, BatchItemIdentityDriftError, BatchItemProjectionDriftError, BatchItemResourceDriftError, BatchItemResumeContractError, BatchMutationReplayError, BatchMutationRetryError, BatchRunLockIdentityConflictError, BatchRunLockTimeoutError, } from './lib/batch/errors.js';
4
+ export { batchRunLockPath, batchRunLockStatePath, withBatchRunLock } from './lib/batch/run-lock.js';
5
+ export { MAX_BATCH_CONCURRENCY } from './lib/batch/types.js';
6
+ //# sourceMappingURL=batch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"batch.js","sourceRoot":"","sources":["../../src/batch.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,0BAA0B,EAC1B,8BAA8B,EAC9B,kBAAkB,EAClB,mBAAmB,EACnB,uBAAuB,EACvB,kBAAkB,EAClB,sBAAsB,EACtB,gBAAgB,EAChB,eAAe,GAChB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EACL,kBAAkB,EAClB,2BAA2B,EAC3B,6BAA6B,EAC7B,2BAA2B,EAC3B,4BAA4B,EAC5B,wBAAwB,EACxB,uBAAuB,EACvB,iCAAiC,EACjC,wBAAwB,GACzB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AACpG,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC","sourcesContent":["export {\n assertBatchContractMatches,\n assertBatchItemContractMatches,\n canonicalBatchJson,\n createBatchContract,\n createBatchItemContract,\n parseBatchContract,\n parseBatchItemContract,\n sha256BatchBytes,\n sha256BatchJson,\n} from './lib/batch/canonical-contracts.js';\nexport { runBoundedBatch } from './lib/batch/engine.js';\nexport {\n BatchContractError,\n BatchItemIdentityDriftError,\n BatchItemProjectionDriftError,\n BatchItemResourceDriftError,\n BatchItemResumeContractError,\n BatchMutationReplayError,\n BatchMutationRetryError,\n BatchRunLockIdentityConflictError,\n BatchRunLockTimeoutError,\n} from './lib/batch/errors.js';\nexport { batchRunLockPath, batchRunLockStatePath, withBatchRunLock } from './lib/batch/run-lock.js';\nexport { MAX_BATCH_CONCURRENCY } from './lib/batch/types.js';\nexport type {\n BatchAttemptedResumeItem,\n BatchClock,\n BatchCompletedResumeItem,\n BatchContract,\n BatchEvent,\n BatchEventType,\n BatchExclusiveKeyContext,\n BatchExecutionContext,\n BatchItemContract,\n BatchItemFailedResult,\n BatchItemResult,\n BatchItemResultStatus,\n BatchItemSucceededResult,\n BatchItemSuccessStatus,\n BatchJsonObject,\n BatchJsonPrimitive,\n BatchJsonValue,\n BatchMode,\n BatchMutationRecoveryContext,\n BatchMutationRecoveryResult,\n BatchPauseContext,\n BatchRecoverySource,\n BatchResumeItem,\n BatchResumeState,\n BatchRetryContext,\n BatchRetryPolicy,\n BatchRunLockOptions,\n BatchRunLockReceipt,\n BatchRunResult,\n BatchSleep,\n BatchStatus,\n BatchStopContext,\n CreateBatchContractOptions,\n CreateBatchItemContractOptions,\n RunBoundedBatchOptions,\n} from './lib/batch/types.js';\n"]}
@@ -0,0 +1,161 @@
1
+ import type { DotEnvLoadResult } from './lib/dotenv.js';
2
+ import type { FetchLike } from './lib/http.js';
3
+ import { type AuthIdentityReceipt, type RunAuthIdentityReceiptOptions } from './lib/auth-identity-receipt.js';
4
+ import { type LifecyclemodelAutoBuildReport, type RunLifecyclemodelAutoBuildOptions } from './lib/lifecyclemodel-auto-build.js';
5
+ import { type LifecyclemodelResultingProcessReport, type RunLifecyclemodelResultingProcessOptions } from './lib/lifecyclemodel-resulting-process.js';
6
+ import { type LifecyclemodelPublishResultingProcessReport, type RunLifecyclemodelPublishResultingProcessOptions } from './lib/lifecyclemodel-publish-resulting-process.js';
7
+ import { type LifecyclemodelValidateBuildReport, type RunLifecyclemodelValidateBuildOptions } from './lib/lifecyclemodel-validate-build.js';
8
+ import { type LifecyclemodelPublishBuildReport, type RunLifecyclemodelPublishBuildOptions } from './lib/lifecyclemodel-publish-build.js';
9
+ import { type LifecyclemodelSaveDraftReport, type RunLifecyclemodelSaveDraftOptions } from './lib/lifecyclemodel-save-draft-run.js';
10
+ import { type LifecyclemodelGraphReport, type RunLifecyclemodelGraphOptions } from './lib/lifecyclemodel-graph.js';
11
+ import { type LifecyclemodelOrchestrateReport, type RunLifecyclemodelOrchestrateOptions } from './lib/lifecyclemodel-orchestrate.js';
12
+ import { type ProcessAutoBuildReport, type RunProcessAutoBuildOptions } from './lib/process-auto-build.js';
13
+ import { type ProcessGetReport, type RunProcessGetOptions } from './lib/process-get.js';
14
+ import { type ProcessListReport, type RunProcessListOptions } from './lib/process-list.js';
15
+ import { type ProcessBatchBuildReport, type RunProcessBatchBuildOptions } from './lib/process-batch-build.js';
16
+ import { type ProcessScopeStatisticsReport, type RunProcessScopeStatisticsOptions } from './lib/process-scope-statistics.js';
17
+ import { type ProcessRefreshReferencesReport, type RunProcessRefreshReferencesOptions } from './lib/process-refresh-references.js';
18
+ import { type ProcessDedupReviewReport, type RunProcessDedupReviewOptions } from './lib/process-dedup-review.js';
19
+ import { type ProcessResumeBuildReport, type RunProcessResumeBuildOptions } from './lib/process-resume-build.js';
20
+ import { type ProcessPublishBuildReport, type RunProcessPublishBuildOptions } from './lib/process-publish-build.js';
21
+ import { type ProcessSaveDraftReport, type RunProcessSaveDraftOptions } from './lib/process-save-draft-run.js';
22
+ import { type ProcessRequiredFieldsReport, type RunProcessRequiredFieldsCompleteOptions } from './lib/process-required-fields.js';
23
+ import { type ProcessVerifyRowsReport, type RunProcessVerifyRowsOptions } from './lib/process-verify-rows.js';
24
+ import { type FlowBuildPlanGateReport, type ProcessBuildPlanGateReport, type RunFlowBuildPlanMaterializeOptions, type RunFlowBuildPlanValidateOptions, type RunProcessBuildPlanMaterializeOptions, type RunProcessBuildPlanValidateOptions } from './lib/process-flow-build-plan.js';
25
+ import { type FlowIdentityPreflightReport, type ProcessIdentityPreflightReport, type RunFlowIdentityPreflightOptions, type RunProcessIdentityPreflightOptions } from './lib/identity-preflight.js';
26
+ import { type PublishReport, type RunPublishOptions } from './lib/publish.js';
27
+ import { type ProcessQaReport, type RunProcessQaOptions } from './lib/process-qa.js';
28
+ import { type FlowQaReport, type RunFlowQaOptions } from './lib/flow-qa.js';
29
+ import { type LifecyclemodelQaReport, type RunLifecyclemodelQaOptions } from './lib/lifecyclemodel-qa.js';
30
+ import { type FlowRemediationReport, type RunFlowRemediateOptions } from './lib/flow-remediate.js';
31
+ import { type FlowFetchRowsReport, type RunFlowFetchRowsOptions } from './lib/flow-fetch-rows.js';
32
+ import { type FlowMaterializeDecisionsReport, type RunFlowMaterializeDecisionsOptions } from './lib/flow-materialize-decisions.js';
33
+ import { type FlowGetReport, type RunFlowGetOptions } from './lib/flow-get.js';
34
+ import { type FlowListReport, type RunFlowListOptions } from './lib/flow-list.js';
35
+ import { type FlowPublishVersionReport, type RunFlowPublishVersionOptions } from './lib/flow-publish-version.js';
36
+ import { type FlowReviewedPublishDataReport, type RunFlowReviewedPublishDataOptions } from './lib/flow-publish-reviewed-data.js';
37
+ import { type FlowBuildAliasMapReport, type RunFlowBuildAliasMapOptions } from './lib/flow-build-alias-map.js';
38
+ import { type FlowApplyProcessFlowRepairsReport, type FlowPlanProcessFlowRepairsReport, type FlowRegenProductReport, type FlowScanProcessFlowRefsReport, type FlowValidateProcessesReport, type RunFlowApplyProcessFlowRepairsOptions, type RunFlowPlanProcessFlowRepairsOptions, type RunFlowRegenProductOptions, type RunFlowScanProcessFlowRefsOptions, type RunFlowValidateProcessesOptions } from './lib/flow-regen-product.js';
39
+ import { type LcaReleaseReport, type RunLcaReleaseOptions } from './lib/lca-release.js';
40
+ import { type RunValidationOptions, type ValidationRunReport } from './lib/validation.js';
41
+ import { type DatasetValidateReport, type RunDatasetValidateOptions } from './lib/dataset-validate.js';
42
+ import { type DatasetCurationQueueBuildReport, type DatasetCurationQueueNextReport, type DatasetCurationQueueVerifyReport, type RunDatasetCurationQueueBuildOptions, type RunDatasetCurationQueueNextOptions, type RunDatasetCurationQueueVerifyOptions } from './lib/dataset-curation-queue.js';
43
+ import { type DatasetReferencesRewriteReport, type RunDatasetReferencesRewriteOptions } from './lib/dataset-references-rewrite.js';
44
+ import { type DatasetRemoteRefreshReport, type RunDatasetRemoteRefreshOptions } from './lib/dataset-remote-refresh.js';
45
+ import { type DatasetRemoteVerificationReport, type RunDatasetRemoteVerifyOptions } from './lib/dataset-remote-verify.js';
46
+ import { type DatasetBilingualApplyReport, type DatasetBilingualExtractReport, type DatasetBilingualValidateReport, type RunDatasetBilingualApplyOptions, type RunDatasetBilingualExtractOptions, type RunDatasetBilingualValidateOptions } from './lib/dataset-bilingual.js';
47
+ import { type EvidenceSearchReport, type RunDatasetEvidenceSearchOptions } from './lib/dataset-evidence-search.js';
48
+ import { type DatasetContractReport, type RunDatasetContractOptions } from './lib/dataset-contract.js';
49
+ import { type DatasetImportLcaReport, type RunDatasetImportLcaConvertOptions } from './lib/dataset-import-lca.js';
50
+ import { type DatasetAuthorReport, type RunDatasetAuthorOptions } from './lib/dataset-author.js';
51
+ import { type DatasetPatchApplyReport, type RunDatasetPatchApplyOptions } from './lib/dataset-patch.js';
52
+ import { type DatasetSaveDraftReport, type RunDatasetSaveDraftOptions } from './lib/dataset-save-draft-run.js';
53
+ import { type DatasetClassificationApplyReport, type DatasetClassificationAuditReport, type DatasetClassificationChildrenReport, type DatasetClassificationPathReport, type RunDatasetClassificationApplyOptions, type RunDatasetClassificationAuditOptions, type RunDatasetClassificationChildrenOptions, type RunDatasetClassificationPathOptions } from './lib/dataset-classification.js';
54
+ import { type DatasetMaintenanceClearAccountReport, type RunDatasetMaintenanceClearAccountOptions } from './lib/dataset-maintenance-clear-account.js';
55
+ import { runDatasetMaintenancePlan } from './lib/dataset-maintenance-plan.js';
56
+ import { runDatasetMaintenanceApply } from './lib/dataset-maintenance-apply.js';
57
+ import { freezeDatasetMaintenanceProtected } from './lib/dataset-maintenance-protected-freeze.js';
58
+ import { runDatasetMaintenanceProtected } from './lib/dataset-maintenance-protected-run.js';
59
+ import { sealDatasetMaintenanceProtectedApproval } from './lib/dataset-maintenance-protected-seal.js';
60
+ import { runDatasetMaintenanceVerify } from './lib/dataset-maintenance-verify.js';
61
+ import { runFlowIdentityPlanFromFiles } from './lib/dataset-maintenance-flow-identity-command.js';
62
+ import { captureFlowIdentity } from './lib/dataset-maintenance-flow-identity-capture.js';
63
+ import { freezeFlowIdentity } from './lib/dataset-maintenance-flow-identity-freeze.js';
64
+ import { sealFlowIdentityApproval } from './lib/dataset-maintenance-flow-identity-seal.js';
65
+ import { freezeFlowIdentityRecovery, sealFlowIdentityRecoveryApproval } from './lib/dataset-maintenance-flow-identity-recovery.js';
66
+ import { runFlowIdentity } from './lib/dataset-maintenance-flow-identity-run.js';
67
+ import { verifyFlowIdentity } from './lib/dataset-maintenance-flow-identity-verify.js';
68
+ import { type DatasetSourceUploadAttachmentsReport, type RunDatasetSourceUploadAttachmentsOptions } from './lib/dataset-source-upload-attachments.js';
69
+ export type CliDeps = {
70
+ env: NodeJS.ProcessEnv;
71
+ dotEnvStatus: DotEnvLoadResult;
72
+ fetchImpl: FetchLike;
73
+ runAuthIdentityReceiptImpl?: (options: RunAuthIdentityReceiptOptions) => Promise<AuthIdentityReceipt>;
74
+ runPublishImpl?: (options: RunPublishOptions) => Promise<PublishReport>;
75
+ runValidationImpl?: (options: RunValidationOptions) => Promise<ValidationRunReport>;
76
+ runLcaReleaseImpl?: (options: RunLcaReleaseOptions) => Promise<LcaReleaseReport>;
77
+ runLifecyclemodelAutoBuildImpl?: (options: RunLifecyclemodelAutoBuildOptions) => Promise<LifecyclemodelAutoBuildReport>;
78
+ runLifecyclemodelBuildResultingProcessImpl?: (options: RunLifecyclemodelResultingProcessOptions) => Promise<LifecyclemodelResultingProcessReport>;
79
+ runLifecyclemodelPublishResultingProcessImpl?: (options: RunLifecyclemodelPublishResultingProcessOptions) => Promise<LifecyclemodelPublishResultingProcessReport>;
80
+ runLifecyclemodelValidateBuildImpl?: (options: RunLifecyclemodelValidateBuildOptions) => Promise<LifecyclemodelValidateBuildReport>;
81
+ runLifecyclemodelPublishBuildImpl?: (options: RunLifecyclemodelPublishBuildOptions) => Promise<LifecyclemodelPublishBuildReport>;
82
+ runLifecyclemodelSaveDraftImpl?: (options: RunLifecyclemodelSaveDraftOptions) => Promise<LifecyclemodelSaveDraftReport>;
83
+ runLifecyclemodelGraphImpl?: (options: RunLifecyclemodelGraphOptions) => Promise<LifecyclemodelGraphReport>;
84
+ runLifecyclemodelOrchestrateImpl?: (options: RunLifecyclemodelOrchestrateOptions) => Promise<LifecyclemodelOrchestrateReport>;
85
+ runProcessGetImpl?: (options: RunProcessGetOptions) => Promise<ProcessGetReport>;
86
+ runProcessListImpl?: (options: RunProcessListOptions) => Promise<ProcessListReport>;
87
+ runProcessAutoBuildImpl?: (options: RunProcessAutoBuildOptions) => Promise<ProcessAutoBuildReport>;
88
+ runProcessBatchBuildImpl?: (options: RunProcessBatchBuildOptions) => Promise<ProcessBatchBuildReport>;
89
+ runProcessScopeStatisticsImpl?: (options: RunProcessScopeStatisticsOptions) => Promise<ProcessScopeStatisticsReport>;
90
+ runProcessRefreshReferencesImpl?: (options: RunProcessRefreshReferencesOptions) => Promise<ProcessRefreshReferencesReport>;
91
+ runProcessDedupReviewImpl?: (options: RunProcessDedupReviewOptions) => Promise<ProcessDedupReviewReport>;
92
+ runProcessResumeBuildImpl?: (options: RunProcessResumeBuildOptions) => Promise<ProcessResumeBuildReport>;
93
+ runProcessPublishBuildImpl?: (options: RunProcessPublishBuildOptions) => Promise<ProcessPublishBuildReport>;
94
+ runProcessSaveDraftImpl?: (options: RunProcessSaveDraftOptions) => Promise<ProcessSaveDraftReport>;
95
+ runProcessRequiredFieldsCompleteImpl?: (options: RunProcessRequiredFieldsCompleteOptions) => Promise<ProcessRequiredFieldsReport>;
96
+ runProcessVerifyRowsImpl?: (options: RunProcessVerifyRowsOptions) => Promise<ProcessVerifyRowsReport>;
97
+ runProcessIdentityPreflightImpl?: (options: RunProcessIdentityPreflightOptions) => Promise<ProcessIdentityPreflightReport>;
98
+ runProcessBuildPlanValidateImpl?: (options: RunProcessBuildPlanValidateOptions) => Promise<ProcessBuildPlanGateReport>;
99
+ runProcessBuildPlanMaterializeImpl?: (options: RunProcessBuildPlanMaterializeOptions) => Promise<ProcessBuildPlanGateReport>;
100
+ runProcessQaImpl?: (options: RunProcessQaOptions) => Promise<ProcessQaReport>;
101
+ runFlowQaImpl?: (options: RunFlowQaOptions) => Promise<FlowQaReport>;
102
+ runLifecyclemodelQaImpl?: (options: RunLifecyclemodelQaOptions) => Promise<LifecyclemodelQaReport>;
103
+ runFlowRemediateImpl?: (options: RunFlowRemediateOptions) => Promise<FlowRemediationReport>;
104
+ runFlowFetchRowsImpl?: (options: RunFlowFetchRowsOptions) => Promise<FlowFetchRowsReport>;
105
+ runFlowMaterializeDecisionsImpl?: (options: RunFlowMaterializeDecisionsOptions) => Promise<FlowMaterializeDecisionsReport>;
106
+ runFlowGetImpl?: (options: RunFlowGetOptions) => Promise<FlowGetReport>;
107
+ runFlowListImpl?: (options: RunFlowListOptions) => Promise<FlowListReport>;
108
+ runFlowPublishVersionImpl?: (options: RunFlowPublishVersionOptions) => Promise<FlowPublishVersionReport>;
109
+ runFlowReviewedPublishDataImpl?: (options: RunFlowReviewedPublishDataOptions) => Promise<FlowReviewedPublishDataReport>;
110
+ runFlowBuildAliasMapImpl?: (options: RunFlowBuildAliasMapOptions) => Promise<FlowBuildAliasMapReport>;
111
+ runFlowScanProcessFlowRefsImpl?: (options: RunFlowScanProcessFlowRefsOptions) => Promise<FlowScanProcessFlowRefsReport>;
112
+ runFlowPlanProcessFlowRepairsImpl?: (options: RunFlowPlanProcessFlowRepairsOptions) => Promise<FlowPlanProcessFlowRepairsReport>;
113
+ runFlowApplyProcessFlowRepairsImpl?: (options: RunFlowApplyProcessFlowRepairsOptions) => Promise<FlowApplyProcessFlowRepairsReport>;
114
+ runFlowRegenProductImpl?: (options: RunFlowRegenProductOptions) => Promise<FlowRegenProductReport>;
115
+ runFlowValidateProcessesImpl?: (options: RunFlowValidateProcessesOptions) => Promise<FlowValidateProcessesReport>;
116
+ runFlowIdentityPreflightImpl?: (options: RunFlowIdentityPreflightOptions) => Promise<FlowIdentityPreflightReport>;
117
+ runFlowBuildPlanValidateImpl?: (options: RunFlowBuildPlanValidateOptions) => Promise<FlowBuildPlanGateReport>;
118
+ runFlowBuildPlanMaterializeImpl?: (options: RunFlowBuildPlanMaterializeOptions) => Promise<FlowBuildPlanGateReport>;
119
+ runDatasetValidateImpl?: (options: RunDatasetValidateOptions) => Promise<DatasetValidateReport>;
120
+ runDatasetCurationQueueBuildImpl?: (options: RunDatasetCurationQueueBuildOptions) => Promise<DatasetCurationQueueBuildReport>;
121
+ runDatasetCurationQueueNextImpl?: (options: RunDatasetCurationQueueNextOptions) => Promise<DatasetCurationQueueNextReport>;
122
+ runDatasetCurationQueueVerifyImpl?: (options: RunDatasetCurationQueueVerifyOptions) => Promise<DatasetCurationQueueVerifyReport>;
123
+ runDatasetReferencesRewriteImpl?: (options: RunDatasetReferencesRewriteOptions) => Promise<DatasetReferencesRewriteReport>;
124
+ runDatasetRemoteRefreshImpl?: (options: RunDatasetRemoteRefreshOptions) => Promise<DatasetRemoteRefreshReport>;
125
+ runDatasetRemoteVerifyImpl?: (options: RunDatasetRemoteVerifyOptions) => Promise<DatasetRemoteVerificationReport>;
126
+ runDatasetBilingualExtractImpl?: (options: RunDatasetBilingualExtractOptions) => Promise<DatasetBilingualExtractReport>;
127
+ runDatasetBilingualApplyImpl?: (options: RunDatasetBilingualApplyOptions) => Promise<DatasetBilingualApplyReport>;
128
+ runDatasetBilingualValidateImpl?: (options: RunDatasetBilingualValidateOptions) => Promise<DatasetBilingualValidateReport>;
129
+ runDatasetEvidenceSearchImpl?: (options: RunDatasetEvidenceSearchOptions) => Promise<EvidenceSearchReport>;
130
+ runDatasetContractImpl?: (options: RunDatasetContractOptions) => Promise<DatasetContractReport>;
131
+ runDatasetImportLcaConvertImpl?: (options: RunDatasetImportLcaConvertOptions) => Promise<DatasetImportLcaReport> | DatasetImportLcaReport;
132
+ runDatasetAuthorImpl?: (options: RunDatasetAuthorOptions) => Promise<DatasetAuthorReport>;
133
+ runDatasetPatchApplyImpl?: (options: RunDatasetPatchApplyOptions) => Promise<DatasetPatchApplyReport>;
134
+ runDatasetSaveDraftImpl?: (options: RunDatasetSaveDraftOptions) => Promise<DatasetSaveDraftReport>;
135
+ runDatasetClassificationChildrenImpl?: (options: RunDatasetClassificationChildrenOptions) => Promise<DatasetClassificationChildrenReport>;
136
+ runDatasetClassificationPathImpl?: (options: RunDatasetClassificationPathOptions) => Promise<DatasetClassificationPathReport>;
137
+ runDatasetClassificationAuditImpl?: (options: RunDatasetClassificationAuditOptions) => Promise<DatasetClassificationAuditReport>;
138
+ runDatasetClassificationApplyImpl?: (options: RunDatasetClassificationApplyOptions) => Promise<DatasetClassificationApplyReport>;
139
+ runDatasetMaintenanceClearAccountImpl?: (options: RunDatasetMaintenanceClearAccountOptions) => Promise<DatasetMaintenanceClearAccountReport>;
140
+ runDatasetMaintenancePlanImpl?: typeof runDatasetMaintenancePlan;
141
+ runDatasetMaintenanceApplyImpl?: typeof runDatasetMaintenanceApply;
142
+ freezeDatasetMaintenanceProtectedImpl?: typeof freezeDatasetMaintenanceProtected;
143
+ runDatasetMaintenanceProtectedImpl?: typeof runDatasetMaintenanceProtected;
144
+ sealDatasetMaintenanceProtectedApprovalImpl?: typeof sealDatasetMaintenanceProtectedApproval;
145
+ runDatasetMaintenanceVerifyImpl?: typeof runDatasetMaintenanceVerify;
146
+ runFlowIdentityPlanFromFilesImpl?: typeof runFlowIdentityPlanFromFiles;
147
+ captureFlowIdentityImpl?: typeof captureFlowIdentity;
148
+ freezeFlowIdentityImpl?: typeof freezeFlowIdentity;
149
+ sealFlowIdentityApprovalImpl?: typeof sealFlowIdentityApproval;
150
+ freezeFlowIdentityRecoveryImpl?: typeof freezeFlowIdentityRecovery;
151
+ sealFlowIdentityRecoveryApprovalImpl?: typeof sealFlowIdentityRecoveryApproval;
152
+ runFlowIdentityImpl?: typeof runFlowIdentity;
153
+ verifyFlowIdentityImpl?: typeof verifyFlowIdentity;
154
+ runDatasetSourceUploadAttachmentsImpl?: (options: RunDatasetSourceUploadAttachmentsOptions) => Promise<DatasetSourceUploadAttachmentsReport>;
155
+ };
156
+ export type CliResult = {
157
+ exitCode: number;
158
+ stdout: string;
159
+ stderr: string;
160
+ };
161
+ export declare function executeCli(argv: string[], deps: CliDeps): Promise<CliResult>;
package/dist/src/cli.js CHANGED
@@ -3,6 +3,7 @@ import { buildDoctorReport, readRuntimeEnv } from './lib/env.js';
3
3
  import { CliError, toErrorPayload } from './lib/errors.js';
4
4
  import { stringifyJson } from './lib/io.js';
5
5
  import { loadCliPackageVersion } from './lib/package-version.js';
6
+ import { AUTH_IDENTITY_MAX_TIMEOUT_MS, AUTH_IDENTITY_RECEIPT_SCHEMA, runAuthIdentityReceipt, } from './lib/auth-identity-receipt.js';
6
7
  import { runLifecyclemodelAutoBuild, } from './lib/lifecyclemodel-auto-build.js';
7
8
  import { runLifecyclemodelBuildResultingProcess, } from './lib/lifecyclemodel-resulting-process.js';
8
9
  import { runLifecyclemodelPublishResultingProcess, } from './lib/lifecyclemodel-publish-resulting-process.js';
@@ -86,6 +87,7 @@ Usage:
86
87
  Commands:
87
88
  Implemented Commands:
88
89
  doctor show environment diagnostics
90
+ auth identity-receipt
89
91
  search flow | process | lifecyclemodel
90
92
  process get | list | identity-preflight | build-plan | scope-statistics | dedup-review | auto-build | resume-build | publish-build | complete-required-fields | save-draft | batch-build | refresh-references | verify-rows
91
93
  dataset contract get | context-pack | classification children/path/audit/apply | curation-queue build/next/verify | import-lca convert | author | patch apply | save-draft | source upload-attachments | validate | verify-remote | bilingual extract/apply/validate | evidence-search plan/run | references rewrite/refresh-remote | maintenance clear-account/plan/apply/verify/flow-identity
@@ -105,6 +107,7 @@ Planned commands currently print an explicit "not implemented yet" message and e
105
107
 
106
108
  Examples:
107
109
  tiangong-lca doctor
110
+ tiangong-lca auth identity-receipt --expected-project-ref <project-ref> --expected-user-id <user-id> --json
108
111
  tiangong-lca search flow --input ./request.json
109
112
  tiangong-lca search process --input ./request.json --dry-run
110
113
  tiangong-lca process get --id <process-id>
@@ -180,6 +183,50 @@ Environment:
180
183
  .env loaded: ${dotEnvStatus.loaded ? `yes (${dotEnvStatus.path}, ${dotEnvStatus.count} keys)` : 'no'}
181
184
  `.trim();
182
185
  }
186
+ function renderAuthHelp() {
187
+ return `Usage:
188
+ tiangong-lca auth identity-receipt [options]
189
+
190
+ Implemented Subcommands:
191
+ identity-receipt Live, read-only proof of the authenticated account and Supabase project
192
+
193
+ Planned Subcommands:
194
+ whoami | doctor-auth
195
+
196
+ Use "tiangong-lca auth identity-receipt --help" for the machine-receipt contract.
197
+ `.trim();
198
+ }
199
+ function renderAuthIdentityReceiptHelp() {
200
+ return `Usage:
201
+ tiangong-lca auth identity-receipt [options]
202
+
203
+ Options:
204
+ --expected-project-ref <ref> Assert the exact Supabase project before session/network access
205
+ --expected-user-id <id> Assert the exact server-verified authenticated user
206
+ --timeout-ms <n> Request timeout 1..${AUTH_IDENTITY_MAX_TIMEOUT_MS} ms (default: 10000)
207
+ --json Print compact JSON; default output is pretty JSON
208
+ -h, --help
209
+
210
+ Receipt schema:
211
+ ${AUTH_IDENTITY_RECEIPT_SCHEMA}
212
+
213
+ Safety:
214
+ This is a read-only command that performs one live read of /auth/v1/user, with at most one
215
+ force-refresh retry after a 401 or 403. It never emits API keys, bearer/session
216
+ tokens, full email addresses, session paths, or credential-derived fingerprints. Production guards
217
+ must pass both expected assertions and require assertions.mode="intent-bound".
218
+
219
+ Required env:
220
+ TIANGONG_LCA_API_BASE_URL
221
+ TIANGONG_LCA_API_KEY
222
+ TIANGONG_LCA_SUPABASE_PUBLISHABLE_KEY
223
+
224
+ Optional session env:
225
+ TIANGONG_LCA_SESSION_FILE
226
+ TIANGONG_LCA_DISABLE_SESSION_CACHE
227
+ TIANGONG_LCA_FORCE_REAUTH
228
+ `.trim();
229
+ }
183
230
  function renderDoctorHelp() {
184
231
  return `Usage:
185
232
  tiangong-lca doctor [--json]
@@ -2269,6 +2316,59 @@ function parseDoctorFlags(args) {
2269
2316
  json: Boolean(values.json),
2270
2317
  };
2271
2318
  }
2319
+ function parseAuthIdentityReceiptFlags(args) {
2320
+ let parsed;
2321
+ try {
2322
+ parsed = parseArgs({
2323
+ args,
2324
+ allowPositionals: false,
2325
+ strict: true,
2326
+ tokens: true,
2327
+ options: {
2328
+ help: { type: 'boolean', short: 'h' },
2329
+ json: { type: 'boolean' },
2330
+ 'expected-project-ref': { type: 'string' },
2331
+ 'expected-user-id': { type: 'string' },
2332
+ 'timeout-ms': { type: 'string' },
2333
+ },
2334
+ });
2335
+ }
2336
+ catch (error) {
2337
+ throw new CliError(String(error), {
2338
+ code: 'INVALID_ARGS',
2339
+ exitCode: 2,
2340
+ });
2341
+ }
2342
+ const tokens = parsed.tokens;
2343
+ for (const optionName of ['expected-project-ref', 'expected-user-id', 'timeout-ms']) {
2344
+ const occurrences = tokens.filter((entry) => entry.kind === 'option' && entry.name === optionName).length;
2345
+ if (occurrences > 1) {
2346
+ throw new CliError(`Option --${optionName} may be provided only once.`, {
2347
+ code: 'INVALID_ARGS',
2348
+ exitCode: 2,
2349
+ });
2350
+ }
2351
+ }
2352
+ const timeoutText = typeof parsed.values['timeout-ms'] === 'string' ? parsed.values['timeout-ms'] : undefined;
2353
+ const timeoutMs = timeoutText === undefined ? 10_000 : Number(timeoutText);
2354
+ if (!Number.isInteger(timeoutMs) || timeoutMs <= 0 || timeoutMs > AUTH_IDENTITY_MAX_TIMEOUT_MS) {
2355
+ throw new CliError(`Expected --timeout-ms to be an integer between 1 and ${AUTH_IDENTITY_MAX_TIMEOUT_MS}.`, {
2356
+ code: 'INVALID_TIMEOUT',
2357
+ exitCode: 2,
2358
+ });
2359
+ }
2360
+ return {
2361
+ help: Boolean(parsed.values.help),
2362
+ json: Boolean(parsed.values.json),
2363
+ expectedProjectRef: typeof parsed.values['expected-project-ref'] === 'string'
2364
+ ? parsed.values['expected-project-ref']
2365
+ : null,
2366
+ expectedUserId: typeof parsed.values['expected-user-id'] === 'string'
2367
+ ? parsed.values['expected-user-id']
2368
+ : null,
2369
+ timeoutMs,
2370
+ };
2371
+ }
2272
2372
  function parseRemoteFlags(args) {
2273
2373
  let values;
2274
2374
  try {
@@ -5442,6 +5542,7 @@ function applyRemoteOverrides(env, overrides) {
5442
5542
  export async function executeCli(argv, deps) {
5443
5543
  try {
5444
5544
  const { flags, command, subcommand, commandArgs } = parseCommandLine(argv);
5545
+ const authIdentityReceiptImpl = deps.runAuthIdentityReceiptImpl ?? runAuthIdentityReceipt;
5445
5546
  const publishImpl = deps.runPublishImpl ?? runPublish;
5446
5547
  const validationImpl = deps.runValidationImpl ?? runValidation;
5447
5548
  const lcaReleaseImpl = deps.runLcaReleaseImpl ?? runLcaRelease;
@@ -5541,6 +5642,35 @@ export async function executeCli(argv, deps) {
5541
5642
  stderr: '',
5542
5643
  };
5543
5644
  }
5645
+ if (command === 'auth' && !subcommand) {
5646
+ if (commandArgs.length === 0 ||
5647
+ (commandArgs.length === 1 && ['--help', '-h'].includes(commandArgs[0]))) {
5648
+ return { exitCode: 0, stdout: `${renderAuthHelp()}\n`, stderr: '' };
5649
+ }
5650
+ throw new CliError('The auth namespace accepts only -h or --help.', {
5651
+ code: 'INVALID_ARGS',
5652
+ exitCode: 2,
5653
+ });
5654
+ }
5655
+ if (command === 'auth' && subcommand === 'identity-receipt') {
5656
+ const authFlags = parseAuthIdentityReceiptFlags(commandArgs);
5657
+ if (authFlags.help) {
5658
+ return { exitCode: 0, stdout: `${renderAuthIdentityReceiptHelp()}\n`, stderr: '' };
5659
+ }
5660
+ const receipt = await authIdentityReceiptImpl({
5661
+ env: deps.env,
5662
+ fetchImpl: deps.fetchImpl,
5663
+ cliVersion: loadCliPackageVersion(import.meta.url),
5664
+ expectedProjectRef: authFlags.expectedProjectRef,
5665
+ expectedUserId: authFlags.expectedUserId,
5666
+ timeoutMs: authFlags.timeoutMs,
5667
+ });
5668
+ return {
5669
+ exitCode: 0,
5670
+ stdout: stringifyJson(receipt, authFlags.json),
5671
+ stderr: '',
5672
+ };
5673
+ }
5544
5674
  if (command === 'search' && !subcommand && commandArgs.includes('--help')) {
5545
5675
  return { exitCode: 0, stdout: `${renderSearchHelp()}\n`, stderr: '' };
5546
5676
  }