@pie-players/pie-assessment-toolkit 0.3.65 → 0.3.66

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 (43) hide show
  1. package/README.md +36 -16
  2. package/dist/components/ItemToolBar.custom-element.js +1 -1
  3. package/dist/components/PieAssessmentToolkit.custom-element.js +9 -8
  4. package/dist/components/SectionToolBar.custom-element.js +1 -1
  5. package/dist/components/chunks/{ItemToolBar-cckwpz6c.js → ItemToolBar-8jgdz50p.js} +9 -9
  6. package/dist/components/chunks/ItemToolBar-cvs646j3.js +36 -0
  7. package/dist/index.d.ts +3 -3
  8. package/dist/index.js +1 -1
  9. package/dist/policy/core/PolicySource.d.ts +2 -2
  10. package/dist/policy/core/PolicySource.js +2 -2
  11. package/dist/policy/core/ToolPolicyEngine.d.ts +7 -3
  12. package/dist/policy/core/ToolPolicyEngine.js +11 -3
  13. package/dist/policy/core/compose-decision.d.ts +3 -2
  14. package/dist/policy/core/compose-decision.js +3 -2
  15. package/dist/policy/core/decision-types.d.ts +2 -2
  16. package/dist/policy/core/decision-types.js +2 -2
  17. package/dist/policy/core/feature-decision.d.ts +28 -1
  18. package/dist/policy/core/feature-decision.js +25 -3
  19. package/dist/policy/core/pnp-policy-inputs.d.ts +2 -2
  20. package/dist/policy/core/pnp-policy-inputs.js +2 -2
  21. package/dist/policy/core/provenance.d.ts +4 -1
  22. package/dist/policy/core/provenance.js +4 -1
  23. package/dist/policy/sources/PnpPolicySource.d.ts +2 -1
  24. package/dist/policy/sources/PnpPolicySource.js +2 -1
  25. package/dist/runtime/core/engine-transition.js +3 -1
  26. package/dist/services/AccessibilityCatalogResolver.d.ts +49 -10
  27. package/dist/services/AccessibilityCatalogResolver.js +180 -11
  28. package/dist/services/TTSService.d.ts +11 -0
  29. package/dist/services/TTSService.js +220 -32
  30. package/dist/services/ToolRegistry.d.ts +55 -14
  31. package/dist/services/ToolRegistry.js +57 -3
  32. package/dist/services/ToolkitCoordinator.d.ts +18 -1
  33. package/dist/services/ToolkitCoordinator.js +24 -2
  34. package/dist/services/catalog-owner.d.ts +71 -0
  35. package/dist/services/catalog-owner.js +64 -0
  36. package/dist/services/framework-error.d.ts +1 -1
  37. package/dist/services/interfaces.d.ts +15 -3
  38. package/dist/services/tts/browser-provider.js +189 -23
  39. package/dist/tools/internal.d.ts +1 -0
  40. package/package.json +9 -9
  41. package/dist/components/chunks/ItemToolBar-pryf0rtz.js +0 -22
  42. package/dist/runtime/catalog-registration.d.ts +0 -67
  43. package/dist/runtime/catalog-registration.js +0 -86
