@animalabs/agent-framework 0.32.0 → 0.33.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.
- package/README.md +204 -14
- package/dist/src/admission/admit.d.ts +18 -0
- package/dist/src/admission/admit.d.ts.map +1 -1
- package/dist/src/admission/admit.js +16 -3
- package/dist/src/admission/admit.js.map +1 -1
- package/dist/src/agent.d.ts +185 -78
- package/dist/src/agent.d.ts.map +1 -1
- package/dist/src/agent.js +279 -102
- package/dist/src/agent.js.map +1 -1
- package/dist/src/api/mcp-server-core.d.ts.map +1 -1
- package/dist/src/api/mcp-server-core.js +50 -12
- package/dist/src/api/mcp-server-core.js.map +1 -1
- package/dist/src/api/server.d.ts.map +1 -1
- package/dist/src/api/server.js +4 -20
- package/dist/src/api/server.js.map +1 -1
- package/dist/src/code-execution/isolate/scripts.d.ts +12 -8
- package/dist/src/code-execution/isolate/scripts.d.ts.map +1 -1
- package/dist/src/code-execution/isolate/scripts.js +24 -0
- package/dist/src/code-execution/isolate/scripts.js.map +1 -1
- package/dist/src/config-checks.d.ts +7 -0
- package/dist/src/config-checks.d.ts.map +1 -1
- package/dist/src/config-checks.js +14 -0
- package/dist/src/config-checks.js.map +1 -1
- package/dist/src/context-manager-errors.d.ts +25 -0
- package/dist/src/context-manager-errors.d.ts.map +1 -0
- package/dist/src/context-manager-errors.js +31 -0
- package/dist/src/context-manager-errors.js.map +1 -0
- package/dist/src/context-options.d.ts +67 -0
- package/dist/src/context-options.d.ts.map +1 -0
- package/dist/src/context-options.js +85 -0
- package/dist/src/context-options.js.map +1 -0
- package/dist/src/deferred-import.d.ts +93 -0
- package/dist/src/deferred-import.d.ts.map +1 -0
- package/dist/src/deferred-import.js +177 -0
- package/dist/src/deferred-import.js.map +1 -0
- package/dist/src/dendrite/audience.d.ts +223 -0
- package/dist/src/dendrite/audience.d.ts.map +1 -0
- package/dist/src/dendrite/audience.js +202 -0
- package/dist/src/dendrite/audience.js.map +1 -0
- package/dist/src/dendrite/index.d.ts +5 -3
- package/dist/src/dendrite/index.d.ts.map +1 -1
- package/dist/src/dendrite/index.js +2 -1
- package/dist/src/dendrite/index.js.map +1 -1
- package/dist/src/dendrite/presets.d.ts +10 -5
- package/dist/src/dendrite/presets.d.ts.map +1 -1
- package/dist/src/dendrite/presets.js +17 -5
- package/dist/src/dendrite/presets.js.map +1 -1
- package/dist/src/dendrite/registry.d.ts +62 -7
- package/dist/src/dendrite/registry.d.ts.map +1 -1
- package/dist/src/dendrite/registry.js +179 -10
- package/dist/src/dendrite/registry.js.map +1 -1
- package/dist/src/dendrite/types.d.ts +91 -8
- package/dist/src/dendrite/types.d.ts.map +1 -1
- package/dist/src/foreign-rounds.d.ts +69 -0
- package/dist/src/foreign-rounds.d.ts.map +1 -0
- package/dist/src/foreign-rounds.js +152 -0
- package/dist/src/foreign-rounds.js.map +1 -0
- package/dist/src/framework.d.ts +1976 -818
- package/dist/src/framework.d.ts.map +1 -1
- package/dist/src/framework.js +7566 -3422
- package/dist/src/framework.js.map +1 -1
- package/dist/src/gate/event-gate.d.ts +85 -15
- package/dist/src/gate/event-gate.d.ts.map +1 -1
- package/dist/src/gate/event-gate.js +421 -47
- package/dist/src/gate/event-gate.js.map +1 -1
- package/dist/src/gate/index.d.ts +1 -1
- package/dist/src/gate/index.d.ts.map +1 -1
- package/dist/src/gate/index.js.map +1 -1
- package/dist/src/gate/rule-scope.d.ts +30 -0
- package/dist/src/gate/rule-scope.d.ts.map +1 -0
- package/dist/src/gate/rule-scope.js +41 -0
- package/dist/src/gate/rule-scope.js.map +1 -0
- package/dist/src/gate/suppress-script-worker.d.ts +2 -0
- package/dist/src/gate/suppress-script-worker.d.ts.map +1 -0
- package/dist/src/gate/suppress-script-worker.js +103 -0
- package/dist/src/gate/suppress-script-worker.js.map +1 -0
- package/dist/src/gate/suppress-scripts.d.ts +105 -0
- package/dist/src/gate/suppress-scripts.d.ts.map +1 -0
- package/dist/src/gate/suppress-scripts.js +403 -0
- package/dist/src/gate/suppress-scripts.js.map +1 -0
- package/dist/src/gate/suppression-review.d.ts +143 -0
- package/dist/src/gate/suppression-review.d.ts.map +1 -0
- package/dist/src/gate/suppression-review.js +463 -0
- package/dist/src/gate/suppression-review.js.map +1 -0
- package/dist/src/gate/suppression-stats.d.ts +125 -0
- package/dist/src/gate/suppression-stats.d.ts.map +1 -0
- package/dist/src/gate/suppression-stats.js +214 -0
- package/dist/src/gate/suppression-stats.js.map +1 -0
- package/dist/src/gate/types.d.ts +135 -7
- package/dist/src/gate/types.d.ts.map +1 -1
- package/dist/src/gate/wake-onboarding.d.ts +119 -0
- package/dist/src/gate/wake-onboarding.d.ts.map +1 -0
- package/dist/src/gate/wake-onboarding.js +277 -0
- package/dist/src/gate/wake-onboarding.js.map +1 -0
- package/dist/src/held-writes.d.ts +31 -23
- package/dist/src/held-writes.d.ts.map +1 -1
- package/dist/src/held-writes.js +44 -59
- package/dist/src/held-writes.js.map +1 -1
- package/dist/src/index.d.ts +5 -2
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +3 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/jsonrpc-envelope.d.ts +69 -0
- package/dist/src/jsonrpc-envelope.d.ts.map +1 -0
- package/dist/src/jsonrpc-envelope.js +66 -0
- package/dist/src/jsonrpc-envelope.js.map +1 -0
- package/dist/src/mcpl/channel-registry.d.ts +131 -15
- package/dist/src/mcpl/channel-registry.d.ts.map +1 -1
- package/dist/src/mcpl/channel-registry.js +290 -46
- package/dist/src/mcpl/channel-registry.js.map +1 -1
- package/dist/src/mcpl/checkpoint-manager.d.ts +2 -4
- package/dist/src/mcpl/checkpoint-manager.d.ts.map +1 -1
- package/dist/src/mcpl/checkpoint-manager.js.map +1 -1
- package/dist/src/mcpl/feature-set-manager.d.ts +2 -4
- package/dist/src/mcpl/feature-set-manager.d.ts.map +1 -1
- package/dist/src/mcpl/feature-set-manager.js.map +1 -1
- package/dist/src/mcpl/inbound-source.d.ts +2 -1
- package/dist/src/mcpl/inbound-source.d.ts.map +1 -1
- package/dist/src/mcpl/inbound-source.js +2 -1
- package/dist/src/mcpl/inbound-source.js.map +1 -1
- package/dist/src/mcpl/inference-router.d.ts +6 -6
- package/dist/src/mcpl/inference-router.d.ts.map +1 -1
- package/dist/src/mcpl/inference-router.js.map +1 -1
- package/dist/src/mcpl/push-coalescer.d.ts +132 -22
- package/dist/src/mcpl/push-coalescer.d.ts.map +1 -1
- package/dist/src/mcpl/push-coalescer.js +105 -15
- package/dist/src/mcpl/push-coalescer.js.map +1 -1
- package/dist/src/mcpl/push-handler.d.ts +9 -7
- package/dist/src/mcpl/push-handler.d.ts.map +1 -1
- package/dist/src/mcpl/push-handler.js.map +1 -1
- package/dist/src/mcpl/server-connection.d.ts +13 -10
- package/dist/src/mcpl/server-connection.d.ts.map +1 -1
- package/dist/src/mcpl/server-connection.js +134 -56
- package/dist/src/mcpl/server-connection.js.map +1 -1
- package/dist/src/mcpl/tool-classes.d.ts.map +1 -1
- package/dist/src/mcpl/tool-classes.js +3 -0
- package/dist/src/mcpl/tool-classes.js.map +1 -1
- package/dist/src/mcpl/types.d.ts +8 -2
- package/dist/src/mcpl/types.d.ts.map +1 -1
- package/dist/src/mcpl/types.js.map +1 -1
- package/dist/src/module-registry.d.ts +24 -1
- package/dist/src/module-registry.d.ts.map +1 -1
- package/dist/src/module-registry.js +68 -18
- package/dist/src/module-registry.js.map +1 -1
- package/dist/src/modules/discord/index.d.ts +45 -8
- package/dist/src/modules/discord/index.d.ts.map +1 -1
- package/dist/src/modules/discord/index.js +237 -86
- package/dist/src/modules/discord/index.js.map +1 -1
- package/dist/src/modules/history/index.d.ts +59 -0
- package/dist/src/modules/history/index.d.ts.map +1 -1
- package/dist/src/modules/history/index.js +432 -67
- package/dist/src/modules/history/index.js.map +1 -1
- package/dist/src/modules/history/semantic.d.ts +6 -5
- package/dist/src/modules/history/semantic.d.ts.map +1 -1
- package/dist/src/modules/history/semantic.js +15 -22
- package/dist/src/modules/history/semantic.js.map +1 -1
- package/dist/src/modules/workspace/disk-agreement.d.ts +1 -1
- package/dist/src/modules/workspace/disk-agreement.js +1 -1
- package/dist/src/modules/workspace/index.d.ts +28 -7
- package/dist/src/modules/workspace/index.d.ts.map +1 -1
- package/dist/src/modules/workspace/index.js +76 -22
- package/dist/src/modules/workspace/index.js.map +1 -1
- package/dist/src/notice-tags.d.ts +10 -1
- package/dist/src/notice-tags.d.ts.map +1 -1
- package/dist/src/notice-tags.js +10 -1
- package/dist/src/notice-tags.js.map +1 -1
- package/dist/src/operator-log.d.ts +36 -3
- package/dist/src/operator-log.d.ts.map +1 -1
- package/dist/src/operator-log.js +2 -2
- package/dist/src/operator-log.js.map +1 -1
- package/dist/src/presentation.d.ts +746 -0
- package/dist/src/presentation.d.ts.map +1 -0
- package/dist/src/presentation.js +1435 -0
- package/dist/src/presentation.js.map +1 -0
- package/dist/src/prose-drafts.d.ts +15 -11
- package/dist/src/prose-drafts.d.ts.map +1 -1
- package/dist/src/prose-drafts.js +16 -12
- package/dist/src/prose-drafts.js.map +1 -1
- package/dist/src/read-marks.d.ts +192 -0
- package/dist/src/read-marks.d.ts.map +1 -0
- package/dist/src/read-marks.js +242 -0
- package/dist/src/read-marks.js.map +1 -0
- package/dist/src/recovery/offline-branch.d.ts +91 -6
- package/dist/src/recovery/offline-branch.d.ts.map +1 -1
- package/dist/src/recovery/offline-branch.js +273 -29
- package/dist/src/recovery/offline-branch.js.map +1 -1
- package/dist/src/recovery/recover-cli.js +22 -3
- package/dist/src/recovery/recover-cli.js.map +1 -1
- package/dist/src/send-tools.d.ts +5 -9
- package/dist/src/send-tools.d.ts.map +1 -1
- package/dist/src/send-tools.js +40 -7
- package/dist/src/send-tools.js.map +1 -1
- package/dist/src/stored-injections.d.ts +2 -2
- package/dist/src/stored-injections.js +2 -2
- package/dist/src/stored-removal.d.ts +17 -4
- package/dist/src/stored-removal.d.ts.map +1 -1
- package/dist/src/stored-removal.js +29 -5
- package/dist/src/stored-removal.js.map +1 -1
- package/dist/src/tool-result-guard.d.ts +12 -1
- package/dist/src/tool-result-guard.d.ts.map +1 -1
- package/dist/src/tool-result-guard.js +42 -8
- package/dist/src/tool-result-guard.js.map +1 -1
- package/dist/src/tune-out/coordinator.d.ts +1159 -79
- package/dist/src/tune-out/coordinator.d.ts.map +1 -1
- package/dist/src/tune-out/coordinator.js +3709 -363
- package/dist/src/tune-out/coordinator.js.map +1 -1
- package/dist/src/tune-out/tools.d.ts +114 -17
- package/dist/src/tune-out/tools.d.ts.map +1 -1
- package/dist/src/tune-out/tools.js +87 -27
- package/dist/src/tune-out/tools.js.map +1 -1
- package/dist/src/tune-out/window-anchor.d.ts +143 -0
- package/dist/src/tune-out/window-anchor.d.ts.map +1 -0
- package/dist/src/tune-out/window-anchor.js +202 -0
- package/dist/src/tune-out/window-anchor.js.map +1 -0
- package/dist/src/types/agent.d.ts +82 -20
- package/dist/src/types/agent.d.ts.map +1 -1
- package/dist/src/types/events.d.ts +2 -0
- package/dist/src/types/events.d.ts.map +1 -1
- package/dist/src/types/framework.d.ts +32 -12
- package/dist/src/types/framework.d.ts.map +1 -1
- package/dist/src/types/module.d.ts +180 -69
- package/dist/src/types/module.d.ts.map +1 -1
- package/dist/src/types/trace.d.ts +510 -36
- package/dist/src/types/trace.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/admission/admit.ts +32 -3
- package/src/agent.ts +323 -120
- package/src/api/mcp-server-core.ts +54 -17
- package/src/api/server.ts +4 -23
- package/src/code-execution/isolate/scripts.ts +28 -3
- package/src/config-checks.ts +14 -0
- package/src/context-manager-errors.ts +37 -0
- package/src/context-options.ts +96 -0
- package/src/deferred-import.ts +239 -0
- package/src/dendrite/audience.ts +315 -0
- package/src/dendrite/index.ts +14 -2
- package/src/dendrite/presets.ts +18 -6
- package/src/dendrite/registry.ts +209 -12
- package/src/dendrite/types.ts +92 -8
- package/src/foreign-rounds.ts +199 -0
- package/src/framework.ts +7804 -3546
- package/src/gate/event-gate.ts +428 -65
- package/src/gate/index.ts +3 -0
- package/src/gate/rule-scope.ts +45 -0
- package/src/gate/suppress-script-worker.ts +89 -0
- package/src/gate/suppress-scripts.ts +414 -0
- package/src/gate/suppression-review.ts +517 -0
- package/src/gate/suppression-stats.ts +314 -0
- package/src/gate/types.ts +141 -7
- package/src/gate/wake-onboarding.ts +309 -0
- package/src/held-writes.ts +49 -60
- package/src/index.ts +9 -2
- package/src/jsonrpc-envelope.ts +81 -0
- package/src/mcpl/channel-registry.ts +353 -85
- package/src/mcpl/checkpoint-manager.ts +3 -2
- package/src/mcpl/feature-set-manager.ts +2 -1
- package/src/mcpl/inbound-source.ts +2 -1
- package/src/mcpl/inference-router.ts +7 -4
- package/src/mcpl/push-coalescer.ts +193 -34
- package/src/mcpl/push-handler.ts +10 -5
- package/src/mcpl/server-connection.ts +141 -60
- package/src/mcpl/tool-classes.ts +3 -0
- package/src/mcpl/types.ts +8 -2
- package/src/module-registry.ts +73 -17
- package/src/modules/discord/index.ts +229 -81
- package/src/modules/history/index.ts +439 -70
- package/src/modules/history/semantic.ts +15 -21
- package/src/modules/workspace/disk-agreement.ts +1 -1
- package/src/modules/workspace/index.ts +85 -23
- package/src/notice-tags.ts +10 -1
- package/src/operator-log.ts +36 -3
- package/src/presentation.ts +1676 -0
- package/src/prose-drafts.ts +16 -12
- package/src/read-marks.ts +328 -0
- package/src/recovery/offline-branch.ts +346 -32
- package/src/recovery/recover-cli.ts +21 -3
- package/src/send-tools.ts +40 -7
- package/src/stored-injections.ts +2 -2
- package/src/stored-removal.ts +31 -7
- package/src/tool-result-guard.ts +41 -7
- package/src/tune-out/coordinator.ts +4089 -457
- package/src/tune-out/tools.ts +160 -43
- package/src/tune-out/window-anchor.ts +277 -0
- package/src/types/agent.ts +86 -20
- package/src/types/events.ts +2 -0
- package/src/types/framework.ts +32 -12
- package/src/types/module.ts +181 -68
- package/src/types/trace.ts +542 -40
|
@@ -16,8 +16,9 @@
|
|
|
16
16
|
*/
|
|
17
17
|
import type { ContentBlock } from '@animalabs/membrane';
|
|
18
18
|
import type { StoredMessage } from '@animalabs/context-manager';
|
|
19
|
-
import type
|
|
19
|
+
import { type ChannelRef, type ChannelRegistry, type TuneOutParams } from '../mcpl/channel-registry.js';
|
|
20
20
|
import type { McplServerRegistry } from '../mcpl/server-registry.js';
|
|
21
|
+
import type { TraceEventInput } from '../types/trace.js';
|
|
21
22
|
/** Defaults for tune_out tool params. */
|
|
22
23
|
export declare const TUNE_OUT_DEFAULTS: {
|
|
23
24
|
readonly cadenceSeconds: 1800;
|
|
@@ -41,30 +42,94 @@ export interface ReaderInvocation {
|
|
|
41
42
|
trigger: 'cadence' | 'wake' | 'cancel';
|
|
42
43
|
/** The host-framed notice for this invocation (bracket style). */
|
|
43
44
|
notice: string;
|
|
44
|
-
/** Held messages not yet handed to any reader fork, oldest first. */
|
|
45
|
-
backlog: StoredMessage[];
|
|
46
45
|
/**
|
|
47
|
-
* Held messages not yet handed to any reader fork
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
* rather than in the store.
|
|
46
|
+
* Held messages not yet handed to any reader fork, oldest first. A held
|
|
47
|
+
* message is stored as it arrives, whatever the resident's turn (#291), so
|
|
48
|
+
* a reader is handed what arrives while the resident is busy, which is
|
|
49
|
+
* when a reader is most useful.
|
|
52
50
|
*/
|
|
53
|
-
|
|
51
|
+
backlog: StoredMessage[];
|
|
54
52
|
/** Standing dispositions, as text, or null when there are none. */
|
|
55
53
|
dispositions: string | null;
|
|
56
54
|
}
|
|
57
55
|
/**
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
*
|
|
56
|
+
* Where the persistent subconscious's window starts (#291, AF-5): at the
|
|
57
|
+
* oldest active tune-out's start, never forward past one, so a tune-out's
|
|
58
|
+
* reader sees every message it held. `sequence` is where the tune-out
|
|
59
|
+
* started in the record (its startedAtSequence), which places the start
|
|
60
|
+
* while the subconscious's window is the record. Once its window follows the
|
|
61
|
+
* presentation index, the start is a place in that window, an index
|
|
62
|
+
* ordinal, fixed once per tune-out and recorded (`ordinal`;
|
|
63
|
+
* TuneOutCoordinator.subconsciousWindowFixed), since a row stored before
|
|
64
|
+
* the start can be presented after it, and the sequence converted again
|
|
65
|
+
* then gives another window. `epochIds` are the active tune-outs starting
|
|
66
|
+
* there: one, or a channel's and the all-except hold's begun at the same
|
|
67
|
+
* sequence.
|
|
62
68
|
*/
|
|
63
|
-
export
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
|
|
67
|
-
|
|
69
|
+
export interface SubconsciousWindowStart {
|
|
70
|
+
sequence: number;
|
|
71
|
+
/** The start as the subconscious's index ordinal, once fixed for one of `epochIds`. */
|
|
72
|
+
ordinal?: number;
|
|
73
|
+
epochIds: readonly string[];
|
|
74
|
+
/**
|
|
75
|
+
* At a resume: `ordinal` is the start in force before the restart (a
|
|
76
|
+
* cancelled tune-out's, earlier than the start kept for `epochIds`), set
|
|
77
|
+
* again and kept as the start in force only, never as theirs.
|
|
78
|
+
*/
|
|
79
|
+
inForceOnly?: true;
|
|
80
|
+
/**
|
|
81
|
+
* At a resume that finds no start in force kept: the anchor the
|
|
82
|
+
* subconscious's strategy persisted is kept, as the start in force only,
|
|
83
|
+
* where it is earlier than `ordinal`, the one kept for `epochIds` (a
|
|
84
|
+
* cancelled tune-out's start that was set but never kept), or, with no
|
|
85
|
+
* `ordinal` (their start fixed and set, its keeping failed), wherever it
|
|
86
|
+
* is: the sequence converted again could give a later start, once rows
|
|
87
|
+
* have been presented out of record order. Their own start is then fixed
|
|
88
|
+
* without moving the window to it.
|
|
89
|
+
*/
|
|
90
|
+
keepEarlierAnchor?: true;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* The answer to a cancel that waits for held writes (deferCancel): what it
|
|
94
|
+
* waits for, and what a stop meanwhile does. `noteDropped`: the caller's
|
|
95
|
+
* note isn't delivered, as the cancel already waiting carries one.
|
|
96
|
+
* `noteKept`: the caller's note waits with the cancel, and the answer says
|
|
97
|
+
* where it goes and what the caller is told of it. It is delivered when a
|
|
98
|
+
* cancel ends the hold, or tries to, else told lost to its author
|
|
99
|
+
* (tellNoteLost), a notice that can't be written being traced and
|
|
100
|
+
* tried again (writeLossNotices) until it is written, and, for the
|
|
101
|
+
* persistent subconscious (`persistent`), kept in the store too
|
|
102
|
+
* (writeLossRecord), so the next boot writes one a stop left unwritten
|
|
103
|
+
* (restoreLossNotices). Where another cancel ends the hold and the note
|
|
104
|
+
* can't be delivered then, the loss is told in that cancel's release
|
|
105
|
+
* (queuedNoteFirst), which the subconscious's window holds. A note written
|
|
106
|
+
* while writes are held again is kept in memory with them, the hold in
|
|
107
|
+
* force; where storing it when they are stored fails, the framework says
|
|
108
|
+
* so (heldWriteLost), and the note is told lost by a notice, as above, once
|
|
109
|
+
* the hold ends, or as one that may be lost where the store can't tell
|
|
110
|
+
* whether it landed, as is the stop's notice, or a hold's that ends
|
|
111
|
+
* without the cancel, before then (`noteUnknown`); it isn't written
|
|
112
|
+
* again. Stored then, it counts as delivered (heldWriteStored), even while
|
|
113
|
+
* the cancel still waits. The waiting
|
|
114
|
+
* cancel, and the note with it, is kept in memory only: a stop before the
|
|
115
|
+
* hold ends loses both, unless the stop's own wait for an operator's
|
|
116
|
+
* operation lets the hold end, which runs the cancel first (the
|
|
117
|
+
* framework's stop calls stop() only after that wait; stopTimers before
|
|
118
|
+
* it), or the note went out already (the cancel's run delivered it and
|
|
119
|
+
* failed before the end: the stop drops the cancel alone, dropQueued; AF
|
|
120
|
+
* #844 review 5, #26), and the subconscious is told of the note's loss
|
|
121
|
+
* as of any other, by a notice kept in the store for the next boot (stop),
|
|
122
|
+
* or, where the store refuses that or the host crashes, by the next boot's
|
|
123
|
+
* notice that any cancel then waiting was lost (noteUnstampedStop).
|
|
124
|
+
* The cancel can't wait for the delivery, which comes only when a cancel
|
|
125
|
+
* ends the hold, or tries to.
|
|
126
|
+
* A reader fork's (`fork`) goes out as its mail even after its run has
|
|
127
|
+
* ended (deliverReaderNote), but a notice of its loss reaches it only while
|
|
128
|
+
* it runs: an ended fork is no agent the framework writes to, and the loss
|
|
129
|
+
* is then traced only (writeLossNotice); a stop drops a fork's notice not
|
|
130
|
+
* yet written, and a fork's note not delivered yet is lost with the cancel.
|
|
131
|
+
*/
|
|
132
|
+
export declare function cancelWaitsNote(what: string, noteDropped?: boolean, noteKept?: 'persistent' | 'fork', unmarked?: boolean): string;
|
|
68
133
|
/**
|
|
69
134
|
* The all-except scope (issue #232 §3.2; focus folded into tune-out): a
|
|
70
135
|
* resident-level policy epoch holding every channel but one, for a bounded
|
|
@@ -92,7 +157,12 @@ export interface AllExceptState {
|
|
|
92
157
|
params: AllExceptParams;
|
|
93
158
|
wakeCount: number;
|
|
94
159
|
}
|
|
95
|
-
/**
|
|
160
|
+
/**
|
|
161
|
+
* `check`: what is held right now, without releasing anything. A hold's
|
|
162
|
+
* messages an earlier release of it delivered (its end not recorded, the
|
|
163
|
+
* hold still in force) are delivered, not held, and are counted and peeked
|
|
164
|
+
* no more: what is held is what its next release delivers (AF #844, Oscar).
|
|
165
|
+
*/
|
|
96
166
|
export interface TuneOutCheck {
|
|
97
167
|
allExcept: {
|
|
98
168
|
epochId: string;
|
|
@@ -114,6 +184,41 @@ export interface TuneOutCheck {
|
|
|
114
184
|
/** Up to `peekLimit` newest held lines of the peeked channel, oldest first. */
|
|
115
185
|
peek?: string[];
|
|
116
186
|
}
|
|
187
|
+
/** A row of the persistent subconscious's window as the boot reads it (subconsciousWindow). */
|
|
188
|
+
export type WindowRow = Pick<StoredMessage, 'participant' | 'content' | 'metadata' | 'sequence'> & {
|
|
189
|
+
shardIndex?: number;
|
|
190
|
+
};
|
|
191
|
+
/**
|
|
192
|
+
* The rows of a window (`window`, the persistent subconscious's, `author`)
|
|
193
|
+
* that `keep` keeps and that come after its last row of its own: shown to
|
|
194
|
+
* it, and no turn of its since. A note of its that a cancel delivered is a
|
|
195
|
+
* row under its name but no turn of it (`subconscious-note`), so isn't its
|
|
196
|
+
* own here. A row stored in shards is one row: its first shard.
|
|
197
|
+
*/
|
|
198
|
+
export declare function unansweredIn(window: readonly WindowRow[], author: string, keep: (m: WindowRow) => boolean): WindowRow[];
|
|
199
|
+
/** A `cancel_tuneout` call of the persistent subconscious's (cancelAsksIn). */
|
|
200
|
+
export interface CancelAsk {
|
|
201
|
+
/** Its row's sequence. */
|
|
202
|
+
sequence: number;
|
|
203
|
+
input: Record<string, unknown>;
|
|
204
|
+
/** Its result answered it as waiting (`waiting: true`). */
|
|
205
|
+
waiting: boolean;
|
|
206
|
+
/** The server its result names, where it names one. */
|
|
207
|
+
serverId?: string;
|
|
208
|
+
/** The scope its result names (`all-except`), where it names one. */
|
|
209
|
+
scope?: string;
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* The `cancel_tuneout` calls a window (`window`, the persistent
|
|
213
|
+
* subconscious's, `author`) holds, its own rows', each with what its
|
|
214
|
+
* result, where the window holds it, answered: waiting or not, and the
|
|
215
|
+
* server and scope it names. A result row that isn't an answer's JSON (the
|
|
216
|
+
* tool-result guard's placeholder, its batch not settled) is read from
|
|
217
|
+
* `archived`, the original results by tool use id (the guard's audit,
|
|
218
|
+
* subconsciousGuardedResults), where it holds one. A result that isn't
|
|
219
|
+
* there, or isn't an answer, isn't waiting.
|
|
220
|
+
*/
|
|
221
|
+
export declare function cancelAsksIn(window: readonly WindowRow[], author: string, archived?: ReadonlyMap<string, unknown>): CancelAsk[];
|
|
117
222
|
/**
|
|
118
223
|
* tune_out's refusal of a channel already tuned out: its settings, then what
|
|
119
224
|
* its transport is now where the repeat tried to open it again (`transport`,
|
|
@@ -137,22 +242,57 @@ export interface TuneOutFrameworkHooks {
|
|
|
137
242
|
* `reader: 'forks'`: deliver a reader fork's own words to the resident
|
|
138
243
|
* as attributed mail (its name, its incarnation). Absent in persistent
|
|
139
244
|
* mode, where the subconscious writes under its own name directly.
|
|
245
|
+
* Answers the row's id where it is written as a row, empty where that
|
|
246
|
+
* write was kept in memory; nothing for mail, which the registry keeps.
|
|
140
247
|
*/
|
|
141
|
-
deliverFromReader?: (reader: string, content: ContentBlock[], metadata: Record<string, unknown>) => void;
|
|
248
|
+
deliverFromReader?: (reader: string, content: ContentBlock[], metadata: Record<string, unknown>) => string | void;
|
|
142
249
|
/** The primary resident's registry name. */
|
|
143
250
|
primaryName: () => string | null;
|
|
144
|
-
/**
|
|
251
|
+
/**
|
|
252
|
+
* Read the primary's stored messages (shared slot, unfiltered). A held
|
|
253
|
+
* message is stored as it arrives, even during the resident's turn, so
|
|
254
|
+
* this is every message an epoch holds (#232 gap 7), but for those a live
|
|
255
|
+
* surgery's hold keeps in memory, or that the primary's context manager,
|
|
256
|
+
* refusing its work, keeps until a branch move re-initializes it
|
|
257
|
+
* (heldForRecovery): getSurgeryHeldMessages.
|
|
258
|
+
*/
|
|
145
259
|
getStoredMessages: () => StoredMessage[];
|
|
146
260
|
/**
|
|
147
|
-
*
|
|
148
|
-
*
|
|
149
|
-
*
|
|
261
|
+
* The writes for the primary's store kept in memory, in arrival order:
|
|
262
|
+
* those the primary's context manager, refusing its work, keeps until a
|
|
263
|
+
* branch move re-initializes it (heldForRecovery), which come first, then
|
|
264
|
+
* those a live surgery's hold keeps, made while the operator's switch is
|
|
265
|
+
* awaited, and stored, in that order, only at its release. A check during the hold
|
|
266
|
+
* counts and peeks a tune-out's held messages among them as it does the
|
|
267
|
+
* stored ones (#232 gap 7). A cancel waits for the release (writesHeld),
|
|
268
|
+
* so a dump lists them only where writesHeld throws and the cancel goes
|
|
269
|
+
* on during the hold. Left out, none are.
|
|
270
|
+
*/
|
|
271
|
+
getSurgeryHeldMessages?: () => Array<Pick<StoredMessage, 'participant' | 'content' | 'metadata'>>;
|
|
272
|
+
/**
|
|
273
|
+
* Make what was just delivered durable, and answer whether it is: a cancel
|
|
274
|
+
* stores its release and makes it durable before it records the epoch's
|
|
275
|
+
* end (#232 gap 6), and a release that can't be (false) leaves the
|
|
276
|
+
* tune-out in force, the cancel throwing. Left out, a stored release
|
|
277
|
+
* counts as durable.
|
|
150
278
|
*/
|
|
151
|
-
getDeferredMessages?: () => Array<Pick<StoredMessage, 'participant' | 'content' | 'metadata'> & {
|
|
152
|
-
writeId?: string;
|
|
153
|
-
heldAt?: number;
|
|
154
|
-
}>;
|
|
155
279
|
commitDeliveries?: () => boolean;
|
|
280
|
+
/**
|
|
281
|
+
* Whether a write the coordinator made now would be kept in memory rather
|
|
282
|
+
* than stored: a live surgery's hold, or a context manager of the primary
|
|
283
|
+
* or the subconscious refusing its work until a branch move re-initializes it.
|
|
284
|
+
* A cancel then waits (deferCancel), the tune-out still in
|
|
285
|
+
* force, until the framework says the writes are stored again, or told of
|
|
286
|
+
* where storing one fails (runDeferredCancels), so the release is in the
|
|
287
|
+
* store before the epoch's end is recorded. With `forAgent` (a loss
|
|
288
|
+
* notice's author, a reader fork's or the subconscious's), whether a write
|
|
289
|
+
* for that agent would be kept: a surgery's hold or its replay, or that
|
|
290
|
+
* agent's own manager refusing its work or waiting for its recovery; not
|
|
291
|
+
* the primary's or the subconscious's, which keep their own agent's writes
|
|
292
|
+
* alone. The loss notices are written by that answer, even while the
|
|
293
|
+
* release's is true (AF #844 review 5, #53). Left out, never.
|
|
294
|
+
*/
|
|
295
|
+
writesHeld?: (forAgent?: string) => boolean;
|
|
156
296
|
/**
|
|
157
297
|
* The history-reading tool the resident actually has (e.g. a server's
|
|
158
298
|
* `fetch_history`), or null. A truncation note names it only when it exists
|
|
@@ -169,20 +309,80 @@ export interface TuneOutFrameworkHooks {
|
|
|
169
309
|
residentMessageChars?: () => number | undefined;
|
|
170
310
|
/** Current chronicle head sequence (window anchor for new epochs). */
|
|
171
311
|
currentSequence: () => number;
|
|
172
|
-
/**
|
|
173
|
-
|
|
312
|
+
/**
|
|
313
|
+
* The name of the store's branch now, whose sequences currentSequence
|
|
314
|
+
* counts: the stop stamp names it with its run's start (StopStamp). Left
|
|
315
|
+
* out, none is named, and a stamp's start is read on any branch.
|
|
316
|
+
*/
|
|
317
|
+
currentBranch?: () => string;
|
|
318
|
+
/**
|
|
319
|
+
* The branch `name` was made from (`parent`, by name) and the sequence it
|
|
320
|
+
* was made at (`branchPoint`: it holds the parent's rows up to there, at
|
|
321
|
+
* the same sequences), where the store says; undefined for a branch made
|
|
322
|
+
* from none, or where the host can't say. A move to a branch made from
|
|
323
|
+
* this run's at a point past this run's start keeps that start for it
|
|
324
|
+
* (branchMoved). Left out, a move's destination is read from its head.
|
|
325
|
+
*/
|
|
326
|
+
branchOrigin?: (name: string) => {
|
|
327
|
+
parent: string;
|
|
328
|
+
branchPoint: number;
|
|
329
|
+
} | undefined;
|
|
330
|
+
/**
|
|
331
|
+
* Move the subconscious window anchor to `start`, the oldest active
|
|
332
|
+
* tune-out's (never forward past active epochs): by its sequence while
|
|
333
|
+
* the subconscious's window is the record, by its ordinal once that is
|
|
334
|
+
* known, and else by an ordinal the framework fixes for it and reports
|
|
335
|
+
* (subconsciousWindowFixed). `others` are the other active tune-outs'
|
|
336
|
+
* starts whose ordinal isn't kept yet, which the framework fixes and
|
|
337
|
+
* reports the same way without moving the window to them.
|
|
338
|
+
*/
|
|
339
|
+
setSubconsciousAnchor: (start: SubconsciousWindowStart, others?: readonly SubconsciousWindowStart[]) => void;
|
|
340
|
+
/**
|
|
341
|
+
* Whether the subconscious's window keeps index ordinals (its context
|
|
342
|
+
* manager presents rows, #291), so each tune-out's window start is kept as
|
|
343
|
+
* one (`subconscious/<primary>/window-starts`). Left out, or false, none
|
|
344
|
+
* is kept or read, and the anchor goes by sequence alone.
|
|
345
|
+
*/
|
|
346
|
+
subconsciousWindowOrdinals?: () => boolean;
|
|
347
|
+
/**
|
|
348
|
+
* How many of the residents' stored messages `keep` keeps that the
|
|
349
|
+
* persistent subconscious hasn't been shown yet: with the presentation
|
|
350
|
+
* index, those its window doesn't hold; else those stored after its last
|
|
351
|
+
* compile. A cancel the subconscious makes itself gives it a report turn
|
|
352
|
+
* when any of its tune-out's are, since it wrote its note without them.
|
|
353
|
+
* Left out, none are.
|
|
354
|
+
*/
|
|
355
|
+
unseenBySubconscious?: (keep: (m: Pick<StoredMessage, 'metadata'>) => boolean) => number;
|
|
356
|
+
/**
|
|
357
|
+
* The persistent subconscious's window, as written down (its presented
|
|
358
|
+
* rows): a boot reads it for the losses told to it whose turn a stop lost
|
|
359
|
+
* (askTurnsForUnreadLosses), for its own cancels of a hold the last stop
|
|
360
|
+
* didn't stamp, and for what it was told of that stop already
|
|
361
|
+
* (noteUnstampedStop). Left out, or with no subconscious, none.
|
|
362
|
+
*/
|
|
363
|
+
subconsciousWindow?: () => readonly WindowRow[];
|
|
364
|
+
/**
|
|
365
|
+
* The persistent subconscious's own stored rows (its slot's record),
|
|
366
|
+
* presented or not: a boot reads them for the notices written to it
|
|
367
|
+
* already (lossNoticeId, stopUnrecorded, lostAtStop), which its window
|
|
368
|
+
* doesn't hold yet where its presentation is frozen (a quiesced boot) or
|
|
369
|
+
* a crash came before it presented them. Left out, its window alone.
|
|
370
|
+
*/
|
|
371
|
+
subconsciousStoredMessages?: () => readonly WindowRow[];
|
|
372
|
+
/**
|
|
373
|
+
* The persistent subconscious's tool results as the tool-result guard
|
|
374
|
+
* archived them before it stored their placeholders (its audit's staged
|
|
375
|
+
* batches), by tool use id: a boot reads one where a crash before the
|
|
376
|
+
* guard settled left the placeholder for the result (cancelAsksIn). Left
|
|
377
|
+
* out, or with no guard's audit, none.
|
|
378
|
+
*/
|
|
379
|
+
subconsciousGuardedResults?: () => ReadonlyMap<string, unknown>;
|
|
174
380
|
/** True when a channel is bound to a conversation-fork agent. */
|
|
175
381
|
isForkBound: (channel: ChannelRef) => boolean;
|
|
176
382
|
/** Gate privileged-users list (#77: privileged authors wake, like mentions). */
|
|
177
383
|
isPrivilegedAuthor: (authorId: string | null | undefined) => boolean;
|
|
178
384
|
/** speak_in_channel master switch (recipe-side, canary-gated). */
|
|
179
385
|
allowChannelSpeech: () => boolean;
|
|
180
|
-
/**
|
|
181
|
-
* Whether a tune-out may hold a channel with no reader at all — a silent
|
|
182
|
-
* hold (issue #232 §3.3), which the host opts into (`tuneOut.enabled`).
|
|
183
|
-
* Left out, or false, a hold with no reader is refused.
|
|
184
|
-
*/
|
|
185
|
-
holdWithoutReader?: () => boolean;
|
|
186
386
|
/**
|
|
187
387
|
* Post a line into a channel under the resident's name. Used for the
|
|
188
388
|
* all-except scope's entry and release announcements in the excepted
|
|
@@ -193,10 +393,7 @@ export interface TuneOutFrameworkHooks {
|
|
|
193
393
|
success: boolean;
|
|
194
394
|
error?: string;
|
|
195
395
|
}>;
|
|
196
|
-
emitTrace: (event:
|
|
197
|
-
type: string;
|
|
198
|
-
[key: string]: unknown;
|
|
199
|
-
}) => void;
|
|
396
|
+
emitTrace: (event: TraceEventInput) => void;
|
|
200
397
|
}
|
|
201
398
|
export declare class TuneOutCoordinator {
|
|
202
399
|
private readonly channelRegistry;
|
|
@@ -209,6 +406,20 @@ export declare class TuneOutCoordinator {
|
|
|
209
406
|
* the end time does when its cancel finds the tune-out already ended,
|
|
210
407
|
* and the channel's next accepted enter does in any case. */
|
|
211
408
|
private expiryTimers;
|
|
409
|
+
/** A releaseAll asked to retry its failures (a reader that ended): the next try. */
|
|
410
|
+
private releaseRetry;
|
|
411
|
+
/** stop() has run: no timer is armed after it. */
|
|
412
|
+
private stopped;
|
|
413
|
+
/**
|
|
414
|
+
* stop() has kept what it found (keepAtStop): a loss told after it (a
|
|
415
|
+
* trace listener's stop, during a cancel's run or a notice's write) is
|
|
416
|
+
* kept as it kept those (keepAfterStop).
|
|
417
|
+
*/
|
|
418
|
+
private stopDone;
|
|
419
|
+
/** The holds the stop's stamp left out (writeStopStamp), which a stamp written again after it leaves out too. */
|
|
420
|
+
private stopUnaccounted;
|
|
421
|
+
/** The holds the stop left out of its stamp because a waiting cancel's note was still kept in memory (StopStamp's `notesKept`). */
|
|
422
|
+
private stopNotesKept;
|
|
212
423
|
/** Channels with a wake invocation pending inside the coalescing window. */
|
|
213
424
|
private pendingWakes;
|
|
214
425
|
/**
|
|
@@ -239,19 +450,11 @@ export declare class TuneOutCoordinator {
|
|
|
239
450
|
* held, which is the right side to err on.
|
|
240
451
|
*/
|
|
241
452
|
private readerCursor;
|
|
242
|
-
/**
|
|
243
|
-
* `reader: 'forks'`: the deferred writes handed to a reader fork while
|
|
244
|
-
* still queued, per epoch and channel. Each lands in the store later as a row
|
|
245
|
-
* stamped with the same id (`metadata.deferredWriteId`), past the cursor;
|
|
246
|
-
* that row is not handed again. Cleared with the cursor.
|
|
247
|
-
*/
|
|
248
|
-
private readerHandedWrites;
|
|
249
453
|
/**
|
|
250
454
|
* `reader: 'forks'`: held messages a reader fork was handed but never read,
|
|
251
|
-
* per epoch and channel: its derive failed, or its run threw before
|
|
252
|
-
* (readerFailed). The next invocation is handed them again,
|
|
253
|
-
*
|
|
254
|
-
* (stored or still queued now). Cleared with the cursor.
|
|
455
|
+
* per epoch and channel, by id: its derive failed, or its run threw before
|
|
456
|
+
* it reported (readerFailed). The next invocation is handed them again,
|
|
457
|
+
* cursor or no. Cleared with the cursor.
|
|
255
458
|
*/
|
|
256
459
|
private readerReturned;
|
|
257
460
|
/**
|
|
@@ -261,6 +464,110 @@ export declare class TuneOutCoordinator {
|
|
|
261
464
|
private lateForks;
|
|
262
465
|
/** The all-except scope's durable record, cached (undefined = not read yet). */
|
|
263
466
|
private scopeCache;
|
|
467
|
+
/**
|
|
468
|
+
* Cancels asked for while the framework keeps writes in memory
|
|
469
|
+
* (writesHeld), by channel key, the all-except hold's under SCOPE_KEY:
|
|
470
|
+
* each runs as it was asked, with its note, or a later cancel's when it
|
|
471
|
+
* had none (deferCancel), once the writes are stored again, or told of
|
|
472
|
+
* where storing one fails (runDeferredCancels). Each is for the epoch it
|
|
473
|
+
* was asked for (`for`), and ends that one only: one whose epoch no longer
|
|
474
|
+
* holds is dropped, told (dropDeferred), never run against a later one.
|
|
475
|
+
* In memory: a restart before then finds the tune-out still in force,
|
|
476
|
+
* and an end time that passed cancels it at once (resumeActiveEpochs); a
|
|
477
|
+
* note one carries is told lost at the stop, its notice kept in the store
|
|
478
|
+
* for the persistent subconscious (stop).
|
|
479
|
+
*/
|
|
480
|
+
private readonly deferredCancels;
|
|
481
|
+
/**
|
|
482
|
+
* The notices to a lost queued note's author that weren't written yet
|
|
483
|
+
* (tellNoteLost), by author, in the order the losses came: each is tried
|
|
484
|
+
* again, by runDeferredCancels, at the next release and at the retry,
|
|
485
|
+
* until it is written. Those for the persistent subconscious are kept in
|
|
486
|
+
* the store too (writeLossRecord), and stay there at stop for the next
|
|
487
|
+
* boot to write (restoreLossNotices); a reader fork's are in memory only,
|
|
488
|
+
* cleared at stop, as the deferred cancels are.
|
|
489
|
+
*/
|
|
490
|
+
private readonly lossNotices;
|
|
491
|
+
/**
|
|
492
|
+
* The persistent subconscious's kept notices as the store's record was
|
|
493
|
+
* last written or read (writeLossRecord, readLossRecord), so that it is
|
|
494
|
+
* written only when they change.
|
|
495
|
+
*/
|
|
496
|
+
private lossRecordShape;
|
|
497
|
+
/**
|
|
498
|
+
* The record may not hold the notices kept in memory: its write failed,
|
|
499
|
+
* or was put off while writes were held. The next change, or the stop,
|
|
500
|
+
* writes it.
|
|
501
|
+
*/
|
|
502
|
+
private lossRecordStale;
|
|
503
|
+
/** The record couldn't be read: nothing is written over it until it can be (readLossRecord). */
|
|
504
|
+
private lossRecordUnread;
|
|
505
|
+
/**
|
|
506
|
+
* The store's head sequence when this run began (noteUnstampedStop), which
|
|
507
|
+
* the stop's stamp names, so that the next boot reads only this run's rows
|
|
508
|
+
* for what became of a note. Undefined until the boot, or where it
|
|
509
|
+
* couldn't be read.
|
|
510
|
+
*/
|
|
511
|
+
private runStartedAt;
|
|
512
|
+
/** The branch `runStartedAt` is a place on (currentBranch), where the host names one. */
|
|
513
|
+
private runBranch;
|
|
514
|
+
/** Where this run's rows begin on each branch it has been on, by branch (branchMoved): a move back to one keeps its start. */
|
|
515
|
+
private readonly runStarts;
|
|
516
|
+
/**
|
|
517
|
+
* The bound the last stop's stamp gave this boot's reading of that run
|
|
518
|
+
* (its `runStartedAt` and `branch`), kept while a notice the boot derived
|
|
519
|
+
* from it is kept in memory only (stampNoticesUnkept): this run's stamp
|
|
520
|
+
* carries it then (runBound), so a crash meanwhile leaves the next boot
|
|
521
|
+
* reading the same rows, and telling the same.
|
|
522
|
+
*/
|
|
523
|
+
private carriedBound;
|
|
524
|
+
/** The ids of the notices the store's loss record holds, as last written or read (writeLossRecord, readLossRecord). */
|
|
525
|
+
private lossRecordIds;
|
|
526
|
+
/**
|
|
527
|
+
* This run's stamp (noteUnstampedStop) where the store refused it at boot,
|
|
528
|
+
* tried again until it lands (writePendingMarker); a stop's own stamp
|
|
529
|
+
* replaces it. Meanwhile a waiting cancel's answer to the persistent
|
|
530
|
+
* subconscious says the host's death before the cancel runs may go untold.
|
|
531
|
+
*/
|
|
532
|
+
private markerPending;
|
|
533
|
+
/** A write of `markerPending` failed, which was logged (once). */
|
|
534
|
+
private markerUnwritten;
|
|
535
|
+
/**
|
|
536
|
+
* The boot's telling of the last stop's stamp (tellUnstampedHolds) threw
|
|
537
|
+
* before it finished, so a hold it didn't reach may be told nothing: the
|
|
538
|
+
* carried bound stays for the run (carriedNeeded), so a crash leaves the
|
|
539
|
+
* next boot reading those rows again.
|
|
540
|
+
*/
|
|
541
|
+
private carriedUntold;
|
|
542
|
+
/**
|
|
543
|
+
* The notices of an unrecorded stop (`unstamped-stop`) this boot wrote
|
|
544
|
+
* from the store's record (restoreLossNotices): told, though the
|
|
545
|
+
* subconscious's window may not hold them yet (a quiesced boot), as the
|
|
546
|
+
* boot's own reading of the stamp counts them (noteUnstampedStop).
|
|
547
|
+
*/
|
|
548
|
+
private restoredTold;
|
|
549
|
+
/**
|
|
550
|
+
* The ids of the notices the boot read from the store's record whose
|
|
551
|
+
* rows it couldn't read (restoreLossNotices): each may be written already,
|
|
552
|
+
* so none is written until a try reads those rows (checkLossNoticesWritten).
|
|
553
|
+
*/
|
|
554
|
+
private readonly lossNoticesUnchecked;
|
|
555
|
+
/** The authors whose loss notice is being written now (writeLossNotices): a loss told for one meanwhile waits behind it. */
|
|
556
|
+
private readonly lossNoticesWriting;
|
|
557
|
+
/** The host's stop has begun (stopTimers): a turn asked for from here on is dropped with the stop's closed queue. */
|
|
558
|
+
private timersStopped;
|
|
559
|
+
/** The release turns asked for while the stop was under way (StopStamp's `wakesOwed`), for the stop's stamp. */
|
|
560
|
+
private readonly wakesInStop;
|
|
561
|
+
/** The release turns this run asked for, by whose: a boot that asks one for its own release asks none again for the last stop's. */
|
|
562
|
+
private readonly releaseTurnsAsked;
|
|
563
|
+
/**
|
|
564
|
+
* The one retry of the deferred cancels whose run threw (a release that
|
|
565
|
+
* couldn't be made durable, a store operation that threw), and of the
|
|
566
|
+
* loss notices not written (lossNotices), armed by runDeferredCancels and
|
|
567
|
+
* tellNoteLost, unref'd, cleared at stop. A later release's
|
|
568
|
+
* runDeferredCancels runs them sooner.
|
|
569
|
+
*/
|
|
570
|
+
private deferredRetry;
|
|
264
571
|
/** Timer key for the scope's cadence and expiry. */
|
|
265
572
|
private static readonly SCOPE_KEY;
|
|
266
573
|
constructor(channelRegistry: ChannelRegistry, serverRegistry: McplServerRegistry, hooks: TuneOutFrameworkHooks);
|
|
@@ -279,9 +586,104 @@ export declare class TuneOutCoordinator {
|
|
|
279
586
|
* cancel_tuneout take back; or, for a channel no string picks alone, its
|
|
280
587
|
* id and its server. */
|
|
281
588
|
private shown;
|
|
589
|
+
/**
|
|
590
|
+
* Every message of the primary's store, in arrival order: those stored,
|
|
591
|
+
* then those a live surgery's hold keeps in memory until its release
|
|
592
|
+
* (getSurgeryHeldMessages). What a check counts and peeks, and what a
|
|
593
|
+
* dump lists: a dump made during the hold, which a cancel makes only
|
|
594
|
+
* where writesHeld throws, still has what the tune-out held then. A
|
|
595
|
+
* reader is handed stored rows only (getStoredMessages): those the hold
|
|
596
|
+
* keeps have no id until stored, and the dump has them.
|
|
597
|
+
*/
|
|
598
|
+
private residentMessages;
|
|
282
599
|
private quotedShown;
|
|
283
600
|
/** Restart cadence + expiry timers and re-anchor after a process restart. */
|
|
284
601
|
resumeActiveEpochs(): void;
|
|
602
|
+
/**
|
|
603
|
+
* At boot (resumeActiveEpochs), after this boot's own releases (an end
|
|
604
|
+
* time passed, a wake budget spent): each hold on record then still in
|
|
605
|
+
* force whose release the resident has, stored before this boot (a
|
|
606
|
+
* `tune-out-cancel` row of its epoch), its end never recorded. The
|
|
607
|
+
* resident read "[Tune-out: … cancelled …]", and nothing said the
|
|
608
|
+
* tune-out still stood: a stop whose wait for an operator's operation ran
|
|
609
|
+
* out, the hold's release after it storing the release, or a throw
|
|
610
|
+
* between a cancel's release and its end (a store fault). It is told,
|
|
611
|
+
* once, by a row in the residents' slot (`tune-out-end-unrecorded`) that
|
|
612
|
+
* the release reached it but the end wasn't recorded, so the tune-out is
|
|
613
|
+
* still in force, what arrives there held for its next release, and how
|
|
614
|
+
* it ends; the release row stays as the record of the release. A row of
|
|
615
|
+
* that kind for the epoch after its latest release silences a later boot;
|
|
616
|
+
* a release after it (another cancel that failed at its end) is told
|
|
617
|
+
* again. The subconscious, whose window holds the residents' rows, reads
|
|
618
|
+
* it too. A write that throws is logged, and tried at the next boot
|
|
619
|
+
* (AF #844, Oscar). Never throws.
|
|
620
|
+
*/
|
|
621
|
+
private tellResidentUnended;
|
|
622
|
+
/** The epochs of the tune-outs active now, a channel's and the all-except hold (the anchor's branchMoved reads them). */
|
|
623
|
+
activeEpochIds(): string[];
|
|
624
|
+
/** The tune-outs active now, a channel's and the all-except hold, with where each started in the record. */
|
|
625
|
+
private activeStarts;
|
|
626
|
+
/**
|
|
627
|
+
* Set the subconscious's window start to the oldest active tune-out's
|
|
628
|
+
* (setSubconsciousAnchor), with its ordinal when one was fixed for it. The
|
|
629
|
+
* all-except hold counts with the channels' tune-outs, wherever this is
|
|
630
|
+
* called, so a channel's tune-out entered during an older hold leaves the
|
|
631
|
+
* start at the hold's. Nothing when none is active: the anchor stays where
|
|
632
|
+
* it was, as a cancel leaves it.
|
|
633
|
+
*
|
|
634
|
+
* A cancel leaves the start where it was while another tune-out stays
|
|
635
|
+
* active too, so the subconscious's report on the one cancelled still has
|
|
636
|
+
* what it held, and the start in force is kept (`inForce`). At a resume
|
|
637
|
+
* that start is set again rather than the oldest active tune-out's, which
|
|
638
|
+
* is later than it once the oldest was cancelled: so the window is the
|
|
639
|
+
* same across a restart. An enter sets the oldest active tune-out's, as it
|
|
640
|
+
* always has. Where the window presents, the other active tune-outs whose
|
|
641
|
+
* start isn't kept yet go with it, for the framework to fix as soon as
|
|
642
|
+
* each can be: the oldest one's too, where a resume sets the start in
|
|
643
|
+
* force instead of it.
|
|
644
|
+
*/
|
|
645
|
+
private anchorSubconscious;
|
|
646
|
+
/** Where each active tune-out's window start is kept, by ordinal: a snapshot state, on each branch its own. */
|
|
647
|
+
private get windowStartsStateId();
|
|
648
|
+
/** Whether the subconscious's window keeps ordinals, so its starts are kept (subconsciousWindowOrdinals). */
|
|
649
|
+
private ordinalsKept;
|
|
650
|
+
/**
|
|
651
|
+
* Each tune-out's window start as an ordinal, by epoch id, as kept on the
|
|
652
|
+
* store's branch now, and the start in force (`inForce`: the ordinal the
|
|
653
|
+
* window start was last set to while a tune-out is active), which a
|
|
654
|
+
* restart sets again (anchorSubconscious). A state that isn't this format
|
|
655
|
+
* (`{ v: 1, starts, inForce? }`) reads as none kept, and is written over
|
|
656
|
+
* at the next fix, with a line saying so. A read that throws answers null:
|
|
657
|
+
* what is kept can't be told, so nothing is written over it (a fix isn't
|
|
658
|
+
* kept, and is tried again at the next presentation), and the window
|
|
659
|
+
* start isn't moved. A state an earlier version kept, with no `inForce`,
|
|
660
|
+
* reads as one with none in force, and a restart sets the oldest active
|
|
661
|
+
* tune-out's start, or the anchor the subconscious's strategy persisted
|
|
662
|
+
* where that is earlier (keepEarlierAnchor).
|
|
663
|
+
*/
|
|
664
|
+
private readWindowState;
|
|
665
|
+
/** Keep `state`, answering whether it was written; a write that fails is logged, and the anchor the strategy holds stays as it is. */
|
|
666
|
+
private writeWindowState;
|
|
667
|
+
/**
|
|
668
|
+
* The framework fixed the subconscious's window start for `epochIds` at
|
|
669
|
+
* `ordinal` (its index ordinal, #291): kept for each of them still active,
|
|
670
|
+
* so a later anchor (another tune-out's enter, a restart) sets that
|
|
671
|
+
* ordinal again rather than converting the tune-out's sequence anew, and
|
|
672
|
+
* kept as the start in force while any tune-out is active, which a
|
|
673
|
+
* restart sets again (anchorSubconscious), when it is the start in force
|
|
674
|
+
* (`inForce`; another active tune-out's start fixed beside it isn't).
|
|
675
|
+
* Answers whether it is kept, so that the anchor tries again at its next
|
|
676
|
+
* presentation when it isn't: not when the record can't be read, which
|
|
677
|
+
* is never written over then.
|
|
678
|
+
*/
|
|
679
|
+
subconsciousWindowFixed(epochIds: readonly string[], ordinal: number, inForce?: boolean): boolean;
|
|
680
|
+
/**
|
|
681
|
+
* An ended tune-out's window start goes, and, once none is active, the
|
|
682
|
+
* start in force with it: the next enter sets its own.
|
|
683
|
+
*/
|
|
684
|
+
private forgetWindowStart;
|
|
685
|
+
/** The window starts of tune-outs no longer active go. */
|
|
686
|
+
private pruneWindowStarts;
|
|
285
687
|
private armExpiry;
|
|
286
688
|
/** A timer callback's work threw. Report it on stderr and as a trace rather
|
|
287
689
|
* than throw it into the event loop, where an uncaught exception ends the
|
|
@@ -314,18 +716,638 @@ export declare class TuneOutCoordinator {
|
|
|
314
716
|
error: string;
|
|
315
717
|
alreadyTunedOut?: true;
|
|
316
718
|
};
|
|
719
|
+
/**
|
|
720
|
+
* Whether a write the coordinator just made was kept in memory, by what
|
|
721
|
+
* it answered: an empty id, the framework's answer for a write it keeps
|
|
722
|
+
* (a surgery's hold, a context manager refusing its work), with writes
|
|
723
|
+
* held now, as they are while it keeps one. A write that answered an id
|
|
724
|
+
* landed, whether or not writes are held since (a hold begun as it
|
|
725
|
+
* returned); one that answered no id with nothing held (a host that
|
|
726
|
+
* answers none) isn't kept. Never judged by writesHeld alone (Weft, #844).
|
|
727
|
+
*/
|
|
728
|
+
private writeKept;
|
|
729
|
+
/**
|
|
730
|
+
* Whether the resident's last word on a hold (`what`, as the log names
|
|
731
|
+
* it) is the boot's row that it still stands (toldStillStands), read from
|
|
732
|
+
* the residents' stored rows for the cancel that ends it with nothing
|
|
733
|
+
* more to deliver. A read that throws, or rows that can't be read, count
|
|
734
|
+
* as yes, said once: one redundant release line is the cheaper error
|
|
735
|
+
* against a "still stands" left as the last word on a tune-out that has
|
|
736
|
+
* ended (AF #844, Oscar). Never throws.
|
|
737
|
+
*/
|
|
738
|
+
private residentToldStillStands;
|
|
739
|
+
/** Whether the framework keeps writes in memory now (writesHeld), with `forAgent`'s among them; a hook that throws counts as not. */
|
|
740
|
+
private writesHeldNow;
|
|
741
|
+
/**
|
|
742
|
+
* Keep a cancel asked for while writes are kept in memory, for
|
|
743
|
+
* runDeferredCancels, with its note, for the epoch it was asked for
|
|
744
|
+
* (`target`). The first one asked for a hold stands, with its reason and
|
|
745
|
+
* source. A later one for the same hold (an end time's retry, a wake past
|
|
746
|
+
* the budget, an agent's cancel) adds nothing, except a note: the waiting
|
|
747
|
+
* cancel takes it, with its author, when it has none or its own went out
|
|
748
|
+
* already (noteDelivered), and otherwise the
|
|
749
|
+
* later note is dropped, with a log line, and this answers 'note-dropped'
|
|
750
|
+
* so its caller can be told. One waiting for an earlier epoch there,
|
|
751
|
+
* whose hold ended without it, is dropped (dropDeferred), and this one
|
|
752
|
+
* waits in its place. Once stopped (a listener of that drop's trace, say),
|
|
753
|
+
* none waits: this one is told as the stop tells a waiting cancel.
|
|
754
|
+
*/
|
|
755
|
+
private deferCancel;
|
|
756
|
+
/**
|
|
757
|
+
* Run the cancels asked for while writes were kept in memory (deferCancel),
|
|
758
|
+
* in the order asked, now that the framework stores them again: it calls
|
|
759
|
+
* this once a surgery's release has stored what its hold kept, or told of
|
|
760
|
+
* what it couldn't store, and the retry timer calls it. One whose writes
|
|
761
|
+
* are still held waits on. One whose epoch no longer holds (its hold
|
|
762
|
+
* ended without it, and a later one may hold there now) is dropped, told
|
|
763
|
+
* (dropDeferred): it ends nothing, a later hold included. One that throws
|
|
764
|
+
* (its release couldn't be made durable, a store operation threw) stays
|
|
765
|
+
* waiting, with its note, the tune-out still in force: it runs again at
|
|
766
|
+
* the next call, or EXPIRY_RETRY_MS later, which one timer arms; one that
|
|
767
|
+
* threw after it recorded its hold's end isn't kept, and a note it hadn't
|
|
768
|
+
* delivered by then is told lost (dropDeferred). Each leaves the queue
|
|
769
|
+
* just before it runs, so a stop meanwhile (a trace listener's) finds
|
|
770
|
+
* those not run yet, and tells them as it tells any (stop): none runs
|
|
771
|
+
* after it, and no retry is armed then. First, the loss notices not
|
|
772
|
+
* written yet are tried again (writeLossNotices); the retry is armed while
|
|
773
|
+
* one is left. Never throws.
|
|
774
|
+
*/
|
|
775
|
+
runDeferredCancels(): void;
|
|
776
|
+
/**
|
|
777
|
+
* A write the framework kept in memory while writes were held, lost when
|
|
778
|
+
* it stored them: its replay threw (`error`), and where context-manager
|
|
779
|
+
* couldn't tell whether any of it landed (`mayBeStored`), it may be stored
|
|
780
|
+
* after all. `metadata` is the write's, as it was given: what tells the
|
|
781
|
+
* coordinator's own writes apart. The framework calls this from its
|
|
782
|
+
* release, before it runs the deferred cancels (runDeferredCancels), and
|
|
783
|
+
* tells the operator as well (`message:lost`, `store-held-lost`).
|
|
784
|
+
* A queued cancel's note delivered while writes were held (heldInMemory:
|
|
785
|
+
* by its own run, or ahead of another cancel's release, queuedNoteFirst)
|
|
786
|
+
* was answered as waiting, with the promise that its author is told if it
|
|
787
|
+
* can't be delivered, and why. Its write (`subconscious-note`, of the
|
|
788
|
+
* cancel's epoch) lost here unsettles it (lostAtRelease): the run that ends
|
|
789
|
+
* the hold tells it lost then, with this error, as it tells a note it
|
|
790
|
+
* can't write (noteNow, dropDeferred), and a stop before then tells it
|
|
791
|
+
* lost with the cancel (dropQueued). The note is never written again,
|
|
792
|
+
* since it may be stored after all. A release kept so that told a queued
|
|
793
|
+
* note's loss (`tune-out-cancel` with `lostNote`, queuedNoteFirst), lost
|
|
794
|
+
* here, told nothing: the entry it settled (lostInRelease, heldInMemory)
|
|
795
|
+
* is unsettled, that loss moved to lostAtRelease, so the run that ends
|
|
796
|
+
* the hold tells it by a notice, and the note isn't written again (AF
|
|
797
|
+
* #844 review 5, #18). The note's loss is known whether or not that
|
|
798
|
+
* release may have landed: told twice, where it did, rather than never.
|
|
799
|
+
* Any other write is left to the operator. Never throws.
|
|
800
|
+
*/
|
|
801
|
+
heldWriteLost(metadata: Readonly<Record<string, unknown>> | undefined, error: unknown, mayBeStored?: boolean): void;
|
|
802
|
+
/**
|
|
803
|
+
* A write the framework kept in memory while writes were held, stored when
|
|
804
|
+
* it stored them (its replay landed), by its metadata as it was given:
|
|
805
|
+
* heldWriteLost's sibling, called from the same release. What a queued
|
|
806
|
+
* cancel kept in memory so (heldInMemory) is in the store now, so a stop
|
|
807
|
+
* no longer loses it: the queued note written by the cancel's own run or
|
|
808
|
+
* ahead of another cancel's release (`subconscious-note`, of the cancel's
|
|
809
|
+
* epoch) counts as delivered, and a release that told its loss
|
|
810
|
+
* (`tune-out-cancel` with `lostNote`, queuedNoteFirst) as told. The cancel
|
|
811
|
+
* can still wait after that (writes held again before it runs, or a run
|
|
812
|
+
* that throws before it records the end): a stop then drops it as one
|
|
813
|
+
* whose note is settled, telling the author nothing false. A loss notice
|
|
814
|
+
* whose own write was kept so (writeLossNotice: a hold begun at it) is
|
|
815
|
+
* written now, by its id (`lossNoticeId`): it leaves the notices kept, and
|
|
816
|
+
* the store's record, so it isn't written a second time (Weft, #844). Any
|
|
817
|
+
* other write changes nothing. Never throws.
|
|
818
|
+
*/
|
|
819
|
+
heldWriteStored(metadata: Readonly<Record<string, unknown>> | undefined): void;
|
|
820
|
+
/**
|
|
821
|
+
* A queued cancel back on the queue (`key`) after a run that didn't end
|
|
822
|
+
* its hold: one that threw, or met writes held again (waitForWrites). A
|
|
823
|
+
* cancel queued there meanwhile, for the same epoch (a trace listener's,
|
|
824
|
+
* during the run), joins it, as a later cancel joins one waiting
|
|
825
|
+
* (deferCancel): the run's stands, with its reason and its note, as it
|
|
826
|
+
* was (settled, or told in a release), and takes the later one's askers,
|
|
827
|
+
* and its note where it has none, or where its own went out already
|
|
828
|
+
* (noteDelivered: the run delivered it, and failed before the end), the
|
|
829
|
+
* later note then going out when the hold ends; a later note beside its
|
|
830
|
+
* own still to go out is dropped,
|
|
831
|
+
* told (dropDeferred, `superseded`), its caller having been answered as
|
|
832
|
+
* waiting. One queued for a later epoch leaves the run nothing to end: it
|
|
833
|
+
* is dropped, told (dropQueued).
|
|
834
|
+
*/
|
|
835
|
+
private requeue;
|
|
836
|
+
/** Where a hold is, as askTurnForLoss names it: the all-except hold's, or the channel shown. */
|
|
837
|
+
private whereOf;
|
|
838
|
+
/**
|
|
839
|
+
* A queued cancel off the queue with its work undone (`drop`), as
|
|
840
|
+
* dropDeferred tells it, its note as it stands: one whose loss a release
|
|
841
|
+
* told is told so (lossesToldInRelease), where its hold has ended
|
|
842
|
+
* (`hold-ended`); one delivered, or told lost already, isn't told lost
|
|
843
|
+
* again: its drop is logged and traced as one with no note, unless the
|
|
844
|
+
* write that settled it is kept in memory at a stop (heldInMemory), which
|
|
845
|
+
* loses it; one stored since (heldWriteStored) is settled. One whose write
|
|
846
|
+
* was lost when the writes were stored (lostAtRelease) isn't settled: it
|
|
847
|
+
* is told lost by this drop, once.
|
|
848
|
+
*/
|
|
849
|
+
private dropQueued;
|
|
850
|
+
/**
|
|
851
|
+
* Queued cancels leaving the queue with their hold ended, by the run that
|
|
852
|
+
* ended it or after it: a note whose loss a release told (lostInRelease;
|
|
853
|
+
* the release this run wrote, or an earlier cancel's, not made durable
|
|
854
|
+
* then) is traced and logged as lost now, as that release says, and the
|
|
855
|
+
* subconscious is asked for a turn to read it (at `where`), once.
|
|
856
|
+
*/
|
|
857
|
+
private lossesToldInRelease;
|
|
858
|
+
/**
|
|
859
|
+
* A deferred cancel taken off the queue without what it was for being
|
|
860
|
+
* done (`drop`, DeferredDrop), told on stderr and as a trace
|
|
861
|
+
* (`tune-out:deferred-cancel-dropped`) with the epoch it was asked for. A
|
|
862
|
+
* note it carried is lost: the trace names its author (noteAuthorOf), and
|
|
863
|
+
* the author is told so in its own context where it still exists, a
|
|
864
|
+
* reader fork whose run has ended being written nothing (tellNoteLost),
|
|
865
|
+
* unless the release of the cancel that ended the hold tells it already
|
|
866
|
+
* (`told` release, queuedNoteFirst): no second notice is written then. A
|
|
867
|
+
* note that may be stored after all (lostAtRelease, `mayBeStored`) is
|
|
868
|
+
* traced so (`noteMayBeStored`, with the `error`), as its notice says it.
|
|
869
|
+
*/
|
|
870
|
+
private dropDeferred;
|
|
871
|
+
/**
|
|
872
|
+
* Whose a queued cancel's note is: the name deliverReaderNote would
|
|
873
|
+
* deliver it under, the persistent subconscious's, else the reader fork's
|
|
874
|
+
* that left it (`noteAuthor`). Undefined where neither is known; the
|
|
875
|
+
* fork's name where the subconscious's can't be read.
|
|
876
|
+
*/
|
|
877
|
+
private noteAuthorOf;
|
|
878
|
+
/**
|
|
879
|
+
* The author of a queued cancel's lost note (`author`, noteAuthorOf), told
|
|
880
|
+
* in its own context that the note was not delivered and why (`drop`):
|
|
881
|
+
* its cancel was answered as waiting, so nothing else tells it. The
|
|
882
|
+
* notice is kept (lossNotices) and written now (writeLossNotices). One
|
|
883
|
+
* whose write fails stays kept, its first failure traced, and is tried
|
|
884
|
+
* again at the next release and at the retry, which this arms, until it
|
|
885
|
+
* is written; what dropped the cancel goes on either way. One for the
|
|
886
|
+
* persistent subconscious is kept in the store as well (writeLossRecord),
|
|
887
|
+
* so a stop leaves it for the next boot to write (restoreLossNotices); a
|
|
888
|
+
* reader fork's is lost at a stop, as the fork's run is. While writes are
|
|
889
|
+
* held it waits for their release, as the cancels do. A reader fork that
|
|
890
|
+
* has ended is no agent the framework writes to any more: it is written
|
|
891
|
+
* nothing, the loss reaching no one, which is traced (writeLossNotice),
|
|
892
|
+
* and the trace of the drop (dropDeferred) still names the fork. An
|
|
893
|
+
* author not known is logged. One told at the stop is kept, not written:
|
|
894
|
+
* the stop keeps it in the store with the others (writeLossRecord), for
|
|
895
|
+
* the next boot; one told after the stop has kept those (a trace
|
|
896
|
+
* listener's stop, during the run of a cancel it found off its queue) is
|
|
897
|
+
* added to that record (keepAfterStop). Where the store refuses that record too, the stop's
|
|
898
|
+
* stamp leaves the hold out (writeStopStamp), and the next boot tells the
|
|
899
|
+
* subconscious, for a hold still on record, what that run's rows show of
|
|
900
|
+
* a cancel of it then waiting (noteUnstampedStop); a stop that can't write
|
|
901
|
+
* its stamp either leaves the one this run's boot wrote, which covers no
|
|
902
|
+
* hold, so the next boot tells it the same, where that one landed. Where
|
|
903
|
+
* the store refused every one, this run's too, nothing in the store says
|
|
904
|
+
* the stop came: the next boot reads no stamp as a first start (#844
|
|
905
|
+
* round 8, Weft) and tells nothing. Where every
|
|
906
|
+
* write refuses through the stop (the note, the notice, the store's
|
|
907
|
+
* record) and no release carries the loss (queuedNoteFirst), for a hold
|
|
908
|
+
* that has ended, the trace of the drop, with that of the notice's
|
|
909
|
+
* failure, and the log are all that is left of it: nothing else here
|
|
910
|
+
* outlives the stop.
|
|
911
|
+
*/
|
|
912
|
+
private tellNoteLost;
|
|
913
|
+
/**
|
|
914
|
+
* Write the loss notices kept (lossNotices), `author`'s or every
|
|
915
|
+
* author's, each author's in the order its losses came: one written, or
|
|
916
|
+
* whose author has ended, leaves the queue; one whose write fails stays
|
|
917
|
+
* for the next try (writeLossNotice), and that author's later ones with
|
|
918
|
+
* it, behind it. None is written while its author's writes are
|
|
919
|
+
* held (writesHeld(author)): the framework would keep it in memory and answer an
|
|
920
|
+
* empty id, which then couldn't tell a kept write from an ended author's
|
|
921
|
+
* dropped one. The release or the retry writes them. Nor is one the boot
|
|
922
|
+
* read from the store's record while whether it was written before the
|
|
923
|
+
* stop can't be read (checkLossNoticesWritten). The store's record, where
|
|
924
|
+
* it wasn't read in yet, is read first, and while it can't be, none of
|
|
925
|
+
* the persistent subconscious's is written, as one it keeps would come
|
|
926
|
+
* after it. Then the store's
|
|
927
|
+
* record of the persistent subconscious's kept notices is brought in
|
|
928
|
+
* line (writeLossRecord). A loss told for an author while its notice is
|
|
929
|
+
* being written (a listener of that write) waits behind it, written next
|
|
930
|
+
* in this pass. Each leaves its author's list just before it
|
|
931
|
+
* is written, as a deferred cancel leaves its queue, so a stop meanwhile
|
|
932
|
+
* (a listener of the write) keeps those not written yet in the store
|
|
933
|
+
* (stop), and none is written after it; one whose write that stop met and
|
|
934
|
+
* failed is kept as a loss told after the stop is (keepAfterStop). Never
|
|
935
|
+
* throws.
|
|
936
|
+
*/
|
|
937
|
+
private writeLossNotices;
|
|
938
|
+
/** Where the persistent subconscious's kept loss notices are kept: a snapshot state, beside the coordinator's others. */
|
|
939
|
+
private get lossNoticesStateId();
|
|
940
|
+
/** The persistent subconscious's kept notices (lossNotices) in the record's form, in the order kept. */
|
|
941
|
+
private persistedLossNotices;
|
|
942
|
+
/**
|
|
943
|
+
* Keep the persistent subconscious's kept loss notices in the store
|
|
944
|
+
* (`tune-out/<primary>/loss-notices`, PersistedLossNotice), as they are
|
|
945
|
+
* in memory: one kept is added, one written leaves. Only when they
|
|
946
|
+
* changed since the record was last written or read, or a write of it
|
|
947
|
+
* failed; never while writes are held (writesHeld): the release, the
|
|
948
|
+
* retry or the stop writes it then. Not over a record that couldn't be
|
|
949
|
+
* read (readLossRecord, tried again first). A write that fails, or can't
|
|
950
|
+
* be made durable at once (stateDurable), is logged, and the notices stay
|
|
951
|
+
* kept in memory, written or tried again as before;
|
|
952
|
+
* a stop meanwhile loses them. At `stop`, written whenever one is kept,
|
|
953
|
+
* held writes or not, and answers whether the record holds them. At
|
|
954
|
+
* `boot`, written where they changed, held writes or not, as the boot's
|
|
955
|
+
* stamp is (noteUnstampedStop). Never throws.
|
|
956
|
+
*/
|
|
957
|
+
private writeLossRecord;
|
|
958
|
+
/**
|
|
959
|
+
* Read the persistent subconscious's kept loss notices from the store
|
|
960
|
+
* (writeLossRecord) into memory (lossNotices), ahead of any kept since for
|
|
961
|
+
* the same author: at boot (restoreLossNotices), and, where it couldn't
|
|
962
|
+
* be read before (a boot's read threw, or a branch move), before the
|
|
963
|
+
* notices are written (writeLossNotices) and before the record is
|
|
964
|
+
* written. Answers whether it was read.
|
|
965
|
+
* One that throws is logged and answers false: nothing is written over it
|
|
966
|
+
* until it is read. A record not in this format (`{ v: 1,
|
|
967
|
+
* pendingLossNotices }`) reads as none kept, logged, and is written over
|
|
968
|
+
* at the next change; an entry this version can't read is logged and left
|
|
969
|
+
* out, so the next write drops it. Those read in wait to be checked
|
|
970
|
+
* against the subconscious's rows (lossNoticesUnchecked), as a boot's do.
|
|
971
|
+
*/
|
|
972
|
+
private readLossRecord;
|
|
973
|
+
/**
|
|
974
|
+
* Make the coordinator's own record just written (the loss record, a
|
|
975
|
+
* stamp) durable (commitDeliveries), answering whether it is: a boot reads
|
|
976
|
+
* them after a crash, which a write the store's periodic sync hadn't
|
|
977
|
+
* reached yet doesn't outlive. Left out, a write counts as durable.
|
|
978
|
+
*/
|
|
979
|
+
private stateDurable;
|
|
980
|
+
/**
|
|
981
|
+
* The persistent subconscious's rows as a boot reads them for what it was
|
|
982
|
+
* told already: its window, and its own stored rows
|
|
983
|
+
* (subconsciousStoredMessages), which hold a notice its window doesn't yet.
|
|
984
|
+
* Either read that throws is logged, with what follows (`then`), and read
|
|
985
|
+
* as none; `unread` says one did.
|
|
986
|
+
*/
|
|
987
|
+
private subconsciousRows;
|
|
988
|
+
/**
|
|
989
|
+
* Of the notices read from the store's record at boot (restoreLossNotices),
|
|
990
|
+
* those the subconscious's rows hold already (`lossNoticeId`: written,
|
|
991
|
+
* the record not brought in line before the stop) leave the record, not
|
|
992
|
+
* written again. Where its rows can't be read, they stay unchecked
|
|
993
|
+
* (lossNoticesUnchecked), and none of them is written (writeLossNotices)
|
|
994
|
+
* until a later try reads them.
|
|
995
|
+
*/
|
|
996
|
+
private checkLossNoticesWritten;
|
|
997
|
+
/** The epoch holding where a kept notice's cancel was (DeferredFor's `current`): the channel's tune-out, or the all-except hold. */
|
|
998
|
+
private epochHoldingAt;
|
|
999
|
+
/**
|
|
1000
|
+
* The holds on record, a channel's and the all-except hold (its excepted
|
|
1001
|
+
* channel, with `scope`): the registry's record of each channel's, whether
|
|
1002
|
+
* or not the channel is registered yet, as at boot it isn't
|
|
1003
|
+
* (tuneOutsOnRecord; the registered ones, listActive, where the registry
|
|
1004
|
+
* has no such list). May throw.
|
|
1005
|
+
*/
|
|
1006
|
+
private holdsOnRecord;
|
|
1007
|
+
/** Where the last stop's stamp is kept (StopStamp): a snapshot state, beside the loss notices. */
|
|
1008
|
+
private get stopStampStateId();
|
|
1009
|
+
/**
|
|
1010
|
+
* At the stop, once the loss notices are written or kept: the stamp
|
|
1011
|
+
* (StopStamp) naming the holds on record now, a channel's and the
|
|
1012
|
+
* all-except hold, whose waiting cancels this stop accounted for, written
|
|
1013
|
+
* and made durable (stateDurable), as the loss record before it is. Left
|
|
1014
|
+
* out are the epochs of a note whose loss couldn't be kept (`unaccounted`;
|
|
1015
|
+
* every persistent notice's where the store refused the record,
|
|
1016
|
+
* `recorded` false), and of one still kept in memory at the stop, which
|
|
1017
|
+
* the stamp names (`notesKept`, stopNotesKept), so the next boot tells
|
|
1018
|
+
* the subconscious of them (noteUnstampedStop), that a kept note may be
|
|
1019
|
+
* lost where that run's rows don't hold it. A stamp the store refuses too is logged: nothing
|
|
1020
|
+
* more can be done at the stop. The next boot then finds this run's own
|
|
1021
|
+
* stamp, covering no hold, where it landed, and tells the subconscious of
|
|
1022
|
+
* each hold; where the store refused that too, it finds none, which it
|
|
1023
|
+
* reads as a first start, and tells nothing. Never throws.
|
|
1024
|
+
*/
|
|
1025
|
+
private writeStopStamp;
|
|
1026
|
+
/**
|
|
1027
|
+
* At boot (resumeActiveEpochs), for the holds on record (`onRecord`, read
|
|
1028
|
+
* before any is resumed or ended): those the last stop's stamp doesn't
|
|
1029
|
+
* cover (writeStopStamp; after a crash the stamp is the one the boot
|
|
1030
|
+
* before wrote, covering none; one the store refused at a stop is that
|
|
1031
|
+
* boot's too) may have had a cancel waiting, with a note, which that stop
|
|
1032
|
+
* didn't account for. No stamp at all is a first boot on this version
|
|
1033
|
+
* (every boot writes one), not a crash: every hold counts as covered. A
|
|
1034
|
+
* hold whose waiting cancel's loss the stop kept in the store
|
|
1035
|
+
* (`stopKept`, restoreLossNotices) is accounted for. For the others, the
|
|
1036
|
+
* rows from that run on (the stamp's `runStartedAt`) say what they can
|
|
1037
|
+
* (UnstampedStop): a release that told the queued note's loss
|
|
1038
|
+
* (`lostNote`, queuedNoteFirst) needs nothing more; a release of that
|
|
1039
|
+
* epoch stored since the cancel was asked (or since the hold and the run
|
|
1040
|
+
* began) is `ran`; a note of that epoch delivered with no release since,
|
|
1041
|
+
* `delivered`; the subconscious's own `cancel_tuneout` of it answered as
|
|
1042
|
+
* waiting (askedCancelOf), `asked`; else `unknown`, told conditionally.
|
|
1043
|
+
* Each by a loss notice (`unstamped-stop`) kept and written as the others
|
|
1044
|
+
* are (writeLossNotices), with a turn to read it, kept in the store and
|
|
1045
|
+
* tried again where the store still refuses; traced as
|
|
1046
|
+
* `tune-out:stop-unrecorded` with what was `found`. A hold already told so
|
|
1047
|
+
* (its notice in the subconscious's window, or kept to be written) is told
|
|
1048
|
+
* again only what says more (FOUND_RANK), or another note. A reader fork
|
|
1049
|
+
* is told nothing: none outlives the stop. The stamp is then written again
|
|
1050
|
+
* covering no hold and naming this run's start (`runStartedAt`, and its
|
|
1051
|
+
* `branch`), so it can't cover a later stop and a crash during this run
|
|
1052
|
+
* leaves it so: last, once those notices are written or kept in the store,
|
|
1053
|
+
* and, while one is neither, naming the last stop's bound instead
|
|
1054
|
+
* (runBound), so a crash meanwhile reads the same rows again. A write that
|
|
1055
|
+
* fails is kept and tried again as the loss notices are
|
|
1056
|
+
* (writePendingMarker), and meanwhile a waiting cancel's answer says so.
|
|
1057
|
+
* A stamp that can't be read, or isn't in this version's form, covers
|
|
1058
|
+
* nothing; one whose run start is on another branch than the store's now
|
|
1059
|
+
* bounds nothing here, sequences being each branch's own, so no row is
|
|
1060
|
+
* read as that run's and each hold it doesn't cover is told conditionally
|
|
1061
|
+
* (`unknown`). Never throws.
|
|
1062
|
+
*/
|
|
1063
|
+
private noteUnstampedStop;
|
|
1064
|
+
/**
|
|
1065
|
+
* At boot, the release turns the last stop's stamp says it dropped
|
|
1066
|
+
* (StopStamp's `wakesOwed`: asked while it was under way), asked again
|
|
1067
|
+
* as the boot's wake for a release row still owed asks them (the
|
|
1068
|
+
* framework's `tune-out released (restored)` and `tune-out (restored)`,
|
|
1069
|
+
* so a row both owed and recorded is asked once), each unless this boot
|
|
1070
|
+
* asked that turn for a release of its own already. Asked once: the
|
|
1071
|
+
* boot's marker is written over that stamp. Never throws.
|
|
1072
|
+
*/
|
|
1073
|
+
private askWakesOwed;
|
|
1074
|
+
/**
|
|
1075
|
+
* noteUnstampedStop's telling, for the holds on record (`onRecord`) the
|
|
1076
|
+
* last stop's stamp doesn't cover (`covered`), reading that run's rows
|
|
1077
|
+
* from its start (`since`) to this boot's (`bootHead`), none where its
|
|
1078
|
+
* start is on another branch (`elsewhere`). May throw.
|
|
1079
|
+
*/
|
|
1080
|
+
private tellUnstampedHolds;
|
|
1081
|
+
/** The store's branch now (currentBranch), or undefined where the host names none or it can't be read. */
|
|
1082
|
+
private branchNow;
|
|
1083
|
+
/**
|
|
1084
|
+
* Whether a notice a boot derived from the last stop's stamp
|
|
1085
|
+
* (`unstamped-stop`) is kept in memory only: not written to the
|
|
1086
|
+
* subconscious yet, nor in the store's loss record (lossRecordIds).
|
|
1087
|
+
*/
|
|
1088
|
+
private stampNoticesUnkept;
|
|
1089
|
+
/**
|
|
1090
|
+
* Whether the last stop's bound (carriedBound) is still needed: a notice
|
|
1091
|
+
* this boot derived from that stamp is kept in memory only
|
|
1092
|
+
* (stampNoticesUnkept), or the boot's telling of it threw before it
|
|
1093
|
+
* finished (carriedUntold).
|
|
1094
|
+
*/
|
|
1095
|
+
private carriedNeeded;
|
|
1096
|
+
/**
|
|
1097
|
+
* Where the next boot reads this run's rows from (StopStamp's
|
|
1098
|
+
* `runStartedAt` and `branch`): this run's start, or, while that stamp's
|
|
1099
|
+
* bound is needed (carriedNeeded: a notice this boot derived from the last
|
|
1100
|
+
* stop's stamp is kept in memory only, or its telling threw), that bound
|
|
1101
|
+
* (carriedBound), so a crash then leaves the next boot reading what this
|
|
1102
|
+
* boot read.
|
|
1103
|
+
*/
|
|
1104
|
+
private runBound;
|
|
1105
|
+
/** This run's marker: a stamp covering no hold, bounded where this run's rows begin (runBound). */
|
|
1106
|
+
private runMarker;
|
|
1107
|
+
/**
|
|
1108
|
+
* The store's branch moved under this run (the framework's
|
|
1109
|
+
* followBranchMove), so the snapshot states the coordinator keeps are the
|
|
1110
|
+
* destination's now. Its stamp may cover a hold this run holds, and
|
|
1111
|
+
* bounds the rows by another run's sequence: this run's marker is written
|
|
1112
|
+
* there (writePendingMarker, tried again as at boot where it fails),
|
|
1113
|
+
* naming the destination and its head now as where this run's rows on it
|
|
1114
|
+
* begin (or where they began, on a branch this run was on before: a failed
|
|
1115
|
+
* surgery's restore, say; or this run's start, on a branch made from this
|
|
1116
|
+
* run's past it, which holds those rows: inheritedStart), so that a crash from here on reads only what
|
|
1117
|
+
* this run stored on it. The destination's kept loss notices aren't in memory: the next write
|
|
1118
|
+
* of the record reads them in first (lossRecordUnread), and writes this
|
|
1119
|
+
* run's kept ones there too; where this run keeps any, that write is
|
|
1120
|
+
* made here, before the marker, and the last stop's bound is judged by
|
|
1121
|
+
* the destination's record (carriedNeeded). Never throws.
|
|
1122
|
+
*/
|
|
1123
|
+
branchMoved(): void;
|
|
1124
|
+
/**
|
|
1125
|
+
* This run's start (runStartedAt), where `branch`, moved to, was made
|
|
1126
|
+
* from the branch this run was on (runBranch) at a point past that start
|
|
1127
|
+
* (branchOrigin): the branch holds this run's rows since then, at their
|
|
1128
|
+
* sequences. Undefined otherwise, or where the store can't say.
|
|
1129
|
+
*/
|
|
1130
|
+
private inheritedStart;
|
|
1131
|
+
/**
|
|
1132
|
+
* This run's stamp (noteUnstampedStop), written; one the store refused is
|
|
1133
|
+
* kept (`markerPending`) and tried again at each release and by the retry
|
|
1134
|
+
* timer, as the loss notices are (runDeferredCancels), never while writes
|
|
1135
|
+
* are held but at boot and at a branch move (branchMoved), until it lands
|
|
1136
|
+
* or the stop writes its own. Never throws.
|
|
1137
|
+
*/
|
|
1138
|
+
private writePendingMarker;
|
|
1139
|
+
/**
|
|
1140
|
+
* For a hold the last stop didn't stamp (noteUnstampedStop): the persistent
|
|
1141
|
+
* subconscious's own `cancel_tuneout` of it (`asks`, cancelAsksIn),
|
|
1142
|
+
* answered as waiting, since the hold began and since the last run began
|
|
1143
|
+
* (`since`). One names the hold where its result says the all-except hold
|
|
1144
|
+
* (`scope`, the call naming that scope or a channel only that hold held),
|
|
1145
|
+
* for that hold; else, for a channel's, where it names the channel (its
|
|
1146
|
+
* id, its shown name, or its server-qualified name) and its server: the
|
|
1147
|
+
* result's (`serverId`), the call's, or the qualified name's. A bare name
|
|
1148
|
+
* with no server that two holds on record answer to names neither. Answers
|
|
1149
|
+
* the first such call's sequence, and the first line, at most
|
|
1150
|
+
* NOTE_QUOTE_CHARS characters, of the first such call's note (a cancel
|
|
1151
|
+
* waiting with none takes a later call's note; a later note is dropped,
|
|
1152
|
+
* and its caller told so). Undefined where none is found.
|
|
1153
|
+
*/
|
|
1154
|
+
private askedCancelOf;
|
|
1155
|
+
/**
|
|
1156
|
+
* At boot (resumeActiveEpochs), before this boot writes any notice: a
|
|
1157
|
+
* loss told to the persistent subconscious before the stop, by a notice
|
|
1158
|
+
* (`tune-out-note-undelivered`) or in a release (`lostNote`,
|
|
1159
|
+
* queuedNoteFirst), asked for a turn to read it, which was kept in memory
|
|
1160
|
+
* only. Shown to it at rest, such a row is in its window, so the boot's
|
|
1161
|
+
* wake for rows its window is still owed doesn't count it; one with no
|
|
1162
|
+
* turn of the subconscious's after it in its window (unansweredIn) gets
|
|
1163
|
+
* that turn asked for again, once per hold, for the reason the notice
|
|
1164
|
+
* asked it for. Never throws.
|
|
1165
|
+
*/
|
|
1166
|
+
private askTurnsForUnreadLosses;
|
|
1167
|
+
/**
|
|
1168
|
+
* At boot (resumeActiveEpochs): the loss notices a stop left kept in the
|
|
1169
|
+
* store for the persistent subconscious (writeLossRecord) are written now,
|
|
1170
|
+
* as tellNoteLost writes them, each with a turn to read it
|
|
1171
|
+
* (writeLossNotice); one written leaves the record, and one whose write
|
|
1172
|
+
* fails stays, kept and tried again at the next release and at the retry,
|
|
1173
|
+
* which this arms. A notice whose author is no agent the framework writes
|
|
1174
|
+
* to now reaches no one, which is traced (`author-gone`), and leaves the
|
|
1175
|
+
* record. One whose row the subconscious's rows hold already
|
|
1176
|
+
* (`lossNoticeId`: written, its record not brought in line before the
|
|
1177
|
+
* stop) leaves the record, not written again; where those rows can't be
|
|
1178
|
+
* read, none is written, kept in the record, until a retry reads them
|
|
1179
|
+
* (checkLossNoticesWritten). The notices of an unrecorded stop written
|
|
1180
|
+
* here count as told (restoredTold). Never throws.
|
|
1181
|
+
*/
|
|
1182
|
+
private restoreLossNotices;
|
|
1183
|
+
/**
|
|
1184
|
+
* One loss notice (LossNotice) written into its author's context: a
|
|
1185
|
+
* host-framed notice, as the coordinator's other notices to a reader are,
|
|
1186
|
+
* and for the persistent subconscious a turn to read it, as they ask: the
|
|
1187
|
+
* loss can come with no turn of its (a release, a retry, a cancel it
|
|
1188
|
+
* didn't make), and one asked for with a cancel's own notice is the same
|
|
1189
|
+
* turn. A reader fork still alive is in its run, which takes the notice
|
|
1190
|
+
* at its next point. Answers what became of it. `failed`: its write
|
|
1191
|
+
* threw, or its words couldn't be put together; it is logged, traced at
|
|
1192
|
+
* its first failure (`tune-out:note-loss-untold`, `write-failed`), and
|
|
1193
|
+
* kept. `gone`: the framework wrote nothing, answering an empty id, as it
|
|
1194
|
+
* does for a write for an agent it has no registration of, a reader fork
|
|
1195
|
+
* whose run has ended among them: the loss reaches no one, which is
|
|
1196
|
+
* logged and traced (`author-gone`). It is written only while writes
|
|
1197
|
+
* aren't held (writeLossNotices), so an empty id is no write kept in
|
|
1198
|
+
* memory, unless this write began such a hold (a context manager that
|
|
1199
|
+
* refuses its work from it on), which writesHeld then says: memory alone
|
|
1200
|
+
* holds it then, which a crash or a stop loses, so it answers `failed`,
|
|
1201
|
+
* kept in the store's record and written again once writes are stored,
|
|
1202
|
+
* unless the kept write is stored then: the framework says so
|
|
1203
|
+
* (heldWriteStored), and it leaves the notices kept, written once. A stop
|
|
1204
|
+
* before then keeps it in the store, and a boot that finds its row
|
|
1205
|
+
* (`lossNoticeId`) leaves the record (restoreLossNotices). writesHeld is asked about
|
|
1206
|
+
* the author too, so a reader fork still registered whose own context
|
|
1207
|
+
* manager refuses its work is told apart from one whose run has ended:
|
|
1208
|
+
* the notice stays kept for it, and isn't written while that lasts
|
|
1209
|
+
* (writeLossNotices). A turn that can't be asked for is logged. Never
|
|
1210
|
+
* throws.
|
|
1211
|
+
*/
|
|
1212
|
+
private writeLossNotice;
|
|
1213
|
+
/**
|
|
1214
|
+
* The queued cancel of this hold (`epochId`, deferCancel), off the queue:
|
|
1215
|
+
* a cancel that ends the hold first leaves it nothing to end, and
|
|
1216
|
+
* delivers its note: the persistent subconscious's before its release
|
|
1217
|
+
* (queuedNoteFirst), a reader fork's after the end (deliverQueuedNote). One queued for an earlier epoch
|
|
1218
|
+
* there is dropped, told (dropDeferred). The retry timer goes with the
|
|
1219
|
+
* last one, unless a loss notice waits for it (lossNotices).
|
|
1220
|
+
*/
|
|
1221
|
+
private takeDeferred;
|
|
1222
|
+
/**
|
|
1223
|
+
* A reader's note to the resident, verbatim: the persistent subconscious's
|
|
1224
|
+
* under its own name, a reader fork's (`author`) as attributed mail under
|
|
1225
|
+
* the fork's name and incarnation, never the resident's voice. `metadata`
|
|
1226
|
+
* is the subconscious's row's; a fork's mail has it without the server.
|
|
1227
|
+
* Answers how it went, from what the write itself answered: `stored`, or
|
|
1228
|
+
* `kept`, where the framework kept the write in memory (an empty id: a
|
|
1229
|
+
* surgery's hold, or a context manager refusing its work), to store it at
|
|
1230
|
+
* their release; false where neither is configured to deliver it. A
|
|
1231
|
+
* write stored, and writes held only after it, is `stored`: whether
|
|
1232
|
+
* writes are held now says nothing of a write already made (Weft, #844).
|
|
1233
|
+
* A fork's mail, which the registry keeps until it is delivered, or a
|
|
1234
|
+
* write whose answer isn't known, counts as `stored`.
|
|
1235
|
+
*/
|
|
1236
|
+
private deliverReaderNote;
|
|
1237
|
+
/**
|
|
1238
|
+
* The note a queued cancel carries, delivered once its hold has ended, as
|
|
1239
|
+
* a cancel's release delivers its caller's (deliverReaderNote): by
|
|
1240
|
+
* another cancel that ended the hold first (takeDeferred, `by` another),
|
|
1241
|
+
* a reader fork's, the subconscious's going out before that cancel's
|
|
1242
|
+
* release instead (queuedNoteFirst), or by the queued cancel's own run
|
|
1243
|
+
* (`by` itself). One that can't be is told lost, with the reason, on
|
|
1244
|
+
* stderr, as a trace and to its author where it still exists
|
|
1245
|
+
* (dropDeferred), and the cancel that ended the hold goes on: no caller
|
|
1246
|
+
* waits on it to be told. One settled already, delivered or told lost
|
|
1247
|
+
* (an earlier end whose release then failed), isn't delivered again.
|
|
1248
|
+
* Answers whether it was delivered now.
|
|
1249
|
+
*/
|
|
1250
|
+
private deliverQueuedNote;
|
|
1251
|
+
/**
|
|
1252
|
+
* A queued cancel's note (deliverReaderNote), delivered now and settled,
|
|
1253
|
+
* or, where it can't be, why (`lost`, for the caller to tell); undefined
|
|
1254
|
+
* where it has none, or one settled already. One delivered while writes
|
|
1255
|
+
* were held, and lost when they were stored (lostAtRelease), is lost with
|
|
1256
|
+
* that error, `by` this caller, and isn't written again.
|
|
1257
|
+
*/
|
|
1258
|
+
private noteNow;
|
|
1259
|
+
/**
|
|
1260
|
+
* Before a cancel writes its release, the note of a cancel of this hold
|
|
1261
|
+
* still queued (deferCancel; its own release failed since, say) for the
|
|
1262
|
+
* persistent subconscious: delivered now, ahead of the release, where a
|
|
1263
|
+
* reader fork's goes out after the end (deliverQueuedNote), so that the
|
|
1264
|
+
* release can say so where it can't be (lossInRelease). The loss is then
|
|
1265
|
+
* stored with the release and made durable with it, or not at all: the
|
|
1266
|
+
* hold doesn't end without the release, which throws, the hold staying in
|
|
1267
|
+
* force and the queued cancel waiting on with its note, not lost. A
|
|
1268
|
+
* notice to the subconscious and the store's record of it are writes of
|
|
1269
|
+
* their own, which can be refused while the release is stored, leaving
|
|
1270
|
+
* nothing of the loss after a stop; the subconscious's window holds the
|
|
1271
|
+
* residents' rows, the release among them, so no notice is written too.
|
|
1272
|
+
* Answers the queued cancel and, where its note couldn't be delivered,
|
|
1273
|
+
* why; undefined where there is no such note: none queued, one for
|
|
1274
|
+
* another epoch (takeDeferred drops it), one with no note or one settled
|
|
1275
|
+
* already, or no subconscious (reader forks read); nor one written while
|
|
1276
|
+
* writes were held and lost when they were stored (lostAtRelease), which
|
|
1277
|
+
* isn't written again: it is told lost after the end instead, as a reader
|
|
1278
|
+
* fork's is (deliverQueuedNote).
|
|
1279
|
+
*/
|
|
1280
|
+
private queuedNoteFirst;
|
|
1281
|
+
/**
|
|
1282
|
+
* The words a cancel's release adds for a queued cancel's note it
|
|
1283
|
+
* couldn't deliver (queuedNoteFirst): whose note it was, the hold
|
|
1284
|
+
* (`hold`, a `tune-out` or a `hold`), the resident it was for, and why,
|
|
1285
|
+
* as a notice to the note's author says them (writeLossNotice). The
|
|
1286
|
+
* residents and the subconscious read them there.
|
|
1287
|
+
*/
|
|
1288
|
+
private lossInRelease;
|
|
1289
|
+
/**
|
|
1290
|
+
* The turn a release asks for (`whose`: the resident's, or the
|
|
1291
|
+
* subconscious's for its report), as requestInference asks it; one asked
|
|
1292
|
+
* while the host's stop is under way (stopTimers, the stop proper not
|
|
1293
|
+
* yet run) is dropped with the stop's closed queue, so the stop's stamp
|
|
1294
|
+
* records it (`wakesOwed`) and the next boot asks it again.
|
|
1295
|
+
*/
|
|
1296
|
+
private askReleaseTurn;
|
|
1297
|
+
/** A turn for the persistent subconscious to read the loss of its note that a release told (queuedNoteFirst), as a notice asks for one (writeLossNotice). */
|
|
1298
|
+
private askTurnForLoss;
|
|
1299
|
+
/**
|
|
1300
|
+
* Arm the one retry of the deferred cancels and the loss notices not
|
|
1301
|
+
* written (lossNotices), and of the loss record not read yet
|
|
1302
|
+
* (lossRecordUnread), unless it is armed; it arms itself again while
|
|
1303
|
+
* one still waits.
|
|
1304
|
+
*/
|
|
1305
|
+
private armDeferredRetry;
|
|
1306
|
+
/**
|
|
1307
|
+
* A cancel that waits for the writes kept in memory (deferCancel), its
|
|
1308
|
+
* hold in force: one asked for while writes are held, or one whose release
|
|
1309
|
+
* met a hold as it was written. A queued cancel's own run (`asQueued`)
|
|
1310
|
+
* goes back on the queue as it is, its note and askers with it (requeue).
|
|
1311
|
+
*/
|
|
1312
|
+
private waitForWrites;
|
|
317
1313
|
/** Whether a reader (persistent subconscious or reader forks) attends holds. */
|
|
318
1314
|
hasReader(): boolean;
|
|
1315
|
+
/**
|
|
1316
|
+
* End a tune-out: system-framed backlog dump into the resident's window
|
|
1317
|
+
* (capped), stored and made durable before the epoch's end is recorded,
|
|
1318
|
+
* then the lifecycle notice and one wake for the resident.
|
|
1319
|
+
* `subconsciousNote` is the subconscious's own text (from its
|
|
1320
|
+
* cancel_tuneout call) — delivered verbatim under its name, never
|
|
1321
|
+
* synthesized here. A dump that can't be made durable (commitDeliveries)
|
|
1322
|
+
* throws, the tune-out still in force, and a later cancel dumps what no
|
|
1323
|
+
* earlier dump of the epoch covered (`released`). While the framework
|
|
1324
|
+
* keeps writes in memory (writesHeld: a surgery's hold, a manager refusing
|
|
1325
|
+
* its work), nothing is dumped or ended yet: the cancel waits, the
|
|
1326
|
+
* tune-out in force, and runs once the writes are stored, or told of
|
|
1327
|
+
* where storing one fails (runDeferredCancels). It answers `deferred`
|
|
1328
|
+
* then.
|
|
1329
|
+
*/
|
|
319
1330
|
cancel(serverId: string, channelId: string, source: string, reason: string, subconsciousNote?: string,
|
|
320
1331
|
/** `reader: 'forks'`: the reader fork whose note this is. */
|
|
321
1332
|
noteAuthor?: string,
|
|
322
1333
|
/** The lifecycle state the channel returns to (a tool close ends in 'closed'). */
|
|
323
1334
|
nextState?: 'open' | 'closed'): {
|
|
324
1335
|
ok: true;
|
|
1336
|
+
deferred?: true;
|
|
1337
|
+
noteDropped?: true;
|
|
325
1338
|
} | {
|
|
326
1339
|
ok: false;
|
|
327
1340
|
error: string;
|
|
328
1341
|
};
|
|
1342
|
+
/**
|
|
1343
|
+
* cancel's work. `asQueued`: the queued cancel this call runs
|
|
1344
|
+
* (runDeferredCancels), whose note (`subconsciousNote`) is delivered as a
|
|
1345
|
+
* queued one is (deliverQueuedNote), told lost (dropDeferred) where it
|
|
1346
|
+
* can't be, the cancel going on.
|
|
1347
|
+
*/
|
|
1348
|
+
private endTuneOut;
|
|
1349
|
+
/** How many stored messages `keep` keeps the subconscious hasn't been shown (the hook's count), 0 where the host can't say. */
|
|
1350
|
+
private unseenBySubconscious;
|
|
329
1351
|
/**
|
|
330
1352
|
* Consulted by the framework for every incoming channel message BEFORE
|
|
331
1353
|
* storage. Null = channel not tuned out (proceed normally). Otherwise the
|
|
@@ -344,6 +1366,19 @@ export declare class TuneOutCoordinator {
|
|
|
344
1366
|
/** The channel unprefixed speech lands in while an all-except hold is active, with its server, else null. */
|
|
345
1367
|
focusChannel(): ChannelRef | null;
|
|
346
1368
|
private get scopeStateId();
|
|
1369
|
+
/**
|
|
1370
|
+
* End every hold on record and deliver each backlog to the resident: the
|
|
1371
|
+
* per-channel holds, then the all-except scope. For a host with no reader
|
|
1372
|
+
* (AgentFramework.releaseTuneOutsWithoutReader) and a reader that ended; a
|
|
1373
|
+
* hold whose end fails stays on record, and says so in the log. A
|
|
1374
|
+
* per-channel hold ends under its own source, so an agent's tune-out keeps
|
|
1375
|
+
* the agent's provenance (the housekeeping guard reads it); `source` is the
|
|
1376
|
+
* all-except scope's.
|
|
1377
|
+
*/
|
|
1378
|
+
releaseAll(source: string, reason: string, options?: {
|
|
1379
|
+
retry?: boolean;
|
|
1380
|
+
attempt?: number;
|
|
1381
|
+
}): void;
|
|
347
1382
|
getAllExcept(): AllExceptState | null;
|
|
348
1383
|
private writeScope;
|
|
349
1384
|
enterAllExcept(except: {
|
|
@@ -375,12 +1410,24 @@ export declare class TuneOutCoordinator {
|
|
|
375
1410
|
private clearScopeTimers;
|
|
376
1411
|
/** Channels held by the scope (not by their own epoch) with the count held under it. */
|
|
377
1412
|
private scopeHeldCounts;
|
|
1413
|
+
/**
|
|
1414
|
+
* End the all-except hold: one release notice with a per-channel backlog
|
|
1415
|
+
* (each capped), stored and made durable before the hold's end is
|
|
1416
|
+
* recorded, as a channel's cancel does, then the reader's note if any,
|
|
1417
|
+
* one wake for the resident, and the reader's own look at what it had not
|
|
1418
|
+
* seen. While the framework keeps writes in memory it waits, as cancel
|
|
1419
|
+
* does.
|
|
1420
|
+
*/
|
|
378
1421
|
cancelAllExcept(source: string, reason: string, note?: string, noteAuthor?: string): {
|
|
379
1422
|
ok: true;
|
|
1423
|
+
deferred?: true;
|
|
1424
|
+
noteDropped?: true;
|
|
380
1425
|
} | {
|
|
381
1426
|
ok: false;
|
|
382
1427
|
error: string;
|
|
383
1428
|
};
|
|
1429
|
+
/** cancelAllExcept's work; `asQueued` as endTuneOut's. */
|
|
1430
|
+
private endAllExcept;
|
|
384
1431
|
/** What is held right now — per-channel epochs and the scope — without releasing. */
|
|
385
1432
|
check(opts?: {
|
|
386
1433
|
peek?: {
|
|
@@ -413,16 +1460,20 @@ export declare class TuneOutCoordinator {
|
|
|
413
1460
|
/**
|
|
414
1461
|
* One subconscious turn: a system-framed trigger notice (bracket style —
|
|
415
1462
|
* what happened, never what to say) plus standing dispositions, then an
|
|
416
|
-
* inference request.
|
|
1463
|
+
* inference request. Its view supplies the actual traffic: the merged
|
|
1464
|
+
* record while its window is the record, and with the presentation index
|
|
1465
|
+
* (#291) what its window holds, which takes what it hasn't been shown at
|
|
1466
|
+
* the turn's start, the notice included.
|
|
417
1467
|
*/
|
|
418
1468
|
private invokeSubconscious;
|
|
1469
|
+
/** How many of the writes the framework keeps in memory (getSurgeryHeldMessages) `keep` keeps; 0 where they can't be read. */
|
|
1470
|
+
private keptInMemory;
|
|
419
1471
|
/**
|
|
420
|
-
* Count again, from the held messages
|
|
421
|
-
*
|
|
422
|
-
*
|
|
423
|
-
*
|
|
424
|
-
*
|
|
425
|
-
* Nothing holding the channel leaves no count.
|
|
1472
|
+
* Count again, from the held messages (all stored, #291), those the reader
|
|
1473
|
+
* of the epoch holding this channel now hasn't looked at: for reader
|
|
1474
|
+
* forks, those no fork was handed; for the persistent subconscious, those
|
|
1475
|
+
* held since its last look (lastLooks). Nothing holding the channel leaves
|
|
1476
|
+
* no count.
|
|
426
1477
|
*/
|
|
427
1478
|
private rebuildTally;
|
|
428
1479
|
private get lastLooksStateId();
|
|
@@ -442,16 +1493,14 @@ export declare class TuneOutCoordinator {
|
|
|
442
1493
|
/**
|
|
443
1494
|
* `reader: 'forks'`: hand the framework one invocation. The backlog is
|
|
444
1495
|
* the epoch's held messages not yet handed to any fork — each is
|
|
445
|
-
* delivered to exactly one reader —
|
|
446
|
-
* queued behind the resident's turn, plus the standing dispositions. A
|
|
1496
|
+
* delivered to exactly one reader — plus the standing dispositions. A
|
|
447
1497
|
* cadence look with nothing new is skipped. True when a fork was asked for.
|
|
448
1498
|
*/
|
|
449
1499
|
private invokeReaderFork;
|
|
450
1500
|
/**
|
|
451
|
-
* What no reader fork has read yet, of the given held messages
|
|
452
|
-
*
|
|
453
|
-
*
|
|
454
|
-
* the queued ones no fork was handed, or a failed fork returned.
|
|
1501
|
+
* What no reader fork has read yet, of the given held messages, oldest
|
|
1502
|
+
* first: those past the epoch's cursor for the channel, plus those a
|
|
1503
|
+
* failed fork returned.
|
|
455
1504
|
*/
|
|
456
1505
|
private unhandedBacklog;
|
|
457
1506
|
/**
|
|
@@ -466,23 +1515,16 @@ export declare class TuneOutCoordinator {
|
|
|
466
1515
|
* only reader its messages had: one late fork is handed them instead
|
|
467
1516
|
* (lateFork). Returns how many went back or to the late fork.
|
|
468
1517
|
*/
|
|
469
|
-
readerFailed(invocation: Pick<ReaderInvocation, 'serverId' | 'channelId' | 'epochId' | 'backlog'
|
|
1518
|
+
readerFailed(invocation: Pick<ReaderInvocation, 'serverId' | 'channelId' | 'epochId' | 'backlog'>): number;
|
|
470
1519
|
/**
|
|
471
1520
|
* A fork that failed after its epoch ended: one late fork is handed what it
|
|
472
1521
|
* was, with a notice saying a reader handed them failed after the tune-out
|
|
473
|
-
* ended.
|
|
474
|
-
* handed
|
|
475
|
-
* reader that keeps failing costs one more fork, not a chain
|
|
476
|
-
* Returns how many the late fork was handed.
|
|
1522
|
+
* ended. Every held message is stored as it arrives (#291), so what it was
|
|
1523
|
+
* handed is what the late fork is. A late fork's own failure derives no
|
|
1524
|
+
* other, so a reader that keeps failing costs one more fork, not a chain
|
|
1525
|
+
* of them. Returns how many the late fork was handed.
|
|
477
1526
|
*/
|
|
478
1527
|
private lateFork;
|
|
479
|
-
/**
|
|
480
|
-
* The held messages still queued behind the resident's turn that `keep`
|
|
481
|
-
* keeps, oldest first, with their write ids. One the host gives no id for
|
|
482
|
-
* is left to reach a reader once it is stored: without the id, its stored
|
|
483
|
-
* row couldn't be told from a message no reader has had.
|
|
484
|
-
*/
|
|
485
|
-
private queuedHeld;
|
|
486
1528
|
private dispositionsCache;
|
|
487
1529
|
private get dispositionsStateId();
|
|
488
1530
|
/**
|
|
@@ -540,11 +1582,49 @@ export declare class TuneOutCoordinator {
|
|
|
540
1582
|
private notTunedOut;
|
|
541
1583
|
/**
|
|
542
1584
|
* The reader ended, not the framework: its turns stop (cadence and
|
|
543
|
-
* coalescing wakes)
|
|
544
|
-
*
|
|
1585
|
+
* coalescing wakes). The framework then releases every hold with
|
|
1586
|
+
* releaseAll ("its reader ended"); a hold whose release fails keeps its end
|
|
1587
|
+
* time, which releases it to the resident with no reader.
|
|
545
1588
|
*/
|
|
546
1589
|
stopReader(): void;
|
|
547
|
-
/**
|
|
1590
|
+
/**
|
|
1591
|
+
* The stop's keeping of the loss notices kept (stop): the persistent
|
|
1592
|
+
* subconscious's in the store (writeLossRecord), the stop stamped
|
|
1593
|
+
* (writeStopStamp, leaving out `unaccounted`) at the stop (`stamp`
|
|
1594
|
+
* 'stop'), or again where the store refused the record (`unrecorded`),
|
|
1595
|
+
* and each logged and dropped from memory. Never throws.
|
|
1596
|
+
*/
|
|
1597
|
+
private keepAtStop;
|
|
1598
|
+
/**
|
|
1599
|
+
* A loss told once the stop had kept what it found (a trace listener's
|
|
1600
|
+
* stop, during a queued cancel's run or a notice's write, that found the
|
|
1601
|
+
* cancel or the notice off its queue): kept as the stop keeps those
|
|
1602
|
+
* (keepAtStop), the store's record read in again first, so that what the
|
|
1603
|
+
* stop kept there stays, and the stamp written again, its hold left out,
|
|
1604
|
+
* where the store refuses the record. Never throws.
|
|
1605
|
+
*/
|
|
1606
|
+
private keepAfterStop;
|
|
1607
|
+
/**
|
|
1608
|
+
* The timers quieted, at the start of the framework's stop: a hold's end
|
|
1609
|
+
* time, a reader's cadence and wake, a release's or a waiting cancel's
|
|
1610
|
+
* retry. Nothing else stops: a waiting cancel still runs when the
|
|
1611
|
+
* framework stores the writes it waits for (runDeferredCancels), which the
|
|
1612
|
+
* stop's wait for an operator's operation can let happen; then stop()
|
|
1613
|
+
* tells and keeps what is left (Weft's hold 2, #844). Never throws.
|
|
1614
|
+
*/
|
|
1615
|
+
stopTimers(): void;
|
|
1616
|
+
/**
|
|
1617
|
+
* Stop all timers (framework shutdown), tell each waiting cancel's note
|
|
1618
|
+
* lost (one still kept in memory left for the next boot instead, its hold
|
|
1619
|
+
* out of the stamp: a release after the stop may store it), keep the
|
|
1620
|
+
* persistent subconscious's notices in the store, and
|
|
1621
|
+
* stamp the stop (writeStopStamp). A second stop stamps nothing: the
|
|
1622
|
+
* first one's notices are no longer in memory to say what it kept. The
|
|
1623
|
+
* framework calls it once its stop has waited for an operator's
|
|
1624
|
+
* operations, so a hold that keeps a waiting cancel's writes, released
|
|
1625
|
+
* during that wait, lets the cancel run first (stopTimers, before the
|
|
1626
|
+
* wait, quiets the timers).
|
|
1627
|
+
*/
|
|
548
1628
|
stop(): void;
|
|
549
1629
|
}
|
|
550
1630
|
//# sourceMappingURL=coordinator.d.ts.map
|