ctxtop 4.0.0 → 4.1.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 (89) hide show
  1. package/.antigravity-plugin/plugin.json +1 -1
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/CHECKSUMS.sha256 +59 -42
  4. package/README.md +351 -330
  5. package/bin/ah-statusline.mjs +30 -0
  6. package/bin/ctxtop.mjs +330 -5
  7. package/config/default_flightcheck.json +19 -0
  8. package/config/modelCatalog.json +165 -0
  9. package/hooks/handlers/compact-lifecycle.mjs +323 -8
  10. package/hooks/handlers/config-change.mjs +402 -0
  11. package/hooks/handlers/hookIo.mjs +56 -0
  12. package/hooks/handlers/post-model-switch.mjs +111 -0
  13. package/hooks/handlers/post-tool-use.mjs +117 -16
  14. package/hooks/handlers/pre-model-switch.mjs +823 -24
  15. package/hooks/handlers/pre-tool-use.mjs +271 -4
  16. package/hooks/handlers/stop-gate.mjs +297 -11
  17. package/hooks/handlers/user-prompt-submit.mjs +224 -0
  18. package/hooks/hooks.json +50 -0
  19. package/hooks/post_tool_use.mjs +8 -0
  20. package/hooks/register.js +48 -9
  21. package/hooks/session_start.mjs +11 -1
  22. package/hooks/stop.mjs +11 -1
  23. package/package.json +11 -4
  24. package/packages/antigravity/package.json +1 -1
  25. package/packages/claude-code/package.json +1 -1
  26. package/packages/core/package.json +1 -1
  27. package/packages/engine-node/package.json +1 -1
  28. package/packages/mcp/package.json +1 -1
  29. package/packages/mcp/src/server.mjs +1 -1
  30. package/packages/pro/package.json +1 -1
  31. package/plugin.json +1 -1
  32. package/sidecars/horizon-daemon/server.mjs +38 -2
  33. package/skills/handoff/SKILL.md +8 -0
  34. package/src/adapters/antigravity/index.mjs +31 -1
  35. package/src/adapters/claude-code/index.mjs +40 -1
  36. package/src/cli/horizon_hud.mjs +254 -52
  37. package/src/config/modelCatalog.json +84 -0
  38. package/src/core/bucket_b_runtime.mjs +1200 -0
  39. package/src/core/constants.mjs +191 -4
  40. package/src/core/detectors_det01_to_16.mjs +54 -5
  41. package/src/core/doc_indexer.mjs +338 -0
  42. package/src/core/layer5_hygiene.mjs +118 -0
  43. package/src/core/parser.mjs +2 -1
  44. package/src/core/paths.mjs +3 -2
  45. package/src/core/rsl_clash_auditor.mjs +423 -0
  46. package/src/core/rsl_distiller.mjs +372 -0
  47. package/src/core/rsl_ledger.mjs +969 -0
  48. package/src/core/rsl_triage.mjs +909 -0
  49. package/src/core/session_auditor.mjs +658 -0
  50. package/src/core/shield_manager.mjs +1417 -0
  51. package/src/core/task_quota_router.mjs +1 -1
  52. package/src/core-isomorphic/coach/cacheGravityRouter.mjs +874 -47
  53. package/src/core-isomorphic/coach/resumeToolsetAuditor.mjs +321 -0
  54. package/src/core-isomorphic/coach/smartCompactAdvisor.mjs +305 -0
  55. package/src/core-isomorphic/coach/ttlWatchdog.mjs +13 -6
  56. package/src/core-isomorphic/config/anthropicModelCatalog.json +404 -1
  57. package/src/core-isomorphic/config/catalogLoader.mjs +546 -46
  58. package/src/core-isomorphic/config/horizonConfig.mjs +47 -1
  59. package/src/core-isomorphic/diagnostics/prompt_hygiene_governor.mjs +266 -0
  60. package/src/core-isomorphic/economics/cacheGravity.mjs +18 -0
  61. package/src/core-isomorphic/economics/cliffBreaker.mjs +98 -12
  62. package/src/core-isomorphic/economics/driftLatency.mjs +114 -0
  63. package/src/core-isomorphic/guards/bucketBAlphaBeta.mjs +860 -0
  64. package/src/core-isomorphic/guards/bucketBGamma.mjs +442 -0
  65. package/src/core-isomorphic/guards/bucketBHeuristics.mjs +37 -0
  66. package/src/core-isomorphic/guards/circuitBreakers.mjs +191 -191
  67. package/src/core-isomorphic/guards/det01_03_shell_secret.mjs +154 -5
  68. package/src/core-isomorphic/guards/det04_12_thrash_rot.mjs +103 -11
  69. package/src/core-isomorphic/guards/det13_20_mcp_scope.mjs +311 -1
  70. package/src/core-isomorphic/guards/docIndexCore.mjs +446 -0
  71. package/src/core-isomorphic/guards/losslessPostSanitizer.mjs +16 -0
  72. package/src/core-isomorphic/guards/slopsquatGate.mjs +551 -0
  73. package/src/core-isomorphic/index.js +1 -0
  74. package/src/core-isomorphic/telemetry/telemetryBridge.mjs +36 -12
  75. package/src/core-isomorphic/ui/horizonPanelHtml.mjs +293 -237
  76. package/src/core-isomorphic/ui/modViews.mjs +35 -9
  77. package/src/diagnostics/claudeHookCapabilities.mjs +396 -0
  78. package/src/diagnostics/doctorEngine.mjs +95 -3
  79. package/src/engine-node/db/probe.mjs +234 -2
  80. package/src/engine-node/index.mjs +3 -0
  81. package/src/engine-node/sensors/blindspots.mjs +13 -6
  82. package/src/hooks/antigravity_rsl_hook.mjs +250 -0
  83. package/src/hooks/claude_rsl_hook.mjs +288 -0
  84. package/src/hooks/post_invocation.mjs +196 -4
  85. package/src/hooks/pre_invocation.mjs +732 -22
  86. package/src/hooks/session_start.mjs +39 -1
  87. package/src/utils/modelSwitchTelemetry.mjs +308 -0
  88. package/src/utils/sessionCalibration.mjs +657 -0
  89. package/src/webview/horizon_panel.html +1325 -317
