counterparts 0.3.11 → 0.3.13
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/CHANGELOG.md +326 -0
- package/docs/QUICKSTART.md +5 -0
- package/docs/README.md +2 -2
- package/docs/module-map.md +3 -3
- package/package.json +1 -1
- package/src/adapters/claude-code/CONTRACT.md +36 -10
- package/src/adapters/claude-code/INTERFACE-GAPS.md +116 -16
- package/src/adapters/claude-code/NOTES.md +182 -0
- package/src/adapters/claude-code/bin/hook.ts +46 -12
- package/src/adapters/claude-code/bin/runner.ts +7 -1
- package/src/adapters/claude-code/doctor.ts +632 -18
- package/src/adapters/claude-code/hooks.ts +61 -16
- package/src/adapters/claude-code/index.ts +11 -0
- package/src/adapters/claude-code/night-run.ts +150 -14
- package/src/adapters/claude-code/transcript.ts +268 -1
- package/src/adapters/cli/CONTRACT.md +5 -0
- package/src/adapters/cli/INTERFACE-GAPS.md +8 -4
- package/src/adapters/cli/NOTES.md +111 -0
- package/src/adapters/cli/commands.ts +134 -92
- package/src/adapters/cli/dream-core.ts +57 -42
- package/src/adapters/cli/export.ts +320 -21
- package/src/adapters/cli/help.ts +2 -1
- package/src/adapters/cli/index.ts +1 -0
- package/src/adapters/cli/install.ts +39 -7
- package/src/adapters/cli/mechanisms.ts +7 -1
- package/src/adapters/cli/uninstall.ts +13 -5
- package/src/adapters/cli/wire.ts +189 -63
- package/src/adapters/config.ts +2 -0
- package/src/adapters/dashboard/INTERFACE-GAPS.md +10 -1
- package/src/adapters/dashboard/NOTES.md +79 -0
- package/src/adapters/dashboard/registries.ts +34 -2
- package/src/adapters/dashboard/web/README.md +19 -14
- package/src/adapters/dashboard/web/actions.ts +23 -1
- package/src/adapters/dashboard/web/flow.ts +14 -0
- package/src/adapters/dashboard/web/lanes.ts +10 -0
- package/src/adapters/dashboard/web/narrate.ts +88 -2
- package/src/adapters/dashboard/web/pages/flow/sections/fired.js +1 -0
- package/src/adapters/dashboard/web/pages/health/sections/checks.js +2 -0
- package/src/adapters/dashboard/web/pages/health/sections/wake.js +3 -1
- package/src/adapters/dashboard/web/pages/memories/memories.css +17 -4
- package/src/adapters/dashboard/web/pages/memories/row.js +37 -21
- package/src/adapters/dashboard/web/pages/memories/sections/search.js +279 -60
- package/src/adapters/dashboard/web/pages/memories/state.js +2 -1
- package/src/adapters/dashboard/web/server.ts +0 -5
- package/src/adapters/dashboard/web/shared/memory-marks.css +7 -0
- package/src/adapters/dashboard/web/shared/memory-marks.js +33 -0
- package/src/adapters/dashboard/web/shared/memory-modal.js +5 -3
- package/src/adapters/dashboard/web/views/health.ts +21 -3
- package/src/adapters/dashboard/web/views/search.ts +4 -45
- package/src/adapters/dashboard/web/views.ts +2 -2
- package/src/adapters/fired.ts +430 -28
- package/src/adapters/host-wiring.ts +300 -0
- package/src/adapters/hosts.ts +11 -0
- package/src/adapters/lifecycle.ts +42 -2
- package/src/adapters/log/index.ts +9 -0
- package/src/adapters/mcp/CONTRACT.md +151 -11
- package/src/adapters/mcp/INTERFACE-GAPS.md +24 -2
- package/src/adapters/mcp/NOTES.md +313 -1
- package/src/adapters/mcp/bin/serve.ts +74 -1
- package/src/adapters/mcp/deliberate.ts +169 -651
- package/src/adapters/mcp/facts.ts +1094 -0
- package/src/adapters/mcp/index.ts +25 -7
- package/src/adapters/mcp/meaning.ts +1610 -0
- package/src/adapters/mcp/server.ts +835 -150
- package/src/adapters/mcp/stdio.ts +3 -1
- package/src/adapters/mcp/stood-down.ts +51 -0
- package/src/adapters/mcp/tools.ts +167 -41
- package/src/adapters/plugin-run.sh +133 -0
- package/src/adapters/plugin.ts +329 -0
- package/src/adapters/sessions.ts +18 -4
- package/src/core/associate/CONTRACT.md +2 -1
- package/src/core/associate/INTERFACE-GAPS.md +6 -1
- package/src/core/associate/NOTES.md +45 -0
- package/src/core/briefing.ts +12 -3
- package/src/core/contradictions.ts +184 -0
- package/src/core/counterpart.ts +797 -51
- package/src/core/dream/CONTRACT.md +36 -4
- package/src/core/dream/INTERFACE-GAPS.md +29 -6
- package/src/core/dream/NOTES.md +107 -0
- package/src/core/dream/feeling-weeks.ts +198 -0
- package/src/core/dream/index.ts +109 -18
- package/src/core/dream/reflect.ts +346 -87
- package/src/core/dream/tunables.ts +24 -4
- package/src/core/encode/INTERFACE-GAPS.md +3 -1
- package/src/core/encode/NOTES.md +7 -0
- package/src/core/encode/words.ts +45 -0
- package/src/core/fit/INTERFACE-GAPS.md +8 -2
- package/src/core/fit/NOTES.md +39 -1
- package/src/core/fit/index.ts +40 -0
- package/src/core/handoff/CONTRACT.md +37 -2
- package/src/core/handoff/INTERFACE-GAPS.md +10 -0
- package/src/core/handoff/NOTES.md +72 -0
- package/src/core/handoff/index.ts +214 -12
- package/src/core/handoff/last-here.ts +6 -4
- package/src/core/mint.ts +12 -2
- package/src/core/physics/CONTRACT.md +14 -2
- package/src/core/physics/NOTES.md +33 -1
- package/src/core/physics/index.ts +28 -5
- package/src/core/prospective/CONTRACT.md +45 -6
- package/src/core/prospective/INTERFACE-GAPS.md +4 -0
- package/src/core/prospective/NOTES.md +138 -0
- package/src/core/prospective/derive.ts +33 -5
- package/src/core/prospective/index.ts +90 -5
- package/src/core/prospective/windows.ts +72 -1
- package/src/core/recall/CONTRACT.md +31 -12
- package/src/core/recall/INTERFACE-GAPS.md +28 -4
- package/src/core/recall/NOTES.md +70 -1
- package/src/core/recall/feeling-ask.ts +10 -1
- package/src/core/recall/index.ts +3 -1
- package/src/core/recall/probe.ts +58 -0
- package/src/core/recall/session.ts +46 -2
- package/src/core/recall/time-ask.ts +487 -0
- package/src/core/remember/CONTRACT.md +4 -1
- package/src/core/remember/INTERFACE-GAPS.md +9 -1
- package/src/core/remember/NOTES.md +8 -0
- package/src/core/remember/proposals.ts +47 -5
- package/src/core/revision.ts +18 -1
- package/src/core/schemas/CONTRACT.md +21 -1
- package/src/core/schemas/INTERFACE-GAPS.md +20 -2
- package/src/core/schemas/NOTES.md +144 -0
- package/src/core/schemas/aliases.ts +55 -5
- package/src/core/schemas/index.ts +93 -1
- package/src/core/schemas/types.ts +2 -0
- package/src/core/self/CONTRACT.md +32 -5
- package/src/core/self/INTERFACE-GAPS.md +7 -2
- package/src/core/self/NOTES.md +102 -1
- package/src/core/self/behind.ts +43 -3
- package/src/core/self/briefing.ts +12 -2
- package/src/core/self/chapter-address.ts +254 -0
- package/src/core/self/episodes.ts +27 -0
- package/src/core/self/index.ts +83 -8
- package/src/core/self/page.ts +88 -0
- package/src/core/self/tunables.ts +5 -0
- package/src/core/self/work.ts +35 -2
- package/src/core/self/writer.ts +30 -0
- package/src/core/sleep/INTERFACE-GAPS.md +22 -3
- package/src/core/sleep/NOTES.md +20 -1
- package/src/core/sleep/consolidate.ts +59 -7
- package/src/core/sleep/index.ts +3 -0
- package/src/core/sleep/prune.ts +6 -2
- package/src/core/sleep/types.ts +7 -0
- package/src/core/store/CONTRACT.md +16 -0
- package/src/core/store/NOTES.md +66 -0
- package/src/core/store/feelings.ts +14 -1
- package/src/core/store/index.ts +483 -16
- package/src/core/store/operational.ts +95 -2
- package/src/core/store/owner-op-seam.ts +23 -0
- package/src/core/time.ts +152 -0
- package/tools/install-loop/run.sh +48 -12
- package/src/adapters/dashboard/web/pages/memories/fold.js +0 -53
package/src/core/counterpart.ts
CHANGED
|
@@ -47,13 +47,18 @@ import { UNRESOLVED_META_KEY, mintProposal } from "./mint.js";
|
|
|
47
47
|
import type { MintResult } from "./mint.js";
|
|
48
48
|
import { isObserver } from "./observer.js";
|
|
49
49
|
import type { Stance } from "./observer.js";
|
|
50
|
-
import { Prospective, DATE_LINEAGE_MAX, DATE_MOVED_TO_META, cueModeOf } from "./prospective/index.js";
|
|
50
|
+
import { Prospective, DATE_LINEAGE_MAX, DATE_MOVED_TO_META, cueModeOf, recurrenceOf } from "./prospective/index.js";
|
|
51
51
|
import type { PlainDue } from "./prospective/index.js";
|
|
52
52
|
import {
|
|
53
|
+
ASKED_KIND,
|
|
54
|
+
ASKED_MAX,
|
|
55
|
+
askedTurn,
|
|
53
56
|
Recall,
|
|
54
57
|
isConfidential,
|
|
58
|
+
judgedThrough,
|
|
55
59
|
loadGateState,
|
|
56
60
|
loadSessionSemantic,
|
|
61
|
+
markJudged,
|
|
57
62
|
saveSessionSemantic,
|
|
58
63
|
} from "./recall/index.js";
|
|
59
64
|
import { resolveReferences } from "./recall/reference.js";
|
|
@@ -61,6 +66,7 @@ import type { ReferenceCandidate } from "./recall/reference.js";
|
|
|
61
66
|
import type {
|
|
62
67
|
CandidateVerdict,
|
|
63
68
|
CreditResult,
|
|
69
|
+
GateState,
|
|
64
70
|
RecallDecision,
|
|
65
71
|
Turn as RecallTurn,
|
|
66
72
|
RecallResult,
|
|
@@ -112,8 +118,15 @@ import type {
|
|
|
112
118
|
import { recallTurn } from "./retrieval.js";
|
|
113
119
|
import { applyRevision } from "./revision.js";
|
|
114
120
|
import type { RevisionApplication } from "./revision.js";
|
|
115
|
-
import {
|
|
116
|
-
|
|
121
|
+
import {
|
|
122
|
+
CONTRADICTION_HELD_EVENT,
|
|
123
|
+
heldView,
|
|
124
|
+
settle as settleContradiction,
|
|
125
|
+
undo as undoContradiction,
|
|
126
|
+
updateRelatedness,
|
|
127
|
+
writeNeighbours,
|
|
128
|
+
} from "./contradictions.js";
|
|
129
|
+
import type { HeldUpdate, Neighbour, SettleInput, SettleOutcome, UndoOutcome } from "./contradictions.js";
|
|
117
130
|
import { Schemas } from "./schemas/index.js";
|
|
118
131
|
import {
|
|
119
132
|
HANDOFF_CLEARED_EVENT,
|
|
@@ -130,26 +143,33 @@ import { CLAIM_CHAPTER, askFromStretch, chapterClaims, claimUnwritten, sessionSt
|
|
|
130
143
|
import { LAST_HERE_LIFE_DAYS, LAST_HERE_NOROOM_EVENT, chaptersBySession, chaptersHere, chaptersOn, elsewhereLine, lastHereLadder, yesterdayLine } from "./handoff/last-here.js";
|
|
131
144
|
import type { ChapterHere, LastHere } from "./handoff/last-here.js";
|
|
132
145
|
import { addDays, isDay, localStamp, localStampAfter } from "./time.js";
|
|
133
|
-
import {
|
|
146
|
+
import type { Recurrence } from "./time.js";
|
|
147
|
+
import { EPISODE_REGROWN_REASON, leftAs } from "./leaving.js";
|
|
134
148
|
import type { LeftAs } from "./leaving.js";
|
|
135
149
|
import {
|
|
136
150
|
BRIEFING_KEY,
|
|
137
151
|
BRIEFING_TRIM_LOG_CAP,
|
|
138
152
|
LANE_ORDER,
|
|
139
|
-
NIGHT_WRITER_MEMORY_BYTES,
|
|
140
153
|
NIGHT_WRITER_MEMORY_MAX,
|
|
154
|
+
NIGHT_WRITER_TOOL,
|
|
141
155
|
PREFACE_RESERVE_BYTES,
|
|
142
156
|
Self,
|
|
143
157
|
byteLength,
|
|
144
158
|
markWakeBehind,
|
|
159
|
+
noteWakeBuild,
|
|
145
160
|
noteWakeCaught,
|
|
146
161
|
settledOver,
|
|
162
|
+
threadsShown,
|
|
147
163
|
spliceBeforeSentinel,
|
|
148
164
|
wakeBehind,
|
|
165
|
+
wakeFromOtherBuild,
|
|
166
|
+
WORK_OVERFLOW_EVENT,
|
|
167
|
+
rotateWork,
|
|
149
168
|
workHere,
|
|
150
169
|
workHereBlock,
|
|
151
170
|
workHereBytes,
|
|
152
171
|
writerInstruction,
|
|
172
|
+
fitNightWriter,
|
|
153
173
|
} from "./self/index.js";
|
|
154
174
|
import type {
|
|
155
175
|
ChapterAppend,
|
|
@@ -171,13 +191,13 @@ import type {
|
|
|
171
191
|
WakeTrigger,
|
|
172
192
|
WriterInput,
|
|
173
193
|
} from "./self/index.js";
|
|
174
|
-
import { cyclePartial, runCycle } from "./sleep/index.js";
|
|
194
|
+
import { cyclePartial, ownerNames, runCycle } from "./sleep/index.js";
|
|
175
195
|
import type { CyclePartial, CycleReport, Phase } from "./sleep/index.js";
|
|
176
|
-
import { CORE_ABOUT_MARKS, Store, assertSafeDataDir, hashText, indexTextOf } from "./store/index.js";
|
|
196
|
+
import { CORE_ABOUT_MARKS, Store, assertSafeDataDir, hashText, indexTextOf, occurredOnOf, saidByOf, statusOf } from "./store/index.js";
|
|
177
197
|
import type {
|
|
178
198
|
AboutMark,
|
|
179
199
|
AddFeelingsResult,
|
|
180
|
-
FeelingInput, Embedder, StoreEvent, TraitInput } from "./store/index.js";
|
|
200
|
+
FeelingInput, Embedder, StoreEvent, TraitInput, MemoryRow, MemoryStatus, SaidBy } from "./store/index.js";
|
|
181
201
|
import { TUNABLES as PHYSICS, band as bandOf } from "./physics/index.js";
|
|
182
202
|
import type { UseTier } from "./physics/index.js";
|
|
183
203
|
import type { Kind } from "./types.js";
|
|
@@ -516,6 +536,11 @@ export const ASSOCIATE_FLUSH_EVENT = "associate.flush";
|
|
|
516
536
|
* store's first session, never an old store's whole history.
|
|
517
537
|
*/
|
|
518
538
|
export const CONTIGUITY_CURSOR_META = "associateContiguityCursor";
|
|
539
|
+
/** Meta key: the v12 subject backfill's record (latch + what it linked, for doctor). */
|
|
540
|
+
export const SUBJECTS_BACKFILL_META = "subjects.v12.backfill";
|
|
541
|
+
/** Meta key: the one-time carry of the links regrown chapter copies were left
|
|
542
|
+
* holding (2026-10-09) — its latch, and what it carried. */
|
|
543
|
+
export const REGROWN_RELINK_META = "associate.regrown.relink";
|
|
519
544
|
|
|
520
545
|
/** What one boundary's temporal contiguity pass did. Counts only. */
|
|
521
546
|
export interface ContiguityPass {
|
|
@@ -619,6 +644,66 @@ export const SPAWN_STARTED_EVENT = "adapter.spawn.started";
|
|
|
619
644
|
* that repeats on a timer, and it is bounded by the host's own tool budget.
|
|
620
645
|
*/
|
|
621
646
|
export const MCP_RECALL_EVENT = "mcp.recall";
|
|
647
|
+
/**
|
|
648
|
+
* WHAT REACHED THE MODEL, NOT WHAT RAN (2026-10-02). Two rows the MCP server
|
|
649
|
+
* writes because a tool result the host would not show looked, from the
|
|
650
|
+
* store, exactly like one it did: the night of 10-02 the dream's begin and
|
|
651
|
+
* its part 2 went past Claude Code's ceiling (`fit/TOOL_RESULT_CEILING`), were
|
|
652
|
+
* saved to a file the run could not open, and every count stayed green.
|
|
653
|
+
*
|
|
654
|
+
* - `mcp.part` — one later part of a dream's or a reflection's bundle was
|
|
655
|
+
* handed through phase `part`: the mechanism, its run's id, which part of
|
|
656
|
+
* how many, and the characters it left as. With `parts` on `dream.begun`
|
|
657
|
+
* and on the reflection's row, doctor can say a part was never fetched.
|
|
658
|
+
* - `mcp.result.oversize` — a result came to more than the ceiling and the
|
|
659
|
+
* server cut it there, saying so in the result: the tool, the phase, what
|
|
660
|
+
* it measured and what it was cut to. Never the text.
|
|
661
|
+
*
|
|
662
|
+
* Ids and counts only; no `dedupKey` (each is a deliberate call).
|
|
663
|
+
*/
|
|
664
|
+
export const MCP_PART_EVENT = "mcp.part";
|
|
665
|
+
export const MCP_OVERSIZE_EVENT = "mcp.result.oversize";
|
|
666
|
+
/**
|
|
667
|
+
* …AND WHAT THE HOST DID AFTER (2026-10-09, U14 item 3). The two rows above
|
|
668
|
+
* are the server's view: what it handed, what it cut. Neither can see the host
|
|
669
|
+
* cut a result the server sized under the ceiling — a remote flag can lower
|
|
670
|
+
* Claude Code's line below it. The nightly run reads its own child's
|
|
671
|
+
* transcript once the child exits (`claude-code/transcript.ts#readToolSpills`)
|
|
672
|
+
* and writes one `mcp.result.spilled` row per result of ours the host showed
|
|
673
|
+
* only as a preview: the run, the tool, the phase, the marker's shape and the
|
|
674
|
+
* size the host said. Never the saved file's path, never the text. No
|
|
675
|
+
* `dedupKey`: a run is read once.
|
|
676
|
+
*/
|
|
677
|
+
export const MCP_SPILLED_EVENT = "mcp.result.spilled";
|
|
678
|
+
|
|
679
|
+
/**
|
|
680
|
+
* WHAT A DELIVERY COULD NOT CARRY (durable since 2026-10-02; ring-only
|
|
681
|
+
* before, so doctor could not see a dropped session-start notice or hook
|
|
682
|
+
* output past the host's 10,000-character cap):
|
|
683
|
+
*
|
|
684
|
+
* - `adapter.envelope.overcap` — even the plain form was past the host's
|
|
685
|
+
* cap, so the host showed a preview (`bin/hook.ts#Delivery.overCap`);
|
|
686
|
+
* - `adapter.notice.dropped` — the owner's notice was dropped so the JSON
|
|
687
|
+
* envelope stayed under it, and the wake went plain;
|
|
688
|
+
* - `adapter.envelope.gave-way` — a part waited for want of room (the
|
|
689
|
+
* write-up pointer, the scope question, the turn's recall, a reminder,
|
|
690
|
+
* the dream offer, the update notice): which hook, which part;
|
|
691
|
+
* - `adapter.injection.overbudget` — a session start sent more than the
|
|
692
|
+
* ceiling the host reported.
|
|
693
|
+
*
|
|
694
|
+
* Counts and bytes only. One row per hook, part and session per lived day
|
|
695
|
+
* (`Lifecycle#noteDeliveryWarning`'s `dedupKey`), so a long session that
|
|
696
|
+
* gives way at every prompt writes one row, not hundreds.
|
|
697
|
+
*/
|
|
698
|
+
export const ENVELOPE_OVERCAP_EVENT = "adapter.envelope.overcap";
|
|
699
|
+
export const NOTICE_DROPPED_EVENT = "adapter.notice.dropped";
|
|
700
|
+
export const ENVELOPE_GAVE_WAY_EVENT = "adapter.envelope.gave-way";
|
|
701
|
+
export const INJECTION_OVERBUDGET_EVENT = "adapter.injection.overbudget";
|
|
702
|
+
export type DeliveryWarningName =
|
|
703
|
+
| typeof ENVELOPE_OVERCAP_EVENT
|
|
704
|
+
| typeof NOTICE_DROPPED_EVENT
|
|
705
|
+
| typeof ENVELOPE_GAVE_WAY_EVENT
|
|
706
|
+
| typeof INJECTION_OVERBUDGET_EVENT;
|
|
622
707
|
/**
|
|
623
708
|
* WHICH CHECKOUT WAS LIVE AT THIS SESSION START (2026-09-14).
|
|
624
709
|
*
|
|
@@ -704,6 +789,26 @@ export interface CreditSummary {
|
|
|
704
789
|
* shown are on each turn's `recall.decision` (`spread.pointersShown`);
|
|
705
790
|
* this is the other half: whether they get used. */
|
|
706
791
|
readonly pointersExpanded: number;
|
|
792
|
+
/** The ambient showings this boundary scored (2026-10-09): what recall showed
|
|
793
|
+
* this session since the last boundary that judged, by lane. Measurement
|
|
794
|
+
* only — nothing is strengthened, weakened or re-ranked by it. */
|
|
795
|
+
readonly shown: ShownLanes;
|
|
796
|
+
/** Of those, how many the replies neither expanded nor quoted, by lane. */
|
|
797
|
+
readonly unused: ShownLanes;
|
|
798
|
+
/** Their ids, oldest showing first: with `recall.decision`'s rows, a hit rate
|
|
799
|
+
* per memory and per lane. */
|
|
800
|
+
readonly shownNotUsed: string[];
|
|
801
|
+
/** The recall turn the scored stretch ends at (the session's `judged` mark
|
|
802
|
+
* after this pass); 0 when the session has shown nothing yet. */
|
|
803
|
+
readonly judgedThrough: number;
|
|
804
|
+
}
|
|
805
|
+
|
|
806
|
+
/** Ambient showings by lane: shown loud, footnoted on the turn's own cues, or
|
|
807
|
+
* footnoted as a quiet pointer (reached only through links). */
|
|
808
|
+
export interface ShownLanes {
|
|
809
|
+
readonly loud: number;
|
|
810
|
+
readonly footnotes: number;
|
|
811
|
+
readonly pointers: number;
|
|
707
812
|
}
|
|
708
813
|
|
|
709
814
|
/**
|
|
@@ -750,6 +855,10 @@ export type AdapterDurableEventName =
|
|
|
750
855
|
| typeof RUNNER_FAILED_EVENT
|
|
751
856
|
| typeof WRITE_UP_FAILED_EVENT
|
|
752
857
|
| typeof MCP_RECALL_EVENT
|
|
858
|
+
| typeof MCP_PART_EVENT
|
|
859
|
+
| typeof MCP_OVERSIZE_EVENT
|
|
860
|
+
| typeof MCP_SPILLED_EVENT
|
|
861
|
+
| DeliveryWarningName
|
|
753
862
|
| typeof CHECKOUT_EVENT
|
|
754
863
|
| typeof SNAPSHOT_TAKEN_EVENT
|
|
755
864
|
| typeof SNAPSHOT_FAILED_EVENT
|
|
@@ -833,6 +942,22 @@ export interface CounterpartOptions extends Stance {
|
|
|
833
942
|
* it does not write the page. Absent: `session`, the config's own default.
|
|
834
943
|
*/
|
|
835
944
|
pageWriterMode?: PageWriterMode;
|
|
945
|
+
/**
|
|
946
|
+
* The package version this process runs (2026-10-02), from the adapter that
|
|
947
|
+
* knows it (`sessions.ts#installedVersion`). Each wake this process publishes
|
|
948
|
+
* is stamped with it, and `refreshWake` re-renders a wake another build
|
|
949
|
+
* published (`self/behind.ts`, the `version` trigger). Absent or null: no
|
|
950
|
+
* stamp and no comparison — today's behaviour.
|
|
951
|
+
*/
|
|
952
|
+
build?: string | null;
|
|
953
|
+
/**
|
|
954
|
+
* READ A DREAM'S AND A REFLECTION'S BUNDLES AS THE OWNER (review of #318).
|
|
955
|
+
* No host sets it: a bundle is a guest's on every server
|
|
956
|
+
* (`dream/tunables.ts#BUNDLE_OWNER`). The store-level tests of what an
|
|
957
|
+
* owner-read bundle must keep — a merge of a confidential memory is
|
|
958
|
+
* confidential, a page rests on nothing confidential — set it. Absent: false.
|
|
959
|
+
*/
|
|
960
|
+
bundlesAsOwner?: boolean;
|
|
836
961
|
/**
|
|
837
962
|
* `self/`'s knobs over its defaults (`self/tunables.ts`). Absent: the
|
|
838
963
|
* defaults. Added 2026-10-01 so the craft lane's switch
|
|
@@ -879,13 +1004,50 @@ export interface WakeHere {
|
|
|
879
1004
|
readonly exportsFrom?: (scope: string) => boolean;
|
|
880
1005
|
}
|
|
881
1006
|
|
|
1007
|
+
/**
|
|
1008
|
+
* v12 (2026-10-03): THE WRITER'S THREE FIELDS AS SENT, read and checked by
|
|
1009
|
+
* the door (`mcp/server.ts#readWriteFacts` drops what it cannot read, with a
|
|
1010
|
+
* note, and never refuses the memory for it). Per field: absent = not sent —
|
|
1011
|
+
* a revision (`updates:`, declared and resolved) carries it over from the
|
|
1012
|
+
* memory it revises; `null` = sent as none — nothing is carried.
|
|
1013
|
+
*/
|
|
1014
|
+
export interface SentFacts {
|
|
1015
|
+
readonly occurredOn?: string | null;
|
|
1016
|
+
readonly saidBy?: SaidBy | null;
|
|
1017
|
+
readonly status?: MemoryStatus | null;
|
|
1018
|
+
}
|
|
1019
|
+
|
|
1020
|
+
/** The three fields' names, as a writer sends them. */
|
|
1021
|
+
export type FactField = "occurredOn" | "saidBy" | "status";
|
|
1022
|
+
|
|
1023
|
+
/** What a deposit recorded of the three fields (v12), and what it carried over. */
|
|
1024
|
+
export interface DepositFacts {
|
|
1025
|
+
readonly occurredOn: string | null;
|
|
1026
|
+
readonly saidBy: SaidBy | null;
|
|
1027
|
+
readonly status: MemoryStatus | null;
|
|
1028
|
+
/** Fields taken from the memory this one revises because the writer left them out. */
|
|
1029
|
+
readonly inherited: readonly FactField[];
|
|
1030
|
+
/** The memory they were taken from, when any was. */
|
|
1031
|
+
readonly from: string | null;
|
|
1032
|
+
}
|
|
1033
|
+
|
|
882
1034
|
export interface DepositContext {
|
|
883
1035
|
session: string;
|
|
884
1036
|
scope: string;
|
|
1037
|
+
/** v12: the writer's three fields, as sent (`SentFacts`). Absent: none sent. */
|
|
1038
|
+
facts?: SentFacts;
|
|
885
1039
|
/** The span this deposit IS (a jot's own words), withheld from the sweep. */
|
|
886
1040
|
ownSpanHash?: string | null;
|
|
887
1041
|
/** The model writing it, from host state (`MintOptions.model`); absent = NULL. */
|
|
888
1042
|
model?: string;
|
|
1043
|
+
/**
|
|
1044
|
+
* THE CALLER'S STANCE FOR THIS DEPOSIT, when it is not the process's
|
|
1045
|
+
* (2026-10-02): a Claude Code session from Desktop's Code tab is served by
|
|
1046
|
+
* Desktop's server, whose store opened as a guest, and it is still the
|
|
1047
|
+
* owner's own session. Read only by the thread close (`closeThread`).
|
|
1048
|
+
* Absent: the process's own `owner`.
|
|
1049
|
+
*/
|
|
1050
|
+
owner?: boolean;
|
|
889
1051
|
}
|
|
890
1052
|
|
|
891
1053
|
/**
|
|
@@ -949,6 +1111,14 @@ export interface DepositResult {
|
|
|
949
1111
|
* settled, or why it was not. Absent when nothing was declared.
|
|
950
1112
|
*/
|
|
951
1113
|
readonly revision?: RevisionApplication;
|
|
1114
|
+
/**
|
|
1115
|
+
* The declared `updates:` this deposit HELD (2026-10-09, the update guard):
|
|
1116
|
+
* a `changed` or `corrected` at a memory that looked unrelated to the new
|
|
1117
|
+
* one, so the new memory landed unlinked and the old one was not settled
|
|
1118
|
+
* (`Counterpart#guardUpdate`). The old memory's title and text ride out, so
|
|
1119
|
+
* the writer can settle it itself if it meant to. Absent otherwise.
|
|
1120
|
+
*/
|
|
1121
|
+
readonly held?: HeldUpdate;
|
|
952
1122
|
/**
|
|
953
1123
|
* The open thread this deposit CLOSED (2026-10-01, lane 8): the memory it
|
|
954
1124
|
* revises was flagged `unresolved` and the author sent `unresolved` — false
|
|
@@ -957,6 +1127,8 @@ export interface DepositResult {
|
|
|
957
1127
|
* `Counterpart#closeThread`) or the clear did not land. Absent otherwise.
|
|
958
1128
|
*/
|
|
959
1129
|
readonly thread?: { readonly from: string; readonly closed: boolean; readonly refused?: ThreadRefusal };
|
|
1130
|
+
/** v12: the writer's three fields as recorded — after a revision's carry-over. */
|
|
1131
|
+
readonly facts?: DepositFacts;
|
|
960
1132
|
}
|
|
961
1133
|
|
|
962
1134
|
/**
|
|
@@ -976,8 +1148,13 @@ export interface DepositReminder {
|
|
|
976
1148
|
/** The date the new memory carries, or null when the revision dropped it. */
|
|
977
1149
|
readonly eventDate: string | null;
|
|
978
1150
|
readonly remind: "plain" | "quiet" | null;
|
|
1151
|
+
/** How often the carried date comes round (2026-10-09), or null: once. */
|
|
1152
|
+
readonly recurring: Recurrence | null;
|
|
1153
|
+
/** A repeat — sent or carried — that the new date cannot take (only a day
|
|
1154
|
+
* repeats), so it was dropped: said in the answer, never silently lost. */
|
|
1155
|
+
readonly recurringDropped?: boolean;
|
|
979
1156
|
/** Which fields came from `from` because the author left them out. */
|
|
980
|
-
readonly inherited: readonly ("eventDate" | "remind")[];
|
|
1157
|
+
readonly inherited: readonly ("eventDate" | "remind" | "recurring")[];
|
|
981
1158
|
/** False only when clearing `from`'s date failed (evented). */
|
|
982
1159
|
readonly moved: boolean;
|
|
983
1160
|
}
|
|
@@ -987,7 +1164,8 @@ interface ReminderCarryPlan {
|
|
|
987
1164
|
readonly proposal: Proposal;
|
|
988
1165
|
/** The dated memory being revised, or null when there is nothing to carry. */
|
|
989
1166
|
readonly from: string | null;
|
|
990
|
-
readonly inherited: readonly ("eventDate" | "remind")[];
|
|
1167
|
+
readonly inherited: readonly ("eventDate" | "remind" | "recurring")[];
|
|
1168
|
+
readonly recurringDropped?: boolean;
|
|
991
1169
|
}
|
|
992
1170
|
|
|
993
1171
|
export interface SweepEntry {
|
|
@@ -1555,6 +1733,8 @@ export class Counterpart {
|
|
|
1555
1733
|
private readonly owner: boolean;
|
|
1556
1734
|
/** The host's `pageWriter.mode` (`session` when absent): who runs the nightly writer. */
|
|
1557
1735
|
private readonly pageWriterModeOpt: PageWriterMode;
|
|
1736
|
+
/** The package version this process runs, when the adapter said (`CounterpartOptions.build`). */
|
|
1737
|
+
private readonly build: string | null;
|
|
1558
1738
|
private reportedBudget: number | null;
|
|
1559
1739
|
private readonly onEvent: ((e: CounterpartEvent) => void) | undefined;
|
|
1560
1740
|
private readonly nowFn: () => number;
|
|
@@ -1587,6 +1767,7 @@ export class Counterpart {
|
|
|
1587
1767
|
this.observer = isObserver(opts);
|
|
1588
1768
|
this.owner = opts.owner === true && !this.observer;
|
|
1589
1769
|
this.pageWriterModeOpt = opts.pageWriterMode ?? "session";
|
|
1770
|
+
this.build = typeof opts.build === "string" && opts.build.length > 0 ? opts.build : null;
|
|
1590
1771
|
this.onEvent = opts.onEvent;
|
|
1591
1772
|
this.nowFn = opts.now ?? ((): number => Date.now());
|
|
1592
1773
|
this.reportedBudget = opts.budgetBytes ?? null;
|
|
@@ -1651,6 +1832,15 @@ export class Counterpart {
|
|
|
1651
1832
|
},
|
|
1652
1833
|
onEvent: (e) => this.relay("schemas", { at: e.at, name: e.event, ...(e.ref === undefined ? {} : { ref: e.ref }), ...(e.data === undefined ? {} : { data: e.data }) }),
|
|
1653
1834
|
});
|
|
1835
|
+
// v12 (2026-10-03): WHAT A MEMORY NAMES, linked at every write. The store
|
|
1836
|
+
// cannot import `schemas/`, so the finder is handed to it here, and every
|
|
1837
|
+
// door that writes a memory — this file's, `dream/`'s, `self/`'s — links
|
|
1838
|
+
// through the same one. Then, once per store, the memories written before.
|
|
1839
|
+
this.store.findSubjectsWith((text) => this.schemas.subjectsIn(text));
|
|
1840
|
+
if (!this.observer) this.backfillSubjects();
|
|
1841
|
+
// Once per store, the links regrown chapter copies were left holding
|
|
1842
|
+
// before a regrowth carried them (2026-10-09).
|
|
1843
|
+
if (!this.observer) this.relinkRegrownCopies();
|
|
1654
1844
|
// SEAMS H: the REAL battery, so `self/`'s refusing default is unreachable.
|
|
1655
1845
|
this.self = new Self({
|
|
1656
1846
|
store: this.store,
|
|
@@ -1665,6 +1855,11 @@ export class Counterpart {
|
|
|
1665
1855
|
this.relay("self", e);
|
|
1666
1856
|
},
|
|
1667
1857
|
onMemoryMinted: (m) => this.creditNamedIn(m.title, m.body, m.day, m.id, "episode"),
|
|
1858
|
+
// SEAMS E once more: a regrown chapter copy inherits its archived copy's
|
|
1859
|
+
// links, as a revision's successor and a dream merge's memory do.
|
|
1860
|
+
retarget: (oldId, newId, day) => {
|
|
1861
|
+
this.associate.retargetOnSupersede(oldId, newId, day);
|
|
1862
|
+
},
|
|
1668
1863
|
now: this.nowFn,
|
|
1669
1864
|
...(opts.selfTunables === undefined ? {} : { tunables: opts.selfTunables }),
|
|
1670
1865
|
});
|
|
@@ -1689,6 +1884,13 @@ export class Counterpart {
|
|
|
1689
1884
|
observer: this.observer,
|
|
1690
1885
|
onEvent: (e) => this.relay("handoff", e),
|
|
1691
1886
|
now: this.nowFn,
|
|
1887
|
+
// The "since" line beside the pointer (2026-10-09): a confidential
|
|
1888
|
+
// memory named to the owner only, and nothing a later one settled over.
|
|
1889
|
+
owner: this.owner,
|
|
1890
|
+
settled: () => settledOver(this.store),
|
|
1891
|
+
// …and nothing the published wake already lists under "Still open:"
|
|
1892
|
+
// (review of #332): one place for an open question.
|
|
1893
|
+
listed: () => threadsShown(this.store),
|
|
1692
1894
|
});
|
|
1693
1895
|
this.spans = new SpanBuffer({
|
|
1694
1896
|
dir: this.store.dir,
|
|
@@ -1710,6 +1912,7 @@ export class Counterpart {
|
|
|
1710
1912
|
store: this.store,
|
|
1711
1913
|
observer: this.observer,
|
|
1712
1914
|
owner: this.owner,
|
|
1915
|
+
...(opts.bundlesAsOwner === true ? { bundleOwner: this.owner } : {}),
|
|
1713
1916
|
gate: (text) => {
|
|
1714
1917
|
const redacted = redactSecrets(text);
|
|
1715
1918
|
return redacted.replace(/\[REDACTED[^\]]*\]/g, "").trim().length === 0
|
|
@@ -1740,6 +1943,7 @@ export class Counterpart {
|
|
|
1740
1943
|
store: this.store,
|
|
1741
1944
|
observer: this.observer,
|
|
1742
1945
|
owner: this.owner,
|
|
1946
|
+
...(opts.bundlesAsOwner === true ? { bundleOwner: this.owner } : {}),
|
|
1743
1947
|
gate: (text) => {
|
|
1744
1948
|
const redacted = redactSecrets(text);
|
|
1745
1949
|
return redacted.replace(/\[REDACTED[^\]]*\]/g, "").trim().length === 0
|
|
@@ -1909,7 +2113,7 @@ export class Counterpart {
|
|
|
1909
2113
|
// handoff block is chosen, in the room that block leaves — the handoff and
|
|
1910
2114
|
// "Last here" are chosen first and never give way to it (`withWorkHere`).
|
|
1911
2115
|
const work = this.workHereLines(scope);
|
|
1912
|
-
if (newest === undefined && lastHere.length === 0) return this.withWorkHere(result, null, work, budget);
|
|
2116
|
+
if (newest === undefined && lastHere.length === 0) return this.withWorkHere(result, null, work, budget, scope);
|
|
1913
2117
|
const fits = (block: string): ReturnType<typeof spliceBeforeSentinel> | null => {
|
|
1914
2118
|
const spliced = spliceBeforeSentinel(result.text, block);
|
|
1915
2119
|
return spliced.applied && (budget === null || spliced.bytes <= budget) ? spliced : null;
|
|
@@ -1947,6 +2151,7 @@ export class Counterpart {
|
|
|
1947
2151
|
bytes: i === 0 ? cost - others : own(i),
|
|
1948
2152
|
session: here?.session ?? null,
|
|
1949
2153
|
among: rung.live,
|
|
2154
|
+
...(i === 0 ? { plans: rung.plans.length } : {}),
|
|
1950
2155
|
});
|
|
1951
2156
|
});
|
|
1952
2157
|
} else if (newest !== undefined) {
|
|
@@ -1958,31 +2163,64 @@ export class Counterpart {
|
|
|
1958
2163
|
// The handoff was carried and the line above it was not.
|
|
1959
2164
|
this.noteLastHereNoRoom(lastHereId, { budget, was: result.bytes, besideHandoff: true });
|
|
1960
2165
|
}
|
|
1961
|
-
|
|
2166
|
+
// A memory the "since" line names is not named again in the work lines
|
|
2167
|
+
// above it (2026-10-09).
|
|
2168
|
+
const named = rung?.plans ?? [];
|
|
2169
|
+
const lines = work.lines.filter((l) => !named.some((id) => l.endsWith(`(${id})`)));
|
|
2170
|
+
return this.withWorkHere(result, block, { lines, found: work.found - (work.lines.length - lines.length) }, budget, scope);
|
|
1962
2171
|
}
|
|
1963
2172
|
if (newest !== undefined) this.noteHandoffNoRoom(newest.handoff, smallest?.bytes ?? result.bytes, budget, result.bytes);
|
|
1964
2173
|
if (lastHere.length > 0) this.noteLastHereNoRoom(lastHereId, { budget, was: result.bytes, besideHandoff: false });
|
|
1965
|
-
return this.withWorkHere(result, null, work, budget);
|
|
2174
|
+
return this.withWorkHere(result, null, work, budget, scope);
|
|
1966
2175
|
}
|
|
1967
2176
|
|
|
1968
2177
|
/**
|
|
1969
2178
|
* THIS DIRECTORY'S WORK LINES, best first (`self/work.ts#workHere`), or none
|
|
1970
2179
|
* — with the switch off, with no directory, or with a store that will not
|
|
1971
2180
|
* answer. What a later memory settled over is left out, as every lane but
|
|
1972
|
-
* identity leaves it out.
|
|
2181
|
+
* identity leaves it out. Up to `WORK_HERE_POOL` are ranked and today's
|
|
2182
|
+
* `WORK_HERE_MAX` chosen from them (`rotateWork`, 2026-10-02); `found` is
|
|
2183
|
+
* how many were ranked, for the overflow row. Never throws.
|
|
1973
2184
|
*/
|
|
1974
|
-
private workHereLines(scope: string): string[] {
|
|
2185
|
+
private workHereLines(scope: string): { lines: string[]; found: number } {
|
|
1975
2186
|
const t = this.self.tunables;
|
|
1976
|
-
if (!t.CRAFT_AT_DELIVERY || scope.trim().length === 0) return [];
|
|
2187
|
+
if (!t.CRAFT_AT_DELIVERY || scope.trim().length === 0) return { lines: [], found: 0 };
|
|
1977
2188
|
try {
|
|
1978
|
-
|
|
1979
|
-
|
|
2189
|
+
const day = this.store.livedDay();
|
|
2190
|
+
const ranked = workHere(this.store, scope, {
|
|
2191
|
+
day,
|
|
1980
2192
|
max: t.WORK_HERE_MAX,
|
|
2193
|
+
pool: t.WORK_HERE_POOL,
|
|
1981
2194
|
excerpt: t.WORK_HERE_EXCERPT,
|
|
1982
2195
|
skip: settledOver(this.store),
|
|
1983
2196
|
});
|
|
2197
|
+
return { lines: rotateWork(ranked, t.WORK_HERE_MAX, day), found: ranked.length };
|
|
1984
2198
|
} catch {
|
|
1985
|
-
return [];
|
|
2199
|
+
return { lines: [], found: 0 };
|
|
2200
|
+
}
|
|
2201
|
+
}
|
|
2202
|
+
|
|
2203
|
+
/**
|
|
2204
|
+
* MORE WORK THAN THIS WAKE CARRIED (2026-10-02): the ring event, and one
|
|
2205
|
+
* durable row per directory per lived day (`WORK_OVERFLOW_EVENT`), so doctor
|
|
2206
|
+
* and the dashboard can say the lines rotate or had no room. Never under
|
|
2207
|
+
* observer; never throws.
|
|
2208
|
+
*/
|
|
2209
|
+
private noteWorkOverflow(scope: string, opts: { found: number; shown: number; budget: number | null; was: number }): void {
|
|
2210
|
+
const max = this.self.tunables.WORK_HERE_MAX;
|
|
2211
|
+
const cause = opts.shown < Math.min(opts.found, max) ? "room" : "cap";
|
|
2212
|
+
this.emit("counterpart.work.overflow", undefined, { cause, found: opts.found, shown: opts.shown });
|
|
2213
|
+
if (this.observer) return;
|
|
2214
|
+
try {
|
|
2215
|
+
const day = this.store.livedDay();
|
|
2216
|
+
this.store.appendEvent({
|
|
2217
|
+
name: WORK_OVERFLOW_EVENT,
|
|
2218
|
+
day,
|
|
2219
|
+
dedupKey: `${WORK_OVERFLOW_EVENT}:${cause}:${scope}:${String(day)}`,
|
|
2220
|
+
payload: { scope, cause, found: opts.found, shown: opts.shown, max, budget: opts.budget ?? 0, bytes: opts.was },
|
|
2221
|
+
});
|
|
2222
|
+
} catch {
|
|
2223
|
+
/* an overflow that cannot be recorded still rotated */
|
|
1986
2224
|
}
|
|
1987
2225
|
}
|
|
1988
2226
|
|
|
@@ -1995,20 +2233,31 @@ export class Counterpart {
|
|
|
1995
2233
|
* says the lines had no room. With no lines and no block, the bundle is
|
|
1996
2234
|
* returned untouched. Never throws.
|
|
1997
2235
|
*/
|
|
1998
|
-
private withWorkHere(
|
|
2236
|
+
private withWorkHere(
|
|
2237
|
+
result: WakeResult,
|
|
2238
|
+
block: string | null,
|
|
2239
|
+
work: { lines: readonly string[]; found: number },
|
|
2240
|
+
budget: number | null,
|
|
2241
|
+
scope: string,
|
|
2242
|
+
): WakeResult {
|
|
2243
|
+
const { lines, found } = work;
|
|
1999
2244
|
const spliced = (text: string): WakeResult | null => {
|
|
2000
2245
|
const s = spliceBeforeSentinel(result.text, text);
|
|
2001
2246
|
if (!s.applied || (budget !== null && s.bytes > budget)) return null;
|
|
2002
2247
|
return { ...result, text: s.text, bytes: s.bytes, sentinel: s.sentinel };
|
|
2003
2248
|
};
|
|
2004
2249
|
for (let k = lines.length; k > 0; k--) {
|
|
2005
|
-
const
|
|
2006
|
-
const out = spliced(block === null ?
|
|
2250
|
+
const shown = workHereBlock(lines.slice(0, k));
|
|
2251
|
+
const out = spliced(block === null ? shown : `${shown}\n\n${block}`);
|
|
2007
2252
|
if (out === null) continue;
|
|
2008
2253
|
this.emit("counterpart.work.shown", undefined, { lines: k, of: lines.length, bytes: out.bytes - result.bytes });
|
|
2254
|
+
if (found > k) this.noteWorkOverflow(scope, { found, shown: k, budget, was: result.bytes });
|
|
2009
2255
|
return out;
|
|
2010
2256
|
}
|
|
2011
|
-
if (lines.length > 0)
|
|
2257
|
+
if (lines.length > 0) {
|
|
2258
|
+
this.emit("counterpart.work.noroom", undefined, { lines: lines.length, budget, was: result.bytes });
|
|
2259
|
+
this.noteWorkOverflow(scope, { found, shown: 0, budget, was: result.bytes });
|
|
2260
|
+
}
|
|
2012
2261
|
if (block === null) return result;
|
|
2013
2262
|
const s = spliceBeforeSentinel(result.text, block);
|
|
2014
2263
|
return s.applied ? { ...result, text: s.text, bytes: s.bytes, sentinel: s.sentinel } : result;
|
|
@@ -2390,7 +2639,7 @@ export class Counterpart {
|
|
|
2390
2639
|
try {
|
|
2391
2640
|
const blocks: number[] = [];
|
|
2392
2641
|
for (const scope of this.spans.scopes()) {
|
|
2393
|
-
const lines = this.workHereLines(scope);
|
|
2642
|
+
const { lines } = this.workHereLines(scope);
|
|
2394
2643
|
if (lines.length > 0) blocks.push(workHereBytes(lines));
|
|
2395
2644
|
}
|
|
2396
2645
|
return reserveBytes(blocks, budgetBytes);
|
|
@@ -2516,19 +2765,50 @@ export class Counterpart {
|
|
|
2516
2765
|
for (const a of arrived) {
|
|
2517
2766
|
if (!shown.has(a.memoryId)) continue;
|
|
2518
2767
|
try {
|
|
2519
|
-
this.prospective.
|
|
2768
|
+
const first = this.prospective.occurrenceUndelivered(a.memoryId, a.windowKey);
|
|
2769
|
+
const fired = this.prospective.fire({
|
|
2520
2770
|
memoryId: a.memoryId,
|
|
2521
2771
|
windowKey: a.windowKey,
|
|
2522
2772
|
at,
|
|
2523
2773
|
day: decision.day,
|
|
2524
2774
|
sessionId: decision.sessionId,
|
|
2525
2775
|
});
|
|
2776
|
+
if (fired.fired && first) this.creditOccurrence(a.memoryId, a.windowKey, decision.day, "quiet");
|
|
2526
2777
|
} catch (err) {
|
|
2527
2778
|
this.emit("counterpart.prospective.fire.failed", a.memoryId, { code: errCode(err) });
|
|
2528
2779
|
}
|
|
2529
2780
|
}
|
|
2530
2781
|
}
|
|
2531
2782
|
|
|
2783
|
+
/**
|
|
2784
|
+
* A REPEAT IS KEPT ALIVE BY COMING ROUND (owner decision 2026-10-09, held
|
|
2785
|
+
* lightly). The first delivery of each occurrence of a repeating date — a
|
|
2786
|
+
* quiet fire the gate admitted, or a plain line the host claimed — counts as
|
|
2787
|
+
* one use of the memory, the way rehearsal keeps a memory: `store.reinforce`,
|
|
2788
|
+
* the seam recall's credit ends in, at the `surfaced` tier. Surfaced and not
|
|
2789
|
+
* referenced: it was shown, nothing says the reply used it, and a schedule
|
|
2790
|
+
* earns no RETURN (`physics#creditReturn` refuses `not-referenced`), so a
|
|
2791
|
+
* daily repeat never walks the core's slow lane on the calendar alone. Once
|
|
2792
|
+
* per occurrence (`Prospective.occurrenceUndelivered`, asked before the
|
|
2793
|
+
* delivery); a one-off date, or a repeat whose `recurring` was dropped, is
|
|
2794
|
+
* never credited here. Physics keeps its own refusals (birth day, already
|
|
2795
|
+
* credited today). Never throws into the turn.
|
|
2796
|
+
*/
|
|
2797
|
+
private creditOccurrence(memoryId: string, windowKey: string, day: number, via: "quiet" | "plain"): void {
|
|
2798
|
+
try {
|
|
2799
|
+
const out = this.store.reinforce(memoryId, day, "surfaced");
|
|
2800
|
+
this.emit("counterpart.prospective.occurrence.credited", memoryId, {
|
|
2801
|
+
window: windowKey,
|
|
2802
|
+
via,
|
|
2803
|
+
credited: out.credited,
|
|
2804
|
+
reason: out.reason,
|
|
2805
|
+
day,
|
|
2806
|
+
});
|
|
2807
|
+
} catch (err) {
|
|
2808
|
+
this.emit("counterpart.prospective.occurrence.failed", memoryId, { window: windowKey, code: errCode(err) });
|
|
2809
|
+
}
|
|
2810
|
+
}
|
|
2811
|
+
|
|
2532
2812
|
/**
|
|
2533
2813
|
* PLAIN REMINDERS DUE TODAY, NOT YET CLAIMED — a read. The owner-decided
|
|
2534
2814
|
* exception to "a cue, not a command" (prospective CONTRACT §3): an item its
|
|
@@ -2579,10 +2859,12 @@ export class Counterpart {
|
|
|
2579
2859
|
claimPlainReminder(reminder: PlainDue, input: { at: string; day?: number }): boolean {
|
|
2580
2860
|
if (this.observer) return false;
|
|
2581
2861
|
try {
|
|
2582
|
-
|
|
2583
|
-
|
|
2584
|
-
|
|
2585
|
-
});
|
|
2862
|
+
const day = input.day ?? this.store.livedDay();
|
|
2863
|
+
// Asked BEFORE the claim, which is itself what would make it false.
|
|
2864
|
+
const first = this.prospective.occurrenceUndelivered(reminder.memoryId, reminder.windowKey);
|
|
2865
|
+
const claimed = this.prospective.claimPlain(reminder, { at: input.at, day });
|
|
2866
|
+
if (claimed && first) this.creditOccurrence(reminder.memoryId, reminder.windowKey, day, "plain");
|
|
2867
|
+
return claimed;
|
|
2586
2868
|
} catch (err) {
|
|
2587
2869
|
this.emit("counterpart.prospective.plain.failed", reminder.memoryId, { code: errCode(err) });
|
|
2588
2870
|
return false;
|
|
@@ -2739,10 +3021,22 @@ export class Counterpart {
|
|
|
2739
3021
|
}
|
|
2740
3022
|
|
|
2741
3023
|
/**
|
|
2742
|
-
*
|
|
2743
|
-
*
|
|
2744
|
-
*
|
|
3024
|
+
* THE MEMORIES A DELIBERATE QUESTION'S ANSWER SHOWED, for one session
|
|
3025
|
+
* (Release B, 2026-10-03): recorded as `asked` gate records, so that
|
|
3026
|
+
* quoting one's words in a reply credits it at the boundary
|
|
3027
|
+
* (`creditReferences`). A list shown credits nothing on its own. Written
|
|
3028
|
+
* through the store's gate-record door, so an observer's store refuses it
|
|
3029
|
+
* (the caller swallows that, as it does every telemetry write).
|
|
2745
3030
|
*/
|
|
3031
|
+
noteAsked(sessionId: string, ids: readonly string[]): void {
|
|
3032
|
+
if (ids.length === 0) return;
|
|
3033
|
+
const day = this.store.livedDay();
|
|
3034
|
+
const at = askedTurn(this.store.now());
|
|
3035
|
+
this.store.setGateRecords(
|
|
3036
|
+
[...new Set(ids)].map((id) => ({ sessionId, kind: ASKED_KIND, ref: id, turn: at, lastDay: day, tier: "asked", trains: true })),
|
|
3037
|
+
);
|
|
3038
|
+
}
|
|
3039
|
+
|
|
2746
3040
|
/**
|
|
2747
3041
|
* THE CREDIT SEAM, decided and applied in one call (recall §9.2; INTERFACE-GAPS
|
|
2748
3042
|
* §5, closed). Candidates are what this session surfaced LOUD — read from the
|
|
@@ -2775,6 +3069,35 @@ export class Counterpart {
|
|
|
2775
3069
|
unreadable += 1;
|
|
2776
3070
|
}
|
|
2777
3071
|
}
|
|
3072
|
+
// WHAT A DELIBERATE QUESTION SHOWED (Release B, 2026-10-03): its answer's
|
|
3073
|
+
// memories, with their words, are quotable as a loud surfacing is — the
|
|
3074
|
+
// owner's 09-14 rule (opening or quoting credits) on the deliberate path.
|
|
3075
|
+
// Not `cued`: the display decides, as for an expansion. A memory already a
|
|
3076
|
+
// candidate is not added twice.
|
|
3077
|
+
const have = new Set(candidates.map((c) => c.id));
|
|
3078
|
+
let asked: { ref: string; turn: number }[] = [];
|
|
3079
|
+
try {
|
|
3080
|
+
asked = this.store
|
|
3081
|
+
.gateRecords(sessionId, ASKED_KIND)
|
|
3082
|
+
.sort((a, b) => b.turn - a.turn)
|
|
3083
|
+
.slice(0, ASKED_MAX);
|
|
3084
|
+
} catch {
|
|
3085
|
+
asked = [];
|
|
3086
|
+
}
|
|
3087
|
+
for (const rec of asked) {
|
|
3088
|
+
if (have.has(rec.ref)) continue;
|
|
3089
|
+
have.add(rec.ref);
|
|
3090
|
+
if (input.deadline !== undefined && now() > input.deadline) {
|
|
3091
|
+
budgetExceeded = true;
|
|
3092
|
+
candidates.push({ id: rec.ref, tier: "surfaced", body: "" });
|
|
3093
|
+
continue;
|
|
3094
|
+
}
|
|
3095
|
+
try {
|
|
3096
|
+
candidates.push({ id: rec.ref, tier: "surfaced", body: this.store.readProse(rec.ref).body });
|
|
3097
|
+
} catch {
|
|
3098
|
+
unreadable += 1;
|
|
3099
|
+
}
|
|
3100
|
+
}
|
|
2778
3101
|
const refs = resolveReferences({
|
|
2779
3102
|
assistantTurns: input.assistantTurns,
|
|
2780
3103
|
expansions: input.expansions,
|
|
@@ -2782,6 +3105,16 @@ export class Counterpart {
|
|
|
2782
3105
|
...(input.deadline === undefined ? {} : { deadline: input.deadline }),
|
|
2783
3106
|
...(input.now === undefined ? {} : { now: input.now }),
|
|
2784
3107
|
});
|
|
3108
|
+
// SHOWN, AND NOT USED (2026-10-09). Recall predicts on every turn that what
|
|
3109
|
+
// it shows will help the reply, and until now a miss left no record per
|
|
3110
|
+
// memory. The ambient showings since the last boundary that judged are
|
|
3111
|
+
// scored once, here: used when a reply expanded or quoted them (whether or
|
|
3112
|
+
// not credit then landed), otherwise listed. Measurement only. A boundary
|
|
3113
|
+
// whose slice holds no reply and no expansion judges nothing (review of
|
|
3114
|
+
// #329): a capture that failed or found nothing new is not a reply that
|
|
3115
|
+
// ignored what it was shown.
|
|
3116
|
+
const replied = input.assistantTurns.length > 0 || input.expansions.length > 0;
|
|
3117
|
+
const showings = this.scoreShowings(sessionId, state, refs.uses, day, replied);
|
|
2785
3118
|
// An expansion is an ADDRESS the assistant typed into a tool call, and a
|
|
2786
3119
|
// well-shaped address can still name nothing: a typo, or a memory removed
|
|
2787
3120
|
// since it was footnoted. Physics would throw on it (`requireRow`) and take
|
|
@@ -2884,6 +3217,10 @@ export class Counterpart {
|
|
|
2884
3217
|
refused,
|
|
2885
3218
|
ids,
|
|
2886
3219
|
linkedDespite,
|
|
3220
|
+
shown: showings.shown,
|
|
3221
|
+
unused: showings.unused,
|
|
3222
|
+
shownNotUsed: showings.shownNotUsed,
|
|
3223
|
+
judgedThrough: showings.judgedThrough,
|
|
2887
3224
|
};
|
|
2888
3225
|
this.emit("counterpart.credit", sessionId, {
|
|
2889
3226
|
reason,
|
|
@@ -2894,10 +3231,70 @@ export class Counterpart {
|
|
|
2894
3231
|
credited,
|
|
2895
3232
|
linkedDespite,
|
|
2896
3233
|
pointersExpanded,
|
|
3234
|
+
shown: showings.shown.loud + showings.shown.footnotes + showings.shown.pointers,
|
|
3235
|
+
shownNotUsed: showings.shownNotUsed.length,
|
|
2897
3236
|
});
|
|
2898
3237
|
return summary;
|
|
2899
3238
|
}
|
|
2900
3239
|
|
|
3240
|
+
/**
|
|
3241
|
+
* One boundary's score of recall's ambient showings (2026-10-09; Hawkins
|
|
3242
|
+
* "2a", measurement only). The stretch is every memory this session's gate
|
|
3243
|
+
* state records as shown after the session's `judged` mark — loud,
|
|
3244
|
+
* footnoted, or footnoted as a quiet pointer — and the mark then moves to the
|
|
3245
|
+
* session's newest recall turn, so the next boundary scores only what came
|
|
3246
|
+
* after. A showing used at a later boundary than its own is still counted
|
|
3247
|
+
* once as not used here, and then as used there (`expandedIds`, or a quote):
|
|
3248
|
+
* the score is of the reply it was shown for. A deliberate answer's memories
|
|
3249
|
+
* (`asked`) are not ambient and are not in the gate state's `surfaced`.
|
|
3250
|
+
*
|
|
3251
|
+
* Never throws: a mark that cannot be read scores from the session's start,
|
|
3252
|
+
* one that cannot be written is re-scored next time — both say more misses,
|
|
3253
|
+
* never fewer, and neither costs the boundary its credit. Under observer the
|
|
3254
|
+
* mark is not written (an instrument deposits nothing).
|
|
3255
|
+
*
|
|
3256
|
+
* `replied` false (the slice held no reply and no expansion): nothing is
|
|
3257
|
+
* scored and the mark stays, so the showings wait for the first boundary
|
|
3258
|
+
* that read a reply (review of #329).
|
|
3259
|
+
*/
|
|
3260
|
+
private scoreShowings(
|
|
3261
|
+
sessionId: string,
|
|
3262
|
+
state: GateState,
|
|
3263
|
+
uses: readonly { memoryId: string }[],
|
|
3264
|
+
day: number,
|
|
3265
|
+
replied: boolean,
|
|
3266
|
+
): { shown: ShownLanes; unused: ShownLanes; shownNotUsed: string[]; judgedThrough: number } {
|
|
3267
|
+
let from = 0;
|
|
3268
|
+
try {
|
|
3269
|
+
from = judgedThrough(this.store, sessionId);
|
|
3270
|
+
} catch {
|
|
3271
|
+
from = 0;
|
|
3272
|
+
}
|
|
3273
|
+
const used = new Set(uses.map((u) => u.memoryId));
|
|
3274
|
+
const shown = { loud: 0, footnotes: 0, pointers: 0 };
|
|
3275
|
+
const unused = { loud: 0, footnotes: 0, pointers: 0 };
|
|
3276
|
+
const shownNotUsed: { id: string; turn: number }[] = [];
|
|
3277
|
+
if (!replied) return { shown, unused, shownNotUsed: [], judgedThrough: from };
|
|
3278
|
+
for (const [id, rec] of Object.entries(state.surfaced)) {
|
|
3279
|
+
if (rec.turn <= from) continue;
|
|
3280
|
+
const lane = rec.tier === "surfaced" ? "loud" : rec.via === "link" ? "pointers" : "footnotes";
|
|
3281
|
+
shown[lane] += 1;
|
|
3282
|
+
if (used.has(id)) continue;
|
|
3283
|
+
unused[lane] += 1;
|
|
3284
|
+
shownNotUsed.push({ id, turn: rec.turn });
|
|
3285
|
+
}
|
|
3286
|
+
shownNotUsed.sort((a, b) => a.turn - b.turn || (a.id < b.id ? -1 : a.id > b.id ? 1 : 0));
|
|
3287
|
+
const through = Math.max(from, state.turn);
|
|
3288
|
+
if (through > from && !this.observer) {
|
|
3289
|
+
try {
|
|
3290
|
+
markJudged(this.store, sessionId, through, day);
|
|
3291
|
+
} catch (err) {
|
|
3292
|
+
this.emit("counterpart.credit.judged.failed", sessionId, { code: errCode(err) });
|
|
3293
|
+
}
|
|
3294
|
+
}
|
|
3295
|
+
return { shown, unused, shownNotUsed: shownNotUsed.map((s) => s.id), judgedThrough: through };
|
|
3296
|
+
}
|
|
3297
|
+
|
|
2901
3298
|
/**
|
|
2902
3299
|
* THE HEBBIAN HALF OF THE CREDIT PASS — buffered here, written down elsewhere.
|
|
2903
3300
|
*
|
|
@@ -3123,6 +3520,12 @@ export class Counterpart {
|
|
|
3123
3520
|
return out;
|
|
3124
3521
|
}
|
|
3125
3522
|
|
|
3523
|
+
/**
|
|
3524
|
+
* The same as `resolveUse`, for the whole set a reply used — and then the
|
|
3525
|
+
* Hebbian half: what fired together in one reply is buffered as
|
|
3526
|
+
* co-activation, flushed at the boundary. `associate/` refuses a set of
|
|
3527
|
+
* fewer than two on its own terms.
|
|
3528
|
+
*/
|
|
3126
3529
|
resolveUses(
|
|
3127
3530
|
sessionId: string,
|
|
3128
3531
|
uses: readonly { memoryId: string; tier: UseTier }[],
|
|
@@ -3230,6 +3633,8 @@ export class Counterpart {
|
|
|
3230
3633
|
scope: ctx.scope,
|
|
3231
3634
|
...(ctx.ownSpanHash === undefined ? {} : { ownSpanHash: ctx.ownSpanHash }),
|
|
3232
3635
|
...(ctx.model === undefined ? {} : { model: ctx.model }),
|
|
3636
|
+
...(ctx.owner === undefined ? {} : { owner: ctx.owner }),
|
|
3637
|
+
...(ctx.facts === undefined ? {} : { facts: ctx.facts }),
|
|
3233
3638
|
});
|
|
3234
3639
|
}
|
|
3235
3640
|
|
|
@@ -3612,7 +4017,7 @@ export class Counterpart {
|
|
|
3612
4017
|
}
|
|
3613
4018
|
return { claimed: false, about: due.about, reason: due.reason };
|
|
3614
4019
|
}
|
|
3615
|
-
const built = this.
|
|
4020
|
+
const built = this.nightWriterFitted({ about: due.about, session: input.session, tool: NIGHT_WRITER_TOOL }).built;
|
|
3616
4021
|
const ok = this.self.recordPageWriterRun({
|
|
3617
4022
|
about: due.about,
|
|
3618
4023
|
mode: "session",
|
|
@@ -3673,11 +4078,11 @@ export class Counterpart {
|
|
|
3673
4078
|
| { ok: false; reason: string } {
|
|
3674
4079
|
const claim = this.self.nightClaimFor(input.session);
|
|
3675
4080
|
if (claim === null) return { ok: false, reason: "no-claim" };
|
|
3676
|
-
const built = this.
|
|
4081
|
+
const { built, text } = this.nightWriterFitted({ about: claim.about, session: input.session, tool: input.tool });
|
|
3677
4082
|
return {
|
|
3678
4083
|
ok: true,
|
|
3679
4084
|
about: claim.about,
|
|
3680
|
-
text
|
|
4085
|
+
text,
|
|
3681
4086
|
considered: built.memories.length,
|
|
3682
4087
|
dropped: built.dropped,
|
|
3683
4088
|
omitted: built.omitted,
|
|
@@ -3685,6 +4090,21 @@ export class Counterpart {
|
|
|
3685
4090
|
};
|
|
3686
4091
|
}
|
|
3687
4092
|
|
|
4093
|
+
/**
|
|
4094
|
+
* The night's day for the writer, fitted to one tool result
|
|
4095
|
+
* (`self/writer.ts#fitNightWriter`, 2026-10-02) — the claim and the block
|
|
4096
|
+
* count the same memories. Pure: it reads and composes.
|
|
4097
|
+
*/
|
|
4098
|
+
private nightWriterFitted(input: { about: string; session: string; tool: string }): {
|
|
4099
|
+
built: ReturnType<Counterpart["pageWriterInput"]>;
|
|
4100
|
+
text: string;
|
|
4101
|
+
} {
|
|
4102
|
+
return fitNightWriter(
|
|
4103
|
+
(budgetBytes) => this.pageWriterInput({ about: input.about, budgetBytes, max: NIGHT_WRITER_MEMORY_MAX }),
|
|
4104
|
+
(built) => writerInstruction(built, { tool: input.tool, session: input.session, pageInline: true }),
|
|
4105
|
+
);
|
|
4106
|
+
}
|
|
4107
|
+
|
|
3688
4108
|
/** The unaskable tail — bounded and measured, never pretended away (§2 G12). */
|
|
3689
4109
|
noteOrphanTail(
|
|
3690
4110
|
sessionId: string,
|
|
@@ -3892,8 +4312,9 @@ export class Counterpart {
|
|
|
3892
4312
|
const briefingEvents = this.takeBriefingEvents();
|
|
3893
4313
|
this.recordSleepCycle(cycle, date, briefingEvents, null);
|
|
3894
4314
|
this.recordSelfBriefing(briefingEvents, date);
|
|
3895
|
-
if (
|
|
3896
|
-
noteWakeCaught(this.store, behind.raw);
|
|
4315
|
+
if (briefingEvents.some((e) => e.name === BRIEFING_PUBLISHED_EVENT)) {
|
|
4316
|
+
if (behind !== null) noteWakeCaught(this.store, behind.raw);
|
|
4317
|
+
noteWakeBuild(this.store, this.build);
|
|
3897
4318
|
}
|
|
3898
4319
|
|
|
3899
4320
|
this.emit("counterpart.sessionEnd", undefined, {
|
|
@@ -4195,9 +4616,15 @@ export class Counterpart {
|
|
|
4195
4616
|
* the nightly process (`night-run.ts`, after the child returns). Not at
|
|
4196
4617
|
* SessionStart, whose wake ranks nothing and writes nothing (self CONTRACT
|
|
4197
4618
|
* §5 G1). Its `self.briefing` row says `refresh` and which triggers.
|
|
4619
|
+
*
|
|
4620
|
+
* AND WHEN ANOTHER BUILD PUBLISHED IT (2026-10-02, `version`): the first
|
|
4621
|
+
* turn-end after an install re-renders the wake the old version composed,
|
|
4622
|
+
* so a question the new code closes leaves "Still open" for every session
|
|
4623
|
+
* after that one, not at the next lived day.
|
|
4198
4624
|
*/
|
|
4199
4625
|
refreshWake(input: { budgetBytes?: number; at?: string; trigger?: WakeTrigger } = {}): WakeRefreshReport {
|
|
4200
|
-
const pending = wakeBehind(this.store)?.triggers ?? [];
|
|
4626
|
+
const pending = [...(wakeBehind(this.store)?.triggers ?? [])];
|
|
4627
|
+
if (!pending.includes("version") && wakeFromOtherBuild(this.store, BRIEFING_KEY, this.build)) pending.push("version");
|
|
4201
4628
|
const triggers = input.trigger === undefined || pending.includes(input.trigger) ? [...pending] : [...pending, input.trigger];
|
|
4202
4629
|
if (triggers.length === 0) return { reason: "current", triggers, day: this.store.livedDay(), bytes: 0 };
|
|
4203
4630
|
const report = this.republish(input, "refresh", triggers);
|
|
@@ -4268,8 +4695,9 @@ export class Counterpart {
|
|
|
4268
4695
|
// The caller's date when it passed one: every row a run writes carries the
|
|
4269
4696
|
// run's one date (review of #287).
|
|
4270
4697
|
this.recordSelfBriefing(collected, input.at ?? this.store.today(), why, triggers);
|
|
4271
|
-
if (
|
|
4272
|
-
noteWakeCaught(this.store, behind.raw);
|
|
4698
|
+
if (collected.some((e) => e.name === BRIEFING_PUBLISHED_EVENT)) {
|
|
4699
|
+
if (behind !== null) noteWakeCaught(this.store, behind.raw);
|
|
4700
|
+
noteWakeBuild(this.store, this.build);
|
|
4273
4701
|
}
|
|
4274
4702
|
// The lane counts as the RENDER recorded them — the one place they exist,
|
|
4275
4703
|
// rather than a second count taken here that could disagree with the event.
|
|
@@ -5163,8 +5591,15 @@ export class Counterpart {
|
|
|
5163
5591
|
return { ...none(reason, result.gate), malformed: result.malformed };
|
|
5164
5592
|
}
|
|
5165
5593
|
|
|
5166
|
-
|
|
5167
|
-
|
|
5594
|
+
// THE UPDATE GUARD (2026-10-09), before anything reads the address: a
|
|
5595
|
+
// `changed` or `corrected` at a memory that looks unrelated is HELD. The
|
|
5596
|
+
// proposal goes on without its `updates`, so nothing is linked, carried
|
|
5597
|
+
// over, closed or settled; the hold is recorded and handed back.
|
|
5598
|
+
const held = await this.guardUpdate(result.proposal, ctx);
|
|
5599
|
+
const carry = this.carryReminder(held === null ? result.proposal : withoutUpdates(result.proposal));
|
|
5600
|
+
// v12: the writer's three fields, a revision's carried over where unsent.
|
|
5601
|
+
const facts = this.carryFacts(carry.proposal, ctx.facts);
|
|
5602
|
+
const proposal: Proposal = facts === null ? carry.proposal : { ...carry.proposal, facts: { ...(facts.occurredOn === null ? {} : { occurredOn: facts.occurredOn }), ...(facts.saidBy === null ? {} : { saidBy: facts.saidBy }), ...(facts.status === null ? {} : { status: facts.status }) } };
|
|
5168
5603
|
const mint = mintProposal(this.store, proposal, {
|
|
5169
5604
|
self: this.self,
|
|
5170
5605
|
channel: "authored",
|
|
@@ -5175,7 +5610,7 @@ export class Counterpart {
|
|
|
5175
5610
|
// BEFORE the revision dispatch: a current-state target is superseded there,
|
|
5176
5611
|
// and the date must leave the row while it is still the live one.
|
|
5177
5612
|
const reminder = carry.from === null ? null : this.moveReminder(carry, mint.id);
|
|
5178
|
-
const thread = this.closeThread(proposal, mint.id);
|
|
5613
|
+
const thread = this.closeThread(proposal, mint.id, ctx.owner === undefined ? this.owner : ctx.owner && !this.observer);
|
|
5179
5614
|
this.emit("counterpart.deposit", mint.id, {
|
|
5180
5615
|
source,
|
|
5181
5616
|
kind: proposal.kind,
|
|
@@ -5191,7 +5626,15 @@ export class Counterpart {
|
|
|
5191
5626
|
this.recordDeposit(result, ctx, source, mint);
|
|
5192
5627
|
const titled = this.mentionFromProposal(proposal, `deposit:${mint.id}`);
|
|
5193
5628
|
this.creditNamedIn(proposal.title ?? null, proposal.content, proposal.day, mint.id, source, titled);
|
|
5194
|
-
|
|
5629
|
+
// THE CLOSE AND THE LIST AGREE (2026-10-02). A thread this session may
|
|
5630
|
+
// not close — confidential, or opened in another directory, for a session
|
|
5631
|
+
// that is not the owner's — is not settled over either: the declaration
|
|
5632
|
+
// stays a link (no `how`), so the old memory stays live and stays under
|
|
5633
|
+
// "Still open", which is what the refusal says. It used to be refused and
|
|
5634
|
+
// settled at once, and the wake dropped what the deposit said was open.
|
|
5635
|
+
const keepOpen = thread?.refused === "confidential" || thread?.refused === "other-directory";
|
|
5636
|
+
const revision = this.applyDeclaredRevision(keepOpen ? withoutHow(proposal) : proposal, mint, source, ctx.session);
|
|
5637
|
+
if (held !== null) this.recordHold(held, mint.id, source, ctx, proposal.day);
|
|
5195
5638
|
return {
|
|
5196
5639
|
deposited: true,
|
|
5197
5640
|
reason: "minted",
|
|
@@ -5202,8 +5645,173 @@ export class Counterpart {
|
|
|
5202
5645
|
covers: proposal.covers,
|
|
5203
5646
|
...(reminder === null ? {} : { reminder }),
|
|
5204
5647
|
...(revision === null ? {} : { revision }),
|
|
5648
|
+
...(held === null ? {} : { held }),
|
|
5205
5649
|
...(thread === null ? {} : { thread }),
|
|
5650
|
+
...(facts === null ? {} : { facts }),
|
|
5651
|
+
};
|
|
5652
|
+
}
|
|
5653
|
+
|
|
5654
|
+
/**
|
|
5655
|
+
* THE UPDATE GUARD (2026-10-09): is the memory this write says it changes
|
|
5656
|
+
* or corrects the one it is about? The engine fades or archives on the
|
|
5657
|
+
* writer's word, and a weaker writer points at the wrong one (a 10-02
|
|
5658
|
+
* benchmark read: a Haiku writer, about two thirds of 149 pairs; on the
|
|
5659
|
+
* owner's store, Opus, all 10 checked were right). The pair is read by
|
|
5660
|
+
* `contradictions.ts#updateRelatedness` — by meaning through the local
|
|
5661
|
+
* embedder, by shared content words when there is none — and an unrelated
|
|
5662
|
+
* one comes back as a hold. Null: the declaration goes on as written.
|
|
5663
|
+
*
|
|
5664
|
+
* Only where the write would move the old memory on its word alone:
|
|
5665
|
+
*
|
|
5666
|
+
* - an AUTHOR's `how` of `changed` (said or defaulted) or `corrected` —
|
|
5667
|
+
* `open` moves nothing and stays as it was, and a sweep sends no `how`;
|
|
5668
|
+
* - at an address the author DECLARED and the store resolved — a content
|
|
5669
|
+
* match is the engine's own reading, already held to a score floor and a
|
|
5670
|
+
* margin (`remember/updates.ts`);
|
|
5671
|
+
* - and not a CLOSE or a REDATE (`closesOrRedates`), which acts on that
|
|
5672
|
+
* exact memory by id, usually right after recall showed it, and whose
|
|
5673
|
+
* words ("done") need not share anything with what they close.
|
|
5674
|
+
*
|
|
5675
|
+
* Every door that deposits reaches this, the write-up door and the nightly
|
|
5676
|
+
* catch-up's included: a batch writer has nobody to read the reply, so a
|
|
5677
|
+
* hold there stays a hold, which is the safe side. Never throws: a guard
|
|
5678
|
+
* that cannot read the pair lets the declaration through, as before.
|
|
5679
|
+
*/
|
|
5680
|
+
private async guardUpdate(p: Proposal, ctx: DepositContext): Promise<HeldUpdate | null> {
|
|
5681
|
+
const how = p.how;
|
|
5682
|
+
if (how !== "changed" && how !== "corrected") return null;
|
|
5683
|
+
const target = p.updates?.method === "declared" ? p.updates.resolved : null;
|
|
5684
|
+
if (target === null) return null;
|
|
5685
|
+
let row: MemoryRow | undefined;
|
|
5686
|
+
try {
|
|
5687
|
+
row = this.store.row(target);
|
|
5688
|
+
if (row === undefined || this.closesOrRedates(p, target, row, ctx.facts)) return null;
|
|
5689
|
+
} catch {
|
|
5690
|
+
return null;
|
|
5691
|
+
}
|
|
5692
|
+
let overVec: number[] | null = null;
|
|
5693
|
+
let textVec: number[] | null = null;
|
|
5694
|
+
if (this.vectors !== undefined) {
|
|
5695
|
+
try {
|
|
5696
|
+
// The new memory's vector is the gate's, already in the cache; the old
|
|
5697
|
+
// one's is computed here rather than read from box 3, which a backfill
|
|
5698
|
+
// may not have reached and which may hold another model's vectors.
|
|
5699
|
+
textVec = await this.vectors.vector(p.title, p.content);
|
|
5700
|
+
overVec = await this.vectors.vector(row.title, row.body);
|
|
5701
|
+
} catch {
|
|
5702
|
+
textVec = null;
|
|
5703
|
+
overVec = null;
|
|
5704
|
+
}
|
|
5705
|
+
}
|
|
5706
|
+
let ignoreNames: string[] = [];
|
|
5707
|
+
try {
|
|
5708
|
+
// The owner's names: half the store says them, so sharing one says nothing.
|
|
5709
|
+
ignoreNames = ownerNames(this.store);
|
|
5710
|
+
} catch {
|
|
5711
|
+
// No names to set aside: the words read as they are.
|
|
5712
|
+
}
|
|
5713
|
+
const read = updateRelatedness({
|
|
5714
|
+
over: `${row.title ?? ""}\n${row.body}`,
|
|
5715
|
+
text: `${p.title ?? ""}\n${p.content}`,
|
|
5716
|
+
overVec,
|
|
5717
|
+
textVec,
|
|
5718
|
+
ignoreNames,
|
|
5719
|
+
});
|
|
5720
|
+
this.emit("counterpart.update.read", target, {
|
|
5721
|
+
related: read.related,
|
|
5722
|
+
by: read.by,
|
|
5723
|
+
cosine: read.cosine,
|
|
5724
|
+
shared: read.shared.length,
|
|
5725
|
+
how,
|
|
5726
|
+
});
|
|
5727
|
+
if (read.related) return null;
|
|
5728
|
+
const owner = ctx.owner === undefined ? this.owner : ctx.owner && !this.observer;
|
|
5729
|
+
return { over: target, ...heldView(row, owner), how, by: read.by, cosine: read.cosine, shared: read.shared.length };
|
|
5730
|
+
}
|
|
5731
|
+
|
|
5732
|
+
/**
|
|
5733
|
+
* A CLOSE OR A REDATE goes straight through the update guard (2026-10-09):
|
|
5734
|
+
* the write acts on something the memory it names HOLDS, so it is that
|
|
5735
|
+
* memory the writer means.
|
|
5736
|
+
*
|
|
5737
|
+
* - The memory is an OPEN THREAD. Both roads the tools document close one
|
|
5738
|
+
* — `unresolved: false`, or `how: changed` with the answer — and an
|
|
5739
|
+
* answer rarely repeats its question ("which cache?" / "Redis").
|
|
5740
|
+
* - The write sends a reminder field (`eventDate`, a date or null, or
|
|
5741
|
+
* `remind`) and the memory holds a date: a reschedule or a "done".
|
|
5742
|
+
* - The write sends a `status` and the memory has a different one
|
|
5743
|
+
* (planned, now done).
|
|
5744
|
+
*
|
|
5745
|
+
* A field the memory has nothing for — a date on an undated memory, a
|
|
5746
|
+
* status where it had none — dates or describes the NEW memory, and the
|
|
5747
|
+
* guard reads the pair as it would any other.
|
|
5748
|
+
*/
|
|
5749
|
+
private closesOrRedates(p: Proposal, target: string, row: MemoryRow, sent: SentFacts | undefined): boolean {
|
|
5750
|
+
try {
|
|
5751
|
+
if (this.store.readProse(target).meta[UNRESOLVED_META_KEY] === true) return true;
|
|
5752
|
+
} catch {
|
|
5753
|
+
// Unreadable prose: no thread this can see.
|
|
5754
|
+
}
|
|
5755
|
+
const intent = p.dateIntent;
|
|
5756
|
+
if (intent !== undefined && (intent.eventDate !== "absent" || intent.remind !== null) && this.reminderHolder(target) !== null) return true;
|
|
5757
|
+
const now = sent?.status ?? null;
|
|
5758
|
+
const was = statusOf(row.status ?? null);
|
|
5759
|
+
return now !== null && was !== null && now !== was;
|
|
5760
|
+
}
|
|
5761
|
+
|
|
5762
|
+
/** The hold's durable row and its in-process event. Telemetry never breaks the door. */
|
|
5763
|
+
private recordHold(held: HeldUpdate, holds: string, source: ProposalSource, ctx: SessionEndDepositContext, day: number): void {
|
|
5764
|
+
const payload = {
|
|
5765
|
+
holds,
|
|
5766
|
+
over: held.over,
|
|
5767
|
+
how: held.how,
|
|
5768
|
+
by: held.by,
|
|
5769
|
+
cosine: held.cosine,
|
|
5770
|
+
shared: held.shared,
|
|
5771
|
+
source,
|
|
5772
|
+
writeUp: ctx.writeUp !== undefined,
|
|
5773
|
+
actor: "session",
|
|
5774
|
+
actorId: ctx.session,
|
|
5775
|
+
day,
|
|
5776
|
+
};
|
|
5777
|
+
this.emit("counterpart.update.held", holds, { over: held.over, how: held.how, by: held.by, cosine: held.cosine, shared: held.shared, source });
|
|
5778
|
+
try {
|
|
5779
|
+
this.store.appendEvent({ name: CONTRADICTION_HELD_EVENT, day, ref: holds, payload });
|
|
5780
|
+
} catch (err) {
|
|
5781
|
+
this.emit("counterpart.update.held.record.failed", holds, { error: errCode(err) });
|
|
5782
|
+
}
|
|
5783
|
+
}
|
|
5784
|
+
|
|
5785
|
+
/**
|
|
5786
|
+
* THE WRITER'S THREE FIELDS FOR A NEW MEMORY (v12, 2026-10-03): what the
|
|
5787
|
+
* writer sent, field by field, and — for a revision of a memory the author
|
|
5788
|
+
* addressed by `updates:` (declared and resolved, as `carryReminder` reads
|
|
5789
|
+
* it) — what it left out, taken from the memory it revises. A field sent as
|
|
5790
|
+
* null carries nothing. Unlike the reminder nothing MOVES: the old memory
|
|
5791
|
+
* keeps its own three, which describe its words truly. Null when nothing
|
|
5792
|
+
* was sent and nothing carried.
|
|
5793
|
+
*/
|
|
5794
|
+
private carryFacts(p: Proposal, sent: SentFacts | undefined): DepositFacts | null {
|
|
5795
|
+
const target = p.updates?.method === "declared" ? p.updates.resolved : null;
|
|
5796
|
+
let row: MemoryRow | undefined;
|
|
5797
|
+
try {
|
|
5798
|
+
row = target === null ? undefined : this.store.row(target);
|
|
5799
|
+
} catch {
|
|
5800
|
+
row = undefined;
|
|
5801
|
+
}
|
|
5802
|
+
const inherited: FactField[] = [];
|
|
5803
|
+
const pick = <T extends string>(field: FactField, given: T | null | undefined, prior: T | null): T | null => {
|
|
5804
|
+
if (given !== undefined) return given;
|
|
5805
|
+
if (prior !== null) inherited.push(field);
|
|
5806
|
+
return prior;
|
|
5206
5807
|
};
|
|
5808
|
+
const occurredOn = pick("occurredOn", sent?.occurredOn, occurredOnOf(row?.occurred_on ?? null));
|
|
5809
|
+
const saidBy = pick("saidBy", sent?.saidBy, saidByOf(row?.said_by ?? null));
|
|
5810
|
+
const status = pick("status", sent?.status, statusOf(row?.status ?? null));
|
|
5811
|
+
if (occurredOn === null && saidBy === null && status === null && inherited.length === 0) {
|
|
5812
|
+
return sent === undefined || Object.keys(sent).length === 0 ? null : { occurredOn, saidBy, status, inherited, from: null };
|
|
5813
|
+
}
|
|
5814
|
+
return { occurredOn, saidBy, status, inherited, from: inherited.length > 0 ? (target as string) : null };
|
|
5207
5815
|
}
|
|
5208
5816
|
|
|
5209
5817
|
/**
|
|
@@ -5222,7 +5830,7 @@ export class Counterpart {
|
|
|
5222
5830
|
* the reminder. `Store#revise` keeps the old meta in the version it writes.
|
|
5223
5831
|
* A failed clear does not fail the deposit; it is emitted and reported.
|
|
5224
5832
|
*/
|
|
5225
|
-
private closeThread(p: Proposal, successor: string): { from: string; closed: boolean; refused?: ThreadRefusal } | null {
|
|
5833
|
+
private closeThread(p: Proposal, successor: string, owner: boolean): { from: string; closed: boolean; refused?: ThreadRefusal } | null {
|
|
5226
5834
|
if (p.threadSaid !== true) return null;
|
|
5227
5835
|
const target = p.updates?.method === "declared" ? p.updates.resolved : null;
|
|
5228
5836
|
if (target === null || target === successor) return null;
|
|
@@ -5238,8 +5846,8 @@ export class Counterpart {
|
|
|
5238
5846
|
// nothing written in another directory.
|
|
5239
5847
|
if (row.protected === 1) refused = "protected-refuses-revision";
|
|
5240
5848
|
else if (row.archived === 1) refused = "target-archived";
|
|
5241
|
-
else if (!
|
|
5242
|
-
else if (!
|
|
5849
|
+
else if (!owner && row.confidential === 1) refused = "confidential";
|
|
5850
|
+
else if (!owner && (row.origin_scope ?? "") !== p.scope) refused = "other-directory";
|
|
5243
5851
|
} catch {
|
|
5244
5852
|
return null;
|
|
5245
5853
|
}
|
|
@@ -5293,18 +5901,34 @@ export class Counterpart {
|
|
|
5293
5901
|
const priorDate = this.store.row(from)?.event_date ?? null;
|
|
5294
5902
|
if (priorDate === null) return none;
|
|
5295
5903
|
let priorMode: "plain" | "quiet" = "quiet";
|
|
5904
|
+
let priorRule: Recurrence | null = null;
|
|
5296
5905
|
try {
|
|
5297
|
-
|
|
5906
|
+
const prior = this.store.readProse(from);
|
|
5907
|
+
priorMode = cueModeOf(prior);
|
|
5908
|
+
priorRule = recurrenceOf(prior);
|
|
5298
5909
|
} catch {
|
|
5299
|
-
// Unreadable prose: the date still carries, at the default mode.
|
|
5910
|
+
// Unreadable prose: the date still carries, at the default mode, once.
|
|
5300
5911
|
}
|
|
5301
5912
|
const eventDate =
|
|
5302
5913
|
intent.eventDate === "set" ? p.eventDate : intent.eventDate === "cleared" ? null : priorDate;
|
|
5303
5914
|
const remind = eventDate === null ? null : intent.remind ?? priorMode;
|
|
5304
|
-
|
|
5915
|
+
// HOW OFTEN, field by field like the rest (2026-10-09): what the author
|
|
5916
|
+
// sent, `null` for "no longer repeats", else the revised memory's. Only a
|
|
5917
|
+
// day repeats, so a revision that moves the date to a month or a range
|
|
5918
|
+
// leaves it once — the same occurrence keys are what `lineage` counts.
|
|
5919
|
+
const sentRule = intent.recurring ?? null;
|
|
5920
|
+
const wanted = eventDate === null || sentRule === "cleared" ? null : sentRule ?? priorRule;
|
|
5921
|
+
const recurring = wanted !== null && isDay(eventDate) ? wanted : null;
|
|
5922
|
+
const inherited: ("eventDate" | "remind" | "recurring")[] = [];
|
|
5305
5923
|
if (eventDate !== null && intent.eventDate === "absent") inherited.push("eventDate");
|
|
5306
5924
|
if (eventDate !== null && intent.remind === null) inherited.push("remind");
|
|
5307
|
-
|
|
5925
|
+
if (recurring !== null && sentRule === null) inherited.push("recurring");
|
|
5926
|
+
return {
|
|
5927
|
+
proposal: { ...p, eventDate, remind, recurring, reminderFrom: from },
|
|
5928
|
+
from,
|
|
5929
|
+
inherited,
|
|
5930
|
+
...(wanted !== null && recurring === null ? { recurringDropped: true } : {}),
|
|
5931
|
+
};
|
|
5308
5932
|
}
|
|
5309
5933
|
|
|
5310
5934
|
/**
|
|
@@ -5361,12 +5985,15 @@ export class Counterpart {
|
|
|
5361
5985
|
moved,
|
|
5362
5986
|
eventDate: carry.proposal.eventDate,
|
|
5363
5987
|
remind: carry.proposal.remind,
|
|
5988
|
+
recurring: carry.proposal.recurring ?? null,
|
|
5364
5989
|
inherited: carry.inherited.join(",") || null,
|
|
5365
5990
|
});
|
|
5366
5991
|
return {
|
|
5367
5992
|
from,
|
|
5368
5993
|
eventDate: carry.proposal.eventDate,
|
|
5369
5994
|
remind: carry.proposal.remind,
|
|
5995
|
+
recurring: carry.proposal.recurring ?? null,
|
|
5996
|
+
...(carry.recurringDropped === true ? { recurringDropped: true } : {}),
|
|
5370
5997
|
inherited: carry.inherited,
|
|
5371
5998
|
moved,
|
|
5372
5999
|
};
|
|
@@ -5745,6 +6372,113 @@ export class Counterpart {
|
|
|
5745
6372
|
}
|
|
5746
6373
|
}
|
|
5747
6374
|
|
|
6375
|
+
/**
|
|
6376
|
+
* THE v12 BACKFILL (2026-10-03): the memories written before subject links
|
|
6377
|
+
* existed, linked once to the live cards they name (`via: backfill`), by
|
|
6378
|
+
* the rule a write uses (`Schemas#subjectLinksForAll`). Latched by its
|
|
6379
|
+
* record in meta (`SUBJECTS_BACKFILL_META`), read first, so every open
|
|
6380
|
+
* after the first costs one meta read; idempotent if it is cut short (a
|
|
6381
|
+
* link that exists stays as it was found). Writer-only. Fail-open: a store
|
|
6382
|
+
* whose backfill fails opens all the same, and tries again next open.
|
|
6383
|
+
*/
|
|
6384
|
+
private backfillSubjects(): void {
|
|
6385
|
+
try {
|
|
6386
|
+
if (this.store.getMeta(SUBJECTS_BACKFILL_META) !== undefined) return;
|
|
6387
|
+
const started = this.nowFn();
|
|
6388
|
+
const found = this.schemas.subjectLinksForAll();
|
|
6389
|
+
const added = found.links.length === 0 ? 0 : this.store.linkSubjects(found.links, "backfill");
|
|
6390
|
+
this.store.setMeta(
|
|
6391
|
+
SUBJECTS_BACKFILL_META,
|
|
6392
|
+
JSON.stringify({ at: this.nowFn(), ms: this.nowFn() - started, memories: found.memories, links: added, cards: found.cards }),
|
|
6393
|
+
);
|
|
6394
|
+
this.emit("counterpart.subjects.backfill", undefined, { memories: found.memories, links: added, cards: found.cards });
|
|
6395
|
+
} catch (err) {
|
|
6396
|
+
this.emit("counterpart.subjects.backfill.failed", undefined, { code: errCode(err) });
|
|
6397
|
+
}
|
|
6398
|
+
}
|
|
6399
|
+
|
|
6400
|
+
/**
|
|
6401
|
+
* THE LINKS REGROWN COPIES WERE LEFT HOLDING, carried once (2026-10-09).
|
|
6402
|
+
* Until then a chapter copy archived `episode-regrown` kept every link it
|
|
6403
|
+
* had learned, and an archived row conducts nothing: the owner's store held
|
|
6404
|
+
* 260 of its 1,200 edge rows on such copies on 10-02. Each copy's links go
|
|
6405
|
+
* to its chapter's live copy (`origin_ref`, the chapter's id) by the rule a
|
|
6406
|
+
* regrowth now uses at the time — `associate.retargetOnSupersede`: the
|
|
6407
|
+
* weight as it stands today, `max`, both ways — so a link that has faded
|
|
6408
|
+
* below the floor since carries nothing. Read from the edge table, so the
|
|
6409
|
+
* pass is as long as the links are, not as long as the store. Latched like
|
|
6410
|
+
* the v12 backfill (its record in meta, read first); idempotent if cut
|
|
6411
|
+
* short; writer-only; fail-open, tried again next open.
|
|
6412
|
+
*
|
|
6413
|
+
* Review of #329: a copy a removal has taken dark carries nothing (its rows
|
|
6414
|
+
* wait for the chase, and must not outlive it on the live copy), and the
|
|
6415
|
+
* reads are one per kind, not one per row: `origin_ref` has no index, and a
|
|
6416
|
+
* `list({ originRef })` per chapter cost 2.3 s of a 2.8 s pass on a
|
|
6417
|
+
* 15k-row store (`store.copiesOf` is the one-scan read the wake uses).
|
|
6418
|
+
*/
|
|
6419
|
+
private relinkRegrownCopies(): void {
|
|
6420
|
+
try {
|
|
6421
|
+
if (this.store.getMeta(REGROWN_RELINK_META) !== undefined) return;
|
|
6422
|
+
const started = this.nowFn();
|
|
6423
|
+
const day = this.store.livedDay();
|
|
6424
|
+
const denied = new Set(this.store.deniedIds());
|
|
6425
|
+
const archived = new Set(this.store.list({ type: "memory", archived: true }));
|
|
6426
|
+
let removed = 0;
|
|
6427
|
+
const stale: { id: string; episode: string | null }[] = [];
|
|
6428
|
+
for (const src of new Set(this.store.allEdges().map((e) => e.src))) {
|
|
6429
|
+
if (!archived.has(src)) continue;
|
|
6430
|
+
const row = this.store.row(src);
|
|
6431
|
+
if (row === undefined || row.archived !== 1 || row.archived_reason !== EPISODE_REGROWN_REASON) continue;
|
|
6432
|
+
if (denied.has(src)) {
|
|
6433
|
+
removed += 1;
|
|
6434
|
+
continue;
|
|
6435
|
+
}
|
|
6436
|
+
stale.push({ id: src, episode: row.origin_ref });
|
|
6437
|
+
}
|
|
6438
|
+
// Each chapter's live copy. There is one, unless the chapter's copy was
|
|
6439
|
+
// itself taken out since; were there two, the latest written.
|
|
6440
|
+
const episodes = stale.flatMap((s) => (s.episode === null ? [] : [s.episode]));
|
|
6441
|
+
const held = episodes.length === 0 ? new Map<string, { id: string }[]>() : this.store.copiesOf(episodes);
|
|
6442
|
+
const liveCopy = new Map<string, string | null>();
|
|
6443
|
+
for (const [episode, found] of held) {
|
|
6444
|
+
const ids = found.map((f) => f.id).filter((id) => !denied.has(id));
|
|
6445
|
+
liveCopy.set(
|
|
6446
|
+
episode,
|
|
6447
|
+
ids.length === 0 ? null : ids.reduce((a, b) => ((this.store.row(b)?.created_at ?? 0) > (this.store.row(a)?.created_at ?? 0) ? b : a)),
|
|
6448
|
+
);
|
|
6449
|
+
}
|
|
6450
|
+
let copies = 0;
|
|
6451
|
+
let edges = 0;
|
|
6452
|
+
let noLiveCopy = 0;
|
|
6453
|
+
let failed = 0;
|
|
6454
|
+
for (const { id: src, episode } of stale) {
|
|
6455
|
+
const to = episode === null ? null : (liveCopy.get(episode) ?? null);
|
|
6456
|
+
if (to === null) {
|
|
6457
|
+
noLiveCopy += 1;
|
|
6458
|
+
continue;
|
|
6459
|
+
}
|
|
6460
|
+
const out = this.associate.retargetOnSupersede(src, to, day);
|
|
6461
|
+
// The edge module answers a failed write rather than throwing it.
|
|
6462
|
+
if (out.reason === "failed") {
|
|
6463
|
+
failed += 1;
|
|
6464
|
+
continue;
|
|
6465
|
+
}
|
|
6466
|
+
copies += 1;
|
|
6467
|
+
edges += out.pairs;
|
|
6468
|
+
}
|
|
6469
|
+
this.emit("counterpart.regrown.relink", undefined, { copies, edges, noLiveCopy, removed, failed, day });
|
|
6470
|
+
// A pass a failed write cut short is NOT latched, so the next open tries
|
|
6471
|
+
// again (`max` makes the second carry of what did land a no-op).
|
|
6472
|
+
if (failed > 0) return;
|
|
6473
|
+
this.store.setMeta(
|
|
6474
|
+
REGROWN_RELINK_META,
|
|
6475
|
+
JSON.stringify({ at: this.nowFn(), ms: this.nowFn() - started, day, copies, edges, noLiveCopy, removed }),
|
|
6476
|
+
);
|
|
6477
|
+
} catch (err) {
|
|
6478
|
+
this.emit("counterpart.regrown.relink.failed", undefined, { code: errCode(err) });
|
|
6479
|
+
}
|
|
6480
|
+
}
|
|
6481
|
+
|
|
5748
6482
|
private emit(
|
|
5749
6483
|
name: string,
|
|
5750
6484
|
ref?: string,
|
|
@@ -5762,3 +6496,15 @@ export class Counterpart {
|
|
|
5762
6496
|
this.onEvent?.(event);
|
|
5763
6497
|
}
|
|
5764
6498
|
}
|
|
6499
|
+
|
|
6500
|
+
/** A proposal without its `how`: its declaration links and settles nothing (`revision.ts`). */
|
|
6501
|
+
function withoutHow(p: Proposal): Proposal {
|
|
6502
|
+
const { how: _how, ...rest } = p;
|
|
6503
|
+
void _how;
|
|
6504
|
+
return rest as Proposal;
|
|
6505
|
+
}
|
|
6506
|
+
|
|
6507
|
+
/** A proposal without its `updates` (a held one, `Counterpart#guardUpdate`): a new memory, linked to nothing. */
|
|
6508
|
+
function withoutUpdates(p: Proposal): Proposal {
|
|
6509
|
+
return { ...withoutHow(p), updates: null };
|
|
6510
|
+
}
|