@fundamental-engine/core 0.9.4 → 0.9.5

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 (134) hide show
  1. package/dist/inspect/report.js +2 -2
  2. package/dist/inspect/report.js.map +1 -1
  3. package/dist/recipes/catalog.d.ts +14 -9
  4. package/dist/recipes/catalog.d.ts.map +1 -1
  5. package/dist/recipes/catalog.js +9 -5
  6. package/dist/recipes/catalog.js.map +1 -1
  7. package/dist/recipes/compile.d.ts +26 -16
  8. package/dist/recipes/compile.d.ts.map +1 -1
  9. package/dist/recipes/compile.js +14 -10
  10. package/dist/recipes/compile.js.map +1 -1
  11. package/dist/recipes/index.d.ts +2 -0
  12. package/dist/recipes/index.d.ts.map +1 -1
  13. package/dist/recipes/index.js +5 -3
  14. package/dist/recipes/index.js.map +1 -1
  15. package/dist/recipes/schema.d.ts +27 -17
  16. package/dist/recipes/schema.d.ts.map +1 -1
  17. package/dist/recipes/schema.js +11 -6
  18. package/dist/recipes/schema.js.map +1 -1
  19. package/dist/recipes/wayfinding.d.ts +1 -1
  20. package/dist/version.d.ts +1 -1
  21. package/dist/version.js +1 -1
  22. package/dist/world/ablation/ablation.d.ts +39 -0
  23. package/dist/world/ablation/ablation.d.ts.map +1 -0
  24. package/dist/world/ablation/ablation.js +449 -0
  25. package/dist/world/ablation/ablation.js.map +1 -0
  26. package/dist/world/adapters/field-runtime.d.ts +56 -0
  27. package/dist/world/adapters/field-runtime.d.ts.map +1 -0
  28. package/dist/world/adapters/field-runtime.js +250 -0
  29. package/dist/world/adapters/field-runtime.js.map +1 -0
  30. package/dist/world/adapters/fsm-runtime.d.ts +18 -0
  31. package/dist/world/adapters/fsm-runtime.d.ts.map +1 -0
  32. package/dist/world/adapters/fsm-runtime.js +153 -0
  33. package/dist/world/adapters/fsm-runtime.js.map +1 -0
  34. package/dist/world/adapters/governor-runtime.d.ts +23 -0
  35. package/dist/world/adapters/governor-runtime.d.ts.map +1 -0
  36. package/dist/world/adapters/governor-runtime.js +185 -0
  37. package/dist/world/adapters/governor-runtime.js.map +1 -0
  38. package/dist/world/adapters/planner-runtime.d.ts +20 -0
  39. package/dist/world/adapters/planner-runtime.d.ts.map +1 -0
  40. package/dist/world/adapters/planner-runtime.js +144 -0
  41. package/dist/world/adapters/planner-runtime.js.map +1 -0
  42. package/dist/world/conformance/corpus.d.ts +89 -0
  43. package/dist/world/conformance/corpus.d.ts.map +1 -0
  44. package/dist/world/conformance/corpus.js +195 -0
  45. package/dist/world/conformance/corpus.js.map +1 -0
  46. package/dist/world/conformance/discoveries.d.ts +50 -0
  47. package/dist/world/conformance/discoveries.d.ts.map +1 -0
  48. package/dist/world/conformance/discoveries.js +71 -0
  49. package/dist/world/conformance/discoveries.js.map +1 -0
  50. package/dist/world/conformance/evidence.d.ts +37 -0
  51. package/dist/world/conformance/evidence.d.ts.map +1 -0
  52. package/dist/world/conformance/evidence.js +53 -0
  53. package/dist/world/conformance/evidence.js.map +1 -0
  54. package/dist/world/conformance/negative-results.d.ts +57 -0
  55. package/dist/world/conformance/negative-results.d.ts.map +1 -0
  56. package/dist/world/conformance/negative-results.js +73 -0
  57. package/dist/world/conformance/negative-results.js.map +1 -0
  58. package/dist/world/conformance/predictions.d.ts +66 -0
  59. package/dist/world/conformance/predictions.d.ts.map +1 -0
  60. package/dist/world/conformance/predictions.js +141 -0
  61. package/dist/world/conformance/predictions.js.map +1 -0
  62. package/dist/world/cross-substrate.d.ts +19 -0
  63. package/dist/world/cross-substrate.d.ts.map +1 -0
  64. package/dist/world/cross-substrate.js +123 -0
  65. package/dist/world/cross-substrate.js.map +1 -0
  66. package/dist/world/dynamics.d.ts +166 -0
  67. package/dist/world/dynamics.d.ts.map +1 -0
  68. package/dist/world/dynamics.js +30 -0
  69. package/dist/world/dynamics.js.map +1 -0
  70. package/dist/world/envelope.d.ts +44 -0
  71. package/dist/world/envelope.d.ts.map +1 -0
  72. package/dist/world/envelope.js +77 -0
  73. package/dist/world/envelope.js.map +1 -0
  74. package/dist/world/episodes/episodes.d.ts +64 -0
  75. package/dist/world/episodes/episodes.d.ts.map +1 -0
  76. package/dist/world/episodes/episodes.js +104 -0
  77. package/dist/world/episodes/episodes.js.map +1 -0
  78. package/dist/world/equivalence.d.ts +70 -0
  79. package/dist/world/equivalence.d.ts.map +1 -0
  80. package/dist/world/equivalence.js +205 -0
  81. package/dist/world/equivalence.js.map +1 -0
  82. package/dist/world/experiments/declarative-dynamics.d.ts +87 -0
  83. package/dist/world/experiments/declarative-dynamics.d.ts.map +1 -0
  84. package/dist/world/experiments/declarative-dynamics.js +153 -0
  85. package/dist/world/experiments/declarative-dynamics.js.map +1 -0
  86. package/dist/world/governor-equivalence.d.ts +51 -0
  87. package/dist/world/governor-equivalence.d.ts.map +1 -0
  88. package/dist/world/governor-equivalence.js +126 -0
  89. package/dist/world/governor-equivalence.js.map +1 -0
  90. package/dist/world/kernel.d.ts +49 -0
  91. package/dist/world/kernel.d.ts.map +1 -0
  92. package/dist/world/kernel.js +64 -0
  93. package/dist/world/kernel.js.map +1 -0
  94. package/dist/world/observatory/capture.d.ts +10 -0
  95. package/dist/world/observatory/capture.d.ts.map +1 -0
  96. package/dist/world/observatory/capture.js +371 -0
  97. package/dist/world/observatory/capture.js.map +1 -0
  98. package/dist/world/observatory/evidence-log.d.ts +131 -0
  99. package/dist/world/observatory/evidence-log.d.ts.map +1 -0
  100. package/dist/world/observatory/evidence-log.js +43 -0
  101. package/dist/world/observatory/evidence-log.js.map +1 -0
  102. package/dist/world/opportunity/opportunity.d.ts +85 -0
  103. package/dist/world/opportunity/opportunity.d.ts.map +1 -0
  104. package/dist/world/opportunity/opportunity.js +67 -0
  105. package/dist/world/opportunity/opportunity.js.map +1 -0
  106. package/dist/world/projection/evidence-profile.d.ts +51 -0
  107. package/dist/world/projection/evidence-profile.d.ts.map +1 -0
  108. package/dist/world/projection/evidence-profile.js +93 -0
  109. package/dist/world/projection/evidence-profile.js.map +1 -0
  110. package/dist/world/projection/projection.d.ts +162 -0
  111. package/dist/world/projection/projection.d.ts.map +1 -0
  112. package/dist/world/projection/projection.js +145 -0
  113. package/dist/world/projection/projection.js.map +1 -0
  114. package/dist/world/properties/properties.d.ts +87 -0
  115. package/dist/world/properties/properties.d.ts.map +1 -0
  116. package/dist/world/properties/properties.js +172 -0
  117. package/dist/world/properties/properties.js.map +1 -0
  118. package/dist/world/substrates/fsm.d.ts +59 -0
  119. package/dist/world/substrates/fsm.d.ts.map +1 -0
  120. package/dist/world/substrates/fsm.js +57 -0
  121. package/dist/world/substrates/fsm.js.map +1 -0
  122. package/dist/world/substrates/governor.d.ts +53 -0
  123. package/dist/world/substrates/governor.d.ts.map +1 -0
  124. package/dist/world/substrates/governor.js +73 -0
  125. package/dist/world/substrates/governor.js.map +1 -0
  126. package/dist/world/substrates/planner.d.ts +82 -0
  127. package/dist/world/substrates/planner.d.ts.map +1 -0
  128. package/dist/world/substrates/planner.js +114 -0
  129. package/dist/world/substrates/planner.js.map +1 -0
  130. package/dist/world/world.d.ts +73 -0
  131. package/dist/world/world.d.ts.map +1 -0
  132. package/dist/world/world.js +2 -0
  133. package/dist/world/world.js.map +1 -0
  134. package/package.json +1 -1
