@sublang/playbook 15.0.0 → 16.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. package/README.md +1 -1
  2. package/docs/embedding.md +9 -7
  3. package/package.json +3 -1
  4. package/reference/sdlc/branch.playbook/branch.fsm.d.ts +63 -33
  5. package/reference/sdlc/branch.playbook/branch.fsm.js +190 -108
  6. package/reference/sdlc/branch.playbook/branch.fsm.ts +269 -147
  7. package/reference/sdlc/branch.playbook/branch.gears.md +7 -17
  8. package/reference/sdlc/branch.playbook/branch.playbook.d.ts +12 -16
  9. package/reference/sdlc/branch.playbook/branch.playbook.js +112 -101
  10. package/reference/sdlc/branch.playbook/branch.playbook.ts +128 -171
  11. package/reference/sdlc/branch.playbook/branch.registry.d.ts +3 -2
  12. package/reference/sdlc/branch.playbook/branch.registry.ts +6 -2
  13. package/reference/sdlc/code.playbook/bin/repository-effects.js +54 -13
  14. package/reference/sdlc/code.playbook/code.fsm.d.ts +143 -90
  15. package/reference/sdlc/code.playbook/code.fsm.introspect.d.ts +8 -8
  16. package/reference/sdlc/code.playbook/code.fsm.introspect.ts +13 -13
  17. package/reference/sdlc/code.playbook/code.fsm.js +609 -649
  18. package/reference/sdlc/code.playbook/code.fsm.ts +890 -821
  19. package/reference/sdlc/code.playbook/code.gears.md +39 -29
  20. package/reference/sdlc/code.playbook/code.playbook.d.ts +13 -16
  21. package/reference/sdlc/code.playbook/code.playbook.js +166 -147
  22. package/reference/sdlc/code.playbook/code.playbook.ts +180 -229
  23. package/reference/sdlc/code.playbook/code.registry.d.ts +3 -2
  24. package/reference/sdlc/code.playbook/code.registry.ts +6 -2
  25. package/reference/sdlc/code.playbook/playbook-captain.d.ts +42 -0
  26. package/reference/sdlc/code.playbook/playbook-captain.js +829 -194
  27. package/reference/sdlc/code.playbook/playbook-captain.ts +1227 -220
  28. package/reference/sdlc/decide.md +1 -0
  29. package/reference/sdlc/decide.playbook/decide.fsm.d.ts +270 -154
  30. package/reference/sdlc/decide.playbook/decide.fsm.js +765 -732
  31. package/reference/sdlc/decide.playbook/decide.fsm.ts +1167 -945
  32. package/reference/sdlc/decide.playbook/decide.gears.md +28 -21
  33. package/reference/sdlc/decide.playbook/decide.playbook.d.ts +11 -67
  34. package/reference/sdlc/decide.playbook/decide.playbook.js +155 -3570
  35. package/reference/sdlc/decide.playbook/decide.playbook.ts +186 -5061
  36. package/reference/sdlc/decide.playbook/decide.registry.d.ts +8 -4
  37. package/reference/sdlc/decide.playbook/decide.registry.js +2 -2
  38. package/reference/sdlc/decide.playbook/decide.registry.ts +13 -6
  39. package/reference/sdlc/dev.playbook/dev.fsm.d.ts +113 -131
  40. package/reference/sdlc/dev.playbook/dev.fsm.js +517 -575
  41. package/reference/sdlc/dev.playbook/dev.fsm.ts +667 -787
  42. package/reference/sdlc/dev.playbook/dev.gears.md +52 -54
  43. package/reference/sdlc/dev.playbook/dev.playbook.d.ts +13 -10
  44. package/reference/sdlc/dev.playbook/dev.playbook.js +128 -120
  45. package/reference/sdlc/dev.playbook/dev.playbook.ts +143 -193
  46. package/reference/sdlc/dev.playbook/dev.registry.d.ts +3 -2
  47. package/reference/sdlc/dev.playbook/dev.registry.ts +6 -2
  48. package/reference/sdlc/pr.playbook/pr.fsm.d.ts +92 -85
  49. package/reference/sdlc/pr.playbook/pr.fsm.js +461 -518
  50. package/reference/sdlc/pr.playbook/pr.fsm.ts +533 -663
  51. package/reference/sdlc/pr.playbook/pr.gears.md +47 -63
  52. package/reference/sdlc/pr.playbook/pr.playbook.d.ts +13 -23
  53. package/reference/sdlc/pr.playbook/pr.playbook.js +118 -112
  54. package/reference/sdlc/pr.playbook/pr.playbook.ts +136 -190
  55. package/reference/sdlc/pr.playbook/pr.registry.d.ts +3 -2
  56. package/reference/sdlc/pr.playbook/pr.registry.ts +4 -2
  57. package/reference/sdlc/review.md +3 -3
  58. package/reference/sdlc/review.playbook/review.fsm.d.ts +150 -116
  59. package/reference/sdlc/review.playbook/review.fsm.js +479 -550
  60. package/reference/sdlc/review.playbook/review.fsm.ts +717 -662
  61. package/reference/sdlc/review.playbook/review.gears.md +32 -29
  62. package/reference/sdlc/review.playbook/review.playbook.d.ts +12 -12
  63. package/reference/sdlc/review.playbook/review.playbook.js +180 -155
  64. package/reference/sdlc/review.playbook/review.playbook.ts +190 -230
  65. package/reference/sdlc/review.playbook/review.registry.d.ts +6 -5
  66. package/reference/sdlc/review.playbook/review.registry.js +3 -3
  67. package/reference/sdlc/review.playbook/review.registry.ts +9 -5
  68. package/slc/gears2fsm.md +72 -3
  69. package/slc/link.md +50 -27
  70. package/slc/materialize-link.mjs +51 -13
  71. package/slc/optimize.md +4 -1
  72. package/slc/prefix-prompts.mjs +191 -0
  73. package/slc/prefix.md +203 -0
  74. package/slc/slc.pin-inputs.json +11 -1
  75. package/slc/text2gears.md +71 -11
  76. package/src/xstate-playbook-runtime.d.ts +82 -9
  77. package/src/xstate-playbook-runtime.js +1224 -283
  78. package/src/xstate-playbook-runtime.ts +1671 -338
  79. package/src/xstate-runtime.d.ts +3 -1
  80. package/src/xstate-runtime.js +9 -2
  81. package/src/xstate-runtime.ts +12 -2