package/dist/index.d.ts CHANGED
@@ -10,11 +10,11 @@ export type { AssessmentToolkitHostRuntimeContext, AssessmentToolkitRegionScopeC
10
10
  export type { TTSHighlightContext, TTSHighlightTargetResolver, TTSHighlightTargetResolverProvider, TTSHighlightTargetResolverRuntime, } from "./services/tts/highlight-target-resolver.js";
11
11
  export { assessmentToolkitHostRuntimeContext, assessmentToolkitRegionScopeContext, assessmentToolkitRuntimeContext, assessmentToolkitShellContext, } from "./context/assessment-toolkit-context.js";
12
12
  export { connectAssessmentToolkitHostRuntimeContext, connectAssessmentToolkitRegionScopeContext, connectAssessmentToolkitRuntimeContext, connectAssessmentToolkitShellContext, } from "./context/runtime-context-consumer.js";
13
- export { catalogOwnerContextFor, collectCatalogRegistrations, collectEntityCatalogRegistrations, type CatalogOwnerIdentity, type CatalogRegistration, type CatalogSourceEntity, } from "./runtime/catalog-registration.js";
13
+ export { catalogOwnerContextFor, type CatalogOwnerContext, type CatalogOwnerIdentity, type CatalogOwnerKind, type CatalogSourceEntity, } from "./services/catalog-owner.js";
14
14
  export { PIE_INTERNAL_CONTENT_LOADED_EVENT, PIE_INTERNAL_ITEM_SESSION_CHANGED_EVENT, PIE_INTERNAL_ITEM_PLAYER_ERROR_EVENT, PIE_ITEM_SESSION_CHANGED_EVENT, PIE_REGISTER_EVENT, PIE_UNREGISTER_EVENT, type InternalContentLoadedDetail, type InternalItemSessionChangedDetail, type InternalItemPlayerErrorDetail, type ItemSessionChangedDetail, type RuntimeRegistrationDetail, type RuntimeRegistrationKind, } from "./runtime/registration-events.js";
15
15
  export { connectToolRegionScopeContext, connectToolRuntimeContext, connectToolShellContext, createCrossBoundaryEvent, dispatchCrossBoundaryEvent, isContextValueDefined, } from "./runtime/tool-host-contract.js";
16
16
  export type { AccessibilityCatalogResolverApi, ElementToolStateStoreApi, HighlightCoordinatorApi, I18nServiceApi, ThemeProviderApi, ToolCoordinatorApi, ToolkitCoordinatorApi, TtsServiceApi, ToolState, } from "./services/interfaces.js";
17
- export type { CatalogCardForm, CatalogChangeEvent, CatalogChangeListener, CatalogChangeReason, CatalogLookupContext, CatalogLookupOptions, CatalogOwnerContext, CatalogOwnerKind, CatalogStatistics, CatalogType, ResolvedCatalog, } from "./services/AccessibilityCatalogResolver.js";
17
+ export type { CatalogCardForm, CatalogChangeEvent, CatalogChangeListener, CatalogChangeReason, CatalogLookupContext, CatalogLookupOptions, CatalogOwnerCard, CatalogOwnerRegistration, CatalogOwnerSnapshot, CatalogOwnerView, CatalogStatistics, CatalogType, ResolvedCatalog, } from "./services/AccessibilityCatalogResolver.js";
18
18
  export { AccessibilityCatalogResolver, catalogCardForm, isKnownCatalogType, KNOWN_CATALOG_TYPES, } from "./services/AccessibilityCatalogResolver.js";
19
19
  export { ContextVariableStore } from "./services/ContextVariableStore.js";
20
20
  export { ElementToolStateStore } from "./services/ElementToolStateStore.js";
@@ -24,7 +24,7 @@ export type { SerializedRange } from "./services/RangeSerializer.js";
24
24
  export { RangeSerializer } from "./services/RangeSerializer.js";
25
25
  export type { I18nConfig, PluralTranslation, TranslationBundle, } from "./services/I18nService.js";
26
26
  export { I18nService } from "./services/I18nService.js";
27
- export type { ResolvedToolContext, ToolbarContext, ToolContextResolver, ToolContextResolverContext, ToolContextResolverMap, ToolContextResolverResult, ToolActivation, ToolContentDependency, ToolContentDependencyContext, ToolModuleLoader, ToolSingletonScope, ToolSurfaceRenderContext, ToolSurfaceRenderResult, ToolSurfaceServices, ToolToolbarButtonDefinition, ToolToolbarRenderResult, ToolWindowShellAction, ToolWindowShellAlign, ToolWindowShellConfig, ToolWindowShellContentConfig, ToolRegistration, } from "./services/ToolRegistry.js";
27
+ export type { ResolvedToolContext, ToolbarContext, ToolContextResolver, ToolContextResolverContext, ToolContextResolverMap, ToolContextResolverResult, ToolActivation, ToolContentDependency, ToolContentDependencyContext, ToolModuleLoader, ToolRegistryChangeEvent, ToolRegistryChangeKind, ToolRegistryChangeListener, ToolSingletonScope, ToolSurfaceRenderContext, ToolSurfaceRenderResult, ToolSurfaceServices, ToolToolbarButtonDefinition, ToolToolbarRenderResult, ToolWindowShellAction, ToolWindowShellAlign, ToolWindowShellConfig, ToolWindowShellContentConfig, ToolRegistration, } from "./services/ToolRegistry.js";
28
28
  export { ToolRegistry } from "./services/ToolRegistry.js";
29
29
  export type { AssessmentToolContext, BaseToolContext, ElementToolContext, ItemToolContext, PassageToolContext, RubricToolContext, SectionToolContext, ToolContext, ToolLevel, } from "./services/tool-context.js";
30
30
  export { extractTextContent, hasChoiceInteraction, hasMathContent, hasReadableText, isAssessmentContext, isElementContext, isItemContext, isPassageContext, isRubricContext, isSectionContext, } from "./services/tool-context.js";
package/dist/index.js CHANGED
@@ -8,7 +8,7 @@
8
8
  */
9
9
  export { assessmentToolkitHostRuntimeContext, assessmentToolkitRegionScopeContext, assessmentToolkitRuntimeContext, assessmentToolkitShellContext, } from "./context/assessment-toolkit-context.js";
10
10
  export { connectAssessmentToolkitHostRuntimeContext, connectAssessmentToolkitRegionScopeContext, connectAssessmentToolkitRuntimeContext, connectAssessmentToolkitShellContext, } from "./context/runtime-context-consumer.js";
11
- export { catalogOwnerContextFor, collectCatalogRegistrations, collectEntityCatalogRegistrations, } from "./runtime/catalog-registration.js";
11
+ export { catalogOwnerContextFor, } from "./services/catalog-owner.js";
12
12
  export { PIE_INTERNAL_CONTENT_LOADED_EVENT, PIE_INTERNAL_ITEM_SESSION_CHANGED_EVENT, PIE_INTERNAL_ITEM_PLAYER_ERROR_EVENT, PIE_ITEM_SESSION_CHANGED_EVENT, PIE_REGISTER_EVENT, PIE_UNREGISTER_EVENT, } from "./runtime/registration-events.js";
13
13
  export { connectToolRegionScopeContext, connectToolRuntimeContext, connectToolShellContext, createCrossBoundaryEvent, dispatchCrossBoundaryEvent, isContextValueDefined, } from "./runtime/tool-host-contract.js";
14
14
  export { AccessibilityCatalogResolver, catalogCardForm, isKnownCatalogType, KNOWN_CATALOG_TYPES, } from "./services/AccessibilityCatalogResolver.js";
@@ -1,6 +1,6 @@
1
1
  /**
2
- * Custom `PolicySource` extension point (M8 — see
3
- * `.cursor/plans/m8-design.md` § 5).
2
+ * Custom `PolicySource` extension point. See
3
+ * `docs/tools-and-accomodations/architecture.md`.
4
4
  *
5
5
  * Custom sources run in step 6 of the composition pipeline — *after*
6
6
  * placement membership, provider veto, host policy, and PNP/profile gates.
@@ -1,6 +1,6 @@
1
1
  /**
2
- * Custom `PolicySource` extension point (M8 — see
3
- * `.cursor/plans/m8-design.md` § 5).
2
+ * Custom `PolicySource` extension point. See
3
+ * `docs/tools-and-accomodations/architecture.md`.
4
4
  *
5
5
  * Custom sources run in step 6 of the composition pipeline — *after*
6
6
  * placement membership, provider veto, host policy, and PNP/profile gates.
@@ -1,6 +1,6 @@
1
1
  /**
2
- * Tool Policy Engine — facade class (M8 — see
3
- * `.cursor/plans/m8-design.md` § 2).
2
+ * Tool Policy Engine — facade class. See
3
+ * `docs/tools-and-accomodations/architecture.md`.
4
4
  *
5
5
  * Wraps `composeDecision(...)` with engine-instance state:
6
6
  * - bound inputs (`tools`, `assessment`, `currentItemRef`, ...)
@@ -33,7 +33,7 @@ export interface ToolPolicyEngineInputs {
33
33
  * `assessment` and `currentItemRef`: `"on"` if they carry any
34
34
  * PNP/profile policy material (PNP, district policy, test
35
35
  * administration, item-level required/restricted/parameters),
36
- * `"off"` otherwise. See `.cursor/plans/m8-design.md` F2.
36
+ * `"off"` otherwise. `tests/policy/pnp-default-on.test.ts` locks the rule.
37
37
  *
38
38
  * Hosts that want to force a mode pass `"on"` or `"off"`
39
39
  * explicitly. Embedded under `<pie-section-player-*>` the preferred
@@ -107,6 +107,10 @@ export declare class ToolPolicyEngine {
107
107
  * whenever profile material exists, so this only diverges for a host that
108
108
  * explicitly forces `"off"` while supplying a profile that grants the
109
109
  * feature — and there, honouring the profile is the safer failure.
110
+ *
111
+ * The decision reports whether an assessment was bound, which is the engine's
112
+ * to answer rather than the policy source's — see
113
+ * {@link FeaturePolicyDecision.assessmentBound}.
110
114
  */
111
115
  decideFeature(featureId: string): FeaturePolicyDecision;
112
116
  /**
@@ -1,6 +1,6 @@
1
1
  /**
2
- * Tool Policy Engine — facade class (M8 — see
3
- * `.cursor/plans/m8-design.md` § 2).
2
+ * Tool Policy Engine — facade class. See
3
+ * `docs/tools-and-accomodations/architecture.md`.
4
4
  *
5
5
  * Wraps `composeDecision(...)` with engine-instance state:
6
6
  * - bound inputs (`tools`, `assessment`, `currentItemRef`, ...)
@@ -104,13 +104,21 @@ export class ToolPolicyEngine {
104
104
  * whenever profile material exists, so this only diverges for a host that
105
105
  * explicitly forces `"off"` while supplying a profile that grants the
106
106
  * feature — and there, honouring the profile is the safer failure.
107
+ *
108
+ * The decision reports whether an assessment was bound, which is the engine's
109
+ * to answer rather than the policy source's — see
110
+ * {@link FeaturePolicyDecision.assessmentBound}.
107
111
  */
108
112
  decideFeature(featureId) {
109
113
  this.assertNotDisposed();
110
114
  return interpretFeatureResult(featureId, this.pnpPolicySource.resolveFeature(featureId, {
111
115
  assessment: this.assessment ?? undefined,
112
116
  currentItemRef: this.currentItemRef ?? undefined,
113
- }));
117
+ }),
118
+ // `resolveFeature` takes the assessment as `undefined` either way, so the
119
+ // source cannot tell an unbound host from one whose profile is silent.
120
+ // The engine can.
121
+ { assessmentBound: this.assessment !== null });
114
122
  }
