@pie-players/pie-assessment-toolkit 0.3.74 → 0.3.75

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 (228) hide show
  1. package/README.md +349 -313
  2. package/dist/attempt/TestSession.d.ts +1 -20
  3. package/dist/attempt/TestSession.js +8 -99
  4. package/dist/components/ItemScope.custom-element.d.ts +1 -0
  5. package/dist/components/ItemScope.custom-element.js +1 -0
  6. package/dist/components/ItemToolBar.custom-element.js +1 -1
  7. package/dist/components/PieAssessmentToolkit.custom-element.js +14 -14
  8. package/dist/components/SectionToolBar.custom-element.js +1 -1
  9. package/dist/components/chunks/ItemToolBar-7tt7v2xp.js +4 -0
  10. package/dist/components/chunks/{ItemToolBar-gmrryv2v.js → ItemToolBar-97hx60z4.js} +1 -1
  11. package/dist/components/chunks/ItemToolBar-bxwyhr5p.js +2 -0
  12. package/dist/components/chunks/ItemToolBar-jx38w99s.js +2 -0
  13. package/dist/components/chunks/ItemToolBar-rd2bb4p6.js +40 -0
  14. package/dist/components/chunks/ItemToolBar-vdkyn9f3.js +2 -0
  15. package/dist/components/chunks/sre-engine-jd8cc08x.js +1 -0
  16. package/dist/components/item-scope-element.d.ts +2 -0
  17. package/dist/components/item-scope-element.js +2 -0
  18. package/dist/context/assessment-toolkit-context.d.ts +27 -6
  19. package/dist/index.d.ts +22 -47
  20. package/dist/index.js +12 -36
  21. package/dist/policy/core/PolicySource.d.ts +1 -1
  22. package/dist/policy/core/ToolPolicyEngine.d.ts +77 -32
  23. package/dist/policy/core/ToolPolicyEngine.js +136 -46
  24. package/dist/policy/core/compose-decision.d.ts +28 -7
  25. package/dist/policy/core/compose-decision.js +75 -54
  26. package/dist/policy/core/decision-types.d.ts +65 -34
  27. package/dist/policy/core/feature-decision.d.ts +16 -9
  28. package/dist/policy/core/feature-decision.js +14 -8
  29. package/dist/policy/core/pnp-policy-inputs.d.ts +24 -33
  30. package/dist/policy/core/pnp-policy-inputs.js +28 -56
  31. package/dist/policy/core/provenance.d.ts +9 -4
  32. package/dist/policy/core/provenance.js +1 -1
  33. package/dist/policy/engine.d.ts +7 -23
  34. package/dist/policy/engine.js +5 -20
  35. package/dist/policy/sources/PnpPolicySource.d.ts +44 -61
  36. package/dist/policy/sources/PnpPolicySource.js +117 -118
  37. package/dist/runtime/SectionControllerBinding.d.ts +279 -0
  38. package/dist/runtime/SectionControllerBinding.js +450 -0
  39. package/dist/runtime/SectionRuntimeEngine.d.ts +26 -289
  40. package/dist/runtime/SectionRuntimeEngine.js +30 -372
  41. package/dist/runtime/adapter/SectionEngineAdapter.d.ts +19 -80
  42. package/dist/runtime/adapter/SectionEngineAdapter.js +19 -92
  43. package/dist/runtime/adapter/dom-event-bridge.d.ts +15 -30
  44. package/dist/runtime/adapter/dom-event-bridge.js +17 -44
  45. package/dist/runtime/adapter/subscriber-fanout.d.ts +1 -2
  46. package/dist/runtime/adapter/subscriber-fanout.js +1 -2
  47. package/dist/runtime/catalog-context.d.ts +19 -0
  48. package/dist/runtime/catalog-context.js +28 -0
  49. package/dist/runtime/composition-emit-scheduler.d.ts +9 -15
  50. package/dist/runtime/composition-emit-scheduler.js +9 -15
  51. package/dist/runtime/content-language.d.ts +32 -0
  52. package/dist/runtime/content-language.js +46 -0
  53. package/dist/runtime/content-region.d.ts +17 -0
  54. package/dist/runtime/content-region.js +29 -0
  55. package/dist/runtime/content-registration.d.ts +13 -0
  56. package/dist/runtime/content-registration.js +25 -0
  57. package/dist/runtime/core/SectionEngineCore.d.ts +2 -2
  58. package/dist/runtime/core/SectionEngineCore.js +2 -2
  59. package/dist/runtime/core/cohort.d.ts +1 -1
  60. package/dist/runtime/core/cohort.js +1 -1
  61. package/dist/runtime/core/engine-input.d.ts +18 -30
  62. package/dist/runtime/core/engine-input.js +11 -12
  63. package/dist/runtime/core/engine-output.d.ts +16 -40
  64. package/dist/runtime/core/engine-output.js +9 -21
  65. package/dist/runtime/core/engine-readiness.d.ts +5 -37
  66. package/dist/runtime/core/engine-readiness.js +8 -41
  67. package/dist/runtime/core/engine-resolver.d.ts +46 -74
  68. package/dist/runtime/core/engine-resolver.js +18 -43
  69. package/dist/runtime/core/engine-state.d.ts +28 -36
  70. package/dist/runtime/core/engine-state.js +18 -21
  71. package/dist/runtime/core/engine-transition.d.ts +14 -19
  72. package/dist/runtime/core/engine-transition.js +71 -51
  73. package/dist/runtime/engine.d.ts +16 -19
  74. package/dist/runtime/engine.js +12 -19
  75. package/dist/runtime/page-warnings.d.ts +13 -0
  76. package/dist/runtime/page-warnings.js +22 -0
  77. package/dist/runtime/policy-input-forwarding.d.ts +25 -0
  78. package/dist/runtime/policy-input-forwarding.js +25 -0
  79. package/dist/runtime/registration-events.d.ts +11 -0
  80. package/dist/runtime/runtime-event-claim.d.ts +8 -0
  81. package/dist/runtime/runtime-event-claim.js +15 -0
  82. package/dist/runtime/shell-event-bridge.d.ts +45 -0
  83. package/dist/runtime/shell-event-bridge.js +127 -0
  84. package/dist/runtime/shell-registration.d.ts +73 -0
  85. package/dist/runtime/shell-registration.js +95 -0
  86. package/dist/runtime/shell-scope.d.ts +68 -0
  87. package/dist/runtime/shell-scope.js +188 -0
  88. package/dist/runtime/tool-host-contract.d.ts +8 -10
  89. package/dist/runtime/tool-host-contract.js +11 -11
  90. package/dist/runtime/unclaimed-registration-watch.d.ts +7 -0
  91. package/dist/runtime/unclaimed-registration-watch.js +23 -0
  92. package/dist/services/ElementToolStateStore.d.ts +14 -10
  93. package/dist/services/ElementToolStateStore.js +37 -13
  94. package/dist/services/HighlightCoordinator.d.ts +21 -21
  95. package/dist/services/HighlightCoordinator.js +431 -325
  96. package/dist/services/RangeSerializer.d.ts +10 -1
  97. package/dist/services/RangeSerializer.js +87 -14
  98. package/dist/services/TTSService.d.ts +117 -70
  99. package/dist/services/TTSService.js +668 -578
  100. package/dist/services/ToolCoordinator.d.ts +43 -60
  101. package/dist/services/ToolCoordinator.js +164 -206
  102. package/dist/services/ToolRegistry.d.ts +74 -57
  103. package/dist/services/ToolRegistry.js +104 -114
  104. package/dist/services/ToolkitCoordinator.d.ts +183 -189
  105. package/dist/services/ToolkitCoordinator.js +477 -431
  106. package/dist/services/audio-handoff.d.ts +6 -7
  107. package/dist/services/audio-handoff.js +20 -14
  108. package/dist/services/catalog-owner.d.ts +0 -1
  109. package/dist/services/framework-error-bus.d.ts +3 -6
  110. package/dist/services/framework-error-bus.js +3 -6
  111. package/dist/services/framework-error.d.ts +22 -7
  112. package/dist/services/framework-error.js +9 -7
  113. package/dist/services/interfaces.d.ts +158 -129
  114. package/dist/services/section-session-assignment.d.ts +21 -0
  115. package/dist/services/section-session-assignment.js +82 -0
  116. package/dist/services/spoken-audio-cards.d.ts +0 -2
  117. package/dist/services/spoken-audio-cards.js +0 -2
  118. package/dist/services/tool-config-defaults.d.ts +3 -3
  119. package/dist/services/tool-config-defaults.js +3 -3
  120. package/dist/services/tool-config-validation.d.ts +4 -5
  121. package/dist/services/tool-config-validation.js +36 -61
  122. package/dist/services/tool-context.d.ts +0 -8
  123. package/dist/services/tool-context.js +0 -12
  124. package/dist/services/tool-icons.d.ts +4 -3
  125. package/dist/services/tool-icons.js +4 -3
  126. package/dist/services/tool-instance-id.d.ts +0 -1
  127. package/dist/services/tool-instance-id.js +0 -6
  128. package/dist/services/tool-providers/TTSToolProvider.d.ts +18 -19
  129. package/dist/services/tool-providers/TTSToolProvider.js +37 -34
  130. package/dist/services/tool-providers/ToolProviderApi.d.ts +10 -4
  131. package/dist/services/tool-providers/ToolProviderRegistry.d.ts +30 -26
  132. package/dist/services/tool-providers/ToolProviderRegistry.js +119 -93
  133. package/dist/services/tool-request.d.ts +27 -12
  134. package/dist/services/tool-request.js +24 -14
  135. package/dist/services/toolbar-decided-tools.d.ts +15 -0
  136. package/dist/services/toolbar-decided-tools.js +28 -0
  137. package/dist/services/tools-config-normalizer.d.ts +17 -22
  138. package/dist/services/tools-config-normalizer.js +2 -10
  139. package/dist/services/tts/browser-provider.d.ts +38 -2
  140. package/dist/services/tts/browser-provider.js +276 -140
  141. package/dist/services/tts/flat-tree.d.ts +71 -0
  142. package/dist/services/tts/flat-tree.js +269 -0
  143. package/dist/services/tts/generated-speech/assemble-plan.d.ts +3 -1
  144. package/dist/services/tts/generated-speech/assemble-plan.js +3 -1
  145. package/dist/services/tts/generated-speech/dom/build-dom-plan.d.ts +2 -0
  146. package/dist/services/tts/generated-speech/dom/build-dom-plan.js +1 -1
  147. package/dist/services/tts/generated-speech/math-speech-cache.d.ts +3 -1
  148. package/dist/services/tts/generated-speech/math-speech-cache.js +5 -1
  149. package/dist/services/tts/highlight-pipeline/create-highlight-plan.js +12 -4
  150. package/dist/services/tts/highlight-pipeline/prose-boundary-resolver.js +6 -4
  151. package/dist/services/tts/highlight-pipeline/readable-region.js +3 -2
  152. package/dist/services/tts/highlight-pipeline/types.d.ts +5 -0
  153. package/dist/services/tts/highlight-pipeline/visible-map-range.d.ts +12 -0
  154. package/dist/services/tts/highlight-pipeline/visible-map-range.js +73 -7
  155. package/dist/services/tts/math-aware-text-processing.d.ts +5 -1
  156. package/dist/services/tts/math-aware-text-processing.js +32 -18
  157. package/dist/services/tts/math-control-names.d.ts +21 -0
  158. package/dist/services/tts/math-control-names.js +142 -0
  159. package/dist/services/tts/math-speech.d.ts +11 -0
  160. package/dist/services/tts/math-speech.js +51 -18
  161. package/dist/services/tts/provider-options.d.ts +41 -0
  162. package/dist/services/tts/provider-options.js +1 -0
  163. package/dist/services/tts/ssml/spoken-text.d.ts +2 -26
  164. package/dist/services/tts/ssml/spoken-text.js +29 -0
  165. package/dist/services/tts/start-failure.d.ts +11 -0
  166. package/dist/services/tts/start-failure.js +19 -0
  167. package/dist/services/tts/text-processing.d.ts +9 -0
  168. package/dist/services/tts/text-processing.js +46 -33
  169. package/dist/services/tts/text-segmentation.d.ts +7 -0
  170. package/dist/services/tts/text-segmentation.js +47 -0
  171. package/dist/services/tts-runtime-config.d.ts +25 -17
  172. package/dist/services/tts-runtime-config.js +16 -95
  173. package/dist/tools/content-capability-resolution.d.ts +7 -9
  174. package/dist/tools/content-capability-resolution.js +8 -45
  175. package/dist/tools/registration.d.ts +58 -0
  176. package/dist/tools/registration.js +54 -0
  177. package/dist/tools/registrations/toolbar-registration-helpers.js +2 -2
  178. package/dist/tools/tool-surface-host.d.ts +6 -10
  179. package/dist/tools/tool-surface-host.js +44 -42
  180. package/dist/tools/tool-tag-map.d.ts +5 -15
  181. package/dist/tools/tool-tag-map.js +6 -20
  182. package/dist/utils/structural-equality.d.ts +11 -0
  183. package/dist/utils/structural-equality.js +47 -0
  184. package/package.json +13 -29
  185. package/dist/attempt/adapters/activity-to-test-attempt-session.d.ts +0 -49
  186. package/dist/attempt/adapters/activity-to-test-attempt-session.js +0 -138
  187. package/dist/components/chunks/ItemToolBar-b9dz5jvd.js +0 -40
  188. package/dist/components/chunks/ItemToolBar-h4xap0t0.js +0 -4
  189. package/dist/components/chunks/ItemToolBar-wr2myaah.js +0 -2
  190. package/dist/components/chunks/sre-engine-wf9s43gg.js +0 -1
  191. package/dist/context/runtime-context-consumer.d.ts +0 -13
  192. package/dist/context/runtime-context-consumer.js +0 -18
  193. package/dist/item-loader.d.ts +0 -44
  194. package/dist/item-loader.js +0 -61
  195. package/dist/policy/core/engine-context.d.ts +0 -29
  196. package/dist/policy/core/engine-context.js +0 -27
  197. package/dist/policy/core/policy-source-tag.d.ts +0 -31
  198. package/dist/policy/core/policy-source-tag.js +0 -28
  199. package/dist/policy/internal.d.ts +0 -25
  200. package/dist/policy/internal.js +0 -25
  201. package/dist/runtime/adapter/coordinator-bridge.d.ts +0 -92
  202. package/dist/runtime/adapter/coordinator-bridge.js +0 -126
  203. package/dist/runtime/adapter/framework-error-bridge.d.ts +0 -36
  204. package/dist/runtime/adapter/framework-error-bridge.js +0 -46
  205. package/dist/runtime/adapter/instrumentation-bridge.d.ts +0 -31
  206. package/dist/runtime/adapter/instrumentation-bridge.js +0 -38
  207. package/dist/runtime/core/engine-stage-derivation.d.ts +0 -18
  208. package/dist/runtime/core/engine-stage-derivation.js +0 -29
  209. package/dist/runtime/engine-context.d.ts +0 -39
  210. package/dist/runtime/engine-context.js +0 -31
  211. package/dist/runtime/internal.d.ts +0 -43
  212. package/dist/runtime/internal.js +0 -45
  213. package/dist/runtime/section-runtime-engine-host-context.d.ts +0 -74
  214. package/dist/runtime/section-runtime-engine-host-context.js +0 -57
  215. package/dist/runtime/stage-emit-gate.d.ts +0 -92
  216. package/dist/runtime/stage-emit-gate.js +0 -82
  217. package/dist/services/I18nService.d.ts +0 -47
  218. package/dist/services/I18nService.js +0 -84
  219. package/dist/services/ThemeProvider.d.ts +0 -95
  220. package/dist/services/ThemeProvider.js +0 -334
  221. package/dist/services/defaultPersonalNeedsProfile.d.ts +0 -21
  222. package/dist/services/defaultPersonalNeedsProfile.js +0 -26
  223. package/dist/services/pnp-standard-features.d.ts +0 -238
  224. package/dist/services/pnp-standard-features.js +0 -338
  225. package/dist/tools/client.d.ts +0 -10
  226. package/dist/tools/client.js +0 -10
  227. package/dist/tools/internal.d.ts +0 -44
  228. package/dist/tools/internal.js +0 -39