@@ -44,7 +44,9 @@ export interface SnapshotNormalizationOptions {
44
44
  pendingCall?: PlaybookPendingCall;
45
45
  }
46
46
  export declare function normalizePlaybookSnapshot(snapshot: unknown, options?: SnapshotNormalizationOptions): PlaybookState;
47
- export declare function detachPersistedMachineSnapshot(persisted: unknown): JsonValue;
47
+ export declare function detachPersistedMachineSnapshot(persisted: unknown, completion?: {
48
+ readonly lastError?: NormalizedError;
49
+ }): JsonValue;
48
50
  /** Authority for one governed delegated-player output field (DR-040 §1). */
49
51
  export type PlaybookSemanticFieldAuthority = 'presentation' | 'semantic' | 'effect' | 'runtime';
50
52
  /** One already-validated state-local governed outcome declaration. */
@@ -607,8 +607,15 @@ export function normalizePlaybookSnapshot(snapshot, options = {}) {
607
607
  // DR-014 §1: deep-detach an XState persisted actor snapshot into strict
608
608
  // JSON for a PlaybookRuntimeSnapshot, normalizing any raw Error value
609
609
  // (for example FSM context `lastError`) instead of rejecting it.
610
- export function detachPersistedMachineSnapshot(persisted) {
611
- return snapshotJsonValue(withErrorsNormalized(persisted, new Set()), 'persisted machine snapshot');
610
+ // DR-063 §2: a runtime parked in its failure state supplies the `lastError`
611
+ // it publishes live — completed with the cause it decided — and that record
612
+ // replaces the context's own, which a thrown value may have refused to carry.
613
+ export function detachPersistedMachineSnapshot(persisted, completion = {}) {
614
+ const detached = withErrorsNormalized(persisted, new Set());
615
+ const lastError = completion.lastError;
616
+ return snapshotJsonValue(lastError !== undefined && isRecord(detached) && isRecord(detached.context)
617
+ ? { ...detached, context: { ...detached.context, lastError } }
618
+ : detached, 'persisted machine snapshot');
612
619
  }
613
620
  function withErrorsNormalized(value, ancestors) {
614
621
  if (value instanceof Error)
@@ -902,9 +902,19 @@ export function normalizePlaybookSnapshot(
902
902
  // DR-014 §1: deep-detach an XState persisted actor snapshot into strict
903
903
  // JSON for a PlaybookRuntimeSnapshot, normalizing any raw Error value
904
904
  // (for example FSM context `lastError`) instead of rejecting it.
905
- export function detachPersistedMachineSnapshot(persisted: unknown): JsonValue {
905
+ // DR-063 §2: a runtime parked in its failure state supplies the `lastError`
906
+ // it publishes live — completed with the cause it decided — and that record
907
+ // replaces the context's own, which a thrown value may have refused to carry.
908
+ export function detachPersistedMachineSnapshot(
909
+ persisted: unknown,
910
+ completion: { readonly lastError?: NormalizedError } = {},
911
+ ): JsonValue {
912
+ const detached = withErrorsNormalized(persisted, new Set());
913
+ const lastError = completion.lastError;
906
914
  return snapshotJsonValue(
907
- withErrorsNormalized(persisted, new Set()),
915
+ lastError !== undefined && isRecord(detached) && isRecord(detached.context)
916
+ ? { ...detached, context: { ...detached.context, lastError } }
917
+ : detached,
908
918
  'persisted machine snapshot',
909
919
  );
910
920
  }