@@ -0,0 +1,185 @@
1
+ /**
2
+ * G3.1 — second-substrate adapter: the quality-governor rule set behind `DynamicsContract`.
3
+ *
4
+ * The contract was NOT changed to make this substrate fit. Everything is declared truthfully, and the
5
+ * declarations differ sharply from the field adapter — which is the point of the experiment:
6
+ *
7
+ * field → opaque-native · conditionally-deterministic · snapshot-only (lossy, non-restorable)
8
+ * governor → interpreted · deterministic · snapshot + restore + replay (complete)
9
+ *
10
+ * The generic `World` never holds a substrate instance; the kernel threads opaque `State`. Native error
11
+ * causes are retained INTERNALLY on `DynamicsFailure.cause` (typed `unknown`) and never leak a native
12
+ * type into `World`. Internal/experimental; not exported from the package entry.
13
+ */
14
+ import { createWorldEnvelope } from "../envelope.js";
15
+ import { ESCALATE_RULES, RECOVER_STREAK, DEFAULT_BUDGET_MS, feedGovernor, initialGovernorState, isGovernorState, } from "../substrates/governor.js";
16
+ const SOURCE = { kind: 'substrate', id: 'quality-governor' };
17
+ function record(id, kind, observedAt, payload) {
18
+ return { id, kind, source: SOURCE, observedAt, payload };
19
+ }
20
+ function evidence(parts) {
21
+ return {
22
+ declaredInputs: parts.declaredInputs ?? [],
23
+ substrateResponses: parts.substrateResponses ?? [],
24
+ checkedInvariants: parts.checkedInvariants ?? [],
25
+ executionTrace: parts.executionTrace ?? [],
26
+ unresolvedInterpretations: parts.unresolvedInterpretations ?? [],
27
+ };
28
+ }
29
+ function reading(state) {
30
+ return {
31
+ envelope: state.envelope,
32
+ step: state.step,
33
+ entities: [
34
+ {
35
+ id: 'governor',
36
+ metrics: {
37
+ tier: state.governor.tier,
38
+ overrunStreak: state.governor.overrunStreak,
39
+ cleanStreak: state.governor.cleanStreak,
40
+ },
41
+ },
42
+ ],
43
+ metrics: {
44
+ tier: state.governor.tier,
45
+ overrunStreak: state.governor.overrunStreak,
46
+ cleanStreak: state.governor.cleanStreak,
47
+ budgetMs: state.governor.budgetMs,
48
+ },
49
+ };
50
+ }
51
+ /**
52
+ * A `DynamicsContract` over the governor rule set. `executionKind: 'interpreted'` — the transition law
53
+ * is a DECLARED TABLE (`ESCALATE_RULES` + `RECOVER_STREAK`) interpreted per input, so unlike the field
54
+ * substrate this one may honestly set `declareTransitionLaw: true` and `inspectInternalState: true`.
55
+ */
56
+ export function governorDynamics(world, budgetMs = DEFAULT_BUDGET_MS) {
57
+ return {
58
+ identity: { id: `quality-governor:${world.envelope.worldInstance}`, version: '0.1.0' },
59
+ executionKind: 'interpreted',
60
+ capabilities: {
61
+ initialize: true,
62
+ advance: true,
63
+ snapshot: true,
64
+ restore: true, // state is plain data — a snapshot fully reconstructs it
65
+ replay: true,
66
+ inspectInternalState: true, // streak counters are surfaced, not hidden
67
+ declareTransitionLaw: true, // the escalation table IS the law
68
+ deterministicReplay: true,
69
+ },
70
+ determinism: {
71
+ classification: 'deterministic',
72
+ controlledInputs: ['frame-duration-sequence', 'budgetMs'],
73
+ uncontrolledInputs: [], // no clock, no RNG, no host geometry
74
+ requirements: ['identical input sequence', 'identical initial state'],
75
+ },
76
+ initialize(request) {
77
+ const declared = request.declaration;
78
+ const state = {
79
+ governor: initialGovernorState(budgetMs),
80
+ envelope: declared?.envelope ?? createWorldEnvelope('governor-world'),
81
+ step: 0,
82
+ };
83
+ return {
84
+ ok: true,
85
+ value: state,
86
+ evidence: evidence({
87
+ declaredInputs: [record('init', 'declaration', 0, { budgetMs, rules: ESCALATE_RULES.length, recoverStreak: RECOVER_STREAK })],
88
+ }),
89
+ };
90
+ },
91
+ advance(state, input, context) {
92
+ const duration = input.durationMs;
93
+ if (!Number.isFinite(duration) || duration < 0) {
94
+ // native cause retained internally; no native type leaks onto the generic surface
95
+ return {
96
+ ok: false,
97
+ error: {
98
+ code: 'invalid-state',
99
+ message: `governor: frame duration must be a finite, non-negative number (got ${String(duration)})`,
100
+ cause: { received: duration, expected: 'finite >= 0' },
101
+ },
102
+ evidence: evidence({ declaredInputs: [record('advance-input', 'duration', context.step, { durationMs: duration })] }),
103
+ };
104
+ }
105
+ const stepResult = feedGovernor(state.governor, duration);
106
+ const nextStep = state.step + 1;
107
+ const next = { governor: stepResult.state, envelope: state.envelope, step: nextStep };
108
+ return {
109
+ ok: true,
110
+ value: { state: next, output: { tier: stepResult.state.tier, changed: stepResult.changed !== undefined } },
111
+ evidence: evidence({
112
+ declaredInputs: [record('advance-input', 'duration', context.step, { durationMs: duration })],
113
+ substrateResponses: [record('advance-response', 'tier', nextStep, { tier: stepResult.state.tier, changed: stepResult.changed })],
114
+ executionTrace: [
115
+ {
116
+ id: `g-${nextStep}`,
117
+ step: nextStep,
118
+ source: SOURCE,
119
+ summary: `duration=${duration} → tier ${stepResult.state.tier}` + (stepResult.changed !== undefined ? ' (changed)' : ''),
120
+ },
121
+ ],
122
+ unresolvedInterpretations: [
123
+ // the runtime reports a tier; it must NOT assert what a participant perceives
124
+ { id: 'perceived-quality', claim: 'tier interpreted as participant-perceived quality', authority: 'empirical', status: 'unresolved' },
125
+ ],
126
+ }),
127
+ };
128
+ },
129
+ snapshot(state, _context) {
130
+ return {
131
+ ok: true,
132
+ value: {
133
+ reading: reading(state),
134
+ restorable: true, // complete — the payload reconstructs State exactly
135
+ payload: { ...state.governor },
136
+ },
137
+ evidence: evidence({ substrateResponses: [record('snapshot', 'governor-state', state.step, { tier: state.governor.tier })] }),
138
+ };
139
+ },
140
+ restore(snapshot, _context) {
141
+ if (!snapshot.restorable || !isGovernorState(snapshot.payload)) {
142
+ return {
143
+ ok: false,
144
+ error: {
145
+ code: 'invalid-state',
146
+ message: 'governor: snapshot payload is not a governor state (cannot restore)',
147
+ cause: { restorable: snapshot.restorable },
148
+ },
149
+ evidence: evidence({ substrateResponses: [record('restore', 'rejected', snapshot.reading.step, { restorable: snapshot.restorable })] }),
150
+ };
151
+ }
152
+ const restored = {
153
+ governor: snapshot.payload,
154
+ envelope: snapshot.reading.envelope,
155
+ step: snapshot.reading.step,
156
+ };
157
+ return {
158
+ ok: true,
159
+ value: restored,
160
+ evidence: evidence({ substrateResponses: [record('restore', 'governor-state', restored.step, { tier: restored.governor.tier })] }),
161
+ };
162
+ },
163
+ /**
164
+ * G3.3 refinement. Present because `declareTransitionLaw` is true: the law IS data, so it can be
165
+ * returned as data. The field adapter has no counterpart — it declares the capability false.
166
+ */
167
+ describeTransitionLaw() {
168
+ const rules = [
169
+ ...ESCALATE_RULES.map((r) => ({ kind: 'escalate', aboveMs: r.aboveMs, streak: r.streak, tier: r.tier })),
170
+ { kind: 'recover', cleanStreak: RECOVER_STREAK, tierDelta: -1 },
171
+ { kind: 'overrun-test', factor: 1.3, budgetMs },
172
+ ];
173
+ return {
174
+ ok: true,
175
+ value: {
176
+ kind: 'threshold-table',
177
+ rules,
178
+ notes: 'first matching escalate rule wins; recovery drops exactly one tier (asymmetric hysteresis)',
179
+ },
180
+ evidence: evidence({ substrateResponses: [record('describe-law', 'transition-law', 0, { ruleCount: rules.length })] }),
181
+ };
182
+ },
183
+ };
184
+ }
185
+ //# sourceMappingURL=governor-runtime.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"governor-runtime.js","sourceRoot":"","sources":["../../../src/world/adapters/governor-runtime.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAcrD,OAAO,EACL,cAAc,EACd,cAAc,EACd,iBAAiB,EACjB,YAAY,EACZ,oBAAoB,EACpB,eAAe,GAChB,MAAM,2BAA2B,CAAC;AAkBnC,MAAM,MAAM,GAAG,EAAE,IAAI,EAAE,WAAW,EAAE,EAAE,EAAE,kBAAkB,EAAW,CAAC;AAEtE,SAAS,MAAM,CAAC,EAAU,EAAE,IAAY,EAAE,UAAkB,EAAE,OAAgB;IAC5E,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,CAAC;AAC3D,CAAC;AAED,SAAS,QAAQ,CAAC,KAAgC;IAChD,OAAO;QACL,cAAc,EAAE,KAAK,CAAC,cAAc,IAAI,EAAE;QAC1C,kBAAkB,EAAE,KAAK,CAAC,kBAAkB,IAAI,EAAE;QAClD,iBAAiB,EAAE,KAAK,CAAC,iBAAiB,IAAI,EAAE;QAChD,cAAc,EAAE,KAAK,CAAC,cAAc,IAAI,EAAE;QAC1C,yBAAyB,EAAE,KAAK,CAAC,yBAAyB,IAAI,EAAE;KACjE,CAAC;AACJ,CAAC;AAED,SAAS,OAAO,CAAC,KAA6B;IAC5C,OAAO;QACL,QAAQ,EAAE,KAAK,CAAC,QAAQ;QACxB,IAAI,EAAE,KAAK,CAAC,IAAI;QAChB,QAAQ,EAAE;YACR;gBACE,EAAE,EAAE,UAAU;gBACd,OAAO,EAAE;oBACP,IAAI,EAAE,KAAK,CAAC,QAAQ,CAAC,IAAI;oBACzB,aAAa,EAAE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,QAAQ,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC;aACnI,CAAC;QACJ,CAAC;QAED;;;WAGG;QACH,qBAAqB;YACnB,MAAM,KAAK,GAAwB;gBACjC,GAAG,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;gBACxG,EAAE,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE,cAAc,EAAE,SAAS,EAAE,CAAC,CAAC,EAAE;gBAC/D,EAAE,IAAI,EAAE,cAAc,EAAE,MAAM,EAAE,GAAG,EAAE,QAAQ,EAAE;aAChD,CAAC;YACF,OAAO;gBACL,EAAE,EAAE,IAAI;gBACR,KAAK,EAAE;oBACL,IAAI,EAAE,iBAAiB;oBACvB,KAAK;oBACL,KAAK,EAAE,4FAA4F;iBACpG;gBACD,QAAQ,EAAE,QAAQ,CAAC,EAAE,kBAAkB,EAAE,CAAC,MAAM,CAAC,cAAc,EAAE,gBAAgB,EAAE,CAAC,EAAE,EAAE,SAAS,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC,EAAE,CAAC;aACvH,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,20 @@
1
+ import type { WorldVersionEnvelope } from '../envelope.ts';
2
+ import type { World } from '../world.ts';
3
+ import type { DynamicsContract } from '../dynamics.ts';
4
+ import type { PlannerProblem, PlannerState, PlannerStatus } from '../substrates/planner.ts';
5
+ export interface PlannerSubstrateState {
6
+ readonly planner: PlannerState;
7
+ readonly envelope: WorldVersionEnvelope;
8
+ readonly step: number;
9
+ }
10
+ /** A search has nothing to feed it — each transition is simply "expand once". */
11
+ export interface PlannerAdvanceInput {
12
+ readonly expand?: 1;
13
+ }
14
+ export interface PlannerAdvanceOutput {
15
+ readonly status: PlannerStatus;
16
+ readonly expanded?: string;
17
+ readonly plan?: readonly string[];
18
+ }
19
+ export declare function plannerDynamics(world: World, problem: PlannerProblem): DynamicsContract<PlannerSubstrateState, PlannerAdvanceInput, PlannerAdvanceOutput>;
20
+ //# sourceMappingURL=planner-runtime.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"planner-runtime.d.ts","sourceRoot":"","sources":["../../../src/world/adapters/planner-runtime.ts"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAC3D,OAAO,KAAK,EAAE,KAAK,EAAsB,MAAM,aAAa,CAAC;AAC7D,OAAO,KAAK,EACV,gBAAgB,EAMjB,MAAM,gBAAgB,CAAC;AAExB,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAE5F,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,OAAO,EAAE,YAAY,CAAC;IAC/B,QAAQ,CAAC,QAAQ,EAAE,oBAAoB,CAAC;IACxC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED,iFAAiF;AACjF,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;CACrB;AAED,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC;IAC/B,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,IAAI,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CACnC;AAmCD,wBAAgB,eAAe,CAC7B,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,cAAc,GACtB,gBAAgB,CAAC,qBAAqB,EAAE,mBAAmB,EAAE,oBAAoB,CAAC,CAiGpF"}
@@ -0,0 +1,144 @@
1
+ /**
2
+ * Corpus adapter: the search planner behind `DynamicsContract` (EXPERIMENTAL, internal).
3
+ *
4
+ * The planner is the corpus **falsification candidate**. Two pre-registered predictions, and what
5
+ * actually happened:
6
+ *
7
+ * P2a "it will expose a missing termination concept" — CONFIRMED, but not first. The FSM control
8
+ * exposed it too, which makes termination a general property of lawful evolution rather than a
9
+ * search idiosyncrasy. See `TransitionLifecycle`.
10
+ * P2b "its partial law will force `executionKind: 'hybrid'`" — CONFIRMED. This is the first substrate
11
+ * in the corpus to use that variant, which until now was declared but never exercised.
12
+ *
13
+ * **A contract change that was considered and REJECTED.** The planner's law is partially declarable —
14
+ * expansion order and edge costs are a table, the euclidean heuristic is computed. It is tempting to add
15
+ * a `completeness: 'complete' | 'partial'` field to `TransitionLawDescription` so the planner could
16
+ * publish the declarable half. That was rejected as a **substrate convenience**, not a missing general
17
+ * concept: `declareTransitionLaw` already answers the question truthfully by being **false** — this
18
+ * substrate cannot declare *the* transition law. Wanting to share part of it is a feature request, and
19
+ * the corpus rule is that convenience is a rejection, not a justification.
20
+ */
21
+ import { createWorldEnvelope } from "../envelope.js";
22
+ import { expandPlanner, initialPlannerState, isTerminal, isPlannerState, extractPlan } from "../substrates/planner.js";
23
+ const SOURCE = { kind: 'substrate', id: 'search-planner' };
24
+ function record(id, kind, observedAt, payload) {
25
+ return { id, kind, source: SOURCE, observedAt, payload };
26
+ }
27
+ function evidence(parts) {
28
+ return {
29
+ declaredInputs: parts.declaredInputs ?? [],
30
+ substrateResponses: parts.substrateResponses ?? [],
31
+ checkedInvariants: parts.checkedInvariants ?? [],
32
+ executionTrace: parts.executionTrace ?? [],
33
+ unresolvedInterpretations: parts.unresolvedInterpretations ?? [],
34
+ };
35
+ }
36
+ const STATUS_INDEX = { searching: 0, 'goal-reached': 1, exhausted: 2 };
37
+ function reading(state) {
38
+ return {
39
+ envelope: state.envelope,
40
+ step: state.step,
41
+ entities: state.planner.explored.map((id) => ({ id, metrics: { cost: state.planner.costSoFar[id] ?? 0 } })),
42
+ metrics: {
43
+ frontier: state.planner.frontier.length,
44
+ explored: state.planner.explored.length,
45
+ expansions: state.planner.expansions,
46
+ status: STATUS_INDEX[state.planner.status],
47
+ terminal: isTerminal(state.planner.status) ? 1 : 0,
48
+ },
49
+ };
50
+ }
51
+ export function plannerDynamics(world, problem) {
52
+ return {
53
+ identity: { id: `planner:${problem.id}:${world.envelope.worldInstance}`, version: '0.1.0' },
54
+ // partly a declared table (edges, costs, expansion order), partly computed (the heuristic)
55
+ executionKind: 'hybrid',
56
+ capabilities: {
57
+ initialize: true,
58
+ advance: true,
59
+ snapshot: true,
60
+ restore: true,
61
+ replay: true,
62
+ inspectInternalState: true,
63
+ declareTransitionLaw: false, // cannot declare THE law — the heuristic is not expressible as data
64
+ deterministicReplay: true,
65
+ },
66
+ determinism: {
67
+ classification: 'deterministic',
68
+ controlledInputs: ['problem-graph', 'heuristic', 'frontier-tie-break'],
69
+ uncontrolledInputs: [], // no clock, no RNG; ties break by node id
70
+ requirements: ['identical problem', 'identical expansion count'],
71
+ },
72
+ initialize(request) {
73
+ const declared = request.declaration;
74
+ return {
75
+ ok: true,
76
+ value: {
77
+ planner: initialPlannerState(problem),
78
+ envelope: declared?.envelope ?? createWorldEnvelope('planner-world'),
79
+ step: 0,
80
+ },
81
+ evidence: evidence({
82
+ declaredInputs: [record('init', 'declaration', 0, { problem: problem.id, nodes: problem.nodes.length, edges: problem.edges.length, heuristic: problem.heuristic.kind })],
83
+ }),
84
+ };
85
+ },
86
+ advance(state, _input, context) {
87
+ const step = expandPlanner(problem, state.planner);
88
+ const terminal = isTerminal(step.status);
89
+ // a finished search does not advance its step counter — asking again is neither progress nor error
90
+ const nextStep = terminal && step.expanded === undefined ? state.step : state.step + 1;
91
+ const next = { planner: step.state, envelope: state.envelope, step: nextStep };
92
+ return {
93
+ ok: true,
94
+ value: {
95
+ state: next,
96
+ output: {
97
+ status: step.status,
98
+ ...(step.expanded !== undefined ? { expanded: step.expanded } : {}),
99
+ ...(step.status === 'goal-reached' ? { plan: extractPlan(problem, step.state) } : {}),
100
+ },
101
+ lifecycle: terminal ? 'terminal' : 'continuing',
102
+ },
103
+ evidence: evidence({
104
+ declaredInputs: [record('advance-input', 'expand', context.step, {})],
105
+ substrateResponses: [record('advance-response', 'status', nextStep, { status: step.status, expanded: step.expanded })],
106
+ executionTrace: [
107
+ {
108
+ id: `p-${nextStep}`,
109
+ step: nextStep,
110
+ source: SOURCE,
111
+ summary: step.expanded ? `expanded ${step.expanded} → ${step.status}` : `already ${step.status}`,
112
+ },
113
+ ],
114
+ unresolvedInterpretations: [
115
+ // the runtime found a cheapest path under the declared costs; it must not claim it is "best"
116
+ { id: 'plan-quality', claim: 'the returned plan is the one a participant would prefer', authority: 'empirical', status: 'unresolved' },
117
+ ],
118
+ }),
119
+ };
120
+ },
121
+ snapshot(state, _context) {
122
+ return {
123
+ ok: true,
124
+ value: { reading: reading(state), restorable: true, payload: { ...state.planner } },
125
+ evidence: evidence({ substrateResponses: [record('snapshot', 'planner-state', state.step, { status: state.planner.status })] }),
126
+ };
127
+ },
128
+ restore(snapshot, _context) {
129
+ if (!snapshot.restorable || !isPlannerState(snapshot.payload)) {
130
+ return {
131
+ ok: false,
132
+ error: { code: 'invalid-state', message: 'planner: snapshot payload is not a planner state', cause: { restorable: snapshot.restorable } },
133
+ evidence: evidence({ substrateResponses: [record('restore', 'rejected', snapshot.reading.step, {})] }),
134
+ };
135
+ }
136
+ return {
137
+ ok: true,
138
+ value: { planner: snapshot.payload, envelope: snapshot.reading.envelope, step: snapshot.reading.step },
139
+ evidence: evidence({ substrateResponses: [record('restore', 'planner-state', snapshot.reading.step, { status: snapshot.payload.status })] }),
140
+ };
141
+ },
142
+ };
143
+ }
144
+ //# sourceMappingURL=planner-runtime.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"planner-runtime.js","sourceRoot":"","sources":["../../../src/world/adapters/planner-runtime.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EAAE,mBAAmB,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ExecutionKind } from '../dynamics.ts';
2
+ import type { World } from '../world.ts';
3
+ export type ChurnClass = 'required-member' | 'optional-member' | 'union-variant' | 'consistency-rule' | 'changed-semantics';
4
+ /** Weights fixed by the pre-registration; not tunable after the fact. */
5
+ export declare const CHURN_WEIGHTS: Readonly<Record<ChurnClass, number>>;
6
+ /**
7
+ * Three kinds of refinement, not two. The earlier binary silently folded `representational` into
8
+ * whichever neighbour was convenient, which is exactly the ambiguity that lets a contract drift.
9
+ *
10
+ * structural - the contract LACKED a concept (D-001 accessor, D-002 lifecycle)
11
+ * representational - the concept existed; this expresses it better. Allowed, but not a discovery
12
+ * convenience - makes adaptation easier, adds no explanatory power. NEVER accepted.
13
+ */
14
+ export type ChangeClassification = 'structural' | 'representational' | 'convenience';
15
+ export interface ContractChange {
16
+ readonly member: string;
17
+ readonly churnClass: ChurnClass;
18
+ readonly classification: ChangeClassification;
19
+ readonly rationale: string;
20
+ }
21
+ /** A change that was considered and REJECTED — recorded so the rejection is auditable. */
22
+ export interface RejectedChange {
23
+ readonly member: string;
24
+ readonly classification: 'convenience';
25
+ readonly rationale: string;
26
+ }
27
+ export type CorpusStatus = 'adapted' | 'pending';
28
+ export type CorpusOutcome = 'generalized' | 'generalized-with-refinement' | 'field-fitted' | 'inconclusive' | 'not-yet-run';
29
+ export interface CorpusEntry {
30
+ readonly substrate: string;
31
+ readonly role: string;
32
+ readonly status: CorpusStatus;
33
+ readonly executionKind?: DynamicsExecutionKind;
34
+ readonly outcome: CorpusOutcome;
35
+ /** Churn predicted BEFORE adapting (pre-registration). */
36
+ readonly predictedChurn?: number;
37
+ readonly changes: readonly ContractChange[];
38
+ readonly rejectedChanges: readonly RejectedChange[];
39
+ readonly note?: string;
40
+ }
41
+ export declare function churnOf(changes: readonly ContractChange[]): number;
42
+ /**
43
+ * The corpus as it actually stands. Adapted entries record what each substrate cost; pending entries
44
+ * record what is not yet evidence. `pending` rows must never be read as support for generality.
45
+ */
46
+ export declare function corpus(): CorpusEntry[];
47
+ export interface CorpusLedger {
48
+ readonly adapted: number;
49
+ readonly pending: number;
50
+ readonly totalChurn: number;
51
+ readonly churnBySubstrate: readonly {
52
+ readonly substrate: string;
53
+ readonly churn: number;
54
+ readonly predicted?: number;
55
+ }[];
56
+ readonly executionKindsExercised: readonly DynamicsExecutionKind[];
57
+ /** True only when the MOST RECENTLY adapted substrate cost nothing — never an average. */
58
+ readonly convergingOnLastAdapted: boolean;
59
+ readonly structuralAccepted: number;
60
+ readonly representationalAccepted: number;
61
+ /** Must always be 0. A convenience is a rejection, not a justification. */
62
+ readonly conveniencesAccepted: number;
63
+ /**
64
+ * Only rejections that were WRITTEN DOWN. Rejections made while writing an adapter and never
65
+ * recorded are not counted - the number is a floor, not a total.
66
+ */
67
+ readonly conveniencesRejected: number;
68
+ }
69
+ export declare function corpusLedger(): CorpusLedger;
70
+ export interface ConformanceFinding {
71
+ readonly check: string;
72
+ readonly passed: boolean;
73
+ readonly detail: string;
74
+ }
75
+ export interface ConformanceReport {
76
+ readonly contract: string;
77
+ readonly executionKind: DynamicsExecutionKind;
78
+ readonly findings: readonly ConformanceFinding[];
79
+ readonly conformant: boolean;
80
+ readonly terminated: boolean;
81
+ readonly transitions: number;
82
+ }
83
+ /**
84
+ * Drive any contract through the GENERIC surface only and report what it does. Deliberately knows
85
+ * nothing about any substrate: it reads capabilities and behaves accordingly, so a substrate cannot
86
+ * pass by being recognized.
87
+ */
88
+ export declare function runConformance<S, I, O>(makeWorld: () => World, makeContract: (w: World) => DynamicsContract<S, I, O>, inputs: readonly I[]): ConformanceReport;
89
+ //# sourceMappingURL=corpus.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"corpus.d.ts","sourceRoot":"","sources":["../../../src/world/conformance/corpus.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAC9E,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAIzC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