stylegallery 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 (230) hide show
  1. package/AGENTS.md +4 -1
  2. package/DOMAINS.md +2 -6
  3. package/GOVERNANCE.md +10 -9
  4. package/README.md +29 -127
  5. package/consumer-reference/agent-native/v2/admission-policy.json +646 -0
  6. package/consumer-reference/agent-native/v2/material-registry.json +1 -0
  7. package/consumer-reference/agent-native/v2/schema/admission-policy.schema.json +50 -0
  8. package/consumer-reference/agent-native/v2/schema/material-manifest.schema.json +17 -0
  9. package/consumer-reference/agent-native/v2/schema/material-record.schema.json +20 -0
  10. package/consumer-reference/contract.md +1 -1
  11. package/consumer-reference/index.md +5 -3
  12. package/layout/index.md +124 -0
  13. package/log.md +57 -0
  14. package/package.json +183 -22
  15. package/scripts/agent-native/v2/experimental-extension-registry.mjs +143 -0
  16. package/scripts/agent-native/v2/extensions/a2a-projection.mjs +264 -0
  17. package/scripts/agent-native/v2/extensions/agui-projection.mjs +191 -0
  18. package/scripts/agent-native/v2/material-admission.mjs +295 -0
  19. package/scripts/agent-native/v2/material-cli-adapter.mjs +134 -0
  20. package/scripts/agent-native/v2/material-context.mjs +251 -0
  21. package/scripts/agent-native/v2/material-identity.mjs +71 -0
  22. package/scripts/agent-native/v2/material-mcp-adapter.mjs +253 -0
  23. package/scripts/agent-native/v2/material-operation-registry.mjs +123 -0
  24. package/scripts/agent-native/v2/material-queries.mjs +398 -0
  25. package/scripts/agent-native/v2/material-registry.mjs +319 -0
  26. package/scripts/sg-material-mcp.mjs +98 -0
  27. package/scripts/sg-material.mjs +27 -0
  28. package/consumer-reference/adapters/style-dictionary.config.mjs +0 -36
  29. package/consumer-reference/baselines/calibration.json +0 -260
  30. package/consumer-reference/baselines/manifest.json +0 -21
  31. package/consumer-reference/fixtures/consumer-conformance/e2e-fixture.mjs +0 -282
  32. package/consumer-reference/fixtures/consumer-conformance/manifest.json +0 -102
  33. package/consumer-reference/fixtures/consumer-conformance/runtime-proof.mjs +0 -32
  34. package/consumer-reference/fixtures/consumer-conformance/valid-migration-result.json +0 -18
  35. package/consumer-reference/fixtures/consumer-conformance/valid-migration.json +0 -142
  36. package/consumer-reference/fixtures/invalid-stable-ended-support.json +0 -19
  37. package/consumer-reference/fixtures/promotion/invalid-blocking-evidence.json +0 -26
  38. package/consumer-reference/fixtures/promotion/invalid-count-only.json +0 -29
  39. package/consumer-reference/fixtures/promotion/invalid-missing-owner-migration.json +0 -25
  40. package/consumer-reference/fixtures/promotion/invalid-normative-bypass-no-regression.json +0 -25
  41. package/consumer-reference/fixtures/promotion/invalid-related-counted-independent.json +0 -45
  42. package/consumer-reference/fixtures/promotion/invalid-stable-ended-support.json +0 -26
  43. package/consumer-reference/fixtures/promotion/manifest.json +0 -15
  44. package/consumer-reference/fixtures/promotion/valid-deferred-example.json +0 -67
  45. package/consumer-reference/fixtures/promotion/valid-normative-bypass.json +0 -67
  46. package/consumer-reference/fixtures/token-portability/invalid-cycle.json +0 -7
  47. package/consumer-reference/fixtures/token-portability/invalid-dangling-alias.json +0 -6
  48. package/consumer-reference/fixtures/token-portability/invalid-extends.json +0 -4
  49. package/consumer-reference/fixtures/token-portability/invalid-json-pointer.json +0 -7
  50. package/consumer-reference/fixtures/token-portability/invalid-resolver.json +0 -9
  51. package/consumer-reference/fixtures/token-portability/invalid-type-mismatch.json +0 -10
  52. package/consumer-reference/fixtures/token-portability/invalid-unknown-reserved.json +0 -6
  53. package/consumer-reference/fixtures/token-portability/invalid-untested-type.json +0 -6
  54. package/consumer-reference/fixtures/token-portability/valid-border.json +0 -14
  55. package/consumer-reference/fixtures/token-portability/valid-reference.json +0 -32
  56. package/consumer-reference/fixtures/token-portability/valid-whole-alias.json +0 -7
  57. package/consumer-reference/fixtures/valid-deprecated.json +0 -21
  58. package/consumer-reference/fixtures/valid-experimental.json +0 -19
  59. package/consumer-reference/generated/manifest.json +0 -40
  60. package/consumer-reference/generated/tokens.css +0 -12
  61. package/consumer-reference/policies/shared-experimental.json +0 -37
  62. package/consumer-reference/schema/ax-evidence.schema.json +0 -30
  63. package/consumer-reference/schema/baseline-manifest.schema.json +0 -55
  64. package/consumer-reference/schema/calibration-record.schema.json +0 -190
  65. package/consumer-reference/schema/capture-session.schema.json +0 -161
  66. package/consumer-reference/schema/component-state.schema.json +0 -150
  67. package/consumer-reference/schema/consumer-conformance-record.schema.json +0 -365
  68. package/consumer-reference/schema/dom-evidence.schema.json +0 -38
  69. package/consumer-reference/schema/evidence-record.schema.json +0 -81
  70. package/consumer-reference/schema/fixture-manifest.schema.json +0 -32
  71. package/consumer-reference/schema/item.schema.json +0 -188
  72. package/consumer-reference/schema/page-evidence-manifest.schema.json +0 -216
  73. package/consumer-reference/schema/page-evidence-session.schema.json +0 -119
  74. package/consumer-reference/schema/portable-tokens.schema.json +0 -104
  75. package/consumer-reference/schema/promotion-rfc.schema.json +0 -219
  76. package/consumer-reference/schema/runtime-evidence-manifest.schema.json +0 -33
  77. package/consumer-reference/schema/visual-evidence.schema.json +0 -31
  78. package/design-engineering/consumer-migration-readiness.md +0 -124
  79. package/design-engineering/interface-craft.md +0 -107
  80. package/design-engineering/reference-profiles/external-adaptation/index.md +0 -12
  81. package/design-engineering/reference-profiles/governed-local/editorial/components/button.component.json +0 -125
  82. package/design-engineering/reference-profiles/governed-local/editorial/evidence/button.evidence.json +0 -3504
  83. package/design-engineering/reference-profiles/governed-local/editorial/fixtures/button.fixture.json +0 -65
  84. package/design-engineering/reference-profiles/governed-local/editorial/generated/evidence-coverage.md +0 -23
  85. package/design-engineering/reference-profiles/governed-local/editorial/generated/keyboard-matrix.md +0 -19
  86. package/design-engineering/reference-profiles/governed-local/editorial/generated/state-matrix.md +0 -21
  87. package/design-engineering/reference-profiles/governed-local/editorial/local-foundations.json +0 -12
  88. package/design-engineering/reference-profiles/governed-local/editorial/states/button.states.json +0 -195
  89. package/design-engineering/reference-profiles/governed-local/editorial/tokens.dtcg.json +0 -17
  90. package/design-engineering/reference-profiles/governed-local/terminal/components/button.component.json +0 -125
  91. package/design-engineering/reference-profiles/governed-local/terminal/evidence/button.evidence.json +0 -3504
  92. package/design-engineering/reference-profiles/governed-local/terminal/fixtures/button.fixture.json +0 -65
  93. package/design-engineering/reference-profiles/governed-local/terminal/generated/evidence-coverage.md +0 -23
  94. package/design-engineering/reference-profiles/governed-local/terminal/generated/keyboard-matrix.md +0 -19
  95. package/design-engineering/reference-profiles/governed-local/terminal/generated/state-matrix.md +0 -21
  96. package/design-engineering/reference-profiles/governed-local/terminal/local-foundations.json +0 -12
  97. package/design-engineering/reference-profiles/governed-local/terminal/profile.json +0 -43
  98. package/design-engineering/reference-profiles/governed-local/terminal/states/button.states.json +0 -195
  99. package/design-engineering/reference-profiles/governed-local/terminal/tokens.dtcg.json +0 -17
  100. package/game-ui/classification.md +0 -82
  101. package/game-ui/reference-record.md +0 -62
  102. package/game-ui/screen-hierarchy.md +0 -107
  103. package/game-ui/unity/architecture.md +0 -166
  104. package/game-ui/unity/cli-loop.md +0 -84
  105. package/game-ui/unity/data/unity-technologies-public-repositories.json +0 -26654
  106. package/game-ui/unity/org-wiki.md +0 -146
  107. package/game-ui/unity/repository-map.md +0 -102
  108. package/game-ui/unity/ui-systems.md +0 -85
  109. package/motion/practice-reference.md +0 -145
  110. package/motion/review-workflow.md +0 -86
  111. package/motion/vocabulary.md +0 -82
  112. package/platform-guides/apple-interaction.md +0 -89
  113. package/scripts/agent-native/events.mjs +0 -113
  114. package/scripts/agent-native/immutable-store.mjs +0 -102
  115. package/scripts/artifact-metadata.mjs +0 -20
  116. package/scripts/audit-evidence-freshness.mjs +0 -308
  117. package/scripts/baseline-contract.mjs +0 -189
  118. package/scripts/baseline-schema-parity.mjs +0 -40
  119. package/scripts/build-reference-artifacts.mjs +0 -127
  120. package/scripts/calibration-raw-contract.mjs +0 -172
  121. package/scripts/capture-session-contract.mjs +0 -187
  122. package/scripts/component-state-artifact-fixture.mjs +0 -44
  123. package/scripts/component-state-contract.mjs +0 -99
  124. package/scripts/component-state-semantics.mjs +0 -128
  125. package/scripts/component-state-workflow-contract.mjs +0 -67
  126. package/scripts/component-state-workflow-negative-cases.mjs +0 -64
  127. package/scripts/consumer-conformance-contract.mjs +0 -198
  128. package/scripts/consumer-evidence-governance-contract.mjs +0 -210
  129. package/scripts/consumer-reference-case-runner.mjs +0 -93
  130. package/scripts/consumer-reference-schema.mjs +0 -155
  131. package/scripts/create-component-state-session.mjs +0 -100
  132. package/scripts/create-page-evidence-session.mjs +0 -139
  133. package/scripts/domain-document-boundaries.mjs +0 -40
  134. package/scripts/domain-validation-checks.mjs +0 -141
  135. package/scripts/evidence-artifact-contract.mjs +0 -191
  136. package/scripts/finalize-component-state-evidence.mjs +0 -165
  137. package/scripts/finalize-page-evidence.mjs +0 -197
  138. package/scripts/generate-consumer-reference-evidence.mjs +0 -154
  139. package/scripts/generate-patterns.mjs +0 -218
  140. package/scripts/governance-matrix-contract.mjs +0 -73
  141. package/scripts/governance-matrix-negative-cases.mjs +0 -114
  142. package/scripts/governance-policy-contract.mjs +0 -49
  143. package/scripts/governance-test-fixture.mjs +0 -321
  144. package/scripts/governance-workflow-negative-cases.mjs +0 -241
  145. package/scripts/governed-profile-registry.mjs +0 -125
  146. package/scripts/json-schema-formats.mjs +0 -31
  147. package/scripts/markdown-structure.mjs +0 -45
  148. package/scripts/page-artifact-metadata.mjs +0 -124
  149. package/scripts/page-evidence-contract.mjs +0 -297
  150. package/scripts/page-evidence-fixture.mjs +0 -271
  151. package/scripts/pattern-data.mjs +0 -325
  152. package/scripts/profile-record-contract.mjs +0 -140
  153. package/scripts/promotion-attestation-contract.mjs +0 -91
  154. package/scripts/promotion-boundary-test-contract.mjs +0 -92
  155. package/scripts/promotion-fixture-inventory.mjs +0 -109
  156. package/scripts/promotion-governance-contract.mjs +0 -28
  157. package/scripts/reference-artifact-path-contract.mjs +0 -28
  158. package/scripts/reference-profile-contract.mjs +0 -114
  159. package/scripts/reference-token-contract.mjs +0 -156
  160. package/scripts/run-consumer-page-evidence-ci.mjs +0 -170
  161. package/scripts/summarize-sentinel-calibration.mjs +0 -98
  162. package/scripts/test-agent-adapter-conformance.mjs +0 -250
  163. package/scripts/test-agent-conformance-receipt.mjs +0 -106
  164. package/scripts/test-agent-events.mjs +0 -81
  165. package/scripts/test-agent-execution-effects.mjs +0 -114
  166. package/scripts/test-agent-execution-fixtures.mjs +0 -140
  167. package/scripts/test-agent-execution-kernel.mjs +0 -39
  168. package/scripts/test-agent-execution-learning.mjs +0 -130
  169. package/scripts/test-agent-execution-lifecycle.mjs +0 -143
  170. package/scripts/test-agent-execution-safety.mjs +0 -158
  171. package/scripts/test-agent-execution-views.mjs +0 -117
  172. package/scripts/test-agent-identity-integrity-cases.mjs +0 -160
  173. package/scripts/test-agent-knowledge-kernel.mjs +0 -183
  174. package/scripts/test-agent-learning.mjs +0 -246
  175. package/scripts/test-agent-mcp.mjs +0 -246
  176. package/scripts/test-agent-native-schemas.mjs +0 -215
  177. package/scripts/test-agent-projections.mjs +0 -249
  178. package/scripts/test-agent-registry-mcp-integrity.mjs +0 -215
  179. package/scripts/test-agent-registry-mutations.mjs +0 -110
  180. package/scripts/test-audit-evidence-freshness.mjs +0 -177
  181. package/scripts/test-component-state-sentinel.mjs +0 -35
  182. package/scripts/test-component-state-source-contract.mjs +0 -83
  183. package/scripts/test-consumer-conformance-sentinel.mjs +0 -165
  184. package/scripts/test-consumer-reference-sentinel.mjs +0 -31
  185. package/scripts/test-generate-consumer-reference-evidence.mjs +0 -124
  186. package/scripts/test-json-cli-output.mjs +0 -151
  187. package/scripts/test-json-schema-formats.mjs +0 -40
  188. package/scripts/test-reference-adapters.mjs +0 -199
  189. package/scripts/test-renderer-purity.mjs +0 -34
  190. package/scripts/test-sg-cli.mjs +0 -129
  191. package/scripts/test-summarize-sentinel-calibration.mjs +0 -226
  192. package/scripts/test-validate-baseline-manifest.mjs +0 -234
  193. package/scripts/test-validate-component-state-artifacts.mjs +0 -243
  194. package/scripts/test-validate-component-state.mjs +0 -106
  195. package/scripts/test-validate-consumer-conformance.mjs +0 -427
  196. package/scripts/test-validate-consumer-reference-cli.mjs +0 -69
  197. package/scripts/test-validate-consumer-reference.mjs +0 -263
  198. package/scripts/test-validate-domains.mjs +0 -357
  199. package/scripts/test-validate-governance.mjs +0 -292
  200. package/scripts/test-validate-ia.mjs +0 -262
  201. package/scripts/test-validate-okf.mjs +0 -73
  202. package/scripts/test-validate-page-evidence.mjs +0 -302
  203. package/scripts/test-validate-patterns.mjs +0 -157
  204. package/scripts/test-validate-promotion-rfc.mjs +0 -250
  205. package/scripts/test-validate-reference-profiles.mjs +0 -170
  206. package/scripts/test-validate-unity-org-wiki.mjs +0 -57
  207. package/scripts/test-validate-unity-source-contracts.mjs +0 -67
  208. package/scripts/test-validate-vocabulary.mjs +0 -174
  209. package/scripts/test-validate-webpage-workflow.mjs +0 -293
  210. package/scripts/validate-baseline-manifest.mjs +0 -44
  211. package/scripts/validate-catalog.mjs +0 -65
  212. package/scripts/validate-component-state.mjs +0 -141
  213. package/scripts/validate-consumer-conformance.mjs +0 -477
  214. package/scripts/validate-consumer-reference.mjs +0 -288
  215. package/scripts/validate-domains.mjs +0 -237
  216. package/scripts/validate-governance.mjs +0 -248
  217. package/scripts/validate-ia.mjs +0 -136
  218. package/scripts/validate-links.mjs +0 -66
  219. package/scripts/validate-okf.mjs +0 -104
  220. package/scripts/validate-page-evidence.mjs +0 -191
  221. package/scripts/validate-patterns.mjs +0 -246
  222. package/scripts/validate-promotion-rfc.mjs +0 -224
  223. package/scripts/validate-reference-artifacts.mjs +0 -125
  224. package/scripts/validate-renderer-purity.mjs +0 -56
  225. package/scripts/validate-unity-org-wiki.mjs +0 -146
  226. package/scripts/validate-unity-source-contracts.mjs +0 -107
  227. package/scripts/validate-vocabulary.mjs +0 -115
  228. package/scripts/validate-webpage-workflow.mjs +0 -254
  229. package/scripts/visual-expectation-contract.mjs +0 -20
  230. package/scripts/workflow-action-contract.mjs +0 -163
