counterparts 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CONSTITUTION.md +68 -0
- package/LICENSE +21 -0
- package/README.md +348 -0
- package/docs/ELI5.md +84 -0
- package/docs/QUICKSTART.md +1258 -0
- package/docs/module-map.md +81 -0
- package/package.json +63 -0
- package/src/adapters/claude-code/CONTRACT.md +606 -0
- package/src/adapters/claude-code/INTERFACE-GAPS.md +655 -0
- package/src/adapters/claude-code/NOTES.md +1055 -0
- package/src/adapters/claude-code/bin/hook.ts +820 -0
- package/src/adapters/claude-code/bin/runner.ts +522 -0
- package/src/adapters/claude-code/config.ts +778 -0
- package/src/adapters/claude-code/credentials.ts +199 -0
- package/src/adapters/claude-code/doctor.ts +2557 -0
- package/src/adapters/claude-code/embed-client.ts +617 -0
- package/src/adapters/claude-code/hooks.ts +2240 -0
- package/src/adapters/claude-code/index.ts +224 -0
- package/src/adapters/claude-code/interpret-client.ts +395 -0
- package/src/adapters/claude-code/page-writer.ts +462 -0
- package/src/adapters/claude-code/primacy.ts +162 -0
- package/src/adapters/claude-code/spawn.ts +241 -0
- package/src/adapters/claude-code/standdown.ts +536 -0
- package/src/adapters/claude-code/transcript.ts +661 -0
- package/src/adapters/claude-code/vectors.ts +415 -0
- package/src/adapters/cli/CONTRACT.md +255 -0
- package/src/adapters/cli/INTERFACE-GAPS.md +350 -0
- package/src/adapters/cli/NOTES.md +936 -0
- package/src/adapters/cli/bin/counterparts.ts +74 -0
- package/src/adapters/cli/commands.ts +6095 -0
- package/src/adapters/cli/export.ts +766 -0
- package/src/adapters/cli/index.ts +103 -0
- package/src/adapters/cli/install.ts +670 -0
- package/src/adapters/cli/removal.ts +1186 -0
- package/src/adapters/cli/repair-dates.ts +659 -0
- package/src/adapters/cli/self-page.ts +229 -0
- package/src/adapters/cli/snapshot.ts +279 -0
- package/src/adapters/cli/start-fresh.ts +1228 -0
- package/src/adapters/config-path.ts +342 -0
- package/src/adapters/dashboard/CONTRACT.md +67 -0
- package/src/adapters/dashboard/INTERFACE-GAPS.md +139 -0
- package/src/adapters/dashboard/NOTES.md +474 -0
- package/src/adapters/dashboard/activity.ts +121 -0
- package/src/adapters/dashboard/ansi.ts +82 -0
- package/src/adapters/dashboard/bin/dashboard.ts +479 -0
- package/src/adapters/dashboard/browse.ts +298 -0
- package/src/adapters/dashboard/identity.ts +182 -0
- package/src/adapters/dashboard/index.ts +183 -0
- package/src/adapters/dashboard/layout.ts +149 -0
- package/src/adapters/dashboard/registries.ts +291 -0
- package/src/adapters/dashboard/resolve.ts +206 -0
- package/src/adapters/dashboard/source.ts +48 -0
- package/src/adapters/dashboard/status.ts +327 -0
- package/src/adapters/dashboard/stories.ts +194 -0
- package/src/adapters/dashboard/web/app.html +1731 -0
- package/src/adapters/dashboard/web/brain.html +463 -0
- package/src/adapters/dashboard/web/fired.ts +31 -0
- package/src/adapters/dashboard/web/flow.ts +457 -0
- package/src/adapters/dashboard/web/narrate.ts +1042 -0
- package/src/adapters/dashboard/web/reveal.ts +135 -0
- package/src/adapters/dashboard/web/server.ts +287 -0
- package/src/adapters/dashboard/web/views.ts +1744 -0
- package/src/adapters/expansions.ts +569 -0
- package/src/adapters/fired.ts +1580 -0
- package/src/adapters/mcp/CONTRACT.md +240 -0
- package/src/adapters/mcp/INTERFACE-GAPS.md +271 -0
- package/src/adapters/mcp/NOTES.md +205 -0
- package/src/adapters/mcp/bin/serve.ts +349 -0
- package/src/adapters/mcp/deliberate.ts +619 -0
- package/src/adapters/mcp/index.ts +101 -0
- package/src/adapters/mcp/protocol.ts +170 -0
- package/src/adapters/mcp/server.ts +1740 -0
- package/src/adapters/mcp/stdio.ts +56 -0
- package/src/adapters/mcp/tools.ts +779 -0
- package/src/adapters/scopes.ts +657 -0
- package/src/adapters/sessions.ts +402 -0
- package/src/adapters/snapshots.ts +1069 -0
- package/src/adapters/stance-env.ts +137 -0
- package/src/core/associate/CONTRACT.md +118 -0
- package/src/core/associate/INTERFACE-GAPS.md +173 -0
- package/src/core/associate/NOTES.md +194 -0
- package/src/core/associate/buffer.ts +66 -0
- package/src/core/associate/edges.ts +188 -0
- package/src/core/associate/index.ts +570 -0
- package/src/core/associate/pending.ts +383 -0
- package/src/core/associate/spread.ts +149 -0
- package/src/core/associate/tunables.ts +123 -0
- package/src/core/bridge.ts +272 -0
- package/src/core/briefing.ts +67 -0
- package/src/core/counterpart.ts +3855 -0
- package/src/core/encode/CONTRACT.md +151 -0
- package/src/core/encode/INTERFACE-GAPS.md +135 -0
- package/src/core/encode/NOTES.md +146 -0
- package/src/core/encode/aliases.ts +71 -0
- package/src/core/encode/battery.ts +284 -0
- package/src/core/encode/chunk.ts +265 -0
- package/src/core/encode/emotion.ts +119 -0
- package/src/core/encode/floor.ts +76 -0
- package/src/core/encode/index.ts +100 -0
- package/src/core/encode/precision.ts +162 -0
- package/src/core/encode/preselect.ts +269 -0
- package/src/core/encode/salience.ts +108 -0
- package/src/core/encode/secrets.ts +265 -0
- package/src/core/encode/tunables.ts +99 -0
- package/src/core/encode/types.ts +286 -0
- package/src/core/encode/words.ts +75 -0
- package/src/core/handoff/CONTRACT.md +199 -0
- package/src/core/handoff/INTERFACE-GAPS.md +166 -0
- package/src/core/handoff/NOTES.md +206 -0
- package/src/core/handoff/index.ts +957 -0
- package/src/core/mint.ts +279 -0
- package/src/core/observer.ts +28 -0
- package/src/core/physics/CONTRACT.md +341 -0
- package/src/core/physics/NOTES.md +155 -0
- package/src/core/physics/clock.ts +51 -0
- package/src/core/physics/index.ts +1054 -0
- package/src/core/prospective/CONTRACT.md +137 -0
- package/src/core/prospective/INTERFACE-GAPS.md +112 -0
- package/src/core/prospective/NOTES.md +160 -0
- package/src/core/prospective/derive.ts +188 -0
- package/src/core/prospective/index.ts +1030 -0
- package/src/core/prospective/tunables.ts +72 -0
- package/src/core/prospective/windows.ts +187 -0
- package/src/core/recall/CONTRACT.md +326 -0
- package/src/core/recall/INTERFACE-GAPS.md +163 -0
- package/src/core/recall/NOTES.md +472 -0
- package/src/core/recall/activate.ts +521 -0
- package/src/core/recall/cues.ts +275 -0
- package/src/core/recall/gate.ts +441 -0
- package/src/core/recall/index.ts +692 -0
- package/src/core/recall/probe.ts +239 -0
- package/src/core/recall/reference.ts +201 -0
- package/src/core/recall/render.ts +285 -0
- package/src/core/recall/session.ts +403 -0
- package/src/core/recall/tunables.ts +329 -0
- package/src/core/remember/CONTRACT.md +293 -0
- package/src/core/remember/INTERFACE-GAPS.md +189 -0
- package/src/core/remember/NOTES.md +373 -0
- package/src/core/remember/fallback.ts +452 -0
- package/src/core/remember/index.ts +103 -0
- package/src/core/remember/owner-strike-seam.ts +479 -0
- package/src/core/remember/proposals.ts +609 -0
- package/src/core/remember/spans.ts +1310 -0
- package/src/core/remember/tunables.ts +111 -0
- package/src/core/remember/updates.ts +198 -0
- package/src/core/retrieval.ts +96 -0
- package/src/core/revision.ts +441 -0
- package/src/core/schemas/CONTRACT.md +190 -0
- package/src/core/schemas/INTERFACE-GAPS.md +172 -0
- package/src/core/schemas/NOTES.md +260 -0
- package/src/core/schemas/aliases.ts +160 -0
- package/src/core/schemas/index.ts +1459 -0
- package/src/core/schemas/tunables.ts +44 -0
- package/src/core/schemas/types.ts +387 -0
- package/src/core/self/CONTRACT.md +459 -0
- package/src/core/self/INTERFACE-GAPS.md +284 -0
- package/src/core/self/NOTES.md +1057 -0
- package/src/core/self/briefing.ts +980 -0
- package/src/core/self/episodes.ts +483 -0
- package/src/core/self/freeze.ts +103 -0
- package/src/core/self/identity.ts +604 -0
- package/src/core/self/index.ts +2130 -0
- package/src/core/self/journal-file.ts +760 -0
- package/src/core/self/page.ts +404 -0
- package/src/core/self/tunables.ts +244 -0
- package/src/core/self/writer.ts +714 -0
- package/src/core/sleep/CONTRACT.md +298 -0
- package/src/core/sleep/INTERFACE-GAPS.md +262 -0
- package/src/core/sleep/NOTES.md +770 -0
- package/src/core/sleep/briefing.ts +86 -0
- package/src/core/sleep/consolidate.ts +241 -0
- package/src/core/sleep/cycle.ts +598 -0
- package/src/core/sleep/decay.ts +237 -0
- package/src/core/sleep/dedup.ts +373 -0
- package/src/core/sleep/index.ts +112 -0
- package/src/core/sleep/log.ts +116 -0
- package/src/core/sleep/markers.ts +164 -0
- package/src/core/sleep/prune.ts +170 -0
- package/src/core/sleep/strength-cache.ts +176 -0
- package/src/core/sleep/tunables.ts +135 -0
- package/src/core/sleep/types.ts +542 -0
- package/src/core/store/CONTRACT.md +446 -0
- package/src/core/store/NOTES.md +1068 -0
- package/src/core/store/cache.ts +709 -0
- package/src/core/store/db.ts +275 -0
- package/src/core/store/errors.ts +134 -0
- package/src/core/store/index.ts +2450 -0
- package/src/core/store/operational.ts +610 -0
- package/src/core/store/owner-op-seam.ts +428 -0
- package/src/core/store/paths.ts +494 -0
- package/src/core/store/prose.ts +165 -0
- package/src/core/store/render.ts +87 -0
- package/src/core/store/walk-seam.ts +78 -0
- package/src/core/types.ts +68 -0
- package/tools/install-loop/run.sh +1063 -0
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Every constant this module owns, in one visible place.
|
|
3
|
+
*
|
|
4
|
+
* CAL = calibration-required: it must ship with a recorded measurement against
|
|
5
|
+
* the real name space, or ship disabled (scar §2.8 — "the near-collision
|
|
6
|
+
* similarity bar is measured, not intuited"; v1's 0.60 embedding floor was set
|
|
7
|
+
* from intuition and was inert because arbitrary same-corpus pairs already sat
|
|
8
|
+
* at 0.576).
|
|
9
|
+
*/
|
|
10
|
+
export const TUNABLES = {
|
|
11
|
+
/**
|
|
12
|
+
* CAL. Near collision is TOKEN CONTAINMENT: "Mike" against "Mike Chen".
|
|
13
|
+
* Chosen because it is the exact shape §14.3 names, needs no embedder, and
|
|
14
|
+
* fails toward refusal rather than toward a silent merge. It is NOT a
|
|
15
|
+
* measured similarity bar; a measured one replaces it, and the replacement is
|
|
16
|
+
* the reason this is a tunable rather than a hard-coded `if`.
|
|
17
|
+
*/
|
|
18
|
+
NEAR_COLLISION: "token-containment" as const,
|
|
19
|
+
|
|
20
|
+
/** At most one birth per chunk, counted by the engine (§5 G3). */
|
|
21
|
+
MAX_BIRTHS_PER_CHUNK: 1,
|
|
22
|
+
|
|
23
|
+
/** Minimum characters in a name. Shorter than this cannot be whole-worded
|
|
24
|
+
* usefully and mints handles that collide with English. */
|
|
25
|
+
NAME_MIN_CHARS: 2,
|
|
26
|
+
|
|
27
|
+
/** The tier a re-mention credits. `referenced` deliberately: a mention is the
|
|
28
|
+
* entity being USED, and the ignorable tier (footnoted, w = 0) would make
|
|
29
|
+
* "accumulates" unreachable — a stub that is mentioned every day would still
|
|
30
|
+
* fade, which is not the lifecycle the contract describes (NOTES.md §4). */
|
|
31
|
+
MENTION_TIER: "referenced" as const,
|
|
32
|
+
|
|
33
|
+
/** Why an entity's archive row says it left. One string, one meaning. */
|
|
34
|
+
FADE_REASON: "faded-by-decay" as const,
|
|
35
|
+
|
|
36
|
+
/** What the versions row says when a belief fell to accumulated pressure. */
|
|
37
|
+
REVISED_REASON: "revised-by-pressure" as const,
|
|
38
|
+
|
|
39
|
+
/** And when a "now" fact was replaced on one clear correction (§4.3). The two
|
|
40
|
+
* are DIFFERENT strings because they are different crossings: a reader of the
|
|
41
|
+
* lineage must be able to tell a bar that was climbed from a fact that simply
|
|
42
|
+
* changed (scar §2.4). */
|
|
43
|
+
REPLACED_REASON: "replaced-by-declaration" as const,
|
|
44
|
+
} as const;
|
|
@@ -0,0 +1,387 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `schemas/` — the vocabulary of semantic memory.
|
|
3
|
+
*
|
|
4
|
+
* Three ROLES share one prose family (`type: "schema"`), because what
|
|
5
|
+
* distinguishes them is lifecycle, not shape (behavioral-spec §4.2):
|
|
6
|
+
*
|
|
7
|
+
* - `entity` the organizing unit — a person, a place, a skill, a
|
|
8
|
+
* project/system, the self. Born by mention, dies by decay.
|
|
9
|
+
* - `belief` a statement held about an entity. Revised only by physics
|
|
10
|
+
* §5.6 arithmetic; there is no edit verb (CONTRACT §5 G1).
|
|
11
|
+
* - `current-state` timestamped status about an entity. Refused on the
|
|
12
|
+
* identity schema — the ~72 KB lesson (CONTRACT §3).
|
|
13
|
+
*
|
|
14
|
+
* Every row's `kind` is the ENTITY's kind, fixed at birth and never re-derived,
|
|
15
|
+
* so a belief about a person moves at person inertia (iota 0.8) and project
|
|
16
|
+
* status on an entity moves at entity inertia (0.5) — "a loosening chosen out
|
|
17
|
+
* loud" (§4.3).
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
import type { Band, Kind, Salience } from "../types.js";
|
|
21
|
+
|
|
22
|
+
// ---------------------------------------------------------------------------
|
|
23
|
+
// Roles and kinds
|
|
24
|
+
// ---------------------------------------------------------------------------
|
|
25
|
+
|
|
26
|
+
export const SCHEMA_ROLES = ["entity", "belief", "current-state"] as const;
|
|
27
|
+
export type SchemaRole = (typeof SCHEMA_ROLES)[number];
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* The kinds birth-by-mention may mint. `self` is absent DELIBERATELY and
|
|
31
|
+
* independently of every other check — "one identity core; a second is a
|
|
32
|
+
* category error no evidence could justify" (§14.3, CONTRACT §5 G5). `fact` is
|
|
33
|
+
* absent because a fact is a memory, not a thing memories attach to.
|
|
34
|
+
*/
|
|
35
|
+
export const BIRTH_KINDS = ["person", "entity", "skill", "place"] as const;
|
|
36
|
+
export type BirthKind = (typeof BIRTH_KINDS)[number];
|
|
37
|
+
|
|
38
|
+
export function isBirthKind(kind: Kind): kind is BirthKind {
|
|
39
|
+
return (BIRTH_KINDS as readonly string[]).includes(kind);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// ---------------------------------------------------------------------------
|
|
43
|
+
// Telemetry — ids, hashes, counts, kinds, reasons. NEVER a name, NEVER a body.
|
|
44
|
+
// ---------------------------------------------------------------------------
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* A schema NAME is author content that the store indexes: it is logged as a
|
|
48
|
+
* hash, exactly the way `encode/` logs a dropped alias by index rather than by
|
|
49
|
+
* text. The proposal is logged, not only the outcome (scar §2.4).
|
|
50
|
+
*/
|
|
51
|
+
export interface SchemaEvent {
|
|
52
|
+
at: number;
|
|
53
|
+
event: string;
|
|
54
|
+
ref?: string;
|
|
55
|
+
data?: Record<string, string | number | boolean | null>;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// ---------------------------------------------------------------------------
|
|
59
|
+
// Birth by mention
|
|
60
|
+
// ---------------------------------------------------------------------------
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Outcomes of one mention. `born` and `existing` are both successes and are
|
|
64
|
+
* DIFFERENT RECORDS; every other value is a loud refusal with its ground named
|
|
65
|
+
* (scar §2.4 — v1's zero births were ambiguous precisely because "refused" and
|
|
66
|
+
* "never proposed" were indistinguishable).
|
|
67
|
+
*/
|
|
68
|
+
export type BirthReason =
|
|
69
|
+
| "born"
|
|
70
|
+
| "existing"
|
|
71
|
+
| "second-self-refused"
|
|
72
|
+
| "kind-not-allowed"
|
|
73
|
+
| "name-empty"
|
|
74
|
+
| "name-is-secret"
|
|
75
|
+
| "name-not-in-source"
|
|
76
|
+
| "ambiguous-existing-name"
|
|
77
|
+
| "collision-exact-different-kind"
|
|
78
|
+
| "collision-near"
|
|
79
|
+
| "birth-cap-per-chunk";
|
|
80
|
+
|
|
81
|
+
export interface MentionInput {
|
|
82
|
+
/** The name as the source said it. Matched against the source verbatim. */
|
|
83
|
+
name: string;
|
|
84
|
+
kind: Kind;
|
|
85
|
+
/** The span the name must occur in, as a whole word (§5 G2). */
|
|
86
|
+
source: string;
|
|
87
|
+
/** The chunk this mention came from — the birth cap counts by it (§5 G3). */
|
|
88
|
+
chunkRef: string;
|
|
89
|
+
/** Verified individually and DROPPED rather than fatal (§4). */
|
|
90
|
+
aliases?: readonly string[];
|
|
91
|
+
/** The lived day. Explicit, never read from a wall clock (scar E8). */
|
|
92
|
+
day: number;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export interface BirthOutcome {
|
|
96
|
+
/** True for both `born` and `existing`: a mention that found its home. */
|
|
97
|
+
ok: boolean;
|
|
98
|
+
reason: BirthReason;
|
|
99
|
+
/** The entity this mention resolved to, when there is one. */
|
|
100
|
+
id: string | null;
|
|
101
|
+
born: boolean;
|
|
102
|
+
/** Ids the refusal collided with — a near collision names what it hit. */
|
|
103
|
+
collidedWith: string[];
|
|
104
|
+
/** Aliases the alias gate dropped, BY INDEX (author content, §5 G10). */
|
|
105
|
+
droppedAliases: { index: number; reason: string }[];
|
|
106
|
+
keptAliases: string[];
|
|
107
|
+
/** Credited reinforcement on a re-mention, when one landed. */
|
|
108
|
+
reinforced: boolean;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// ---------------------------------------------------------------------------
|
|
112
|
+
// Beliefs and current state
|
|
113
|
+
// ---------------------------------------------------------------------------
|
|
114
|
+
|
|
115
|
+
export interface DimensionsInput {
|
|
116
|
+
relevance: number;
|
|
117
|
+
emotional: number;
|
|
118
|
+
predictive: number;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export interface BeliefInput {
|
|
122
|
+
entityId: string;
|
|
123
|
+
statement: string;
|
|
124
|
+
day: number;
|
|
125
|
+
dimensions?: DimensionsInput;
|
|
126
|
+
/** A FLOOR, never a value (physics §5.1). Clamped at the mint — and capped
|
|
127
|
+
* by the CHANNEL's ceiling (the authorship doctrine, owner ruling
|
|
128
|
+
* 2026-08-29): a fallback author's claim cuts to `SWEEP_CLAIM_CEILING`. */
|
|
129
|
+
claimedSalience?: number | null;
|
|
130
|
+
/** Who is placing this belief. ENGINE-SET by the composition, defaulting
|
|
131
|
+
* "authored"; the caller placing on behalf of a transcript sweep MUST pass
|
|
132
|
+
* "fallback", and the migrate tool passes "migrated" (full floor — lived
|
|
133
|
+
* v1 state). Persisted as the element's `source`. */
|
|
134
|
+
channel?: "authored" | "fallback" | "episode" | "accommodation" | "migrated";
|
|
135
|
+
protected?: boolean;
|
|
136
|
+
/** Provenance: the memory ids that grounded this belief. */
|
|
137
|
+
groundedIn?: readonly string[];
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export type BeliefAddReason =
|
|
141
|
+
| "added"
|
|
142
|
+
| "entity-unknown"
|
|
143
|
+
| "entity-archived"
|
|
144
|
+
| "statement-empty";
|
|
145
|
+
|
|
146
|
+
export interface BeliefOutcome {
|
|
147
|
+
ok: boolean;
|
|
148
|
+
reason: BeliefAddReason;
|
|
149
|
+
id: string | null;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
export interface CurrentStateInput {
|
|
153
|
+
entityId: string;
|
|
154
|
+
statement: string;
|
|
155
|
+
day: number;
|
|
156
|
+
/** When it was true, at stated precision. Defaults to the store's date. */
|
|
157
|
+
statedOn?: string;
|
|
158
|
+
dimensions?: DimensionsInput;
|
|
159
|
+
claimedSalience?: number | null;
|
|
160
|
+
/** See `BeliefInput.channel` — same doctrine, same ceiling. */
|
|
161
|
+
channel?: "authored" | "fallback" | "episode" | "accommodation" | "migrated";
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* `status-on-identity-refused` IS the ~72 KB lesson, mechanized at this seam:
|
|
166
|
+
* v1 rendered ~68-72 KB of dated project status into every self-keyed prompt,
|
|
167
|
+
* and 14 of self's 19 active beliefs were about projects with no retrieval key.
|
|
168
|
+
* The refusal names where the row belongs instead.
|
|
169
|
+
*/
|
|
170
|
+
export type PlacementReason =
|
|
171
|
+
| "placed"
|
|
172
|
+
| "entity-unknown"
|
|
173
|
+
| "entity-archived"
|
|
174
|
+
| "statement-empty"
|
|
175
|
+
| "status-on-identity-refused";
|
|
176
|
+
|
|
177
|
+
export interface PlacementOutcome {
|
|
178
|
+
ok: boolean;
|
|
179
|
+
reason: PlacementReason;
|
|
180
|
+
id: string | null;
|
|
181
|
+
/** On refusal: the kinds of home this row DOES have. Advice, not a redirect. */
|
|
182
|
+
belongsOn: BirthKind[] | null;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
// ---------------------------------------------------------------------------
|
|
186
|
+
// Revision
|
|
187
|
+
// ---------------------------------------------------------------------------
|
|
188
|
+
|
|
189
|
+
export interface ChallengeInput {
|
|
190
|
+
/** The `updates:` DECLARATION, as written. May name a superseded belief. */
|
|
191
|
+
updates: string;
|
|
192
|
+
/** The challenging memory's id. Must already be in the store. */
|
|
193
|
+
challengerId: string;
|
|
194
|
+
day: number;
|
|
195
|
+
/** The successor's prose. Defaults to the challenger's own body. */
|
|
196
|
+
statement?: string;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/** physics' own `ChallengeReason` values, plus this module's seam refusals. */
|
|
200
|
+
export type RevisionReason =
|
|
201
|
+
| "revised"
|
|
202
|
+
| "below-bar"
|
|
203
|
+
| "no-declared-target"
|
|
204
|
+
| "target-mismatch"
|
|
205
|
+
| "already-challenged-today"
|
|
206
|
+
| "stale-day"
|
|
207
|
+
| "target-unresolvable"
|
|
208
|
+
| "target-not-a-belief"
|
|
209
|
+
| "target-archived"
|
|
210
|
+
| "protected-refuses-revision"
|
|
211
|
+
| "challenger-unknown";
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* A CURRENT-STATE row is a "now" fact, and the owner's ruling (2026-09-04) is
|
|
215
|
+
* that a resolved `updates:` against one REPLACES it immediately, with lineage —
|
|
216
|
+
* no pressure to accumulate. World-state flips on one clear correction (§4.3),
|
|
217
|
+
* and pressure on a fact that is already wrong would only delay the correction
|
|
218
|
+
* while the stale row kept rendering into slices.
|
|
219
|
+
*/
|
|
220
|
+
export type ReplacementReason =
|
|
221
|
+
| "replaced"
|
|
222
|
+
| "no-declared-target"
|
|
223
|
+
| "target-unresolvable"
|
|
224
|
+
| "target-not-current-state"
|
|
225
|
+
| "target-archived"
|
|
226
|
+
| "protected-refuses-revision"
|
|
227
|
+
| "challenger-unknown";
|
|
228
|
+
|
|
229
|
+
export interface ReplacementOutcome {
|
|
230
|
+
ok: boolean;
|
|
231
|
+
reason: ReplacementReason;
|
|
232
|
+
/** The id the declaration resolved to after following the supersede chain. */
|
|
233
|
+
targetId: string | null;
|
|
234
|
+
retargeted: boolean;
|
|
235
|
+
successorId: string | null;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
export interface PressureIncrement {
|
|
239
|
+
readonly event: "revision.pressure";
|
|
240
|
+
readonly targetId: string;
|
|
241
|
+
readonly day: number;
|
|
242
|
+
readonly challengerId: string;
|
|
243
|
+
readonly force: number;
|
|
244
|
+
readonly pressureAfter: number;
|
|
245
|
+
readonly bar: number;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
export interface RevisionOutcome {
|
|
249
|
+
verdict: "revise" | "hold";
|
|
250
|
+
reason: RevisionReason;
|
|
251
|
+
/** Did the pressure field on the target row actually move? */
|
|
252
|
+
credited: boolean;
|
|
253
|
+
/** The id the declaration resolved to after following the supersede chain. */
|
|
254
|
+
targetId: string | null;
|
|
255
|
+
/** True when the declaration named a superseded belief and was retargeted. */
|
|
256
|
+
retargeted: boolean;
|
|
257
|
+
successorId: string | null;
|
|
258
|
+
force: number;
|
|
259
|
+
pressureBefore: number;
|
|
260
|
+
pressureAfter: number;
|
|
261
|
+
bar: number;
|
|
262
|
+
increment: PressureIncrement | null;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
// ---------------------------------------------------------------------------
|
|
266
|
+
// Death by decay
|
|
267
|
+
// ---------------------------------------------------------------------------
|
|
268
|
+
|
|
269
|
+
export type FadeReason =
|
|
270
|
+
| "faded"
|
|
271
|
+
| "not-an-entity"
|
|
272
|
+
| "already-archived"
|
|
273
|
+
| "above-floor"
|
|
274
|
+
| "dwell-too-short"
|
|
275
|
+
| "band-not-episodic"
|
|
276
|
+
| "protected"
|
|
277
|
+
| "in-live-revision-chain"
|
|
278
|
+
| "has-live-attached-elements";
|
|
279
|
+
|
|
280
|
+
export interface FadeVerdict {
|
|
281
|
+
fade: boolean;
|
|
282
|
+
reason: FadeReason;
|
|
283
|
+
/** EVERY blocker, not just the first. */
|
|
284
|
+
blockedBy: FadeReason[];
|
|
285
|
+
strength: number;
|
|
286
|
+
band: Band;
|
|
287
|
+
dwellDays: number;
|
|
288
|
+
attached: number;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
export interface FadeReport {
|
|
292
|
+
day: number;
|
|
293
|
+
examined: number;
|
|
294
|
+
faded: string[];
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
// ---------------------------------------------------------------------------
|
|
298
|
+
// Reads
|
|
299
|
+
// ---------------------------------------------------------------------------
|
|
300
|
+
|
|
301
|
+
export interface EntityView {
|
|
302
|
+
id: string;
|
|
303
|
+
name: string;
|
|
304
|
+
kind: Kind;
|
|
305
|
+
aliases: string[];
|
|
306
|
+
archived: boolean;
|
|
307
|
+
archivedReason: string | null;
|
|
308
|
+
birthDay: number;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
export interface ElementView {
|
|
312
|
+
id: string;
|
|
313
|
+
entityId: string;
|
|
314
|
+
role: SchemaRole;
|
|
315
|
+
statement: string;
|
|
316
|
+
kind: Kind;
|
|
317
|
+
archived: boolean;
|
|
318
|
+
supersededBy: string | null;
|
|
319
|
+
protected: boolean;
|
|
320
|
+
salience: Salience;
|
|
321
|
+
/** Present on current-state rows only: when the status was stated. */
|
|
322
|
+
statedOn?: string;
|
|
323
|
+
statedOnDay?: number;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
/**
|
|
327
|
+
* A schema slice as `encode/preselect.ts` consumes it, plus the elision count
|
|
328
|
+
* guarantee 8 requires. Beliefs and current state are VERBATIM — a paraphrase
|
|
329
|
+
* of a belief cannot be honestly confirmed or contradicted (§8 G7).
|
|
330
|
+
*/
|
|
331
|
+
/** One element on a card: the id is the ADDRESS an `updates:` declaration can
|
|
332
|
+
* name, the statement is verbatim (§8 G7 — a paraphrase cannot be honestly
|
|
333
|
+
* contradicted). */
|
|
334
|
+
export interface SliceElement {
|
|
335
|
+
id: string;
|
|
336
|
+
statement: string;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
export interface SchemaSliceOut {
|
|
340
|
+
id: string;
|
|
341
|
+
name: string;
|
|
342
|
+
aliases: string[];
|
|
343
|
+
beliefs: SliceElement[];
|
|
344
|
+
currentState: SliceElement[];
|
|
345
|
+
/**
|
|
346
|
+
* Announced as a count, never a silent omission (§5 G8). Nonzero when the
|
|
347
|
+
* caller asked for the interpreter's view: protected elements never render
|
|
348
|
+
* into the falsification path (§14.1 G2), and each one filtered is counted
|
|
349
|
+
* here rather than silently absent.
|
|
350
|
+
*/
|
|
351
|
+
elided: number;
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
export interface LineageStep {
|
|
355
|
+
id: string;
|
|
356
|
+
seq: number;
|
|
357
|
+
reason: string;
|
|
358
|
+
day: number;
|
|
359
|
+
successorId: string | null;
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
/** What the dashboard's story view reads (constitution line 16). */
|
|
363
|
+
export interface BeliefStory {
|
|
364
|
+
beliefId: string;
|
|
365
|
+
/** The live head of the chain — `beliefId` itself when nothing superseded it. */
|
|
366
|
+
headId: string;
|
|
367
|
+
lineage: LineageStep[];
|
|
368
|
+
pressure: number;
|
|
369
|
+
lastChallengedDay: number | null;
|
|
370
|
+
bar: number;
|
|
371
|
+
strength: number;
|
|
372
|
+
/** Every credited increment this session logged, oldest first. */
|
|
373
|
+
increments: PressureIncrement[];
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
/**
|
|
377
|
+
* Guarantee 13: every kind reports created-versus-exited counts. A kind whose
|
|
378
|
+
* exit count is zero after the bake-in window is a DEFECT TO INVESTIGATE, not a
|
|
379
|
+
* base rate to accept (scar §2.17) — hence the flag, which is deliberately not
|
|
380
|
+
* called `ok`.
|
|
381
|
+
*/
|
|
382
|
+
export interface LifecycleRow {
|
|
383
|
+
kind: Kind;
|
|
384
|
+
created: number;
|
|
385
|
+
exited: number;
|
|
386
|
+
noExitsYet: boolean;
|
|
387
|
+
}
|