115
123
  /**
116
124
  * Convenience wrapper for hosts that just want the visible tool
@@ -1,5 +1,6 @@
1
1
  /**
2
- * Compose-decision pipeline (M8 — see `.cursor/plans/m8-design.md` § 3).
2
+ * Compose-decision pipeline. See
3
+ * `docs/tools-and-accomodations/architecture.md`.
3
4
  *
4
5
  * Pure function: given a decision request, the host's tools config,
5
6
  * an optional PNP policy source, and the registered custom sources, returns
@@ -7,7 +8,7 @@
7
8
  * mutable state, and never reaches into Svelte / DOM — that is the
8
9
  * `ToolPolicyEngine` class's job.
9
10
  *
10
- * The six steps below mirror the design doc exactly. The tests in
11
+ * The tests in
11
12
  * `tests/policy/compose-decision.test.ts` lock the orchestration in.
12
13
  */
13
14
  import type { AssessmentEntity, AssessmentItemRef } from "@pie-players/pie-players-shared/types";
@@ -1,5 +1,6 @@
1
1
  /**
2
- * Compose-decision pipeline (M8 — see `.cursor/plans/m8-design.md` § 3).
2
+ * Compose-decision pipeline. See
3
+ * `docs/tools-and-accomodations/architecture.md`.
3
4
  *
4
5
  * Pure function: given a decision request, the host's tools config,
5
6
  * an optional PNP policy source, and the registered custom sources, returns
@@ -7,7 +8,7 @@
7
8
  * mutable state, and never reaches into Svelte / DOM — that is the
8
9
  * `ToolPolicyEngine` class's job.
9
10
  *
10
- * The six steps below mirror the design doc exactly. The tests in
11
+ * The tests in
11
12
  * `tests/policy/compose-decision.test.ts` lock the orchestration in.
12
13
  */