@@ -4,12 +4,13 @@
4
4
  * Pure-V8 isomorphic ESM module (zero `node:*` imports).
5
5
  */
6
6
 
7
- import { path } from '../utils/runtime.mjs';
7
+ import { path, getCwd, readJsonSafe, writeJsonAtomic } from '../utils/runtime.mjs';
8
8
  import {
9
9
  FLIGHT_MODES,
10
10
  normalizeFlightMode,
11
11
  isSilentOrOffMode
12
12
  } from '../coach/cacheGravityRouter.mjs';
13
+ import { RELAY_STATES } from '../coach/promptHygieneGovernor.mjs';
13
14
  import { evaluateScopeAndQuotaBrake } from '../telemetry/scopeLockRegistry.mjs';
14
15
  import { EDIT_WRITE_TOOL_REGEX } from './det01_03_shell_secret.mjs';
15
16
 
@@ -601,3 +602,312 @@ export function evaluateDet19SubagentIpiSanitizer(params = {}) {
601
602
  export function evaluateDet20ScopeLockAndQuotaBrake(params = {}, options = {}) {
602
603
  return evaluateScopeAndQuotaBrake(params, options);
603
604
  }
605
+
606
+ /**
607
+ * Sanitizes a session ID for `.claude/cache/ah_breaker_state_<sessionId>.json`.
608
+ * @param {string} [sessionId='default']
609
+ * @returns {string}
610
+ */
611
+ export function sanitizeBreakerSessionId(sessionId = 'default') {
612
+ return String(sessionId || 'default').replace(/[^a-zA-Z0-9._-]/g, '_');
613
+ }
614
+
615
+ /**
616
+ * Resolves the atomic CLI circuit-breaker state file path (`.claude/cache/ah_breaker_state_<sessionId>.json`).
617
+ * @param {string} [sessionId='default']
618
+ * @param {object} [options={}]
619
+ * @returns {string}
620
+ */
621
+ export function getBreakerStateFilePath(sessionId = 'default', options = {}) {
622
+ if (options?.breakerStatePath) {
623
+ return options.breakerStatePath;
624
+ }
625
+ const cwd = getCwd(options);
626
+ return path.join(
627
+ cwd,
628
+ '.claude',
629
+ 'cache',
630
+ `ah_breaker_state_${sanitizeBreakerSessionId(sessionId)}.json`
631
+ );
632
+ }
633
+
634
+ /**
635
+ * Safely reads a persisted `CircuitBreakerEngine` snapshot from disk (`ISS-038`).
636
+ * @param {string} [sessionId='default']
637
+ * @param {object} [options={}]
638
+ * @returns {object | null}
639
+ */
640
+ export function readBreakerStateSnapshot(sessionId = 'default', options = {}) {
641
+ return readJsonSafe(getBreakerStateFilePath(sessionId, options), null, options);
642
+ }
643
+
644
+ /**
645
+ * Atomically writes a `CircuitBreakerEngine` snapshot to disk (`ISS-038`).
646
+ * @param {string} [sessionId='default']
647
+ * @param {object} [snapshot={}]
648
+ * @param {object} [options={}]
649
+ * @returns {boolean}
650
+ */
651
+ export function writeBreakerStateSnapshot(sessionId = 'default', snapshot = {}, options = {}) {
652
+ return writeJsonAtomic(getBreakerStateFilePath(sessionId, options), snapshot, options);
653
+ }
654
+
655
+ /**
656
+ * Exports a serializable snapshot of a `CircuitBreakerEngine` instance (`ISS-038`).
657
+ * @param {object} engine
658
+ * @returns {object}
659
+ */
660
+ export function serializeCircuitBreakerState(engine) {
661
+ const hashObj = {};
662
+ for (const [k, v] of engine.fileHashHistory.entries()) {
663
+ hashObj[k] = Array.isArray(v) ? [...v] : [];
664
+ }
665
+ return {
666
+ schemaVersion: '1.0.0',
667
+ updatedAt: Date.now(),
668
+ mode: engine.mode,
669
+ consecutiveFailures: engine.consecutiveFailures,
670
+ lastFailedToolKey: engine.lastFailedToolKey,
671
+ sequentialSearchCount: engine.sequentialSearchCount,
672
+ fileHashHistory: hashObj,
673
+ modifiedFilesInTurn: Array.from(engine.modifiedFilesInTurn),
674
+ editedFiles: Array.from(engine.modifiedFilesInTurn),
675
+ unverifiedEdits: Array.isArray(engine.unverifiedEdits) ? engine.unverifiedEdits.slice(-32) : [],
676
+ turnFileDiffs: Array.isArray(engine.turnFileDiffs) ? engine.turnFileDiffs.slice(-32) : [],
677
+ pendingBatchEdits: Array.from(engine.pendingBatchEdits),
678
+ pendingFormatFiles: Array.from(engine.pendingFormatFiles),
679
+ codeEditedSinceLastTest: Boolean(engine.codeEditedSinceLastTest),
680
+ pendingVerificationCommand: Boolean(engine.pendingVerificationCommand),
681
+ lastFailingLocation: engine.lastFailingLocation || null,
682
+ pendingDownshiftModel: engine.pendingDownshiftModel || null,
683
+ pending_downshift: engine.pending_downshift ? { ...engine.pending_downshift } : null,
684
+ justCompacted: Boolean(engine.justCompacted),
685
+ turnsSinceLastCompact:
686
+ typeof engine.turnsSinceLastCompact === 'number' && Number.isFinite(engine.turnsSinceLastCompact)
687
+ ? Math.max(0, engine.turnsSinceLastCompact)
688
+ : null,
689
+ taskBoundaryState: engine.taskBoundaryState
690
+ ? {
691
+ openFailure: Boolean(engine.taskBoundaryState.openFailure),
692
+ editsSinceBoundary: Math.max(0, Number(engine.taskBoundaryState.editsSinceBoundary || 0)),
693
+ lastBoundarySuggestedTurn: engine.taskBoundaryState.lastBoundarySuggestedTurn ?? null
694
+ }
695
+ : { openFailure: false, editsSinceBoundary: 0, lastBoundarySuggestedTurn: null },
696
+ lastToolsetHash: engine.lastToolsetHash ? { ...engine.lastToolsetHash } : null,
697
+ lastContextTokens:
698
+ typeof engine.lastContextTokens === 'number' && Number.isFinite(engine.lastContextTokens)
699
+ ? Math.max(0, engine.lastContextTokens)
700
+ : null,
701
+ lastModelId: engine.lastModelId ? String(engine.lastModelId) : null,
702
+ activeBackgroundTasks: Array.isArray(engine.activeBackgroundTasks)
703
+ ? [...engine.activeBackgroundTasks]
704
+ : [],
705
+ activeWriteWorkers: Array.isArray(engine.activeWriteWorkers)
706
+ ? [...engine.activeWriteWorkers]
707
+ : [],
708
+ lastUserPrompt: engine.lastUserPrompt || '',
709
+ lastTurnGitCommitted: Boolean(engine.lastTurnGitCommitted),
710
+ committedTopDirs: Array.isArray(engine.committedTopDirs) ? [...engine.committedTopDirs] : [],
711
+ consecutiveTrivialMaxEffortTurns: engine.consecutiveTrivialMaxEffortTurns,
712
+ recentEditTimestampsByFile: { ...engine.recentEditTimestampsByFile },
713
+ totalDiscoveryCalls: engine.totalDiscoveryCalls,
714
+ consecutiveVisionTurns: engine.consecutiveVisionTurns,
715
+ unanchoredTurnFlag: Boolean(engine.unanchoredTurnFlag),
716
+ candidateFiles: Array.isArray(engine.candidateFiles) ? [...engine.candidateFiles] : [],
717
+ relayState: engine.relayState ? { ...engine.relayState } : { state: RELAY_STATES.IDLE, critiquePastes: 0, boundSpecPath: 'SPEC.md' },
718
+ steeredPrompts: Number(engine.steeredPrompts || 0),
719
+ blockedPrompts: Number(engine.blockedPrompts || 0),
720
+ sightseeingToolsPrevented: Number(engine.sightseeingToolsPrevented || 0),
721
+ subagentTurns: { ...engine.subagentTurns },
722
+ subagentTokens: { ...engine.subagentTokens },
723
+ det11AdvisedTurn: engine.det11AdvisedTurn,
724
+ det13AdvisedTurn: engine.det13AdvisedTurn,
725
+ queuedMutations: engine.router.mutationQueue.toJSON(),
726
+ hysteresisState: engine.router.hysteresisLock.getStatus()
727
+ };
728
+ }
729
+
730
+ /**
731
+ * Hydrates stateful breaker counters and queues onto a `CircuitBreakerEngine` instance (`ISS-038`).
732
+ * @param {object} engine
733
+ * @param {object | null} snap
734
+ * @returns {object}
735
+ */
736
+ export function hydrateCircuitBreakerState(engine, snap) {
737
+ if (!snap || typeof snap !== 'object') return engine;
738
+
739
+ if (typeof snap.consecutiveFailures === 'number' && Number.isFinite(snap.consecutiveFailures)) {
740
+ engine.consecutiveFailures = Math.max(0, snap.consecutiveFailures);
741
+ }
742
+ if (snap.lastFailedToolKey !== undefined) {
743
+ engine.lastFailedToolKey = snap.lastFailedToolKey ? String(snap.lastFailedToolKey) : null;
744
+ }
745
+ if (
746
+ typeof snap.sequentialSearchCount === 'number' &&
747
+ Number.isFinite(snap.sequentialSearchCount)
748
+ ) {
749
+ engine.sequentialSearchCount = Math.max(0, snap.sequentialSearchCount);
750
+ }
751
+ if (snap.fileHashHistory && typeof snap.fileHashHistory === 'object') {
752
+ engine.fileHashHistory = new Map();
753
+ for (const [k, v] of Object.entries(snap.fileHashHistory)) {
754
+ if (Array.isArray(v)) {
755
+ engine.fileHashHistory.set(k, v.slice(-6).map(String));
756
+ }
757
+ }
758
+ }
759
+ const editedList = Array.isArray(snap.modifiedFilesInTurn)
760
+ ? snap.modifiedFilesInTurn
761
+ : Array.isArray(snap.editedFiles)
762
+ ? snap.editedFiles
763
+ : null;
764
+ if (editedList) {
765
+ engine.modifiedFilesInTurn = new Set(editedList.filter(Boolean).map(String));
766
+ }
767
+ if (Array.isArray(snap.unverifiedEdits)) {
768
+ engine.unverifiedEdits = snap.unverifiedEdits
769
+ .filter((e) => e && typeof e.filePath === 'string')
770
+ .slice(-32)
771
+ .map((e) => ({
772
+ filePath: String(e.filePath),
773
+ netLines: Math.max(0, Number(e.netLines) || 0),
774
+ ...(Array.isArray(e.changedLines) ? { changedLines: e.changedLines.slice(0, 64).map(String) } : {})
775
+ }));
776
+ }
777
+ if (Array.isArray(snap.turnFileDiffs)) {
778
+ engine.turnFileDiffs = snap.turnFileDiffs
779
+ .filter((e) => e && typeof e.filePath === 'string')
780
+ .slice(-32)
781
+ .map((e) => ({
782
+ filePath: String(e.filePath),
783
+ addedLines: Array.isArray(e.addedLines) ? e.addedLines.slice(0, 400).map(String) : [],
784
+ deletedLineCount: Math.max(0, Number(e.deletedLineCount) || 0)
785
+ }));
786
+ }
787
+ if (Array.isArray(snap.pendingBatchEdits)) {
788
+ engine.pendingBatchEdits = new Set(snap.pendingBatchEdits.filter(Boolean).map(String));
789
+ }
790
+ if (Array.isArray(snap.pendingFormatFiles)) {
791
+ engine.pendingFormatFiles = new Set(snap.pendingFormatFiles.filter(Boolean).map(String));
792
+ }
793
+ if (typeof snap.codeEditedSinceLastTest === 'boolean') {
794
+ engine.codeEditedSinceLastTest = snap.codeEditedSinceLastTest;
795
+ }
796
+ if (typeof snap.pendingVerificationCommand === 'boolean') {
797
+ engine.pendingVerificationCommand = snap.pendingVerificationCommand;
798
+ }
799
+ if (snap.lastFailingLocation !== undefined) {
800
+ engine.lastFailingLocation = snap.lastFailingLocation ? String(snap.lastFailingLocation) : null;
801
+ }
802
+ if (snap.pendingDownshiftModel !== undefined) {
803
+ engine.pendingDownshiftModel = snap.pendingDownshiftModel ? String(snap.pendingDownshiftModel) : null;
804
+ }
805
+ if (snap.pending_downshift !== undefined) {
806
+ engine.pending_downshift =
807
+ snap.pending_downshift && typeof snap.pending_downshift === 'object'
808
+ ? { ...snap.pending_downshift }
809
+ : null;
810
+ if (engine.pending_downshift?.toModel && snap.pendingDownshiftModel === undefined) {
811
+ engine.pendingDownshiftModel = String(engine.pending_downshift.toModel);
812
+ }
813
+ }
814
+ if (typeof snap.justCompacted === 'boolean') {
815
+ engine.justCompacted = snap.justCompacted;
816
+ }
817
+ if (snap.turnsSinceLastCompact !== undefined) {
818
+ engine.turnsSinceLastCompact =
819
+ snap.turnsSinceLastCompact !== null && Number.isFinite(Number(snap.turnsSinceLastCompact))
820
+ ? Math.max(0, Number(snap.turnsSinceLastCompact))
821
+ : null;
822
+ }
823
+ if (snap.taskBoundaryState && typeof snap.taskBoundaryState === 'object') {
824
+ engine.taskBoundaryState = {
825
+ openFailure: Boolean(snap.taskBoundaryState.openFailure),
826
+ editsSinceBoundary: Math.max(0, Number(snap.taskBoundaryState.editsSinceBoundary || 0)),
827
+ lastBoundarySuggestedTurn: snap.taskBoundaryState.lastBoundarySuggestedTurn ?? null
828
+ };
829
+ }
830
+ if (snap.lastToolsetHash !== undefined) {
831
+ engine.lastToolsetHash =
832
+ snap.lastToolsetHash && typeof snap.lastToolsetHash === 'object'
833
+ ? { ...snap.lastToolsetHash }
834
+ : null;
835
+ }
836
+ if (snap.lastContextTokens !== undefined) {
837
+ engine.lastContextTokens =
838
+ snap.lastContextTokens !== null && Number.isFinite(Number(snap.lastContextTokens))
839
+ ? Math.max(0, Number(snap.lastContextTokens))
840
+ : null;
841
+ }
842
+ if (snap.lastModelId !== undefined) {
843
+ engine.lastModelId = snap.lastModelId ? String(snap.lastModelId) : null;
844
+ }
845
+ if (Array.isArray(snap.activeBackgroundTasks)) {
846
+ engine.activeBackgroundTasks = snap.activeBackgroundTasks.filter(Boolean).map(String);
847
+ }
848
+ if (Array.isArray(snap.activeWriteWorkers)) {
849
+ engine.activeWriteWorkers = snap.activeWriteWorkers.filter(Boolean).map(String);
850
+ }
851
+ if (typeof snap.lastUserPrompt === 'string') {
852
+ engine.lastUserPrompt = snap.lastUserPrompt;
853
+ }
854
+ if (typeof snap.lastTurnGitCommitted === 'boolean') {
855
+ engine.lastTurnGitCommitted = snap.lastTurnGitCommitted;
856
+ }
857
+ if (Array.isArray(snap.committedTopDirs)) {
858
+ engine.committedTopDirs = [...snap.committedTopDirs];
859
+ }
860
+ if (typeof snap.consecutiveTrivialMaxEffortTurns === 'number') {
861
+ engine.consecutiveTrivialMaxEffortTurns = snap.consecutiveTrivialMaxEffortTurns;
862
+ }
863
+ if (snap.recentEditTimestampsByFile && typeof snap.recentEditTimestampsByFile === 'object') {
864
+ engine.recentEditTimestampsByFile = { ...snap.recentEditTimestampsByFile };
865
+ }
866
+ if (typeof snap.totalDiscoveryCalls === 'number') {
867
+ engine.totalDiscoveryCalls = snap.totalDiscoveryCalls;
868
+ }
869
+ if (typeof snap.consecutiveVisionTurns === 'number') {
870
+ engine.consecutiveVisionTurns = snap.consecutiveVisionTurns;
871
+ }
872
+ if (typeof snap.unanchoredTurnFlag === 'boolean') {
873
+ engine.unanchoredTurnFlag = snap.unanchoredTurnFlag;
874
+ }
875
+ if (Array.isArray(snap.candidateFiles)) {
876
+ engine.candidateFiles = [...snap.candidateFiles];
877
+ }
878
+ if (snap.relayState && typeof snap.relayState === 'object') {
879
+ engine.relayState = { ...snap.relayState };
880
+ }
881
+ if (typeof snap.steeredPrompts === 'number') {
882
+ engine.steeredPrompts = snap.steeredPrompts;
883
+ }
884
+ if (typeof snap.blockedPrompts === 'number') {
885
+ engine.blockedPrompts = snap.blockedPrompts;
886
+ }
887
+ if (typeof snap.sightseeingToolsPrevented === 'number') {
888
+ engine.sightseeingToolsPrevented = snap.sightseeingToolsPrevented;
889
+ }
890
+ if (snap.subagentTurns && typeof snap.subagentTurns === 'object') {
891
+ engine.subagentTurns = { ...snap.subagentTurns };
892
+ }
893
+ if (snap.subagentTokens && typeof snap.subagentTokens === 'object') {
894
+ engine.subagentTokens = { ...snap.subagentTokens };
895
+ }
896
+ if (snap.det11AdvisedTurn !== undefined) {
897
+ engine.det11AdvisedTurn = snap.det11AdvisedTurn;
898
+ }
899
+ if (snap.det13AdvisedTurn !== undefined) {
900
+ engine.det13AdvisedTurn = snap.det13AdvisedTurn;
901
+ }
902
+ if (Array.isArray(snap.queuedMutations)) {
903
+ engine.router.mutationQueue.items = [...snap.queuedMutations];
904
+ }
905
+ if (snap.hysteresisState && typeof snap.hysteresisState === 'object') {
906
+ engine.router.hysteresisLock.locked = Boolean(snap.hysteresisState.locked);
907
+ engine.router.hysteresisLock.pinnedModel = snap.hysteresisState.pinnedModel || null;
908
+ engine.router.hysteresisLock.pinnedEffort = snap.hysteresisState.pinnedEffort || null;
909
+ engine.router.hysteresisLock.reason = snap.hysteresisState.reason || null;
910
+ engine.router.hysteresisLock.lockedAtTurn = snap.hysteresisState.lockedAtTurn ?? null;
911
+ }
912
+ return engine;
913
+ }