@smartmemory/stratum 0.3.4 → 0.4.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 (73) hide show
  1. package/dist/cli/guard.js +63 -6
  2. package/dist/cli/guard.js.map +1 -1
  3. package/dist/cli/learn.js +226 -0
  4. package/dist/cli/learn.js.map +1 -0
  5. package/dist/cli/stratum.js +3 -1
  6. package/dist/cli/stratum.js.map +1 -1
  7. package/dist/connectors/background.js +53 -9
  8. package/dist/connectors/background.js.map +1 -1
  9. package/dist/connectors/base.js +16 -0
  10. package/dist/connectors/base.js.map +1 -1
  11. package/dist/connectors/cancellation.js +119 -0
  12. package/dist/connectors/cancellation.js.map +1 -0
  13. package/dist/connectors/claude-bg-worker.js +9 -1
  14. package/dist/connectors/claude-bg-worker.js.map +1 -1
  15. package/dist/connectors/claude.js +179 -86
  16. package/dist/connectors/claude.js.map +1 -1
  17. package/dist/connectors/codex.js +219 -62
  18. package/dist/connectors/codex.js.map +1 -1
  19. package/dist/connectors/runner.js +44 -3
  20. package/dist/connectors/runner.js.map +1 -1
  21. package/dist/contracts/events.json +34 -1
  22. package/dist/contracts/guard-signers.allowed +36 -0
  23. package/dist/contracts/mcp-surface.json +1085 -104
  24. package/dist/engine/checkpoint.js +8 -1
  25. package/dist/engine/checkpoint.js.map +1 -1
  26. package/dist/engine/engine.js +403 -42
  27. package/dist/engine/engine.js.map +1 -1
  28. package/dist/engine/ledger.js +12 -0
  29. package/dist/engine/ledger.js.map +1 -1
  30. package/dist/engine/receipts.js +91 -0
  31. package/dist/engine/receipts.js.map +1 -0
  32. package/dist/engine/state.js +51 -1
  33. package/dist/engine/state.js.map +1 -1
  34. package/dist/guard/authorization.js +71 -0
  35. package/dist/guard/authorization.js.map +1 -0
  36. package/dist/guard/descriptors.js +248 -0
  37. package/dist/guard/descriptors.js.map +1 -0
  38. package/dist/guard/errors.js +12 -0
  39. package/dist/guard/errors.js.map +1 -1
  40. package/dist/guard/evidence.js +24 -3
  41. package/dist/guard/evidence.js.map +1 -1
  42. package/dist/guard/sshsig.js +264 -0
  43. package/dist/guard/sshsig.js.map +1 -0
  44. package/dist/guard/store.js +13 -0
  45. package/dist/guard/store.js.map +1 -1
  46. package/dist/guard/transition.js +484 -33
  47. package/dist/guard/transition.js.map +1 -1
  48. package/dist/guard/trust.js +78 -0
  49. package/dist/guard/trust.js.map +1 -0
  50. package/dist/judge/judged.js +1 -1
  51. package/dist/judge/pricing.js +1 -0
  52. package/dist/judge/pricing.js.map +1 -1
  53. package/dist/learn/apply.js +600 -0
  54. package/dist/learn/apply.js.map +1 -0
  55. package/dist/learn/candidate.js +186 -0
  56. package/dist/learn/candidate.js.map +1 -0
  57. package/dist/learn/classify.js +181 -0
  58. package/dist/learn/classify.js.map +1 -0
  59. package/dist/learn/harvest.js +138 -0
  60. package/dist/learn/harvest.js.map +1 -0
  61. package/dist/learn/smartmemory_egress.js +330 -0
  62. package/dist/learn/smartmemory_egress.js.map +1 -0
  63. package/dist/mcp/server.js +150 -22
  64. package/dist/mcp/server.js.map +1 -1
  65. package/dist/policy/bundle.js +195 -0
  66. package/dist/policy/bundle.js.map +1 -0
  67. package/dist/policy/events.js +51 -0
  68. package/dist/policy/events.js.map +1 -0
  69. package/dist/policy/smartmemory_client.js +332 -0
  70. package/dist/policy/smartmemory_client.js.map +1 -0
  71. package/dist/policy/types.js +2 -0
  72. package/dist/policy/types.js.map +1 -0
  73. package/package.json +3 -2