13
14
  import { normalizeToolList, } from "../../services/tools-config-normalizer.js";
@@ -6,8 +6,8 @@
6
6
  * composition pipeline that produces the response, lives in sibling
7
7
  * modules.
8
8
  *
9
- * See `.cursor/plans/m8-design.md` § 2 for the engine shape, § 3 for
10
- * the composition rule, and § 4 for the provenance contract.
9
+ * `docs/tools-and-accomodations/architecture.md` covers the engine shape,
10
+ * the composition rule, and the provenance contract.
11
11
  */
12
12
  import type { ToolPlacementLevel } from "../../services/tools-config-normalizer.js";
13
13
  import type { ToolContext, ToolLevel } from "../../services/tool-context.js";
@@ -6,7 +6,7 @@
6
6
  * composition pipeline that produces the response, lives in sibling
7
7
  * modules.
8
8
  *
9
- * See `.cursor/plans/m8-design.md` § 2 for the engine shape, § 3 for
10
- * the composition rule, and § 4 for the provenance contract.
9
+ * `docs/tools-and-accomodations/architecture.md` covers the engine shape,
10
+ * the composition rule, and the provenance contract.
11
11
  */
12
12
  export {};
@@ -15,6 +15,10 @@
15
15
  * feature id?* Whether the capability has anything to show is a separate,
