@yiaany/ghostapi 0.1.9 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (292) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/CONTRIBUTING.md +132 -119
  3. package/LICENSE +21 -21
  4. package/PROVENANCE.md +13 -0
  5. package/README.md +78 -84
  6. package/SECURITY.md +56 -53
  7. package/dist/actions/gateway.js +320 -72
  8. package/dist/actions/gateway.js.map +1 -1
  9. package/dist/actions/index.d.ts +2 -2
  10. package/dist/actions/index.js +1 -1
  11. package/dist/actions/index.js.map +1 -1
  12. package/dist/agents/agentPrompt.js +7 -5
  13. package/dist/agents/agentPrompt.js.map +1 -1
  14. package/dist/ai/aiClient.js +5 -5
  15. package/dist/ai/aiClient.js.map +1 -1
  16. package/dist/ai/aiGenerator.js +66 -26
  17. package/dist/ai/aiGenerator.js.map +1 -1
  18. package/dist/ai/genericInference.js +151 -36
  19. package/dist/ai/genericInference.js.map +1 -1
  20. package/dist/ai/prompts.js +55 -49
  21. package/dist/ai/prompts.js.map +1 -1
  22. package/dist/approvals/approvalInbox.js +649 -133
  23. package/dist/approvals/approvalInbox.js.map +1 -1
  24. package/dist/approvals/index.d.ts +2 -2
  25. package/dist/approvals/index.js +1 -1
  26. package/dist/approvals/index.js.map +1 -1
  27. package/dist/behavior/behaviorStore.js +34 -14
  28. package/dist/behavior/behaviorStore.js.map +1 -1
  29. package/dist/cache/index.js +14 -5
  30. package/dist/cache/index.js.map +1 -1
  31. package/dist/cli/index.js +226 -93
  32. package/dist/cli/index.js.map +1 -1
  33. package/dist/cli/openUrl.js +17 -3
  34. package/dist/cli/openUrl.js.map +1 -1
  35. package/dist/cli/parser.js +79 -18
  36. package/dist/cli/parser.js.map +1 -1
  37. package/dist/config/dataPaths.js +4 -2
  38. package/dist/config/dataPaths.js.map +1 -1
  39. package/dist/config/localConfig.js +5 -2
  40. package/dist/config/localConfig.js.map +1 -1
  41. package/dist/config/serverConfig.js +11 -5
  42. package/dist/config/serverConfig.js.map +1 -1
  43. package/dist/contracts/contract.js +311 -83
  44. package/dist/contracts/contract.js.map +1 -1
  45. package/dist/contracts/index.d.ts +2 -2
  46. package/dist/contracts/index.js +1 -1
  47. package/dist/contracts/index.js.map +1 -1
  48. package/dist/credentials/credentialBroker.js +391 -79
  49. package/dist/credentials/credentialBroker.js.map +1 -1
  50. package/dist/credentials/index.d.ts +2 -2
  51. package/dist/credentials/index.js +1 -1
  52. package/dist/credentials/index.js.map +1 -1
  53. package/dist/dashboard/app.js +823 -685
  54. package/dist/dashboard/dashboard.js.map +1 -1
  55. package/dist/dashboard/index.html +704 -267
  56. package/dist/dashboard/styles.css +1040 -349
  57. package/dist/egress/capabilities.js +55 -25
  58. package/dist/egress/capabilities.js.map +1 -1
  59. package/dist/egress/linuxBootstrap.js +47 -11
  60. package/dist/egress/linuxBootstrap.js.map +1 -1
  61. package/dist/egress/run.js +170 -31
  62. package/dist/egress/run.js.map +1 -1
  63. package/dist/errors/errorEngine.js +15 -3
  64. package/dist/errors/errorEngine.js.map +1 -1
  65. package/dist/errors/providerErrors.js.map +1 -1
  66. package/dist/evals/evals.js +304 -78
  67. package/dist/evals/evals.js.map +1 -1
  68. package/dist/evals/index.d.ts +2 -2
  69. package/dist/evals/index.js +1 -1
  70. package/dist/evals/index.js.map +1 -1
  71. package/dist/evidence/index.d.ts +2 -2
  72. package/dist/evidence/index.js +1 -1
  73. package/dist/evidence/index.js.map +1 -1
  74. package/dist/evidence/report.d.ts +1 -1
  75. package/dist/evidence/report.js +263 -79
  76. package/dist/evidence/report.js.map +1 -1
  77. package/dist/fault/faultLab.js +24 -9
  78. package/dist/fault/faultLab.js.map +1 -1
  79. package/dist/index.d.ts +42 -42
  80. package/dist/index.js +21 -21
  81. package/dist/index.js.map +1 -1
  82. package/dist/inventory/analysis.d.ts +1 -1
  83. package/dist/inventory/analysis.js +174 -50
  84. package/dist/inventory/analysis.js.map +1 -1
  85. package/dist/inventory/index.d.ts +4 -4
  86. package/dist/inventory/index.js +3 -3
  87. package/dist/inventory/index.js.map +1 -1
  88. package/dist/inventory/inventoryController.js +362 -115
  89. package/dist/inventory/inventoryController.js.map +1 -1
  90. package/dist/inventory/types.js +680 -140
  91. package/dist/inventory/types.js.map +1 -1
  92. package/dist/ledger/actionLedger.js +355 -78
  93. package/dist/ledger/actionLedger.js.map +1 -1
  94. package/dist/ledger/index.d.ts +2 -2
  95. package/dist/ledger/index.js +1 -1
  96. package/dist/ledger/index.js.map +1 -1
  97. package/dist/mcp/server.js +26 -11
  98. package/dist/mcp/server.js.map +1 -1
  99. package/dist/policy/index.d.ts +2 -2
  100. package/dist/policy/index.js +1 -1
  101. package/dist/policy/index.js.map +1 -1
  102. package/dist/policy/policy.js +112 -32
  103. package/dist/policy/policy.js.map +1 -1
  104. package/dist/productTelemetry/index.js +71 -20
  105. package/dist/productTelemetry/index.js.map +1 -1
  106. package/dist/providers/conformance.js +10 -5
  107. package/dist/providers/conformance.js.map +1 -1
  108. package/dist/providers/discord.js +2 -2
  109. package/dist/providers/generic.js +3 -3
  110. package/dist/providers/github.js +2 -2
  111. package/dist/providers/index.d.ts +3 -3
  112. package/dist/providers/index.js +2 -2
  113. package/dist/providers/index.js.map +1 -1
  114. package/dist/providers/openai.js +3 -3
  115. package/dist/providers/packs/resendPack.js +51 -25
  116. package/dist/providers/packs/resendPack.js.map +1 -1
  117. package/dist/providers/packs/stripePack.js +590 -121
  118. package/dist/providers/packs/stripePack.js.map +1 -1
  119. package/dist/providers/registry.js +4 -4
  120. package/dist/providers/registry.js.map +1 -1
  121. package/dist/providers/runtime.js +7 -6
  122. package/dist/providers/runtime.js.map +1 -1
  123. package/dist/providers/stripeWebhook.js +39 -10
  124. package/dist/providers/stripeWebhook.js.map +1 -1
  125. package/dist/providers/twilio.js +2 -2
  126. package/dist/proxy/cacheKey.js +9 -2
  127. package/dist/proxy/cacheKey.js.map +1 -1
  128. package/dist/proxy/providerDetector.js +22 -9
  129. package/dist/proxy/providerDetector.js.map +1 -1
  130. package/dist/proxy/proxyHandler.js +57 -22
  131. package/dist/proxy/proxyHandler.js.map +1 -1
  132. package/dist/proxy/requestNormalizer.js +4 -2
  133. package/dist/proxy/requestNormalizer.js.map +1 -1
  134. package/dist/reliability/costGovernance.js +211 -49
  135. package/dist/reliability/costGovernance.js.map +1 -1
  136. package/dist/reliability/index.d.ts +8 -8
  137. package/dist/reliability/index.js +4 -4
  138. package/dist/reliability/index.js.map +1 -1
  139. package/dist/reliability/reconciliation.js +274 -65
  140. package/dist/reliability/reconciliation.js.map +1 -1
  141. package/dist/reliability/runtimeHealth.js +127 -35
  142. package/dist/reliability/runtimeHealth.js.map +1 -1
  143. package/dist/reliability/slo.js +257 -50
  144. package/dist/reliability/slo.js.map +1 -1
  145. package/dist/report/safetyReport.d.ts +6 -0
  146. package/dist/report/safetyReport.js +56 -12
  147. package/dist/report/safetyReport.js.map +1 -1
  148. package/dist/rules/aiRules.js +5 -5
  149. package/dist/rules/aiRules.js.map +1 -1
  150. package/dist/safety/index.d.ts +2 -2
  151. package/dist/safety/index.js +1 -1
  152. package/dist/safety/index.js.map +1 -1
  153. package/dist/safety/safetyController.js +675 -165
  154. package/dist/safety/safetyController.js.map +1 -1
  155. package/dist/scenarios/scenarioBundle.js +204 -71
  156. package/dist/scenarios/scenarioBundle.js.map +1 -1
  157. package/dist/scenarios/scenarioStore.js +88 -29
  158. package/dist/scenarios/scenarioStore.js.map +1 -1
  159. package/dist/security/headerSanitizer.js +52 -10
  160. package/dist/security/headerSanitizer.js.map +1 -1
  161. package/dist/security/secrets.js +10 -5
  162. package/dist/security/secrets.js.map +1 -1
  163. package/dist/server/accessControl.js +37 -10
  164. package/dist/server/accessControl.js.map +1 -1
  165. package/dist/server/createServer.js +1 -1
  166. package/dist/server/createServer.js.map +1 -1
  167. package/dist/server/eventsStore.js +15 -5
  168. package/dist/server/eventsStore.js.map +1 -1
  169. package/dist/server/routes.js +61 -19
  170. package/dist/server/routes.js.map +1 -1
  171. package/dist/server/sse.js +1 -1
  172. package/dist/server/sse.js.map +1 -1
  173. package/dist/setup/sdkDetector.js +7 -2
  174. package/dist/setup/sdkDetector.js.map +1 -1
  175. package/dist/setup/setupGenerator.js +136 -48
  176. package/dist/setup/setupGenerator.js.map +1 -1
  177. package/dist/state/stateExtractor.js +3 -1
  178. package/dist/state/stateExtractor.js.map +1 -1
  179. package/dist/state/stateResolver.js +10 -7
  180. package/dist/state/stateResolver.js.map +1 -1
  181. package/dist/state/stateStore.js +13 -4
  182. package/dist/state/stateStore.js.map +1 -1
  183. package/dist/storage/fileStore.js +12 -4
  184. package/dist/storage/fileStore.js.map +1 -1
  185. package/dist/teamControl/controlPlane.js +846 -174
  186. package/dist/teamControl/controlPlane.js.map +1 -1
  187. package/dist/teamControl/deployment.js +19 -5
  188. package/dist/teamControl/deployment.js.map +1 -1
  189. package/dist/teamControl/index.d.ts +4 -4
  190. package/dist/teamControl/index.js +2 -2
  191. package/dist/teamControl/index.js.map +1 -1
  192. package/dist/tests/testGenerator.js +15 -7
  193. package/dist/tests/testGenerator.js.map +1 -1
  194. package/dist/trust/index.d.ts +2 -2
  195. package/dist/trust/index.js +1 -1
  196. package/dist/trust/index.js.map +1 -1
  197. package/dist/trust/trustLadder.js +309 -63
  198. package/dist/trust/trustLadder.js.map +1 -1
  199. package/dist/worlds/index.d.ts +2 -2
  200. package/dist/worlds/index.js +1 -1
  201. package/dist/worlds/index.js.map +1 -1
  202. package/dist/worlds/worlds.js +364 -65
  203. package/dist/worlds/worlds.js.map +1 -1
  204. package/docs/assets/dashboard.png +0 -0
  205. package/docs/ci.md +49 -49
  206. package/docs/github-actions.md +84 -84
  207. package/docs/mcp.md +58 -52
  208. package/docs/policy.md +63 -61
  209. package/docs/providers/authoring-packs.md +180 -175
  210. package/docs/providers/stripe-core-pack.md +84 -82
  211. package/docs/releases/README.md +13 -0
  212. package/docs/security/action-gateway-threat-model.md +34 -34
  213. package/docs/security/action-ledger-incident-replay-threat-model.md +42 -42
  214. package/docs/security/approval-inbox-threat-model.md +35 -35
  215. package/docs/security/credential-broker-threat-model.md +52 -52
  216. package/docs/security/egress-threat-model.md +126 -126
  217. package/docs/security/inventory-threat-model.md +104 -104
  218. package/docs/security/kill-switch-budgets-threat-model.md +37 -37
  219. package/docs/security/reliability-threat-model.md +111 -111
  220. package/docs/security/trust-ladder-threat-model.md +33 -33
  221. package/docs/telemetry.md +14 -0
  222. package/docs/usage.md +680 -571
  223. package/examples/README.md +10 -10
  224. package/examples/agent-instructions/README.md +39 -39
  225. package/examples/ci-smoke/README.md +21 -21
  226. package/examples/ci-smoke/ghostapi.policy.yaml +22 -22
  227. package/examples/ci-smoke/package.json +9 -9
  228. package/examples/ci-smoke/production-egress.mjs +4 -2
  229. package/examples/ci-smoke/safe.mjs +21 -17
  230. package/examples/evals/README.md +24 -24
  231. package/examples/evals/retry-after.eval.json +71 -52
  232. package/examples/generic-rest/README.md +27 -27
  233. package/examples/github-fetch/README.md +38 -35
  234. package/examples/openai-streaming/README.md +16 -16
  235. package/examples/openai-streaming/streaming-tool-call.mjs +44 -31
  236. package/examples/policy/ghostapi.policy.yaml +27 -27
  237. package/examples/record-replay/README.md +19 -19
  238. package/examples/record-replay/replay-requests.json +22 -22
  239. package/examples/record-replay/stripe-checkout.har.json +30 -30
  240. package/examples/resend-node/README.md +22 -22
  241. package/examples/stripe-node/README.md +35 -35
  242. package/examples/stripe-node/checkout-flow.mjs +87 -61
  243. package/examples/twilio-node/README.md +21 -21
  244. package/examples/worlds/README.md +19 -19
  245. package/examples/worlds/subscription-recovery.mjs +21 -12
  246. package/package.json +28 -6
  247. package/dist/landing/assets/index-BXR41fAD.css +0 -1
  248. package/dist/landing/assets/index-CxWsopzP.css +0 -1
  249. package/dist/landing/assets/index-D8_ggMRE.js +0 -55
  250. package/dist/landing/assets/index-DZlpyhqd.js +0 -55
  251. package/dist/landing/assets/index-Dk-Xezs3.js +0 -55
  252. package/dist/landing/index.html +0 -15
  253. package/dist/landing/landing.d.ts +0 -3
  254. package/dist/landing/landing.js +0 -12
  255. package/dist/landing/landing.js.map +0 -1
  256. package/docs/commercial/README.md +0 -29
  257. package/docs/commercial/data-inventory.md +0 -36
  258. package/docs/commercial/manual-invoicing.md +0 -44
  259. package/docs/commercial/metrics.md +0 -51
  260. package/docs/commercial/pricing.md +0 -103
  261. package/docs/commercial/privacy-policy-draft.md +0 -41
  262. package/docs/commercial/terms-topics-for-counsel.md +0 -51
  263. package/docs/design-partners/README.md +0 -52
  264. package/docs/design-partners/demo-narratives.md +0 -33
  265. package/docs/design-partners/design-partner-offer.md +0 -39
  266. package/docs/design-partners/discovery-questions.md +0 -28
  267. package/docs/design-partners/feedback-capture-template.md +0 -48
  268. package/docs/design-partners/icp-one-pager.md +0 -43
  269. package/docs/design-partners/onboarding-checklist.md +0 -33
  270. package/docs/design-partners/pilot-success-criteria.md +0 -27
  271. package/docs/design-partners/pricing-interview-script.md +0 -18
  272. package/docs/design-partners/telemetry-plan.md +0 -48
  273. package/docs/development/baseline.md +0 -114
  274. package/docs/development/onboarding-smoke.md +0 -37
  275. package/docs/development/verification-0.1.8.md +0 -25
  276. package/docs/enterprise-product-roadmap-ru.md +0 -1879
  277. package/docs/fundraising/README.md +0 -87
  278. package/docs/fundraising/data-room-checklist.md +0 -72
  279. package/docs/fundraising/demo-script.md +0 -52
  280. package/docs/fundraising/design-partners-50.md +0 -74
  281. package/docs/fundraising/launch-posts.md +0 -37
  282. package/docs/fundraising/metrics-and-evidence.md +0 -30
  283. package/docs/fundraising/roadmap-12-month.md +0 -25
  284. package/docs/fundraising/technical-due-diligence-index.md +0 -37
  285. package/docs/fundraising/yc-application.md +0 -25
  286. package/docs/hosted-pilot.md +0 -111
  287. package/docs/operations/disaster-recovery-runbook.md +0 -81
  288. package/docs/operations/kill-switch-runbook.md +0 -32
  289. package/docs/release-checklist.md +0 -83
  290. package/docs/release-migration-and-rollback.md +0 -63
  291. package/docs/release-readiness.md +0 -39
  292. package/docs/team-control-plane.md +0 -72