@@ -1,29 +0,0 @@
1
- /**
2
- * Svelte context key for the tool policy engine (M8 PR 1).
3
- *
4
- * Components inside an assessment toolkit subtree consume the engine
5
- * through Svelte's native `getContext(TOOL_POLICY_ENGINE_KEY)`. The
6
- * canonical provider is the `ToolkitCoordinator` wiring (M8 PR 2):
7
- * the toolkit CE constructs a `ToolPolicyEngine`, attaches it to the
8
- * coordinator, and exposes it to descendants via
9
- * `setContext(TOOL_POLICY_ENGINE_KEY, engine)`.
10
- *
11
- * Mirrors the M7 `SECTION_RUNTIME_ENGINE_KEY` pattern. As with the
12
- * runtime engine, the key is a `Symbol` so it cannot collide with
13
- * userland context keys and so descendants are forced to import this
14
- * module rather than guess a string id.
15
- *
16
- * **No cross-CE bridge.** Unlike the runtime engine, there is no
17
- * `connectToolPolicyEngineHostContext` helper — see M8 design Q8.
18
- * Every CE in the tree gets its engine from its own coordinator
19
- * (the toolkit element). This avoids subscription-bridge overhead
20
- * for a function-style engine that hosts can simply re-call after
21
- * an input swap.
22
- *
23
- * **Stability.** This export is part of the stable `policy/engine`
24
- * surface; renaming or replacing the symbol is a major breaking
25
- * change.
26
- */
27
- import type { ToolPolicyEngine } from "./ToolPolicyEngine.js";
28
- export declare const TOOL_POLICY_ENGINE_KEY: unique symbol;
29
- export type ToolPolicyEngineContext = ToolPolicyEngine;
@@ -1,27 +0,0 @@
1
- /**
2
- * Svelte context key for the tool policy engine (M8 PR 1).
3
- *
4
- * Components inside an assessment toolkit subtree consume the engine
5
- * through Svelte's native `getContext(TOOL_POLICY_ENGINE_KEY)`. The
6
- * canonical provider is the `ToolkitCoordinator` wiring (M8 PR 2):
7
- * the toolkit CE constructs a `ToolPolicyEngine`, attaches it to the
8
- * coordinator, and exposes it to descendants via
9
- * `setContext(TOOL_POLICY_ENGINE_KEY, engine)`.
10
- *
11
- * Mirrors the M7 `SECTION_RUNTIME_ENGINE_KEY` pattern. As with the
12
- * runtime engine, the key is a `Symbol` so it cannot collide with
13
- * userland context keys and so descendants are forced to import this
14
- * module rather than guess a string id.
15
- *
16
- * **No cross-CE bridge.** Unlike the runtime engine, there is no
17
- * `connectToolPolicyEngineHostContext` helper — see M8 design Q8.
18
- * Every CE in the tree gets its engine from its own coordinator
19
- * (the toolkit element). This avoids subscription-bridge overhead
20
- * for a function-style engine that hosts can simply re-call after
21
- * an input swap.
22
- *
23
- * **Stability.** This export is part of the stable `policy/engine`
24
- * surface; renaming or replacing the symbol is a major breaking
25
- * change.
26
- */
27
- export const TOOL_POLICY_ENGINE_KEY = Symbol("@pie-players/tool-policy-engine");
@@ -1,31 +0,0 @@
1
- /**
2
- * Policy source tag — attribution for `ToolPolicyEntry.sources`.
3
- *
4
- * The engine attaches a `PolicySourceTag` to every `ToolPolicyEntry` it
5
- * emits, capturing every step from `compose-decision.ts` that contributed
6
- * to the entry being kept (or, in the case of `required-tool-blocked`,
7
- * the step that surfaced the conflict).
8
- *
9
- * Tag vocabulary maps onto the six composition steps in
10
- * `m8-design.md` § 3:
11
- *
12
- * 1. Membership filter → `"placement"`
13
- * 2. Provider veto → `"provider"` (negative; only present when
14
- * the entry survived a
15
- * non-`enabled: false` check)
16
- * 3. Host whitelist → `"policy"`
17
- * 4. Host blocklist → `"policy"` (negative)
18
- * 5. PNP/profile gates → `"pnp.${rule}"` (e.g. `"pnp.pnp-support"`,
19
- * `"pnp.item-requirement"`)
20
- * 6. Custom PolicySources → `"custom.${source.id}"`
21
- *
22
- * Negative tags do not appear on surviving entries — they are reflected
23
- * only in `ToolPolicyProvenance` decisions. The tag union therefore
24
- * tracks contributors that *kept* a tool, not contributors that
25
- * *removed* one. Diagnostic surfacing of removals is the
26
- * provenance/diagnostic channel's job.
27
- */
28
- export type PnpPolicySourceRule = "district-block" | "test-admin-override" | "item-restriction" | "item-requirement" | "district-requirement" | "pnp-support" | "pnp-prohibited";
29
- export type PnpPolicySourceTag = `pnp.${PnpPolicySourceRule}`;
30
- export type CustomPolicySourceTag = `custom.${string}`;
31
- export type PolicySourceTag = "placement" | "policy" | "provider" | PnpPolicySourceTag | CustomPolicySourceTag;
@@ -1,28 +0,0 @@
1
- /**
2
- * Policy source tag — attribution for `ToolPolicyEntry.sources`.
3
- *
4
- * The engine attaches a `PolicySourceTag` to every `ToolPolicyEntry` it
5
- * emits, capturing every step from `compose-decision.ts` that contributed
6
- * to the entry being kept (or, in the case of `required-tool-blocked`,
7
- * the step that surfaced the conflict).
8
- *
9
- * Tag vocabulary maps onto the six composition steps in
10
- * `m8-design.md` § 3:
11
- *
12
- * 1. Membership filter → `"placement"`
13
- * 2. Provider veto → `"provider"` (negative; only present when
14
- * the entry survived a
15
- * non-`enabled: false` check)
16
- * 3. Host whitelist → `"policy"`
17
- * 4. Host blocklist → `"policy"` (negative)
18
- * 5. PNP/profile gates → `"pnp.${rule}"` (e.g. `"pnp.pnp-support"`,
19
- * `"pnp.item-requirement"`)
20
- * 6. Custom PolicySources → `"custom.${source.id}"`
21
- *
22
- * Negative tags do not appear on surviving entries — they are reflected
23
- * only in `ToolPolicyProvenance` decisions. The tag union therefore
24
- * tracks contributors that *kept* a tool, not contributors that
25
- * *removed* one. Diagnostic surfacing of removals is the
26
- * provenance/diagnostic channel's job.
27
- */
28
- export {};
@@ -1,25 +0,0 @@
1
- /**
2
- * Tool policy engine — **internal** entry point (M8 PR 1).
3
- *
4
- * Re-exports the composition pipeline, the PNP policy source, and the
5
- * provenance builder for advanced hosts that want to drive the engine
6
- * components directly, and for the engine's own tests.
7
- *
8
- * **Stability posture.** This module is **not** part of the stable
9
- * public API. Symbols here are subject to change between minor
10
- * versions with only a changeset note. Hosts that need long-term
11
- * stability should depend on the facade (`ToolPolicyEngine` exported
12
- * from `./policy/engine`) instead.
13
- *
14
- * The split is intentional:
15
- * - `./policy/engine` — narrow, stable facade for common host
16
- * wiring and Svelte context.
17
- * - `./policy/internal` — wide, evolving surface for the
18
- * composition pipeline, PNP policy source, and
19
- * any host that wants to reach past the
20
- * facade.
21
- */
22
- export { composeDecision, type ComposeDecisionInputs, } from "./core/compose-decision.js";
23
- export { PnpPolicySource, type PnpPolicyApplyArgs, type PnpPolicyDecisionEvent, type PnpPolicyResult, type PnpPolicyToolFlags, } from "./sources/PnpPolicySource.js";
24
- export { ToolPolicyProvenanceBuilder } from "./core/provenance.js";
25
- export { assessmentHasPnpPolicyInputs, itemRefHasPnpPolicyInputs, resolveDefaultPnpEnforcement, } from "./core/pnp-policy-inputs.js";
@@ -1,25 +0,0 @@
1
- /**
2
- * Tool policy engine — **internal** entry point (M8 PR 1).
3
- *
4
- * Re-exports the composition pipeline, the PNP policy source, and the
5
- * provenance builder for advanced hosts that want to drive the engine
6
- * components directly, and for the engine's own tests.
7
- *
8
- * **Stability posture.** This module is **not** part of the stable
9
- * public API. Symbols here are subject to change between minor
10
- * versions with only a changeset note. Hosts that need long-term
11
- * stability should depend on the facade (`ToolPolicyEngine` exported
12
- * from `./policy/engine`) instead.
13
- *
14
- * The split is intentional:
15
- * - `./policy/engine` — narrow, stable facade for common host
16
- * wiring and Svelte context.
17
- * - `./policy/internal` — wide, evolving surface for the
18
- * composition pipeline, PNP policy source, and
19
- * any host that wants to reach past the
20
- * facade.
21
- */
22
- export { composeDecision, } from "./core/compose-decision.js";
23
- export { PnpPolicySource, } from "./sources/PnpPolicySource.js";
24
- export { ToolPolicyProvenanceBuilder } from "./core/provenance.js";
25
- export { assessmentHasPnpPolicyInputs, itemRefHasPnpPolicyInputs, resolveDefaultPnpEnforcement, } from "./core/pnp-policy-inputs.js";
@@ -1,92 +0,0 @@
1
- /**
2
- * Coordinator bridge for the section runtime engine adapter (M7 —
3
- * Variant C, layered).
4
- *
5
- * Unlike the DOM / framework-error bridges (which translate
6
- * **outputs** into I/O), the coordinator bridge is an **input source**:
7
- * it listens to a `ToolkitCoordinator` and feeds the resulting events
8
- * into the core via the `dispatchCoreInput` callback supplied by the
9
- * adapter.
10
- *
11
- * Responsibilities:
12
- * 1. **Framework-error subscription.** When the coordinator reports
13
- * a framework error through its bus, dispatch a
14
- * `{ kind: "framework-error" }` core input. Listener isolation
15
- * matches `FrameworkErrorBus`: a throwing bridge handler is
16
- * caught and `console.warn`-logged so the original fan-out is
17
- * not interrupted.
18
- *
19
- * 2. **Section-controller resolution.** When the host calls
20
- * `resolveSectionController({ ... })`, the bridge invokes
21
- * `coordinator.getOrCreateSectionController({ ... })` and, on
22
- * successful resolution, dispatches
23
- * `{ kind: "section-controller-resolved" }` to the core. Init
24
- * tokens guard against late resolutions overwriting a more
25
- * recent cohort (mirrors `SectionRuntimeEngine.initialize`'s
26
- * `activeInitToken` pattern).
27
- *
28
- * 3. **Disposal.** On `dispose()`, the bridge unsubscribes from the
29
- * framework-error bus and (if the engine owns the section
30
- * controller for the cohort) calls
31
- * `coordinator.disposeSectionController({ ... })`. It does
32
- * **not** dispose the coordinator itself — the coordinator's
33
- * lifetime is owned by the toolkit CE / host, not by the engine.
34
- *
35
- * Disposal is idempotent: calling `dispose()` twice is a no-op.
36
- *
37
- * The bridge **must not** import `svelte`.
38
- */
39
- import type { SectionControllerHandle } from "../../services/section-controller-types.js";
40
- import type { CohortKey } from "../core/cohort.js";
41
- import type { SectionEngineInput } from "../core/engine-input.js";
42
- /**
43
- * Subset of the `ToolkitCoordinator` surface the bridge consumes. Kept
44
- * structural so tests can pass a fake without pulling the full
45
- * coordinator.
46
- */
47
- export interface CoordinatorPort {
48
- subscribeFrameworkErrors(listener: (model: import("../../services/framework-error.js").FrameworkErrorModel) => void): () => void;
49
- getOrCreateSectionController(args: {
50
- sectionId: string;
51
- attemptId?: string;
52
- input?: unknown;
53
- updateExisting?: boolean;
54
- createDefaultController: () => SectionControllerHandle | Promise<SectionControllerHandle>;
55
- }): Promise<SectionControllerHandle>;
56
- disposeSectionController(args: {
57
- sectionId: string;
58
- attemptId?: string;
59
- }): Promise<void>;
60
- }
61
- export interface ResolveSectionControllerArgs {
62
- cohort: CohortKey;
63
- assessmentId: string;
64
- view: string;
65
- section: unknown;
66
- createDefaultController: () => SectionControllerHandle | Promise<SectionControllerHandle>;
67
- /**
68
- * Optional callback invoked when the controller resolves and on
69
- * every controller `subscribe` event. The kernel uses this to keep
70
- * its composition snapshot in sync with the controller's view.
71
- *
72
- * The bridge is responsible for unsubscribing on dispose / cohort
73
- * change so a stale controller doesn't keep emitting after rollover.
74
- */
75
- onCompositionChanged?: (composition: unknown) => void;
76
- /**
77
- * Optional callback invoked once with the resolved controller handle
78
- * the moment it is available. Lets the host keep a reference for
79
- * direct method calls (e.g. `navigateToItem`, `applySession`)
80
- * without re-querying the coordinator.
81
- */
82
- onControllerResolved?: (controller: SectionControllerHandle) => void;
83
- }
84
- export interface CoordinatorBridgeOptions {
85
- coordinator: CoordinatorPort;
86
- dispatchCoreInput: (input: SectionEngineInput) => void;
87
- }
88
- export interface CoordinatorBridgeHandle {
89
- resolveSectionController(args: ResolveSectionControllerArgs): Promise<void>;
90
- dispose(): Promise<void>;
91
- }
92
- export declare function createCoordinatorBridge(options: CoordinatorBridgeOptions): CoordinatorBridgeHandle;
@@ -1,126 +0,0 @@
1
- /**
2
- * Coordinator bridge for the section runtime engine adapter (M7 —
3
- * Variant C, layered).
4
- *
5
- * Unlike the DOM / framework-error bridges (which translate
6
- * **outputs** into I/O), the coordinator bridge is an **input source**:
7
- * it listens to a `ToolkitCoordinator` and feeds the resulting events
8
- * into the core via the `dispatchCoreInput` callback supplied by the
9
- * adapter.
10
- *
11
- * Responsibilities:
12
- * 1. **Framework-error subscription.** When the coordinator reports
13
- * a framework error through its bus, dispatch a
14
- * `{ kind: "framework-error" }` core input. Listener isolation
15
- * matches `FrameworkErrorBus`: a throwing bridge handler is
16
- * caught and `console.warn`-logged so the original fan-out is
17
- * not interrupted.
18
- *
19
- * 2. **Section-controller resolution.** When the host calls
20
- * `resolveSectionController({ ... })`, the bridge invokes
21
- * `coordinator.getOrCreateSectionController({ ... })` and, on
22
- * successful resolution, dispatches
23
- * `{ kind: "section-controller-resolved" }` to the core. Init
24
- * tokens guard against late resolutions overwriting a more
25
- * recent cohort (mirrors `SectionRuntimeEngine.initialize`'s
26
- * `activeInitToken` pattern).
27
- *
28
- * 3. **Disposal.** On `dispose()`, the bridge unsubscribes from the
29
- * framework-error bus and (if the engine owns the section
30
- * controller for the cohort) calls
31
- * `coordinator.disposeSectionController({ ... })`. It does
32
- * **not** dispose the coordinator itself — the coordinator's
33
- * lifetime is owned by the toolkit CE / host, not by the engine.
34
- *
35
- * Disposal is idempotent: calling `dispose()` twice is a no-op.
36
- *
37
- * The bridge **must not** import `svelte`.
38
- */
39
- export function createCoordinatorBridge(options) {
40
- const { coordinator, dispatchCoreInput } = options;
41
- let activeInitToken = 0;
42
- let activeCohort = null;
43
- let unsubscribeController = null;
44
- let disposed = false;
45
- const unsubscribeFrameworkErrors = coordinator.subscribeFrameworkErrors((model) => {
46
- try {
47
- dispatchCoreInput({ kind: "framework-error", error: model });
48
- }
49
- catch (error) {
50
- console.warn("[CoordinatorBridge] framework-error dispatch failed:", error);
51
- }
52
- });
53
- function detachControllerSubscription() {
54
- if (!unsubscribeController)
55
- return;
56
- try {
57
- unsubscribeController();
58
- }
59
- catch (error) {
60
- console.warn("[CoordinatorBridge] controller unsubscribe failed:", error);
61
- }
62
- unsubscribeController = null;
63
- }
64
- async function resolveSectionController(args) {
65
- if (disposed)
66
- return;
67
- activeInitToken += 1;
68
- const token = activeInitToken;
69
- activeCohort = args.cohort;
70
- const controller = await coordinator.getOrCreateSectionController({
71
- sectionId: args.cohort.sectionId,
72
- attemptId: args.cohort.attemptId || undefined,
73
- input: {
74
- section: args.section,
75
- sectionId: args.cohort.sectionId,
76
- assessmentId: args.assessmentId,
77
- view: args.view,
78
- },
79
- updateExisting: true,
80
- createDefaultController: args.createDefaultController,
81
- });
82
- // Drop late resolutions — a cohort change or dispose may have
83
- // rolled the token forward while we awaited the coordinator.
84
- if (token !== activeInitToken || disposed)
85
- return;
86
- detachControllerSubscription();
87
- args.onControllerResolved?.(controller);
88
- const getCompositionModel = controller.getCompositionModel;
89
- args.onCompositionChanged?.(getCompositionModel?.());
90
- if (typeof controller.subscribe === "function") {
91
- unsubscribeController = controller.subscribe((_event) => {
92
- if (token !== activeInitToken || disposed)
93
- return;
94
- args.onCompositionChanged?.(getCompositionModel?.());
95
- });
96
- }
97
- dispatchCoreInput({ kind: "section-controller-resolved" });
98
- }
99
- async function dispose() {
100
- if (disposed)
101
- return;
102
- disposed = true;
103
- activeInitToken += 1;
104
- detachControllerSubscription();
105
- try {
106
- unsubscribeFrameworkErrors();
107
- }
108
- catch (error) {
109
- console.warn("[CoordinatorBridge] framework-error unsubscribe failed:", error);
110
- }
111
- const cohort = activeCohort;
112
- activeCohort = null;
113
- if (cohort) {
114
- try {
115
- await coordinator.disposeSectionController({
116
- sectionId: cohort.sectionId,
117
- attemptId: cohort.attemptId || undefined,
118
- });
119
- }
120
- catch (error) {
121
- console.warn("[CoordinatorBridge] section-controller dispose failed:", error);
122
- }
123
- }
124
- }
125
- return { resolveSectionController, dispose };
126
- }
@@ -1,36 +0,0 @@
1
- /**
2
- * Framework-error bridge for the section runtime engine adapter (M7 —
3
- * Variant C, layered).
4
- *
5
- * Routes `framework-error` engine outputs into a `FrameworkErrorBus`
6
- * (write side: `FrameworkErrorReporter`). The bus is the single
7
- * fan-out point shared with the toolkit CE's banner, the coordinator's
8
- * canonical `onFrameworkError` lifecycle hook, and any direct host
9
- * subscribers via `subscribeFrameworkErrors`. See
10
- * `packages/assessment-toolkit/src/services/framework-error-bus.ts`
11
- * for the full bus contract.
12
- *
13
- * **Why a separate bridge.** The dom-event-bridge dispatches the
14
- * `framework-error` DOM event on the host. The framework-error-bridge
15
- * routes the same model into the in-process bus so listeners that
16
- * subscribe via `coordinator.subscribeFrameworkErrors(...)` see the
17
- * same fan-out with byte-identical payloads. Splitting the
18
- * responsibilities lets a host opt out of either side (DOM-only or
19
- * bus-only) without re-implementing the other.
20
- *
21
- * **Bus ownership.** The bridge does not construct the bus; the
22
- * adapter receives one externally so the toolkit CE can keep sharing
23
- * its bus with the coordinator (matching today's
24
- * `PieAssessmentToolkit.svelte` lifetime model). This avoids the
25
- * "second bus" pitfall — a dual-bus topology would silently fragment
26
- * fan-out.
27
- */
28
- import type { FrameworkErrorReporter } from "../../services/framework-error-bus.js";
29
- import type { SectionEngineOutput } from "../core/engine-output.js";
30
- export interface FrameworkErrorBridgeOptions {
31
- bus: FrameworkErrorReporter;
32
- }
33
- export interface FrameworkErrorBridgeHandle {
34
- dispatch(output: SectionEngineOutput): void;
35
- }
36
- export declare function createFrameworkErrorBridge(options: FrameworkErrorBridgeOptions): FrameworkErrorBridgeHandle;
@@ -1,46 +0,0 @@
1
- /**
2
- * Framework-error bridge for the section runtime engine adapter (M7 —
3
- * Variant C, layered).
4
- *
5
- * Routes `framework-error` engine outputs into a `FrameworkErrorBus`
6
- * (write side: `FrameworkErrorReporter`). The bus is the single
7
- * fan-out point shared with the toolkit CE's banner, the coordinator's
8
- * canonical `onFrameworkError` lifecycle hook, and any direct host
9
- * subscribers via `subscribeFrameworkErrors`. See
10
- * `packages/assessment-toolkit/src/services/framework-error-bus.ts`
11
- * for the full bus contract.
12
- *
13
- * **Why a separate bridge.** The dom-event-bridge dispatches the
14
- * `framework-error` DOM event on the host. The framework-error-bridge
15
- * routes the same model into the in-process bus so listeners that
16
- * subscribe via `coordinator.subscribeFrameworkErrors(...)` see the
17
- * same fan-out with byte-identical payloads. Splitting the
18
- * responsibilities lets a host opt out of either side (DOM-only or
19
- * bus-only) without re-implementing the other.
20
- *
21
- * **Bus ownership.** The bridge does not construct the bus; the
22
- * adapter receives one externally so the toolkit CE can keep sharing
23
- * its bus with the coordinator (matching today's
24
- * `PieAssessmentToolkit.svelte` lifetime model). This avoids the
25
- * "second bus" pitfall — a dual-bus topology would silently fragment
26
- * fan-out.
27
- */
28
- export function createFrameworkErrorBridge(options) {
29
- const { bus } = options;
30
- function dispatch(output) {
31
- switch (output.kind) {
32
- case "framework-error":
33
- bus.reportFrameworkError(output.error);
34
- return;
35
- case "stage-change":
36
- case "loading-complete":
37
- return;
38
- default: {
39
- const exhaustive = output;
40
- void exhaustive;
41
- return;
42
- }
43
- }
44
- }
45
- return { dispatch };
46
- }
@@ -1,31 +0,0 @@
1
- /**
2
- * Instrumentation bridge for the section runtime engine adapter (M7 —
3
- * Variant C, layered).
4
- *
5
- * Forwards every `SectionEngineOutput` to an optional observability
6
- * hook the host injects (telemetry, debug logger, e2e probe). The
7
- * bridge is intentionally thin: it does not buffer, transform, or
8
- * filter. Hosts that need a different shape can run their own subscriber
9
- * via the adapter's public `subscribe(...)` channel.
10
- *
11
- * **Why a dedicated bridge instead of a generic subscriber.** The
12
- * subscriber-fanout channel is host-shaped — listeners receive batched
13
- * arrays of outputs per `core.dispatch` call so they can reason about
14
- * "what happened in this transition." The instrumentation hook is
15
- * per-output: telemetry pipelines want one record per stage change,
16
- * one record per readiness flip, etc. Splitting the channels keeps
17
- * both shapes ergonomic.
18
- *
19
- * The bridge **must not** import `svelte` per the M7 layering
20
- * constraint.
21
- */
22
- import type { SectionEngineOutput } from "../core/engine-output.js";
23
- export type InstrumentationHook = (output: SectionEngineOutput) => void;
24
- export interface InstrumentationBridgeOptions {
25
- hook?: InstrumentationHook;
26
- }
27
- export interface InstrumentationBridgeHandle {
28
- dispatch(output: SectionEngineOutput): void;
29
- setHook(hook: InstrumentationHook | undefined): void;
30
- }
31
- export declare function createInstrumentationBridge(options?: InstrumentationBridgeOptions): InstrumentationBridgeHandle;
@@ -1,38 +0,0 @@
1
- /**
2
- * Instrumentation bridge for the section runtime engine adapter (M7 —
3
- * Variant C, layered).
4
- *
5
- * Forwards every `SectionEngineOutput` to an optional observability
6
- * hook the host injects (telemetry, debug logger, e2e probe). The
7
- * bridge is intentionally thin: it does not buffer, transform, or
8
- * filter. Hosts that need a different shape can run their own subscriber
9
- * via the adapter's public `subscribe(...)` channel.
10
- *
11
- * **Why a dedicated bridge instead of a generic subscriber.** The
12
- * subscriber-fanout channel is host-shaped — listeners receive batched
13
- * arrays of outputs per `core.dispatch` call so they can reason about
14
- * "what happened in this transition." The instrumentation hook is
15
- * per-output: telemetry pipelines want one record per stage change,
16
- * one record per readiness flip, etc. Splitting the channels keeps
17
- * both shapes ergonomic.
18
- *
19
- * The bridge **must not** import `svelte` per the M7 layering
20
- * constraint.
21
- */
22
- export function createInstrumentationBridge(options = {}) {
23
- let hook = options.hook;
24
- function dispatch(output) {
25
- if (!hook)
26
- return;
27
- try {
28
- hook(output);
29
- }
30
- catch (error) {
31
- console.warn("[InstrumentationBridge] hook failed:", error);
32
- }
33
- }
34
- function setHook(next) {
35
- hook = next;
36
- }
37
- return { dispatch, setHook };
38
- }
@@ -1,18 +0,0 @@
1
- /**
2
- * Stage derivation for the section runtime engine (M7).
3
- *
4
- * Maps the FSM phase onto the canonical M6 stage vocabulary
5
- * (`composed`, `engine-ready`, `interactive`, `disposed`). The phase
6
- * `idle` is the engine's "no cohort yet" state and has no stage; it
7
- * returns `null`.
8
- *
9
- * This module exists as a one-line indirection because:
10
- * - The adapter uses it to guard `pie-stage-change` emit calls.
11
- * - The transition uses it (via the pure helper below) to decide
12
- * when to emit `stage-change` outputs as the phase advances.
13
- * - Future shape-specific stages (e.g. layout-only `paginated`) can
14
- * be wired in here without rewriting callers.
15
- */
16
- import type { Stage } from "@pie-players/pie-players-shared/pie";
17
- import type { SectionEnginePhase } from "./engine-state.js";
18
- export declare function phaseToStage(phase: SectionEnginePhase): Stage | null;
@@ -1,29 +0,0 @@
1
- /**
2
- * Stage derivation for the section runtime engine (M7).
3
- *
4
- * Maps the FSM phase onto the canonical M6 stage vocabulary
5
- * (`composed`, `engine-ready`, `interactive`, `disposed`). The phase
6
- * `idle` is the engine's "no cohort yet" state and has no stage; it
7
- * returns `null`.
8
- *
9
- * This module exists as a one-line indirection because:
10
- * - The adapter uses it to guard `pie-stage-change` emit calls.
11
- * - The transition uses it (via the pure helper below) to decide
12
- * when to emit `stage-change` outputs as the phase advances.
13
- * - Future shape-specific stages (e.g. layout-only `paginated`) can
14
- * be wired in here without rewriting callers.
15
- */
16
- export function phaseToStage(phase) {
17
- switch (phase) {
18
- case "idle":
19
- return null;
20
- case "booting-section":
21
- return "composed";
22
- case "engine-ready":
23
- return "engine-ready";
24
- case "interactive":
25
- return "interactive";
26
- case "disposed":
27
- return "disposed";
28
- }
29
- }
@@ -1,39 +0,0 @@
1
- /**
2
- * Svelte context key for the section runtime engine (M7 PR 5).
3
- *
4
- * Components inside a section player layout consume the engine through
5
- * Svelte's native `getContext(SECTION_RUNTIME_ENGINE_KEY)`. The kernel
6
- * (`SectionPlayerLayoutKernel.svelte`) is the canonical provider — it
7
- * constructs the engine, attaches it to the layout CE host, and exposes
8
- * it to descendants via `setContext(SECTION_RUNTIME_ENGINE_KEY, engine)`.
9
- *
10
- * The contract is one-directional:
11
- * - Provider: the component that owns engine lifetime (kernel today;
12
- * in M7 PR 6 the toolkit CE will fall back to constructing its own
13
- * engine when no upstream provider is present).
14
- * - Consumers: any descendant Svelte component that needs to read
15
- * state, subscribe to outputs, or feed inputs (e.g. the toolkit CE
16
- * reaching the engine through the wrapping kernel).
17
- *
18
- * The key is a `Symbol` so it cannot collide with userland context keys
19
- * and so descendants are forced to import this module rather than
20
- * guess a string id.
21
- *
22
- * **Stability.** This export is part of the stable runtime/engine
23
- * surface; renaming or replacing the symbol is a major breaking
24
- * change. Adding adjacent context keys (e.g. for dedicated read-only
25
- * snapshots) is allowed.
26
- */
27
- import type { SectionRuntimeEngine } from "./SectionRuntimeEngine.js";
28
- /**
29
- * Svelte context key under which a `SectionRuntimeEngine` instance is
30
- * provided to descendants.
31
- */
32
- export declare const SECTION_RUNTIME_ENGINE_KEY: unique symbol;
33
- /**
34
- * Type-level alias for the value stored under
35
- * `SECTION_RUNTIME_ENGINE_KEY`. Exposed as a separate alias so
36
- * consumers can spell the type without importing the implementing
37
- * class directly.
38
- */
39
- export type SectionRuntimeEngineContext = SectionRuntimeEngine;
@@ -1,31 +0,0 @@
1
- /**
2
- * Svelte context key for the section runtime engine (M7 PR 5).
3
- *
4
- * Components inside a section player layout consume the engine through
5
- * Svelte's native `getContext(SECTION_RUNTIME_ENGINE_KEY)`. The kernel
6
- * (`SectionPlayerLayoutKernel.svelte`) is the canonical provider — it
7
- * constructs the engine, attaches it to the layout CE host, and exposes
8
- * it to descendants via `setContext(SECTION_RUNTIME_ENGINE_KEY, engine)`.
9
- *
10
- * The contract is one-directional:
11
- * - Provider: the component that owns engine lifetime (kernel today;
12
- * in M7 PR 6 the toolkit CE will fall back to constructing its own
13
- * engine when no upstream provider is present).
14
- * - Consumers: any descendant Svelte component that needs to read
15
- * state, subscribe to outputs, or feed inputs (e.g. the toolkit CE
16
- * reaching the engine through the wrapping kernel).
17
- *
18
- * The key is a `Symbol` so it cannot collide with userland context keys
19
- * and so descendants are forced to import this module rather than
20
- * guess a string id.
21
- *
22
- * **Stability.** This export is part of the stable runtime/engine
23
- * surface; renaming or replacing the symbol is a major breaking
24
- * change. Adding adjacent context keys (e.g. for dedicated read-only
25
- * snapshots) is allowed.
26
- */
27
- /**
28
- * Svelte context key under which a `SectionRuntimeEngine` instance is
29
- * provided to descendants.
30
- */
31
- export const SECTION_RUNTIME_ENGINE_KEY = Symbol("@pie-players/section-runtime-engine");