16
16
  * independent check owned by its renderer — for signing, whether a matching
17
17
  * catalog card exists. Both are required; neither implies the other.
18
+ *
19
+ * A denial carries `assessmentBound`, because "nobody asked for this" and
20
+ * "nothing was bound to ask against" are the same verdict for different
21
+ * reasons, and only the second is a defect.
18
22
  */
19
23
  import type { PnpPolicyResult } from "../sources/PnpPolicySource.js";
20
24
  import type { PnpPolicySourceRule } from "./policy-source-tag.js";
@@ -35,6 +39,24 @@ export interface FeaturePolicyDecision {
35
39
  sourceType: ToolPolicySourceType;
36
40
  /** Human-readable explanation, suitable for a policy debugger. */
37
41
  reason: string;
42
+ /**
43
+ * Whether an assessment was bound when this was decided.
44
+ *
45
+ * `false` makes a *denial* a wiring gap rather than a verdict: no profile,
46
+ * district policy or test administration could be consulted, because there was
47
+ * no assessment to read them from. It is not itself a denial — an item ref
48
+ * carrying `requiredTools` mandates a feature at precedence 4 with no
49
+ * assessment bound — so read it alongside `granted` rather than instead of it.
50
+ *
51
+ * Granting is unaffected either way: an unbound host with no item mandate still
52
+ * gets `granted: false`, since an accommodation requires a documented need and
53
+ * an absent profile documents nothing.
54
+ *
55
+ * A bound assessment carrying no profile material is deliberately `true`: a
56
+ * test that grants nobody an accommodation is a legitimate configuration,
57
+ * while never binding one cannot be.
58
+ */
59
+ assessmentBound: boolean;
38
60
  /**
39
61
  * `true` when the grant is a mandate (item or district `requiredTools`)
40
62
  * rather than a student-profile support.
@@ -47,6 +69,11 @@ export interface FeaturePolicyDecision {
47
69
  */
48
70
  parameters?: unknown;
49
71
  }