@@ -1,81 +0,0 @@
1
- # Disaster-Recovery Runbook
2
-
3
- Local backup and restore for the GhostAPI data directory (`GHOSTAPI_DATA_DIR`, default `.ghostapi/`).
4
-
5
- ## When To Use This
6
-
7
- - You are replacing or moving the local data directory and need a verified copy.
8
- - A store is corrupt (`ghostapi` reports a degraded runtime health) and you want to restore from a known-good backup.
9
- - You are running a quarterly DR drill: back up, destroy, restore, verify.
10
-
11
- ## Before You Start
12
-
13
- - Run `ghostapi start` is NOT required. Backup and restore work on a stopped or running instance, but restoring over a running instance is not supported — stop the instance first.
14
- - Backups are local directory copies with sha256 manifests. They are not encrypted, do not contain upstream secrets (the credential broker persists metadata only), and are not a substitute for object-storage or offsite backup.
15
- - The default backup destination is `.ghostapi/reliability/backups/backup-<timestamp>-<id>/`. Because the `backups` directory is excluded from future backups, backups never recursively include one another.
16
-
17
- ## Backup
18
-
19
- Backup is available programmatically:
20
-
21
- ```ts
22
- import { backupRuntime } from "@yiaany/ghostapi";
23
- const result = await backupRuntime({ destinationDir: ".ghostapi/reliability/backups/manual-drill" });
24
- // result: { backupId, path, fileCount, totalBytes, verified: true, createdAt }
25
- ```
26
-
27
- The backup verifies every copied file (size + sha256 + JSON structure for `.json` entries) and refuses to overwrite an existing destination. `result.verified` is only true after full verification.
28
-
29
- ## Restore
30
-
31
- ```ts
32
- import { restoreRuntimeBackup } from "@yiaany/ghostapi";
33
- await restoreRuntimeBackup({ sourceDir: ".ghostapi/reliability/backups/manual-drill", targetDir: ".ghostapi-restored" });
34
- ```
35
-
36
- Then point the runtime at the restored directory:
37
-
38
- ```bash
39
- export GHOSTAPI_DATA_DIR=/absolute/path/to/.ghostapi-restored
40
- ghostapi doctor
41
- ```
42
-
43
- Restore refuses:
44
-
45
- - A backup whose manifest was not verified at creation time.
46
- - Any manifest entry path that escapes the backup root (path traversal).
47
- - A target that is the backup source itself or inside it.
48
- - A target directory that is not empty (restore copies into a fresh directory).
49
- - Any entry whose bytes no longer match the manifest (tamper detection).
50
-
51
- ## Verification Steps After Restore
52
-
53
- 1. `ghostapi doctor` reports healthy.
54
- 2. `curl http://127.0.0.1:8080/health` returns `{ "ok": true, "ready": true }`.
55
- 3. `curl http://127.0.0.1:8080/health/readiness` returns HTTP 200 with a `ready: true` report. A 503 means the restored directory has a degraded store — do not continue.
56
- 4. Spot-check state: list actions (`ghostapi actions` or the equivalent CLI), run a reconciliation run, and confirm SLO sample counts are non-zero.
57
-
58
- ## Destroy-The-World Drill (Non-Destructive)
59
-
60
- 1. `backupRuntime` into `.ghostapi/reliability/backups/drill-<date>`.
61
- 2. `Remove-Item -Recurse -Force .ghostapi` (or `rm -rf`) to simulate data loss.
62
- 3. `restoreRuntimeBackup` into a fresh directory.
63
- 4. Point `GHOSTAPI_DATA_DIR` at the restored directory and run the verification steps above.
64
- 5. Confirm the backup directory still exists untouched (restore copies out of it; it never deletes).
65
-
66
- ## Failure Modes
67
-
68
- | Symptom | Meaning | Action |
69
- | --- | --- | --- |
70
- | "Backup destination already exists" | Refusing to overwrite | Use a new destination or remove the old backup deliberately |
71
- | "Backup source entry is not valid JSON" | A `.json` file in the data dir is corrupt | Find and fix/delete the corrupt store, then re-back up |
72
- | "Backup file content changed during copy" | Concurrent write during backup | Stop writers, re-run backup |
73
- | "failed integrity verification" on restore | Backup was tampered or the disk changed | Do not restore; find the original source or a different backup |
74
- | "path escapes its root directory" | Crafted/tampered manifest | Reject the backup as untrusted |
75
- | `/health/readiness` returns 503 | A restored store is corrupt | Inspect the `degraded` store in the report and repair/delete it, then re-check |
76
-
77
- ## Retention Guidance
78
-
79
- - Keep at least two rotating backups: the previous known-good and the current.
80
- - Back up before any release or before switching `GHOSTAPI_DATA_DIR`.
81
- - The 64 MiB backup cap covers the bounded local stores; if your worlds/actions exceed it, prune old synthetic data first.
@@ -1,32 +0,0 @@
1
- # Kill Switch Runbook
2
-
3
- ## Detection
4
-
5
- Use this procedure when policy violations, abnormal action velocity, budget exhaustion, reconciliation mismatch, latency/failure circuit opening, or suspected agent compromise is observed. An alert is evidence only; it is not a stop. Verify the affected organization, project, environment, agent/workload, provider, operation, or risk class before selecting scope.
6
-
7
- ## Stop
8
-
9
- 1. Use an independently authenticated emergency operator with `safety.stop`.
10
- 2. Call the local `LocalSafetyController.stop({ identity, scope, reason })` API with the narrowest safe scope. Use `global` when the scope cannot be established quickly.
11
- 3. Record a bounded factual reason without credentials, raw requests, personal data, or provider payloads.
12
- 4. Confirm the persisted switch is enabled and examine the safety audit chain. Matching queued records must be in the dead-letter queue, not still pending.
13
- 5. Treat actions that passed their final commit check as potentially completed. Do not retry unknown outcomes; investigate or reconcile them first.
14
-
15
- ## Investigation
16
-
17
- 1. Preserve the local safety, action, approval, and credential-broker state files as evidence under the existing local trust model.
18
- 2. Inspect action receipt status, controller audit records, budget ledger, circuit reason, and dead letters.
19
- 3. Identify the exact idempotency key and action hash. A changed action must be submitted as a new reviewed action, never forced through a prior reservation.
20
- 4. For any future provider integration, reconcile against the provider before retrying or compensating. This local synthetic controller cannot prove external outcome.
21
-
22
- ## Recovery
23
-
24
- 1. Correct the policy/configuration or isolate the compromised workload.
25
- 2. Review budgets, circuit thresholds, and the root cause. Do not clear audit, ledger, or dead-letter state to make a control appear healthy.
26
- 3. Require a separately authenticated operator with `safety.reenable`; the stop permission alone is insufficient.
27
- 4. Call `reenable({ identity, scope, reason })` and confirm the audit record and persisted switch state.
28
- 5. Re-admit only a reviewed action. Approved artifacts still require current policy, identity, idempotency, budget, circuit, kill-switch, and final-commit checks.
29
-
30
- ## Game Day
31
-
32
- The `GhostAPI Kill Switch Game Day` workflow runs at `03:17 UTC` each Monday and can be started manually. It executes only the local synthetic controller test. Investigate a failed drill before trusting the control: a successful alert without a verified blocked action is not sufficient.
@@ -1,83 +0,0 @@
1
- # Release Checklist
2
-
3
- Use this checklist before publishing GhostAPI to GitHub or npm.
4
-
5
- ## Metadata
6
-
7
- - `package.json` has the correct `name`, `version`, `description`, `license`, `bin`, `files`, `keywords`, and repository metadata.
8
- - `README.md` explains value, install, CLI, provider coverage, examples, safety, and contributing.
9
- - `CHANGELOG.md` has an entry for the release.
10
- - `LICENSE`, `SECURITY.md`, `CONTRIBUTING.md`, and `CODE_OF_CONDUCT.md` are present.
11
- - [Release readiness matrix](release-readiness.md) and [migration/rollback guide](release-migration-and-rollback.md) are current for the proposed release.
12
-
13
- ## Local Verification
14
-
15
- ```bash
16
- npm run typecheck
17
- npm test
18
- npm run build
19
- npm run smoke:package
20
- ```
21
-
22
- Smoke check the built CLI:
23
-
24
- ```bash
25
- node dist/cli/index.js --help
26
- node dist/cli/index.js providers list
27
- node dist/cli/index.js model get
28
- ```
29
-
30
- Run local proxy smoke tests:
31
-
32
- ```bash
33
- node dist/cli/index.js start --offline --port 8080
34
- ```
35
-
36
- Then verify locally:
37
-
38
- ```bash
39
- curl http://localhost:8080/health
40
- curl http://localhost:8080/dashboard
41
- curl -X POST http://localhost:8080/v1/customers -H "content-type: application/json" -d '{"email":"ada@example.com"}'
42
- curl http://localhost:8080/v1/customers
43
- curl -X POST http://localhost:8080/emails -H "content-type: application/json" -d '{"from":"dev@example.com","to":"ada@example.com","subject":"Hello"}'
44
- curl -X POST http://localhost:8080/2010-04-01/Accounts/AC123/Messages.json -H "content-type: application/x-www-form-urlencoded" -d "To=+15551234567&From=+15557654321&Body=Hello"
45
- ```
46
-
47
- ## Package Verification
48
-
49
- ```bash
50
- npm pack --dry-run
51
- ```
52
-
53
- Confirm the package includes only intended release files and does not include:
54
-
55
- - `.ghostapi/`
56
- - `.env`
57
- - `node_modules/`
58
- - local logs
59
- - test output
60
-
61
- ## Safety Checks
62
-
63
- - GhostAPI does not make real provider API calls by default.
64
- - Ambient `OPENAI_API_KEY` does not enable external LLM access.
65
- - LLM usage requires explicit opt-in plus `GHOSTAPI_LLM_API_KEY`, and receives sanitized requests.
66
- - Dashboard events are sanitized.
67
- - State and persisted event files do not contain secret fixtures used by security tests.
68
- - Cache keys do not include raw secrets.
69
- - Ordered request arrays produce distinct cache keys when their order changes.
70
- - Concurrent child-process state and behavior writes preserve all covered updates.
71
- - Persisted events rotate at 5 MiB and retain no more than two archives.
72
- - Non-loopback startup fails without a strong `GHOSTAPI_AUTH_TOKEN`; dashboard APIs and SSE reject missing tokens.
73
- - Generated tests honor `GHOSTAPI_BASE_URL` instead of requiring port 8080.
74
- - CLI user errors are actionable and do not print confusing stack traces.
75
- - GitHub workflows use least-privilege permissions and SHA-pinned actions.
76
- - Security claims match tests actually run on the target platform; Windows/macOS local simulation is not Linux enforcement evidence.
77
- - Any full-audit findings have a documented owner and remediation plan.
78
-
79
- ## Publish
80
-
81
- - Tag the release.
82
- - Push to GitHub.
83
- - Publish to npm only after package dry-run output has been reviewed.
@@ -1,63 +0,0 @@
1
- # Release Migration And Rollback
2
-
3
- Last reviewed: 2026-08-08.
4
-
5
- This guide covers the published local `@yiaany/ghostapi` package. The separate `hosted/` pilot is not part of the npm package and has no production migration or rollback approval.
6
-
7
- ## Before Upgrade
8
-
9
- 1. Read the target `CHANGELOG.md`, `SECURITY.md`, platform limitations, and package contents.
10
- 2. Keep the project policy and scenarios under normal source control only if they contain no sensitive data. `.ghostapi/` can contain local simulation data and evidence; do not upload it as a generic backup.
11
- 3. If a local backup is needed, make an access-controlled copy of only the required `.ghostapi/` files and review it for secrets before transferring it.
12
- 4. Run `ghostapi doctor --json`. On Windows and macOS, use `ghostapi start --open` for local simulation; do not expect `ghostapi run` enforcement.
13
-
14
- ## Upgrade
15
-
16
- ```bash
17
- npx @yiaany/ghostapi@<version> init
18
- npx @yiaany/ghostapi@<version> doctor --json
19
- ```
20
-
21
- `init` does not overwrite existing setup files. Review generated setup guidance rather than replacing local policy or agent instructions blindly.
22
-
23
- For a source checkout, install the pinned lockfile and run:
24
-
25
- ```bash
26
- npm ci
27
- npm run typecheck
28
- npm test
29
- npm run build
30
- npm run smoke:package
31
- ```
32
-
33
- On supported Linux runners, also run the selected enforced workflow and generate a sanitized evidence report. A successful Windows/macOS local simulation must not be used as substitute evidence for Linux namespace enforcement.
34
-
35
- ## Rollback
36
-
37
- 1. Stop the local GhostAPI process or CI job.
38
- 2. Reinstall the previously reviewed package version or return the source checkout to the previously reviewed commit using the repository's normal non-destructive deployment procedure.
39
- 3. Re-run `ghostapi doctor --json` and the same local smoke or CI workflow used before the upgrade.
40
- 4. Preserve only sanitized evidence needed to explain the rollback. Do not attach raw traffic, secrets, source code, or local data directories to an issue.
41
- 5. If a local data schema rejects an older runtime, do not hand-edit or delete data in place. Work on an access-controlled copy, report the exact version/error through the security or maintainer channel, and retain the original until a recovery path is reviewed.
42
-
43
- ## Rollback Scope
44
-
45
- - The current local runtime has no account, hosted entitlement, billing state, or remote control plane to roll back.
46
- - `ghostapi telemetry disable` removes the optional local aggregate; it is not a product-version rollback tool.
47
- - Local file locks coordinate cooperating processes on one filesystem only. Do not attempt a rollback while concurrent GhostAPI processes write the same data directory.
48
-
49
- ## Release Verification
50
-
51
- Run these on the proposed release commit:
52
-
53
- ```bash
54
- npm ci
55
- npm run typecheck
56
- npm test
57
- npm run build
58
- npm run smoke:package
59
- npm pack --dry-run
60
- npm audit --omit=dev
61
- ```
62
-
63
- Also review the package file list, tracked-source secret scan, direct runtime dependency licenses, GitHub workflow permissions/action pins, and the known gaps in [release readiness](release-readiness.md). Both the production-only and full dependency audits must pass for this release.
@@ -1,39 +0,0 @@
1
- # Release Readiness Matrix
2
-
3
- Last reviewed: 2026-08-22.
4
-
5
- This matrix is a release-candidate review, not a publication approval. No Git tag, GitHub release, or npm publication was created during this review.
6
-
7
- | Feature | Platform / boundary | Guarantee level | Evidence reviewed | Known gap | Owner before release |
8
- | --- | --- | --- | --- | --- | --- |
9
- | Local provider simulation, dashboard, MCP | Node.js on Windows and Ubuntu WSL2 | Local simulation only; no real provider calls by default. | Final 0.1.8 root lint and typecheck; 55 files and 341 tests with zero skipped; build; packed-package smoke; full and production audits with zero vulnerabilities. | GitHub Actions has not yet been observed on the exact final pushed commit. | Maintainer: retain the exact-commit CI results before publication. |
10
- | `ghostapi run` | Linux only when `unshare` and `ip` preflight pass | Loopback-only user/mount/network/PID namespace; fail closed. Not a hostile-code filesystem sandbox. | Native Ubuntu WSL2 enforcement suite passed 12 of 12 tests with zero skipped on 2026-08-22, exercising the Linux namespace boundary. Earlier 0.1.7 WSL evidence remains historical. | Local WSL2 evidence is not a substitute for GitHub Actions on the exact final commit. | Maintainer: observe the pinned workflow after push and retain sanitized evidence. |
11
- | Policy parser | Local YAML input | Bounded, one-document, no anchors/aliases/interpolation, path-contained parsing. | Unit tests plus 400 deterministic malformed-input cases. | Fuzz corpus is deterministic regression coverage, not a replacement for long-running fuzzing. | Maintainer: extend corpus when syntax support changes. |
12
- | Evidence reports | Local files and explicit `--run` input | Bounded report/run input, secret redaction, canonical logical hash, fail-closed CI result. | Evidence tests include corruption, traversal, terminal escapes, malformed and oversized run evidence. | Same-user filesystem TOCTOU remains outside the local lock/store threat boundary. | Maintainer: document/assess before any shared filesystem support. |
13
- | Record/replay and contract import | Local JSON/HAR/OpenAPI input | Bounded JSON only; archives, remote refs, symlinks, unsafe hosts, redirects, and secret-bearing bundles reject. | Scenario and contract suites; deterministic malformed-input coverage. | Sanitization is heuristic and requires operator review before sharing. | Maintainer: maintain provider/sanitizer regression fixtures. |
14
- | Provider packs | Local runtime | Deterministic provider-shaped behavior; unsupported endpoints fail diagnostically. | Stripe lifecycle/conformance tests and provider tests. | Fidelity remains limited to implemented capabilities, not live-provider parity. | Pack maintainer: add conformance before widening claims. |
15
- | Root CI workflow | GitHub Actions | Read-only repository token and SHA-pinned actions. | Workflow regression coverage is included in the final root suite; workflow definitions include lint/typecheck/test/build/package/audit, hosted, Docker, and Linux enforcement checks. | The workflows still must be observed on the exact final commit after push. | Maintainer: review and retain the GitHub run before publication. |
16
- | Hosted pilot | Separate Bun/Elysia codebase, implemented but not deployed | Code-level tenant authorization, role checks, bounded request handling, hashed one-time secrets, durable quotas, idempotency, outbox/worker retries, dead-letter state, retention cleanup, readiness checks, and audit metadata. No live-service guarantee. | Clean hosted install; typecheck; 26 tests with zero skipped, including cloned auth-request body bounds; Bun build; zero-vulnerability audit; local non-root Docker image build; migrations `001`-`004` applied to PostgreSQL 17; concurrent organization quota race passed. | No staging deployment; live Google OAuth, Redis, QStash, sustained load, failover, and disaster-recovery behavior remain unproven. | Hosted owner: complete operational gates before any pilot use. |
17
- | Product telemetry | Local runtime | Disabled by default, aggregate-only, no network transport; opt-out deletes local aggregate. | Product telemetry tests and package smoke. | Not a hosted/team analytics system. | Product owner: obtain explicit partner need before any networked design. |
18
-
19
- ## Threat Model Delta Since Session 06
20
-
21
- - The old proxy-guidance-only model is now explicitly separated from Linux `ghostapi run` enforcement. Unsupported platforms fail closed instead of treating proxy configuration as isolation.
22
- - Process execution now creates bounded lifecycle evidence, strips secret-shaped target environment values, limits target output, and records only aggregate output-secret/limit signals.
23
- - Policy, scenario, contract, evidence, replay, and hosted report inputs have bounded parsers and reject traversal, symlink, archive, remote-reference, unsupported-schema, or secret-bearing inputs where applicable.
24
- - Root CI now explicitly uses `contents: read`; the PR safety workflow remains SHA-pinned, artifact-bounded, and avoids executing fork code in its write-comment job.
25
- - The hosted pilot now implements bounded request parsing, explicit tenant/role authorization, exact-origin mutation checks, one-time hashed invitation and ingest secrets, durable quotas, worker/outbox retry limits, dead-letter handling, retention cleanup, security headers, and dependency-aware readiness. These are locally tested implementation claims, not evidence of a deployed service.
26
-
27
- ## Open P2 Items
28
-
29
- | Item | Plan | Owner |
30
- | --- | --- | --- |
31
- | GitHub Actions on the exact final commit is still required before publication. | Push the final commit, observe every required pinned workflow and job, and retain the run plus sanitized evidence links. | Maintainer. |
32
- | Hosted staging and migration rehearsal are incomplete. | Deploy an isolated staging environment and apply the four application migrations plus the pinned Better Auth migration against production-shaped PostgreSQL; verify rollback/forward-recovery procedures and tenant authorization. | Hosted owner. |
33
- | Hosted load and queue behavior are unproven. | Exercise production-shaped sustained/burst load, Redis rate limits, QStash signature validation/redelivery, outbox leases, worker retries/dead letters, and backlog drain behavior with measured thresholds. | Hosted owner. |
34
- | Hosted disaster recovery is unproven. | Run repeated backup/restore and regional dependency-failure drills; record measured RPO/RTO instead of claiming the architectural targets. | Hosted owner. |
35
- | Live OAuth and operational secret/configuration paths are unproven. | Validate Google OAuth redirect/origin configuration, session expiry/rotation, account-linking restrictions, secret rotation, and failure behavior in staging. | Hosted owner. |
36
-
37
- ## Release Gate
38
-
39
- The root local package passed the final local 0.1.8 verification recorded in [the 0.1.8 verification record](development/verification-0.1.8.md). Publication still requires observing GitHub Actions on the exact final commit after push. Do not claim a deployed hosted service, completed hosted operational readiness, Linux enforcement on Windows/macOS, or billing availability from this matrix.
@@ -1,72 +0,0 @@
1
- # Team Control-Plane Prototype
2
-
3
- ## Scope
4
-
5
- As of August 8, 2026, the cloud/design-partner gate remains unmet. This is a local architecture prototype stored in a private JSON file. It has no hosted or public endpoint, network listener, deployment, SSO/OIDC/SAML integration, cloud synchronization, telemetry, or external dependency. Local GhostAPI workflows do not require an account or team token.
6
-
7
- The store is `.ghostapi/team-control-plane.json` (or the configured `GHOSTAPI_DATA_DIR`). Existing same-directory atomic writes and cooperative cross-process locking protect updates. The store rejects symlinks and data over 1 MiB. This is not a compliance product, immutable storage system, credential broker, or distributed security boundary.
8
-
9
- ## Data Flow
10
-
11
- ```mermaid
12
- flowchart LR
13
- Caller[Local typed-library caller] --> Auth[Token authentication or local actor]
14
- Auth --> Permit[Central permission and scope evaluator]
15
- Permit --> Plane[Local control-plane methods]
16
- Plane --> Lock[Locked atomic JSON store]
17
- Plane --> Ledger[Per-organization SHA-256 audit chain]
18
- Future[Future HTTP transport] -. must apply .-> Headers[CSP and security headers]
19
- Future -. must apply .-> Limit[Fixed-window fail-closed limiter]
20
- Disabled[Disabled identity provider] -. always denies; no I/O .-> Future
21
- ```
22
-
23
- No transport is supplied. A future HTTP layer must authenticate before dispatch, apply `createTeamControlPlaneSecurityHeaders()` (or the immutable `TEAM_CONTROL_PLANE_SECURITY_HEADERS`), use `TeamControlPlaneRateLimiter` before processing with a non-secret opaque principal key, avoid logging raw tokens, and fail closed on invalid keys, invalid limits, invalid clocks, or limiter capacity exhaustion.
24
-
25
- ## Tenant And Authorization Model
26
-
27
- Organizations are tenant boundaries. Projects, environments, scenarios, evidence, policies, service accounts, tokens, and audit records all belong to one organization. Parent references are validated on every read and write. Missing scoped parents return `Resource not found`, preventing cross-tenant identifier disclosure.
28
-
29
- All authorization uses the centralized `TEAM_PERMISSION_MATRIX`. The least-privilege matrix is:
30
-
31
- | Role | Permissions |
32
- | --- | --- |
33
- | `owner` | `member.manage`, `project.manage`, `environment.manage`, `policy.manage`, `token.manage`, `service_account.manage`, `audit.read`, `audit.export`, `data.delete`, `retention.manage`, all scoped reads, `scenario.publish`, `evidence.upload` |
34
- | `admin` | Everything listed for owner except `member.manage` |
35
- | `developer` | Scoped reads, `scenario.publish`, `evidence.upload` |
36
- | `viewer` | Scoped reads only |
37
- | `service_account` | Token-scoped project/environment reads, `scenario.publish`, and `evidence.upload` only; no organization-wide policy or audit access |
38
-
39
- `admin` cannot grant members or issue, rotate, or revoke a token for an owner. `owner` can manage every human-member token. Service-account actors have a distinct `service:<id>` audit identity and cannot impersonate a human member.
40
-
41
- ## Tokens And Service Accounts
42
-
43
- Owners and admins create managed service accounts using an identifier and display name. A service account has no plaintext secret and is not a human member. Tokens are typed `user` or `service`, have SHA-256 digests only in persisted state, are returned once at issuance, can be revoked, and must expire within 90 days.
44
-
45
- `issueToken` remains the human-token API. `issueServiceToken` requires a live service account and a nonempty, bounded list of scope entries. Every entry names an existing `{ projectId, environmentId }` and a nonempty subset of service-account scoped permissions. Authentication validates token digest, expiry, revocation, account state, and scope. A service actor is an in-memory authenticated capability returned only by `authenticateToken`; constructing an object with a token id is rejected. Each scoped method resolves that token's persisted scope, expiry, revocation, and account state again before acting. Rotation revokes the prior token and creates the replacement in one locked mutation; `disableServiceAccount` immediately revokes all of its live tokens. No reusable plaintext token is stored.
46
-
47
- ## Audit Integrity And Export
48
-
49
- Schema v3 uses a per-organization append-only SHA-256 chain. Each record includes `sequence`, `previousHash`, and `recordHash`; the organization anchor supplies the sequence and hash before the retained window. `exportAudit` returns the anchor, records, and an integrity result. `verifyAuditExport` is public and detects changes to a record, record order, sequence, or chain link. Exports contain audit metadata only and never include token plaintext or other secrets.
50
-
51
- Schema v1 migrates through v2 to v3. Legacy `member` becomes `developer`; typed user tokens replace legacy `memberId` token bindings; legacy audit rows are replayed into a validated v3 SHA-256 chain. Unknown fields, malformed references, invalid token scopes, invalid service-account references, and invalid chains fail closed.
52
-
53
- Audit retention is bounded to 90 days and 1,000 records per organization. Pruning does not silently sever the chain: the last pruned record becomes the retained audit anchor. Sanitized evidence is retained for 30 days and capped at 100 records per organization. Owners and admins may explicitly delete evidence; deletion is tenant- and project-bound and audited. `deleteProject` removes that tenant project's environments, scenarios, evidence, and scoped service tokens in the same locked mutation. Audit export is restricted to `audit.export`; data deletion is restricted to `data.delete`.
54
-
55
- ## Identity And Incident Response
56
-
57
- `TeamIdentityProvider` is a future integration boundary only. The single provided implementation, `createDisabledIdentityProvider`, performs no I/O and always denies authentication. No OIDC, SAML, SSO, SCIM, or remote identity protocol is implemented.
58
-
59
- If a token is exposed, an owner or authorized admin must revoke it, remove it from local logs or CI output, rotate or issue a short-lived replacement, and inspect `exportAudit` with `verifyAuditExport`. If the integrity result is false or the store fails validation, stop using the store, preserve the file for local investigation, restore only a reviewed local backup, and do not manually repair records or bypass validation. If evidence is incorrectly retained, use explicit evidence deletion or `pruneRetention`; both actions are audited.
60
-
61
- ## Verification
62
-
63
- ```bash
64
- npm run typecheck
65
- npm test -- --run test/teamControl.test.ts
66
- ```
67
-
68
- ## Explicit Non-Goals
69
-
70
- - No hosted API, public endpoint, deployment, dashboard, cloud sync, billing, SSO, SCIM, or generic project management.
71
- - No raw traffic, source code, secrets, or automatic artifact upload.
72
- - No compliance, legal-hold, immutable-storage, or distributed-isolation claim.