@@ -1,5 +1,5 @@
1
1
  {
2
- "events": 1,
2
+ "events": 2,
3
3
  "shapeLanguage": "Each kind maps to the full event payload shape minus the implicit {at: string, type: string}. Leaf types: number|string|boolean|object|array|null|any, unions with '|', optional keys end in '?', nested objects are declared inline. Undeclared keys are contract violations.",
4
4
  "kinds": {
5
5
  "planned": {},
@@ -60,6 +60,39 @@
60
60
  "fanout_merge": {
61
61
  "stepId": "string",
62
62
  "detail": { "itemIndex": "number", "success": "boolean", "reason?": "string" }
63
+ },
64
+ "usage_debit": {
65
+ "stepId?": "string",
66
+ "detail": {
67
+ "seq": "number",
68
+ "dispatchId": "string",
69
+ "source": "string",
70
+ "amount": "object",
71
+ "model": "string",
72
+ "effort?": "string",
73
+ "durationMs": "number",
74
+ "epoch?": "number",
75
+ "attempt?": "number",
76
+ "item?": { "itemIndex": "number", "stage": "number", "generation": "number" },
77
+ "split?": { "input": "number", "output": "number", "cacheRead?": "number", "cacheCreation?": "number" },
78
+ "usdSource?": "string",
79
+ "reportedAt?": "string"
80
+ }
81
+ },
82
+ "step_reset": {
83
+ "stepId": "string",
84
+ "detail": {
85
+ "reason": "string",
86
+ "reset": { "$array": { "stepId": "string", "fromEpoch": "number", "toEpoch": "number" } },
87
+ "subflowsDropped": { "$array": "string" }
88
+ }
89
+ },
90
+ "checkpoint_reverted": {
91
+ "detail": {
92
+ "label": "string",
93
+ "receiptsAtRevert": "number",
94
+ "stepsRestored": { "$array": "string" }
95
+ }
63
96
  }
64
97
  }
65
98
  }
@@ -0,0 +1,36 @@
1
+ # Guard authorization trust root.
2
+ #
3
+ # Public keys permitted to sign guard authorization artifacts (upgrade
4
+ # descriptors, and any future signed authorization). OpenSSH `allowed_signers`
5
+ # format, restricted to a strict subset:
6
+ #
7
+ # <principal[,principal...]> ssh-ed25519 <base64> [comment]
8
+ #
9
+ # Option lists (cert-authority, namespaces=, valid-before=) are REFUSED, not
10
+ # ignored — a restriction written here must never be silently dropped.
11
+ #
12
+ # THIS FILE IS THE TRUST ROOT. It is read from the installed source tree, never
13
+ # from an environment variable, so changing who may authorize a guard policy
14
+ # change requires editing a committed file. That is deliberate: an environment
15
+ # variable can be set silently by whatever process happens to be running, while
16
+ # a change here shows up in `git status` and in review.
17
+ #
18
+ # Empty by default. There is no default trust: until a key is added, the signed
19
+ # authorization paths report themselves unavailable rather than falling back to
20
+ # something weaker.
21
+ #
22
+ # To enrol a signer:
23
+ # 1. On the operator's machine, create a signing key whose passphrase exists
24
+ # only in the operator's head, and never add it to ssh-agent (an agent that
25
+ # can reach the agent socket can use the key without knowing the passphrase):
26
+ # ssh-keygen -t ed25519 -f ~/.stratum/guard-signing -C "<who>"
27
+ # 2. Append the PUBLIC half here with a principal name:
28
+ # echo "<who> $(cat ~/.stratum/guard-signing.pub)" >> ts/contracts/guard-signers.allowed
29
+ # 3. Commit it. The private half never leaves the operator's machine and is
30
+ # useless to anything that does not know the passphrase.
31
+ #
32
+ # To sign a descriptor file:
33
+ # ssh-keygen -Y sign -f ~/.stratum/guard-signing \
34
+ # -n stratum-guard-descriptors /path/to/guard-upgrades.json
35
+ # (writes /path/to/guard-upgrades.json.sig; you will be prompted for the
36
+ # passphrase, which is the point)