72
+ /** What the engine knows that a single support-id resolution does not. */
73
+ export interface FeatureDecisionContext {
74
+ /** Whether the engine has an assessment bound. */
75
+ assessmentBound: boolean;
76
+ }
50
77
  /**
51
78
  * Interpret a single-feature `PnpPolicySource.resolveFeature(...)` result.
52
79
  *
@@ -54,4 +81,4 @@ export interface FeaturePolicyDecision {
54
81
  * exactly one decision and at most one flags entry — no mapped-tool-id
55
82
  * bookkeeping is needed to read it back out.
56
83
  */
57
- export declare function interpretFeatureResult(featureId: string, result: PnpPolicyResult): FeaturePolicyDecision;
84
+ export declare function interpretFeatureResult(featureId: string, result: PnpPolicyResult, context: FeatureDecisionContext): FeaturePolicyDecision;
@@ -15,7 +15,20 @@
15
15
  * feature id?* Whether the capability has anything to show is a separate,
16
16
  * independent check owned by its renderer — for signing, whether a matching
17
17
  * catalog card exists. Both are required; neither implies the other.
18
+ *
19
+ * A denial carries `assessmentBound`, because "nobody asked for this" and
20
+ * "nothing was bound to ask against" are the same verdict for different
21
+ * reasons, and only the second is a defect.
22
+ */
23
+ /**
24
+ * Reason text for a denial that had no assessment to decide against.
25
+ *
26
+ * Replaces the `pnp-support` skip's "not configured at any level", which is
27
+ * true but reads as a completed evaluation. `rule` and `precedence` stay as the
28
+ * source reported them: nothing fired, so naming a seventh rule would describe
29
+ * a precedence level that does not exist.
18
30
  */
31
+ const unboundAssessmentReason = (featureId) => `No assessment is bound, so no policy source could grant "${featureId}"`;
19
32
  /**
20
33
  * Interpret a single-feature `PnpPolicySource.resolveFeature(...)` result.
21
34
  *
@@ -23,18 +36,27 @@
23
36
  * exactly one decision and at most one flags entry — no mapped-tool-id
24
37
  * bookkeeping is needed to read it back out.
25
38
  */