@@ -1,39 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- import {
4
- loadKernelModule,
5
- modulePaths,
6
- result,
7
- } from "./test-agent-execution-fixtures.mjs";
8
- import { exerciseExecutionEffects } from "./test-agent-execution-effects.mjs";
9
- import { exerciseLearning } from "./test-agent-execution-learning.mjs";
10
- import { exerciseExecutionLifecycle } from "./test-agent-execution-lifecycle.mjs";
11
- import { exerciseEvents, exerciseRetrieval } from "./test-agent-execution-views.mjs";
12
-
13
- async function main() {
14
- const unknownArgs = process.argv.slice(2).filter((arg) => arg !== "--json");
15
- if (unknownArgs.length > 0) {
16
- const report = { ok: false, results: [result("argument_contract", "only --json is accepted", { unknownArgs }, false)] };
17
- process.stdout.write(`${JSON.stringify(report, null, 2)}\n`);
18
- process.exitCode = 1;
19
- return;
20
- }
21
-
22
- const modules = Object.fromEntries(await Promise.all(Object.keys(modulePaths).map(async (name) => [name, await loadKernelModule(name)])));
23
- const lifecycle = await exerciseExecutionLifecycle(modules);
24
- const effects = await exerciseExecutionEffects(modules, lifecycle);
25
- const state = { ...lifecycle, ...effects };
26
- const eventRows = await exerciseEvents(modules, state);
27
- const retrieval = await exerciseRetrieval(modules);
28
- const learningRows = await exerciseLearning(modules, { ...state, ...retrieval });
29
- const results = [...lifecycle.rows, ...effects.rows, ...eventRows, ...retrieval.rows, ...learningRows];
30
- const report = {
31
- contract: "agent-native-execution-kernel",
32
- ok: results.length > 0 && results.every((row) => row.ok),
33
- results,
34
- };
35
- process.stdout.write(`${JSON.stringify(report, null, 2)}\n`);
36
- process.exitCode = report.ok ? 0 : 1;
37
- }
38
-
39
- await main();
@@ -1,130 +0,0 @@
1
- import {
2
- bytes,
3
- callExport,
4
- failFromCall,
5
- fixedNow,
6
- hasAnyText,
7
- idOf,
8
- isObject,
9
- payload,
10
- pick,
11
- result,
12
- stateOf,
13
- } from "./test-agent-execution-fixtures.mjs";
14
-
15
- export async function exerciseLearning(modules, state) {
16
- const rows = [];
17
- const proposalInput = {
18
- claim: { stableRef: "sg:claim/retrieval-improvement", text: "The fixture retriever preserves citation coverage." },
19
- changes: [{ path: "retriever.strategy", value: "hybrid" }],
20
- evidence: [{ receiptId: pick(state.receipt, ["receiptId", "receipt_id", "id"]), stableRef: "sg:evidence/execution-fixture" }],
21
- proposer: "agent:proposer",
22
- proposalId: "sg:proposal/retrieval-improvement",
23
- sourceTask: idOf(state.task, "sg:task/execution-fixture"),
24
- validation: { status: "PASS", validator: "agent:validator", version: "validator@v1" },
25
- };
26
- const proposalCall = await callExport(modules.learning, "learning", "createProposal", proposalInput);
27
- const proposal = proposalCall.ok ? payload(proposalCall.value) : null;
28
- const directPromotionCall = await callExport(modules.learning, "learning", "promoteProposal", { proposal });
29
- const directPromotion = directPromotionCall.ok ? payload(directPromotionCall.value) : null;
30
- rows.push(directPromotionCall.ok
31
- ? result(
32
- "promotion_requires_verify_and_decision",
33
- "proposal cannot promote before an independent verification and accepted governance decision",
34
- directPromotion,
35
- !(isObject(directPromotion) && (directPromotion.promoted === true || directPromotion.status === "PROMOTED")),
36
- )
37
- : failFromCall("promotion_requires_verify_and_decision", "proposal cannot promote before an independent verification and accepted governance decision", directPromotionCall));
38
- if (!proposalCall.ok) {
39
- rows.push(failFromCall("learning_proposal_is_immutable_and_provenanced", "proposal records claim, evidence, validation, proposer, and proposed change", proposalCall));
40
- return rows;
41
- }
42
- rows.push(result(
43
- "learning_proposal_is_immutable_and_provenanced",
44
- "proposal records claim, evidence, validation, proposer, and proposed change",
45
- proposal,
46
- isObject(proposal)
47
- && isObject(pick(proposal, ["claim"]))
48
- && Array.isArray(pick(proposal, ["evidence", "evidenceLinks", "evidence_links"]))
49
- && isObject(pick(proposal, ["validation"]))
50
- && typeof pick(proposal, ["proposer", "proposedBy", "proposed_by"]) === "string"
51
- && Array.isArray(pick(proposal, ["changes", "patch", "delta"])),
52
- ));
53
-
54
- const sameActorCall = await callExport(modules.learning, "learning", "verifyProposal", {
55
- proposal,
56
- verifier: "agent:proposer",
57
- verifierActor: "agent:proposer",
58
- evidence: proposalInput.evidence,
59
- validation: proposalInput.validation,
60
- });
61
- const sameActor = sameActorCall.ok ? payload(sameActorCall.value) : null;
62
- rows.push(sameActorCall.ok
63
- ? result(
64
- "learning_verification_requires_independence",
65
- "proposer cannot satisfy the independent verification gate",
66
- sameActor,
67
- !(isObject(sameActor) && (sameActor.verified === true || sameActor.status === "VERIFIED" || sameActor.ok === true)),
68
- )
69
- : failFromCall("learning_verification_requires_independence", "proposer cannot satisfy the independent verification gate", sameActorCall));
70
-
71
- const verifyCall = await callExport(modules.learning, "learning", "verifyProposal", {
72
- independentOf: "agent:proposer",
73
- proposal,
74
- verifier: "agent:verifier",
75
- verifierActor: "agent:verifier",
76
- evidence: [{ ...proposalInput.evidence[0], independentGroup: "verification-group" }],
77
- validation: { status: "PASS", validator: "agent:validator", version: "validator@v1" },
78
- });
79
- const verification = verifyCall.ok ? payload(verifyCall.value) : null;
80
- rows.push(verifyCall.ok
81
- ? result(
82
- "learning_verification_is_independent_and_validated",
83
- "different actor supplies positive verification with passing validation",
84
- verification,
85
- isObject(verification)
86
- && (pick(verification, ["verified", "isVerified"]) === true || stateOf(verification) === "VERIFIED" || stateOf(verification) === "verified")
87
- && typeof pick(verification, ["verifier", "verifiedBy", "verified_by"]) === "string"
88
- && pick(verification, ["verifier", "verifiedBy", "verified_by"]) !== pick(proposal, ["proposer", "proposedBy", "proposed_by"]),
89
- )
90
- : failFromCall("learning_verification_is_independent_and_validated", "different actor supplies positive verification with passing validation", verifyCall));
91
-
92
- const decisionCall = await callExport(modules.learning, "learning", "decideProposal", {
93
- decision: "ACCEPT",
94
- governanceDecision: { actor: "governor:test", decision: "ACCEPT", scope: "retriever", decidedAt: fixedNow },
95
- proposal,
96
- verification,
97
- });
98
- const decision = decisionCall.ok ? payload(decisionCall.value) : null;
99
- rows.push(decisionCall.ok
100
- ? result(
101
- "learning_governance_decision_is_explicit",
102
- "promotion is gated by an explicit accepted governance decision",
103
- decision,
104
- isObject(decision) && hasAnyText(decision, ["decision", "status", "disposition"], ["ACCEPT", "ACCEPTED", "accepted"]),
105
- )
106
- : failFromCall("learning_governance_decision_is_explicit", "promotion is gated by an explicit accepted governance decision", decisionCall));
107
-
108
- const registryBefore = { entries: [{ stableRef: "sg:retriever/fixture", versionId: "sg:retriever/fixture@sha256:4444444444444444444444444444444444444444444444444444444444444444" }] };
109
- const registryDigestBefore = bytes(registryBefore);
110
- const promotionCall = await callExport(modules.learning, "learning", "promoteProposal", {
111
- decision,
112
- governanceDecision: decision,
113
- proposal,
114
- registry: registryBefore,
115
- verification,
116
- });
117
- const promotion = promotionCall.ok ? payload(promotionCall.value) : null;
118
- rows.push(promotionCall.ok
119
- ? result(
120
- "learning_promotion_never_auto_asserts_truth",
121
- "accepted promotion creates a new governed version/receipt without mutating prior registry or asserting factual truth",
122
- promotion,
123
- isObject(promotion)
124
- && (promotion.promoted === true || hasAnyText(promotion, ["status", "state"], ["PROMOTED", "promoted"]))
125
- && bytes(registryBefore) === registryDigestBefore
126
- && pick(promotion, ["autoTruth", "auto_truth", "truthAccepted", "truth_accepted"]) !== true,
127
- )
128
- : failFromCall("learning_promotion_never_auto_asserts_truth", "accepted promotion creates a new governed version/receipt without mutating prior registry or asserting factual truth", promotionCall));
129
- return rows;
130
- }
@@ -1,143 +0,0 @@
1
- import {
2
- callExport,
3
- failFromCall,
4
- fixedNow,
5
- grantInput,
6
- hasAnyText,
7
- hasText,
8
- idOf,
9
- isObject,
10
- operationInput,
11
- payload,
12
- pick,
13
- result,
14
- stateOf,
15
- } from "./test-agent-execution-fixtures.mjs";
16
-
17
- export async function exerciseExecutionLifecycle(modules) {
18
- const rows = [];
19
- const operationSpec = operationInput();
20
- const grant = grantInput();
21
- const operationCall = await callExport(modules.execution, "execution", "defineOperation", operationSpec);
22
- const operation = operationCall.ok ? payload(operationCall.value) : null;
23
- rows.push(operationCall.ok
24
- ? result(
25
- "operation_spec_defines_effect_and_capability",
26
- "operation has stable identity, NONE effect, idempotency, and required capability",
27
- {
28
- effectClass: pick(operation, ["effectClass", "effect_class", "effect"]),
29
- idempotent: pick(operation, ["idempotent", "isIdempotent"]),
30
- requiredCapability: pick(operation, ["requiredCapability", "required_capability", "capability"]),
31
- stableRef: pick(operation, ["stableRef", "stable_ref", "operation", "name"]),
32
- },
33
- isObject(operation)
34
- && hasAnyText(operation, ["effectClass", "effect_class", "effect"], ["NONE", "none"])
35
- && pick(operation, ["idempotent", "isIdempotent"]) === true
36
- && hasText(operation, ["requiredCapability", "required_capability", "capability"], "wiki.read")
37
- && typeof pick(operation, ["stableRef", "stable_ref", "operation", "name"]) === "string",
38
- )
39
- : failFromCall("operation_spec_defines_effect_and_capability", "operation has stable identity, NONE effect, idempotency, and required capability", operationCall));
40
-
41
- const authorizedCall = await callExport(modules.execution, "execution", "authorizeOperation", {
42
- capability: grant,
43
- grant,
44
- now: fixedNow,
45
- operation,
46
- resource: "sg:profile/editorial-reference-profile",
47
- subject: "agent:test",
48
- });
49
- const authorized = authorizedCall.ok ? payload(authorizedCall.value) : null;
50
- rows.push(authorizedCall.ok
51
- ? result(
52
- "capability_authorizes_scoped_read",
53
- "allowed true with a policy decision bound to subject, operation, resource, and time",
54
- authorized,
55
- isObject(authorized)
56
- && pick(authorized, ["allowed", "isAllowed"]) === true
57
- && isObject(pick(authorized, ["decision", "policyDecision", "policy_decision"]))
58
- && typeof pick(pick(authorized, ["decision", "policyDecision", "policy_decision"]), ["subject", "principal"]) === "string",
59
- )
60
- : failFromCall("capability_authorizes_scoped_read", "allowed true with a policy decision bound to subject, operation, resource, and time", authorizedCall));
61
-
62
- const deniedCall = await callExport(modules.execution, "execution", "authorizeOperation", {
63
- capability: grant,
64
- grant,
65
- now: fixedNow,
66
- operation,
67
- resource: "sg:governance/private",
68
- subject: "agent:other",
69
- });
70
- const denied = deniedCall.ok ? payload(deniedCall.value) : null;
71
- rows.push(deniedCall.ok
72
- ? result(
73
- "capability_denies_wrong_subject_and_resource",
74
- "allowed false with a stable authorization failure",
75
- denied,
76
- isObject(denied) && pick(denied, ["allowed", "isAllowed"]) === false,
77
- )
78
- : failFromCall("capability_denies_wrong_subject_and_resource", "allowed false with a stable authorization failure", deniedCall));
79
-
80
- const taskInput = {
81
- intent: { operation: "resolve", resource: "sg:profile/editorial-reference-profile" },
82
- operation: "resolve",
83
- requiredResult: { type: "profile" },
84
- stableRef: "sg:task/execution-fixture",
85
- taskId: "sg:task/execution-fixture",
86
- };
87
- const taskCall = await callExport(modules.execution, "execution", "createTask", taskInput);
88
- const task = taskCall.ok ? payload(taskCall.value) : null;
89
- rows.push(taskCall.ok
90
- ? result(
91
- "task_preserves_intent_and_required_result",
92
- "task has stable task identity, intent, required result, and initial state",
93
- task,
94
- isObject(task)
95
- && typeof idOf(task, "sg:task/execution-fixture") === "string"
96
- && isObject(pick(task, ["intent", "request"]))
97
- && isObject(pick(task, ["requiredResult", "required_result", "result"]))
98
- && typeof stateOf(task) === "string",
99
- )
100
- : failFromCall("task_preserves_intent_and_required_result", "task has stable task identity, intent, required result, and initial state", taskCall));
101
-
102
- const runCall = await callExport(modules.execution, "execution", "startRun", {
103
- input: { stableRef: "sg:profile/editorial-reference-profile" },
104
- runId: "sg:run/execution-fixture-1",
105
- run_id: "sg:run/execution-fixture-1",
106
- task,
107
- taskId: pick(task, ["taskId", "task_id", "stableRef", "stable_ref"]) ?? "sg:task/execution-fixture",
108
- });
109
- const run = runCall.ok ? payload(runCall.value) : null;
110
- rows.push(runCall.ok
111
- ? result(
112
- "run_belongs_to_one_task",
113
- "run has a distinct run identity linked to the task",
114
- run,
115
- isObject(run)
116
- && pick(run, ["runId", "run_id", "stableRef", "stable_ref", "id"]) === "sg:run/execution-fixture-1"
117
- && pick(run, ["taskId", "task_id"]) === (pick(task, ["taskId", "task_id", "stableRef", "stable_ref"]) ?? "sg:task/execution-fixture")
118
- && typeof stateOf(run) === "string",
119
- )
120
- : failFromCall("run_belongs_to_one_task", "run has a distinct run identity linked to the task", runCall));
121
-
122
- const immediateAuthCall = await callExport(modules.execution, "execution", "authorizeEffect", {
123
- capability: grant,
124
- grant,
125
- now: fixedNow,
126
- operation,
127
- resource: "sg:profile/editorial-reference-profile",
128
- run,
129
- subject: "agent:test",
130
- task,
131
- });
132
- const immediateAuth = immediateAuthCall.ok ? payload(immediateAuthCall.value) : null;
133
- rows.push(immediateAuthCall.ok
134
- ? result(
135
- "effect_rechecks_authorization_immediately",
136
- "effect authorization is explicitly allowed immediately before an external attempt",
137
- immediateAuth,
138
- isObject(immediateAuth) && pick(immediateAuth, ["allowed", "isAllowed"]) === true,
139
- )
140
- : failFromCall("effect_rechecks_authorization_immediately", "effect authorization is explicitly allowed immediately before an external attempt", immediateAuthCall));
141
-
142
- return { rows, operation, grant, task, run, authorized };
143
- }
@@ -1,158 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- import {
4
- authorizeOperation,
5
- defineOperation,
6
- reconcileEffect,
7
- recordEffectAttempt,
8
- } from "./agent-native/execution.mjs";
9
-
10
- const cases = [];
11
-
12
- function test(name, scenario) {
13
- try {
14
- scenario();
15
- cases.push({ name, ok: true });
16
- } catch (error) {
17
- cases.push({
18
- error: error instanceof Error ? error.message : String(error),
19
- name,
20
- ok: false,
21
- });
22
- }
23
- }
24
-
25
- function equal(actual, expected, label) {
26
- if (actual !== expected) throw new Error(`${label}: expected ${expected}, received ${actual}`);
27
- }
28
-
29
- function operation() {
30
- return defineOperation({
31
- effect_class: "EXTERNAL",
32
- name: "publish",
33
- required_capability: "wiki.publish",
34
- stable_ref: "sg:operation/publish",
35
- });
36
- }
37
-
38
- function grant(operations) {
39
- return {
40
- capability: "wiki.publish",
41
- operations,
42
- resource_scope: ["sg:profile/*"],
43
- subject: "agent:test",
44
- };
45
- }
46
-
47
- function authorization(operations) {
48
- return authorizeOperation({
49
- grant: grant(operations),
50
- operation: operation(),
51
- resource: "sg:profile/editorial-reference-profile",
52
- subject: "agent:test",
53
- });
54
- }
55
-
56
- function externalEffect(overrides = {}) {
57
- return recordEffectAttempt({
58
- effect_class: "EXTERNAL",
59
- effect_id: "sg:effect/publish-1",
60
- run_id: "sg:run/publish-1",
61
- task_id: "sg:task/publish-1",
62
- ...overrides,
63
- });
64
- }
65
-
66
- test("empty_operation_scope_denies_protected_operation", () => {
67
- // Given a capability with matching subject, resource, and capability but no operations.
68
- // When authorization evaluates the protected publish operation.
69
- const result = authorization([]);
70
- // Then omission is deny-by-default rather than a wildcard grant.
71
- equal(result.allowed, false, "allowed");
72
- equal(result.failures.includes("operation_denied"), true, "operation_denied");
73
- });
74
-
75
- test("explicit_operation_scope_authorizes_matching_operation", () => {
76
- // Given an explicitly scoped capability.
77
- // When the named operation is evaluated.
78
- const result = authorization(["publish"]);
79
- // Then the operation is authorized.
80
- equal(result.allowed, true, "allowed");
81
- });
82
-
83
- test("external_effect_ignores_forged_committed_state_without_receipt", () => {
84
- // Given an external attempt with no connector receipt and caller state COMMITTED.
85
- // When the attempt is recorded.
86
- const effect = externalEffect({ connector_receipt: null, state: "COMMITTED" });
87
- // Then the kernel derives UNCERTAIN.
88
- equal(effect.state, "UNCERTAIN", "state");
89
- });
90
-
91
- test("empty_connector_receipt_cannot_commit_external_effect", () => {
92
- // Given an external attempt with an empty receipt identifier.
93
- // When the caller requests COMMITTED.
94
- const effect = externalEffect({ connector_receipt: "", state: "COMMITTED" });
95
- // Then empty evidence is treated as absent.
96
- equal(effect.state, "UNCERTAIN", "state");
97
- });
98
-
99
- test("blank_connector_receipt_cannot_commit_external_effect", () => {
100
- // Given an external attempt with only whitespace as receipt evidence.
101
- // When the caller requests COMMITTED.
102
- const effect = externalEffect({ connector_receipt: " ", state: "COMMITTED" });
103
- // Then blank evidence is treated as absent.
104
- equal(effect.state, "UNCERTAIN", "state");
105
- });
106
-
107
- test("durable_receipt_commits_external_effect", () => {
108
- // Given an external attempt backed by a durable connector receipt ID.
109
- // When the caller supplies a conflicting state.
110
- const effect = externalEffect({ connector_receipt: "sg:connector-receipt/publish-1", state: "UNCERTAIN" });
111
- // Then receipt evidence, not caller state, derives COMMITTED.
112
- equal(effect.state, "COMMITTED", "state");
113
- });
114
-
115
- test("positive_observation_without_receipt_stays_uncertain", () => {
116
- // Given an uncertain external effect and an unreceipted positive observation.
117
- // When reconciliation runs.
118
- const reconciled = reconcileEffect({
119
- effect: externalEffect(),
120
- observations: [{ status: "COMMITTED" }],
121
- });
122
- // Then status alone cannot commit the effect.
123
- equal(reconciled.state, "UNCERTAIN", "state");
124
- });
125
-
126
- test("positive_receipted_observation_commits", () => {
127
- // Given an uncertain effect and a positive durable receipt observation.
128
- // When reconciliation runs.
129
- const reconciled = reconcileEffect({
130
- effect: externalEffect(),
131
- observations: [{ connector_receipt: "sg:connector-receipt/recovered", status: "COMMITTED" }],
132
- });
133
- // Then the effect is committed and bound to that receipt.
134
- equal(reconciled.state, "COMMITTED", "state");
135
- equal(reconciled.connector_receipt, "sg:connector-receipt/recovered", "connector_receipt");
136
- });
137
-
138
- test("legacy_unreceipted_committed_effect_is_demoted", () => {
139
- // Given legacy data claiming COMMITTED without receipt evidence.
140
- // When it is reconciled without new observations.
141
- const reconciled = reconcileEffect({
142
- effect: {
143
- effect_class: "EXTERNAL",
144
- effect_id: "sg:effect/legacy",
145
- state: "COMMITTED",
146
- },
147
- });
148
- // Then reconciliation restores the safe UNCERTAIN state.
149
- equal(reconciled.state, "UNCERTAIN", "state");
150
- });
151
-
152
- const report = {
153
- contract: "agent-native-execution-safety",
154
- ok: cases.every((item) => item.ok),
155
- results: cases,
156
- };
157
- process.stdout.write(`${JSON.stringify(report, null, 2)}\n`);
158
- process.exitCode = report.ok ? 0 : 1;
@@ -1,117 +0,0 @@
1
- import {
2
- bytes,
3
- callExport,
4
- failFromCall,
5
- fixedNow,
6
- idOf,
7
- isObject,
8
- payload,
9
- pick,
10
- result,
11
- } from "./test-agent-execution-fixtures.mjs";
12
-
13
- export async function exerciseEvents(modules, state) {
14
- const rows = [];
15
- let events = [];
16
- const entries = [
17
- { eventId: "sg:event/task-created", parents: [], payload: { taskId: idOf(state.task, "sg:task/execution-fixture") }, type: "task.created" },
18
- { eventId: "sg:event/run-started", parents: ["sg:event/task-created"], payload: { runId: idOf(state.run, "sg:run/execution-fixture-1") }, type: "run.started" },
19
- { eventId: "sg:event/effect-reconciled", parents: ["sg:event/task-created"], payload: { effectState: "COMMITTED" }, type: "effect.reconciled" },
20
- ];
21
- for (const event of entries) {
22
- const call = await callExport(modules.events, "events", "appendEvent", { event, events });
23
- if (!call.ok) {
24
- rows.push(failFromCall("event_dag_append_is_immutable", "appendEvent returns an append-only event collection", call));
25
- return rows;
26
- }
27
- const value = payload(call.value);
28
- if (Array.isArray(value)) events = value;
29
- else if (Array.isArray(value?.events)) events = value.events;
30
- else if (isObject(value?.event)) events = [...events, value.event];
31
- else if (isObject(value)) events = [...events, value];
32
- else events = [...events, event];
33
- }
34
- const appendResult = events.map((event) => ({ id: pick(event, ["eventId", "event_id", "id", "stableRef", "stable_ref"]), parents: pick(event, ["parents", "parentIds", "parent_ids"]) }));
35
- rows.push(result(
36
- "event_dag_append_is_immutable",
37
- "three immutable events preserve explicit parent links and event IDs",
38
- appendResult,
39
- events.length === 3
40
- && appendResult.every((event) => typeof event.id === "string" && Array.isArray(event.parents))
41
- && appendResult[1].parents.includes("sg:event/task-created")
42
- && appendResult[2].parents.includes("sg:event/task-created"),
43
- ));
44
-
45
- const headsCall = await callExport(modules.events, "events", "eventHeads", { events });
46
- if (!headsCall.ok) {
47
- rows.push(failFromCall("event_dag_heads_are_deterministic", "eventHeads returns the two concurrent heads in stable order", headsCall));
48
- return rows;
49
- }
50
- const heads = payload(headsCall.value);
51
- const headValues = Array.isArray(heads) ? heads : pick(heads, ["heads", "eventHeads", "event_heads"]);
52
- rows.push(result(
53
- "event_dag_heads_are_deterministic",
54
- "eventHeads returns the two concurrent heads in stable order",
55
- headValues,
56
- Array.isArray(headValues)
57
- && headValues.length === 2
58
- && headValues.map(String).sort().join(",") === "sg:event/effect-reconciled,sg:event/run-started",
59
- ));
60
- return rows;
61
- }
62
-
63
- export async function exerciseRetrieval(modules) {
64
- const rows = [];
65
- const members = [
66
- { content: "Editorial profile uses constrained columns.", stableRef: "sg:profile/editorial-reference-profile", versionId: "sg:profile/editorial-reference-profile@sha256:1111111111111111111111111111111111111111111111111111111111111111" },
67
- { content: "Resolve returns governed profile metadata.", stableRef: "sg:claim/resolve-profile", versionId: "sg:claim/resolve-profile@sha256:2222222222222222222222222222222222222222222222222222222222222222" },
68
- ];
69
- const snapshotInput = {
70
- asOf: fixedNow,
71
- builderVersion: "retriever-fixture@1",
72
- heads: ["sg:event/effect-reconciled", "sg:event/run-started"],
73
- members,
74
- policy: "sg:governance/read-policy@sha256:3333333333333333333333333333333333333333333333333333333333333333",
75
- viewSpec: { queryClass: "exact", stableRef: "sg:view/profile-context", version: "v1" },
76
- };
77
- const snapshotCallA = await callExport(modules.retrieval, "retrieval", "buildViewSnapshot", snapshotInput);
78
- const snapshotCallB = await callExport(modules.retrieval, "retrieval", "buildViewSnapshot", { ...snapshotInput, members: [...members].reverse(), heads: [...snapshotInput.heads].reverse() });
79
- const snapshotA = snapshotCallA.ok ? payload(snapshotCallA.value) : null;
80
- const snapshotB = snapshotCallB.ok ? payload(snapshotCallB.value) : null;
81
- if (!snapshotCallA.ok) rows.push(failFromCall("retrieval_snapshot_is_deterministic", "same inputs produce byte-identical snapshot", snapshotCallA));
82
- else if (!snapshotCallB.ok) rows.push(failFromCall("retrieval_snapshot_is_deterministic", "same inputs produce byte-identical snapshot", snapshotCallB));
83
- else rows.push(result(
84
- "retrieval_snapshot_is_deterministic",
85
- "same logical inputs produce byte-identical immutable snapshot with provenance",
86
- { first: snapshotA, second: snapshotB, equal: bytes(snapshotA) === bytes(snapshotB) },
87
- bytes(snapshotA) === bytes(snapshotB)
88
- && isObject(snapshotA)
89
- && typeof pick(snapshotA, ["versionId", "version_id", "snapshotRef", "snapshot_ref", "digest", "sha256"]) === "string"
90
- && Array.isArray(pick(snapshotA, ["members", "entries", "items"])),
91
- ));
92
-
93
- const contextCall = await callExport(modules.retrieval, "retrieval", "buildContextPackage", {
94
- budget: { tokens: 240 },
95
- members,
96
- policy: snapshotInput.policy,
97
- queryClass: "exact",
98
- query: "Which profile is editorial?",
99
- retriever: "retriever:fixture@v1",
100
- snapshot: snapshotA,
101
- });
102
- const context = contextCall.ok ? payload(contextCall.value) : null;
103
- rows.push(contextCall.ok
104
- ? result(
105
- "context_package_is_bounded_and_provenance_linked",
106
- "context package preserves snapshot/policy/member manifest and token budget",
107
- context,
108
- isObject(context)
109
- && isObject(pick(context, ["budget"]))
110
- && Number.isInteger(pick(pick(context, ["budget"]), ["tokens", "tokenBudget", "token_budget"]))
111
- && Array.isArray(pick(context, ["members", "entries", "items"]))
112
- && pick(context, ["snapshot", "snapshotRef", "snapshot_ref"]) !== undefined
113
- && pick(context, ["policy", "policyRef", "policy_ref"]) !== undefined,
114
- )
115
- : failFromCall("context_package_is_bounded_and_provenance_linked", "context package preserves snapshot/policy/member manifest and token budget", contextCall));
116
- return { rows, snapshot: snapshotA, context };
117
- }