26
- export function interpretFeatureResult(featureId, result) {
39
+ export function interpretFeatureResult(featureId, result, context) {
27
40
  const decision = result.decisions[0];
28
41
  const flags = Array.from(result.perToolFlags.values())[0];
42
+ const granted = decision?.action === "enable";
43
+ const reason = decision?.reason ?? `Feature "${featureId}" not configured`;
29
44
  return {
30
45
  featureId,
31
- granted: decision?.action === "enable",
46
+ granted,
32
47
  action: decision?.action ?? "skip",
33
48
  rule: decision?.rule ?? "pnp-support",
34
49
  precedence: decision?.precedence ?? 6,
35
50
  sourceType: decision?.sourceType ?? "system",
36
- reason: decision?.reason ?? `Feature "${featureId}" not configured`,
51
+ // Only a denial is re-worded. An unbound host can still be granted the
52
+ // feature — an item ref carrying `requiredTools` mandates it at precedence 4
53
+ // with no assessment in sight — and there the source's reason is the true
54
+ // one.
55
+ reason: context.assessmentBound || granted
56
+ ? reason
57
+ : unboundAssessmentReason(featureId),
37
58
  required: Boolean(flags?.required),
38
59
  parameters: flags?.settings,
60
+ assessmentBound: context.assessmentBound,
39
61
  };
40
62
  }
@@ -1,6 +1,6 @@
1
1
  /**
2
- * PNP/profile policy input detection (M8 PR 4 — see `.cursor/plans/m8-design.md` F2 and
3
- * `.cursor/plans/m8-implementation-plan.md` § PR 4).
2
+ * PNP/profile policy input detection. See
3
+ * `docs/tools-and-accomodations/architecture.md`.
4
4
  *
5
5
  * Pure helpers that decide whether the inputs the engine has been given
6
6
  * actually carry PNP/profile policy material. Used by:
@@ -1,6 +1,6 @@
1
1
  /**
2
- * PNP/profile policy input detection (M8 PR 4 — see `.cursor/plans/m8-design.md` F2 and
3
- * `.cursor/plans/m8-implementation-plan.md` § PR 4).
2
+ * PNP/profile policy input detection. See
3
+ * `docs/tools-and-accomodations/architecture.md`.
4
4
  *
5
5
  * Pure helpers that decide whether the inputs the engine has been given
6
6
  * actually carry PNP/profile policy material. Used by:
@@ -1,5 +1,8 @@
1
1
  /**
2
- * Tool Policy Provenance (M8 — see `.cursor/plans/m8-design.md` § 4).
2
+ * Tool Policy Provenance.
3
+ *
4
+ * Precedence and the rule vocabulary are documented in
5
+ * `docs/tools-and-accomodations/architecture.md`.
3
6
  *
4
7
  * Tracks decisions from every Pass-1 contributor: host placement, host policy,
5
8
  * provider veto, PNP/profile gates, and custom policy sources.
@@ -1,5 +1,8 @@
1
1
  /**
2
- * Tool Policy Provenance (M8 — see `.cursor/plans/m8-design.md` § 4).
2
+ * Tool Policy Provenance.
3
+ *
4
+ * Precedence and the rule vocabulary are documented in
5
+ * `docs/tools-and-accomodations/architecture.md`.
3
6
  *
4
7
  * Tracks decisions from every Pass-1 contributor: host placement, host policy,
5
8
  * provider veto, PNP/profile gates, and custom policy sources.
@@ -1,6 +1,7 @@
1
1
  /**
2
2
  * PNP Policy Source for the M8 engine
3
- * (see `.cursor/plans/m8-design.md` § 3 step 5 and § 5).
3
+ * (see
4
+ * `docs/tools-and-accomodations/architecture.md`).
4
5
  *
5
6
  * This source applies the PNP/profile precedence rules as a `(candidates, pnpPolicyInputs) →
6
7
  * (refinedCandidates, perToolFlags, mandates, decisions)` function the
@@ -1,6 +1,7 @@
1
1
  /**
2
2
  * PNP Policy Source for the M8 engine
3
- * (see `.cursor/plans/m8-design.md` § 3 step 5 and § 5).
3
+ * (see
4
+ * `docs/tools-and-accomodations/architecture.md`).
4
5
  *
5
6
  * This source applies the PNP/profile precedence rules as a `(candidates, pnpPolicyInputs) →
6
7
  * (refinedCandidates, perToolFlags, mandates, decisions)` function the
@@ -227,7 +227,9 @@ export function transition(state, input) {
227
227
  lastFrameworkError: input.error,
228
228
  readinessSignals: {
229
229
  ...state.readinessSignals,
230
- runtimeError: true,
230
+ runtimeError: input.error.recoverable === true
231
+ ? state.readinessSignals.runtimeError
232
+ : true,
231
233
  },
232
234
  },
233
235
  outputs: [{ kind: "framework-error", error: input.error }],
@@ -1,15 +1,38 @@
1
1
  import type { AccessibilityCatalog, CatalogCard, CatalogCardPayload } from "@pie-players/pie-players-shared/types";
2
- export type CatalogOwnerKind = "global" | "passage" | "itemModel";
3
- export interface CatalogOwnerContext {
4
- ownerKind: CatalogOwnerKind;
5
- assessmentId?: string;
6
- sectionId?: string;
7
- canonicalItemId?: string;
8
- itemId?: string;
9
- passageId?: string;
10
- modelId?: string;
11
- }
2
+ import { type CatalogOwnerContext, type CatalogOwnerIdentity, type CatalogSourceEntity } from "./catalog-owner.js";
12
3
  export type CatalogLookupContext = CatalogOwnerContext;
4
+ /** One card visible from a mounted content owner's catalog scope. */
5
+ export interface CatalogOwnerCard {
6
+ /** Author-owned identifier; never normalized or prefixed. */
7
+ readonly catalogId: string;
8
+ /** Read-only authored card, including capability-specific metadata. */
9
+ readonly card: Readonly<CatalogCard>;
10
+ }
11
+ /**
12
+ * Immutable point-in-time view of the cards owned by an item or passage.
13
+ *
14
+ * Ordering is deterministic and matches registration precedence: entity-root,
15
+ * extractor-generated, then model-owned catalogs in model order. Capabilities
16
+ * interpret card meaning; the generic resolver owns only scope and traversal.
17
+ */
18
+ export interface CatalogOwnerSnapshot {
19
+ readonly cards: readonly CatalogOwnerCard[];
20
+ }
21
+ /**
22
+ * Owner-bound catalog interface used by content capabilities and their host.
23
+ *
24
+ * The owner context is captured once. Callers no longer coordinate a raw entity,
25
+ * a resolver and a separately assembled lookup context.
26
+ */
27
+ export interface CatalogOwnerView {
28
+ snapshot(): CatalogOwnerSnapshot;
29
+ onChange(listener: () => void): () => void;
30
+ }
31
+ /** Everything needed to register one mounted catalog owner. */
32
+ export interface CatalogOwnerRegistration {
33
+ owner: CatalogOwnerIdentity;
34
+ entity: CatalogSourceEntity | null | undefined;
35
+ }
13
36
  /** What changed in the resolver's catalog set. */
14
37
  export type CatalogChangeReason = "scoped-registered" | "scoped-removed" | "item-added" | "item-cleared";
15
38
  /**
@@ -155,6 +178,7 @@ export declare class AccessibilityCatalogResolver {
155
178
  private defaultLanguage;
156
179
  private sanitizedSpokenCache;
157
180
  private catalogChangeListeners;
181
+ private reportedSnapshotProblems;
158
182
  constructor(assessmentCatalogs?: AccessibilityCatalog[], defaultLanguage?: string);
159
183
  /**
160
184
  * Set the default language for fallback resolution
@@ -191,7 +215,19 @@ export declare class AccessibilityCatalogResolver {
191
215
  * Index catalogs into the appropriate map
192
216
  */
193
217
  private indexCatalogs;
218
+ private insertScopedCatalogs;
219
+ private removeScopedInsertion;
194
220
  registerCatalogs(context: CatalogOwnerContext, catalogs?: AccessibilityCatalog[]): () => void;
221
+ /**
222
+ * Register every catalog carried by one mounted item or passage as one
223
+ * owner-level transaction.
224
+ *
225
+ * The resolver owns the entity walk and emits one post-mutation signal, so a
226
+ * reader never observes only the root or only the model half of an owner.
227
+ */
228
+ registerOwner(registration: CatalogOwnerRegistration): () => void;
229
+ /** Bind catalog reads and change observation to one content owner. */
230
+ forOwner(context: CatalogOwnerContext): CatalogOwnerView;
195
231
  /**
196
232
  * Add item-level catalogs (called when rendering a new item)
197
233
  */
@@ -216,6 +252,9 @@ export declare class AccessibilityCatalogResolver {
216
252
  private scopedCatalogEntries;
217
253
  private findScopedCandidates;
218
254
  private isCompatibleOwnerContext;
255
+ private ownerScopedCatalogEntries;
256
+ private createOwnerSnapshot;
257
+ private catalogChangeAffectsOwner;
219
258
  private sanitizeCatalogs;
220
259
  /**
221
260
  * Find a matching catalog card based on lookup options