memoryking 0.1.0__py3-none-any.whl
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.
- memoryking/__init__.py +3 -0
- memoryking/__main__.py +1328 -0
- memoryking/adapters/__init__.py +1 -0
- memoryking/adapters/adapter_state.py +242 -0
- memoryking/adapters/anchor_schema.sql +7 -0
- memoryking/adapters/atlas.py +441 -0
- memoryking/adapters/browser_commands.py +125 -0
- memoryking/adapters/dashboard.py +510 -0
- memoryking/adapters/dense_search.py +86 -0
- memoryking/adapters/egress_policy.py +244 -0
- memoryking/adapters/egress_schema.sql +13 -0
- memoryking/adapters/embedding.schema.json +302 -0
- memoryking/adapters/embedding_store.py +469 -0
- memoryking/adapters/execution.py +369 -0
- memoryking/adapters/experience.py +423 -0
- memoryking/adapters/experience.schema.json +1508 -0
- memoryking/adapters/experience_records.py +239 -0
- memoryking/adapters/experience_schema.sql +23 -0
- memoryking/adapters/handoff.py +494 -0
- memoryking/adapters/handoff.schema.json +299 -0
- memoryking/adapters/handoff_schema.sql +17 -0
- memoryking/adapters/index_schema.sql +11 -0
- memoryking/adapters/inference.py +454 -0
- memoryking/adapters/inference.schema.json +541 -0
- memoryking/adapters/inspection.py +1128 -0
- memoryking/adapters/inspection.schema.json +568 -0
- memoryking/adapters/knowledge.schema.json +633 -0
- memoryking/adapters/knowledge_schema.sql +37 -0
- memoryking/adapters/knowledge_store.py +800 -0
- memoryking/adapters/legacy_snapshot.py +358 -0
- memoryking/adapters/legacy_tables.py +49 -0
- memoryking/adapters/local_contract.py +45 -0
- memoryking/adapters/local_embeddings.py +189 -0
- memoryking/adapters/local_files.py +242 -0
- memoryking/adapters/local_ipc.py +258 -0
- memoryking/adapters/local_schema.sql +44 -0
- memoryking/adapters/local_store.py +632 -0
- memoryking/adapters/local_wire.schema.json +7672 -0
- memoryking/adapters/models/minilm-l6-v2-onnx.json +57 -0
- memoryking/adapters/models/ms-marco-minilm-l6-v2-onnx.json +57 -0
- memoryking/adapters/optional_schema.sql +43 -0
- memoryking/adapters/plan_dashboard.py +51 -0
- memoryking/adapters/plans.py +253 -0
- memoryking/adapters/postgres_admin.py +300 -0
- memoryking/adapters/postgres_anchor_schema.sql +9 -0
- memoryking/adapters/postgres_counter.sql +14 -0
- memoryking/adapters/postgres_egress_schema.sql +15 -0
- memoryking/adapters/postgres_experience_schema.sql +39 -0
- memoryking/adapters/postgres_index_schema.sql +7 -0
- memoryking/adapters/postgres_optional_schema.sql +71 -0
- memoryking/adapters/postgres_pool.py +77 -0
- memoryking/adapters/postgres_recovery.py +525 -0
- memoryking/adapters/postgres_schema.sql +365 -0
- memoryking/adapters/postgres_sql.py +102 -0
- memoryking/adapters/postgres_store.py +428 -0
- memoryking/adapters/postgres_summary_schema.sql +12 -0
- memoryking/adapters/postgres_trust_schema.sql +20 -0
- memoryking/adapters/processing.schema.json +471 -0
- memoryking/adapters/processing_store.py +346 -0
- memoryking/adapters/projects.py +83 -0
- memoryking/adapters/proposals.py +238 -0
- memoryking/adapters/ranking.py +315 -0
- memoryking/adapters/repository.schema.json +664 -0
- memoryking/adapters/repository_git.py +264 -0
- memoryking/adapters/repository_schema.sql +25 -0
- memoryking/adapters/repository_store.py +960 -0
- memoryking/adapters/retrieval.py +1285 -0
- memoryking/adapters/retrieval.schema.json +553 -0
- memoryking/adapters/retrieval_schema.sql +10 -0
- memoryking/adapters/shared_control.py +40 -0
- memoryking/adapters/shared_dashboard.py +636 -0
- memoryking/adapters/shared_gateway.py +63 -0
- memoryking/adapters/shared_http.py +216 -0
- memoryking/adapters/shared_mcp.py +159 -0
- memoryking/adapters/shared_service.py +124 -0
- memoryking/adapters/stdio.py +193 -0
- memoryking/adapters/stdio.tools.json +6776 -0
- memoryking/adapters/summary_schema.sql +10 -0
- memoryking/adapters/team.py +253 -0
- memoryking/adapters/timeline.py +80 -0
- memoryking/adapters/token_count.py +55 -0
- memoryking/adapters/tokenizers/LICENSE +21 -0
- memoryking/adapters/tokenizers/cl100k_base.tiktoken +100256 -0
- memoryking/adapters/trust.py +123 -0
- memoryking/adapters/trust_schema.sql +13 -0
- memoryking/adapters/web/app.css +1251 -0
- memoryking/adapters/web/app.js +907 -0
- memoryking/adapters/web/brand.js +44 -0
- memoryking/adapters/web/crown-mono.svg +1 -0
- memoryking/adapters/web/crown.svg +8 -0
- memoryking/adapters/web/elephant.png +0 -0
- memoryking/adapters/web/favicon.svg +8 -0
- memoryking/adapters/web/graph-layout.js +52 -0
- memoryking/adapters/web/graph-worker.js +10 -0
- memoryking/adapters/web/graph.js +570 -0
- memoryking/adapters/web/index.html +208 -0
- memoryking/adapters/web/observatory.js +1208 -0
- memoryking/adapters/web/team.js +151 -0
- memoryking/adapters/web/wordmark.svg +1 -0
- memoryking/adapters/working.py +971 -0
- memoryking/adapters/working.schema.json +1717 -0
- memoryking/adapters/working_schema.sql +24 -0
- memoryking/application/__init__.py +1 -0
- memoryking/application/conformance.py +50 -0
- memoryking/application/legacy_import.py +337 -0
- memoryking/application/local_port.py +9 -0
- memoryking/application/storage.py +117 -0
- memoryking/application/store_core.py +1292 -0
- memoryking/backups.py +131 -0
- memoryking/contracts/__init__.py +6 -0
- memoryking/contracts/__main__.py +20 -0
- memoryking/contracts/canonical.py +88 -0
- memoryking/contracts/embedding.schema.json +302 -0
- memoryking/contracts/embedding_generated.py +65 -0
- memoryking/contracts/experience.schema.json +1508 -0
- memoryking/contracts/experience_generated.py +239 -0
- memoryking/contracts/generated.py +122 -0
- memoryking/contracts/handoff.schema.json +299 -0
- memoryking/contracts/handoff_generated.py +69 -0
- memoryking/contracts/inference.schema.json +541 -0
- memoryking/contracts/inference_generated.py +106 -0
- memoryking/contracts/processing.schema.json +471 -0
- memoryking/contracts/processing_generated.py +82 -0
- memoryking/contracts/py.typed +0 -0
- memoryking/contracts/repository.schema.json +664 -0
- memoryking/contracts/repository_generated.py +144 -0
- memoryking/contracts/retrieval.schema.json +553 -0
- memoryking/contracts/retrieval_generated.py +110 -0
- memoryking/contracts/schema.json +696 -0
- memoryking/contracts/validation.py +92 -0
- memoryking/contracts/working.schema.json +1717 -0
- memoryking/contracts/working_generated.py +291 -0
- memoryking/domain/__init__.py +1 -0
- memoryking/domain/anchors.py +97 -0
- memoryking/domain/briefing.py +108 -0
- memoryking/domain/briefing_text.py +222 -0
- memoryking/domain/checkpoint.py +118 -0
- memoryking/domain/compression.py +64 -0
- memoryking/domain/delta.py +129 -0
- memoryking/domain/embeddings.py +90 -0
- memoryking/domain/hints.py +465 -0
- memoryking/domain/http_status.py +45 -0
- memoryking/domain/learning.py +62 -0
- memoryking/domain/local.py +65 -0
- memoryking/domain/plans.py +140 -0
- memoryking/domain/repository.py +118 -0
- memoryking/domain/selectors.py +356 -0
- memoryking/domain/summary.py +88 -0
- memoryking/domain/usage.py +163 -0
- memoryking/embedding_loop.py +98 -0
- memoryking/embedding_worker.py +131 -0
- memoryking/harness.py +882 -0
- memoryking/harness_context.py +376 -0
- memoryking/hooks.py +171 -0
- memoryking/host_hooks.py +454 -0
- memoryking/lean.py +352 -0
- memoryking/memory_tool.py +776 -0
- memoryking/migration.py +194 -0
- memoryking/model_install.py +78 -0
- memoryking/observability.py +101 -0
- memoryking/observability_metrics.py +100 -0
- memoryking/profiles.py +150 -0
- memoryking/providers.py +330 -0
- memoryking/py.typed +0 -0
- memoryking/pytest_plugin.py +69 -0
- memoryking/reference_agent.py +152 -0
- memoryking/repository_worker.py +57 -0
- memoryking/resume_adapter.py +154 -0
- memoryking/sdk.py +302 -0
- memoryking/shared.py +301 -0
- memoryking/shared_sdk.py +101 -0
- memoryking/vault.py +176 -0
- memoryking-0.1.0.dist-info/METADATA +157 -0
- memoryking-0.1.0.dist-info/RECORD +179 -0
- memoryking-0.1.0.dist-info/WHEEL +5 -0
- memoryking-0.1.0.dist-info/entry_points.txt +7 -0
- memoryking-0.1.0.dist-info/licenses/LICENSE +202 -0
- memoryking-0.1.0.dist-info/licenses/NOTICE +12 -0
- memoryking-0.1.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,1208 @@
|
|
|
1
|
+
import { AtlasView } from "./graph.js";
|
|
2
|
+
const e = (tag, text = "", cls = "") => {
|
|
3
|
+
const n = document.createElement(tag);
|
|
4
|
+
n.textContent = text;
|
|
5
|
+
n.className = cls;
|
|
6
|
+
return n;
|
|
7
|
+
};
|
|
8
|
+
const doc = (v) => v !== null && typeof v === "object" && !Array.isArray(v) ? v : {};
|
|
9
|
+
const rows = (v) => (Array.isArray(v) ? v.map(doc) : []);
|
|
10
|
+
const readable = (v) => v === null || v === undefined
|
|
11
|
+
? "Unknown"
|
|
12
|
+
: typeof v === "object"
|
|
13
|
+
? JSON.stringify(v)
|
|
14
|
+
: String(v);
|
|
15
|
+
function markdown(text) {
|
|
16
|
+
// A small, safe renderer for the briefing's own Markdown: headings, list items,
|
|
17
|
+
// emphasis markers stripped, every node built from text content only.
|
|
18
|
+
const nodes = [];
|
|
19
|
+
let list = null;
|
|
20
|
+
const plain = (line) => line.replace(/\*\*|__|(^|\s)_(.+?)_(?=\s|$)/g, "$1$2");
|
|
21
|
+
for (const raw of text.split("\n")) {
|
|
22
|
+
const line = raw.trimEnd();
|
|
23
|
+
if (!line) {
|
|
24
|
+
list = null;
|
|
25
|
+
continue;
|
|
26
|
+
}
|
|
27
|
+
const heading = /^(#{1,3})\s+(.*)$/.exec(line);
|
|
28
|
+
if (heading) {
|
|
29
|
+
list = null;
|
|
30
|
+
nodes.push(e(heading[1].length === 1 ? "h3" : "h4", plain(heading[2])));
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
|
+
const item = /^(?:[-*]|\d+\.)\s+(.*)$/.exec(line);
|
|
34
|
+
if (item) {
|
|
35
|
+
if (!list) {
|
|
36
|
+
list = e(/^\d/.test(line) ? "ol" : "ul");
|
|
37
|
+
nodes.push(list);
|
|
38
|
+
}
|
|
39
|
+
list.append(e("li", plain(item[1])));
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
list = null;
|
|
43
|
+
nodes.push(e("p", plain(line), line.startsWith("_") ? "caption" : ""));
|
|
44
|
+
}
|
|
45
|
+
return nodes;
|
|
46
|
+
}
|
|
47
|
+
function detail(title, value) {
|
|
48
|
+
const d = e("details");
|
|
49
|
+
d.append(e("summary", title), e("pre", JSON.stringify(value, null, 2)));
|
|
50
|
+
return d;
|
|
51
|
+
}
|
|
52
|
+
function button(text, action) {
|
|
53
|
+
const b = e("button", text);
|
|
54
|
+
b.type = "button";
|
|
55
|
+
b.onclick = action;
|
|
56
|
+
return b;
|
|
57
|
+
}
|
|
58
|
+
function field(parent, title, value = "", kind = "text") {
|
|
59
|
+
const label = e("label", title), input = e("input");
|
|
60
|
+
input.type = kind;
|
|
61
|
+
input.value = value;
|
|
62
|
+
input.autocomplete = "off";
|
|
63
|
+
input.maxLength = 256;
|
|
64
|
+
label.append(input);
|
|
65
|
+
parent.append(label);
|
|
66
|
+
return input;
|
|
67
|
+
}
|
|
68
|
+
function table(items, keys) {
|
|
69
|
+
const wrap = e("div", "", "table-scroll"), t = e("table"), h = e("tr");
|
|
70
|
+
for (const k of keys)
|
|
71
|
+
h.append(e("th", k.replaceAll("_", " ")));
|
|
72
|
+
t.append(h);
|
|
73
|
+
for (const row of items) {
|
|
74
|
+
const tr = e("tr");
|
|
75
|
+
for (const k of keys)
|
|
76
|
+
tr.append(e("td", readable(row[k])));
|
|
77
|
+
t.append(tr);
|
|
78
|
+
}
|
|
79
|
+
wrap.append(t);
|
|
80
|
+
if (!items.length)
|
|
81
|
+
wrap.append(e("p", "No authorized records in this window."));
|
|
82
|
+
return wrap;
|
|
83
|
+
}
|
|
84
|
+
/** In-memory views are short lived and bound to the exact browser authority. */
|
|
85
|
+
export class Observatory {
|
|
86
|
+
api;
|
|
87
|
+
current;
|
|
88
|
+
openReceipt;
|
|
89
|
+
root;
|
|
90
|
+
status;
|
|
91
|
+
output;
|
|
92
|
+
project;
|
|
93
|
+
bindings;
|
|
94
|
+
view;
|
|
95
|
+
ticket = 0;
|
|
96
|
+
expires = 0;
|
|
97
|
+
expiresMono = 0;
|
|
98
|
+
nextRefresh = 0;
|
|
99
|
+
lastWall = Date.now();
|
|
100
|
+
lastMono = performance.now();
|
|
101
|
+
cycle = null;
|
|
102
|
+
reader = null;
|
|
103
|
+
signature = "";
|
|
104
|
+
graph = null;
|
|
105
|
+
context = "";
|
|
106
|
+
confirmed = null;
|
|
107
|
+
writing = false;
|
|
108
|
+
lastRead = null;
|
|
109
|
+
constructor(root, api, current, openReceipt = () => { }) {
|
|
110
|
+
this.api = api;
|
|
111
|
+
this.current = current;
|
|
112
|
+
this.openReceipt = openReceipt;
|
|
113
|
+
this.root = root;
|
|
114
|
+
root.append(e("h2", "Memory"), e("p", "Browse stored memories, checkpoints, reviews and processing usage. Active views refresh every five seconds while updates run, with current permission checks."));
|
|
115
|
+
const form = e("form", "", "observatory-form");
|
|
116
|
+
this.project = field(form, "Project", "", "text");
|
|
117
|
+
this.project.required = true;
|
|
118
|
+
this.project.pattern = "[A-Za-z0-9_\\-]{1,96}";
|
|
119
|
+
const label = e("label", "View");
|
|
120
|
+
this.view = e("select");
|
|
121
|
+
this.view.setAttribute("aria-label", "View");
|
|
122
|
+
for (const [id, name] of [
|
|
123
|
+
["brief", "Ask for a briefing"],
|
|
124
|
+
["timeline", "Timeline"],
|
|
125
|
+
["atlas", "Memory graph"],
|
|
126
|
+
["history", "Checkpoint history"],
|
|
127
|
+
["review", "Review & conflicts"],
|
|
128
|
+
["cost", "Usage & costs"],
|
|
129
|
+
["operations", "Jobs & health"],
|
|
130
|
+
["handoffs", "Handoffs & checkpoints"],
|
|
131
|
+
["impact", "Change impact"],
|
|
132
|
+
["influence", "Where did this go"],
|
|
133
|
+
["retention", "Retention & purge"],
|
|
134
|
+
]) {
|
|
135
|
+
const o = e("option", name);
|
|
136
|
+
o.value = id;
|
|
137
|
+
this.view.append(o);
|
|
138
|
+
}
|
|
139
|
+
label.append(this.view);
|
|
140
|
+
form.append(label);
|
|
141
|
+
const advanced = e("details"), bl = e("label", "Applicability bindings (JSON array)");
|
|
142
|
+
this.bindings = e("textarea");
|
|
143
|
+
this.bindings.value = "[{}]";
|
|
144
|
+
this.bindings.rows = 3;
|
|
145
|
+
this.bindings.maxLength = 16384;
|
|
146
|
+
bl.append(this.bindings);
|
|
147
|
+
advanced.append(e("summary", "Task and environment scope"), bl, e("p", "Supply known dimensions such as path, environment or version. Missing dimensions remain unknown and may block constraints; they are never treated as permission.", "caption"));
|
|
148
|
+
form.append(advanced, e("button", "Load current view", "primary"));
|
|
149
|
+
this.status = e("p", "Choose a project and view.");
|
|
150
|
+
this.status.setAttribute("role", "status");
|
|
151
|
+
this.output = e("div", "", "observatory-output");
|
|
152
|
+
root.append(form, this.status, this.output);
|
|
153
|
+
for (const input of [this.project, this.bindings, this.view])
|
|
154
|
+
input.addEventListener("input", () => this.clearResult("Scope changed. Load again to check current access."));
|
|
155
|
+
form.onsubmit = (ev) => {
|
|
156
|
+
ev.preventDefault();
|
|
157
|
+
void this.load();
|
|
158
|
+
};
|
|
159
|
+
for (const type of ["pointerdown", "keydown", "click", "beforeinput"])
|
|
160
|
+
root.addEventListener(type, (event) => {
|
|
161
|
+
const ticket = this.ticket;
|
|
162
|
+
this.tick(false);
|
|
163
|
+
if (ticket !== this.ticket) {
|
|
164
|
+
event.preventDefault();
|
|
165
|
+
event.stopImmediatePropagation();
|
|
166
|
+
}
|
|
167
|
+
}, true);
|
|
168
|
+
}
|
|
169
|
+
clear() {
|
|
170
|
+
this.clearResult("Session changed. Reconnect and select a project.");
|
|
171
|
+
this.project.value = "";
|
|
172
|
+
this.bindings.value = "[{}]";
|
|
173
|
+
this.context = "";
|
|
174
|
+
}
|
|
175
|
+
clearResult(message) {
|
|
176
|
+
this.ticket++;
|
|
177
|
+
this.expires = 0;
|
|
178
|
+
this.expiresMono = 0;
|
|
179
|
+
this.cycle = null;
|
|
180
|
+
this.reader = null;
|
|
181
|
+
this.signature = "";
|
|
182
|
+
this.confirmed = null;
|
|
183
|
+
this.lastRead = null;
|
|
184
|
+
this.graph?.clear();
|
|
185
|
+
this.graph = null;
|
|
186
|
+
this.output.replaceChildren();
|
|
187
|
+
this.status.textContent = message;
|
|
188
|
+
}
|
|
189
|
+
clockValid() {
|
|
190
|
+
const wall = Date.now(), mono = performance.now();
|
|
191
|
+
if (wall < this.lastWall || mono < this.lastMono)
|
|
192
|
+
return false;
|
|
193
|
+
this.lastWall = wall;
|
|
194
|
+
this.lastMono = mono;
|
|
195
|
+
return true;
|
|
196
|
+
}
|
|
197
|
+
tick(refresh = true) {
|
|
198
|
+
if (!this.clockValid()) {
|
|
199
|
+
this.clearResult("Clock changed. Reload after the clock is stable.");
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
const ctx = this.current();
|
|
203
|
+
if (this.context && (!ctx || JSON.stringify(ctx) !== this.context)) {
|
|
204
|
+
this.clear();
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
if (this.expires &&
|
|
208
|
+
(document.hidden ||
|
|
209
|
+
Date.now() >= this.expires ||
|
|
210
|
+
performance.now() >= this.expiresMono)) {
|
|
211
|
+
this.clearResult("View expired or hidden. Load again to check current access.");
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
if (refresh &&
|
|
215
|
+
this.reader &&
|
|
216
|
+
this.expires &&
|
|
217
|
+
!this.cycle &&
|
|
218
|
+
!this.writing &&
|
|
219
|
+
!document.hidden &&
|
|
220
|
+
performance.now() >= this.nextRefresh)
|
|
221
|
+
void this.run(this.reader, true, true);
|
|
222
|
+
}
|
|
223
|
+
/** Only skip DOM replacement after every read for this view has reauthorized. */
|
|
224
|
+
unchanged(...values) {
|
|
225
|
+
const signature = JSON.stringify(values.map((value) => Object.fromEntries(Object.entries(value).filter(([key]) => !["receipt", "evaluated_ms", "fresh_until_ms"].includes(key)))));
|
|
226
|
+
const same = this.cycle?.refreshing && signature === this.signature;
|
|
227
|
+
this.signature = signature;
|
|
228
|
+
return Boolean(same);
|
|
229
|
+
}
|
|
230
|
+
scope() {
|
|
231
|
+
const b = JSON.parse(this.bindings.value);
|
|
232
|
+
if (!Array.isArray(b) ||
|
|
233
|
+
!b.length ||
|
|
234
|
+
b.length > 256 ||
|
|
235
|
+
b.some((x) => !x || typeof x !== "object" || Array.isArray(x)))
|
|
236
|
+
throw Error("Bindings must be a bounded array of objects");
|
|
237
|
+
return b;
|
|
238
|
+
}
|
|
239
|
+
async command(operation, action, args = {}, key, bare = false) {
|
|
240
|
+
const ctx = this.current();
|
|
241
|
+
if (!ctx || document.hidden || !this.clockValid())
|
|
242
|
+
throw Error("Current visible session required");
|
|
243
|
+
const stamp = JSON.stringify(ctx), ticket = this.ticket, project = this.project.value, started = Date.now(), startedMono = performance.now(), cycle = this.cycle;
|
|
244
|
+
// The inference contract binds history inside its arguments, not on the command.
|
|
245
|
+
const command = bare
|
|
246
|
+
? { version: 1, action, args: { ...args, project } }
|
|
247
|
+
: {
|
|
248
|
+
version: 1,
|
|
249
|
+
incarnation: ctx.incarnation,
|
|
250
|
+
action,
|
|
251
|
+
args: { ...args, project },
|
|
252
|
+
};
|
|
253
|
+
if (key)
|
|
254
|
+
command.key = key;
|
|
255
|
+
const result = await this.api("/api/command", {
|
|
256
|
+
csrf: ctx.csrf,
|
|
257
|
+
operation,
|
|
258
|
+
command,
|
|
259
|
+
});
|
|
260
|
+
if (ticket !== this.ticket ||
|
|
261
|
+
JSON.stringify(this.current()) !== stamp ||
|
|
262
|
+
project !== this.project.value ||
|
|
263
|
+
document.hidden ||
|
|
264
|
+
!this.clockValid() ||
|
|
265
|
+
performance.now() >= startedMono + 15000 ||
|
|
266
|
+
Date.now() >= started + 15000)
|
|
267
|
+
throw Error("View changed while checking access");
|
|
268
|
+
this.context = stamp;
|
|
269
|
+
const deadline = typeof result.fresh_until_ms === "number"
|
|
270
|
+
? result.fresh_until_ms
|
|
271
|
+
: started + 15000;
|
|
272
|
+
const expires = Math.min(started + 15000, deadline), monotonic = Math.min(startedMono + 15000, performance.now() + expires - Date.now());
|
|
273
|
+
if (Date.now() >= expires || performance.now() >= monotonic)
|
|
274
|
+
throw Error("Snapshot expired");
|
|
275
|
+
if (cycle) {
|
|
276
|
+
cycle.expires = Math.min(cycle.expires, expires);
|
|
277
|
+
cycle.monotonic = Math.min(cycle.monotonic, monotonic);
|
|
278
|
+
}
|
|
279
|
+
else {
|
|
280
|
+
// A one-off export or confirmation cannot renew unrelated retained content.
|
|
281
|
+
this.expires = Math.min(this.expires || Infinity, expires);
|
|
282
|
+
this.expiresMono = Math.min(this.expiresMono || Infinity, monotonic);
|
|
283
|
+
}
|
|
284
|
+
this.status.textContent = `Current permission checked · ${project} · ${ctx.tenant} / ${ctx.principal} · history ${ctx.incarnation}.`;
|
|
285
|
+
return result;
|
|
286
|
+
}
|
|
287
|
+
async run(action, wholeView = false, refreshing = false) {
|
|
288
|
+
if (wholeView) {
|
|
289
|
+
this.ticket++;
|
|
290
|
+
this.cycle = {
|
|
291
|
+
ticket: this.ticket,
|
|
292
|
+
expires: Infinity,
|
|
293
|
+
monotonic: Infinity,
|
|
294
|
+
refreshing,
|
|
295
|
+
};
|
|
296
|
+
}
|
|
297
|
+
const ticket = this.ticket;
|
|
298
|
+
const cycle = wholeView ? this.cycle : null;
|
|
299
|
+
try {
|
|
300
|
+
await action();
|
|
301
|
+
if (cycle && cycle === this.cycle && ticket === this.ticket) {
|
|
302
|
+
if (!this.clockValid() ||
|
|
303
|
+
document.hidden ||
|
|
304
|
+
Date.now() >= cycle.expires ||
|
|
305
|
+
performance.now() >= cycle.monotonic)
|
|
306
|
+
throw Error("Snapshot expired");
|
|
307
|
+
if (Number.isFinite(cycle.expires)) {
|
|
308
|
+
this.expires = cycle.expires;
|
|
309
|
+
this.expiresMono = cycle.monotonic;
|
|
310
|
+
}
|
|
311
|
+
this.nextRefresh = performance.now() + 5000;
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
catch (error) {
|
|
315
|
+
if (ticket === this.ticket) {
|
|
316
|
+
this.clearResult("Unavailable: " +
|
|
317
|
+
(error instanceof Error
|
|
318
|
+
? error.message.replaceAll("_", " ")
|
|
319
|
+
: "request failed") +
|
|
320
|
+
". Reload to reconcile; mutations are never automatically retried.");
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
finally {
|
|
324
|
+
if (cycle && cycle === this.cycle)
|
|
325
|
+
this.cycle = null;
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
async load() {
|
|
329
|
+
const started = performance.now();
|
|
330
|
+
this.clearResult("Checking current permission…");
|
|
331
|
+
await this.run(async () => {
|
|
332
|
+
switch (this.view.value) {
|
|
333
|
+
case "brief":
|
|
334
|
+
this.brief();
|
|
335
|
+
break;
|
|
336
|
+
case "timeline":
|
|
337
|
+
await this.timeline();
|
|
338
|
+
break;
|
|
339
|
+
case "atlas":
|
|
340
|
+
await this.atlas();
|
|
341
|
+
break;
|
|
342
|
+
case "history":
|
|
343
|
+
await this.history();
|
|
344
|
+
break;
|
|
345
|
+
case "review":
|
|
346
|
+
await this.review();
|
|
347
|
+
break;
|
|
348
|
+
case "cost":
|
|
349
|
+
await this.cost();
|
|
350
|
+
break;
|
|
351
|
+
case "operations":
|
|
352
|
+
await this.operations();
|
|
353
|
+
break;
|
|
354
|
+
case "handoffs":
|
|
355
|
+
await this.handoffs();
|
|
356
|
+
break;
|
|
357
|
+
case "impact":
|
|
358
|
+
this.impact();
|
|
359
|
+
break;
|
|
360
|
+
case "influence":
|
|
361
|
+
this.influence();
|
|
362
|
+
break;
|
|
363
|
+
case "retention":
|
|
364
|
+
this.retention();
|
|
365
|
+
break;
|
|
366
|
+
}
|
|
367
|
+
}, true);
|
|
368
|
+
requestAnimationFrame(() => {
|
|
369
|
+
this.root.dataset.viewReadyMs = String(Math.round(performance.now() - started));
|
|
370
|
+
});
|
|
371
|
+
}
|
|
372
|
+
exportCurrent(load) {
|
|
373
|
+
this.lastRead = load;
|
|
374
|
+
const exportButton = button("Export current authorized JSON", () => void this.run(async () => {
|
|
375
|
+
// Re-fetch through the same authorization gate; never serialize a stale DOM cache.
|
|
376
|
+
if (!this.lastRead)
|
|
377
|
+
throw Error("Reload required");
|
|
378
|
+
const value = await this.lastRead(), url = URL.createObjectURL(new Blob([
|
|
379
|
+
JSON.stringify({
|
|
380
|
+
exported_ms: Date.now(),
|
|
381
|
+
authorization: "current_at_export",
|
|
382
|
+
data: value,
|
|
383
|
+
}, null, 2),
|
|
384
|
+
], { type: "application/json" }));
|
|
385
|
+
const a = e("a");
|
|
386
|
+
a.href = url;
|
|
387
|
+
a.download = "memoryking-authorized-view.json";
|
|
388
|
+
a.click();
|
|
389
|
+
setTimeout(() => URL.revokeObjectURL(url), 0);
|
|
390
|
+
}));
|
|
391
|
+
exportButton.dataset.export = "true";
|
|
392
|
+
this.output.append(exportButton);
|
|
393
|
+
}
|
|
394
|
+
async atlas(focus, cursor) {
|
|
395
|
+
this.reader = () => this.atlas(focus, cursor);
|
|
396
|
+
const args = {
|
|
397
|
+
bindings: this.scope(),
|
|
398
|
+
max_nodes: focus ? 500 : 200,
|
|
399
|
+
max_edges: focus ? 1500 : 400,
|
|
400
|
+
};
|
|
401
|
+
if (focus)
|
|
402
|
+
args.focus = [focus];
|
|
403
|
+
if (cursor)
|
|
404
|
+
args.cursor = cursor;
|
|
405
|
+
const load = () => this.command("retrieval", "atlas", args), data = await load();
|
|
406
|
+
if (!this.graph) {
|
|
407
|
+
this.output.replaceChildren(e("h3", "Memory relationships"));
|
|
408
|
+
const host = e("div");
|
|
409
|
+
this.output.append(host);
|
|
410
|
+
this.graph = new AtlasView(host, (id) => void this.run(() => this.atlas(id)), {
|
|
411
|
+
load: async (id) => {
|
|
412
|
+
const project = this.project.value;
|
|
413
|
+
const data = await this.api("/api/citations/" +
|
|
414
|
+
encodeURIComponent(project) +
|
|
415
|
+
"/" +
|
|
416
|
+
encodeURIComponent(id));
|
|
417
|
+
return (Array.isArray(data.items) ? data.items : []);
|
|
418
|
+
},
|
|
419
|
+
open: (receipt) => this.openReceipt(this.project.value, receipt),
|
|
420
|
+
});
|
|
421
|
+
}
|
|
422
|
+
this.graph.set(data);
|
|
423
|
+
this.output.querySelector(".atlas-footer")?.remove();
|
|
424
|
+
this.output.querySelector("[data-export]")?.remove();
|
|
425
|
+
const footer = e("div", "", "atlas-footer");
|
|
426
|
+
if (data.next_cursor)
|
|
427
|
+
footer.append(button("Next bounded page", () => void this.run(() => this.atlas(focus, String(data.next_cursor)), true)));
|
|
428
|
+
if (focus)
|
|
429
|
+
footer.append(button("Return to overview", () => void this.run(() => this.atlas(), true)));
|
|
430
|
+
this.output.append(footer);
|
|
431
|
+
this.exportCurrent(load);
|
|
432
|
+
}
|
|
433
|
+
async history(position, baseline) {
|
|
434
|
+
this.reader = () => this.history(position, baseline);
|
|
435
|
+
const load = () => this.command("inspection", "history", position === undefined ? {} : { recorded_position: position });
|
|
436
|
+
const data = await load();
|
|
437
|
+
const previous = baseline === undefined
|
|
438
|
+
? null
|
|
439
|
+
: await this.command("inspection", "history", {
|
|
440
|
+
recorded_position: baseline,
|
|
441
|
+
});
|
|
442
|
+
if (this.unchanged(data, ...(previous ? [previous] : [])))
|
|
443
|
+
return;
|
|
444
|
+
this.output.replaceChildren(e("h3", position === undefined
|
|
445
|
+
? "Live checkpoint state"
|
|
446
|
+
: `Historical state at position ${position}`));
|
|
447
|
+
this.output.append(e("p", "Current permissions apply to every frame. Moving through history never invokes a tool, replays a mutation or changes live task state. Operation history and historical liveness are unavailable.", "integrity"));
|
|
448
|
+
const frames = rows(data.frames), controls = e("div", "", "history-controls");
|
|
449
|
+
const pick = e("select");
|
|
450
|
+
pick.setAttribute("aria-label", "Historical checkpoint");
|
|
451
|
+
for (const f of frames) {
|
|
452
|
+
const o = e("option", `${f.task} · r${f.revision} · ${new Date(Number(f.recorded_ms)).toLocaleString()}`);
|
|
453
|
+
o.value = String(f.position);
|
|
454
|
+
pick.append(o);
|
|
455
|
+
}
|
|
456
|
+
if (position !== undefined)
|
|
457
|
+
pick.value = String(position);
|
|
458
|
+
const base = e("select");
|
|
459
|
+
base.setAttribute("aria-label", "Comparison baseline");
|
|
460
|
+
base.append(e("option", "No comparison"));
|
|
461
|
+
base.options[0].value = "";
|
|
462
|
+
for (const f of frames) {
|
|
463
|
+
const o = e("option", `${f.task} · position ${f.position}`);
|
|
464
|
+
o.value = String(f.position);
|
|
465
|
+
base.append(o);
|
|
466
|
+
}
|
|
467
|
+
if (baseline !== undefined)
|
|
468
|
+
base.value = String(baseline);
|
|
469
|
+
controls.append(pick, base, button("Inspect selected frame", () => void this.run(() => this.history(Number(pick.value), base.value ? Number(base.value) : undefined), true)), button("Return to live", () => void this.run(() => this.history(), true)));
|
|
470
|
+
this.output.append(controls);
|
|
471
|
+
if (frames.length) {
|
|
472
|
+
const slider = e("input");
|
|
473
|
+
slider.type = "range";
|
|
474
|
+
slider.min = "0";
|
|
475
|
+
slider.max = String(frames.length - 1);
|
|
476
|
+
slider.value = String(Math.max(0, frames.findIndex((f) => f.position === position)));
|
|
477
|
+
slider.setAttribute("aria-label", "Checkpoint timeline");
|
|
478
|
+
slider.onchange = () => {
|
|
479
|
+
const next = Number(frames[Number(slider.value)].position);
|
|
480
|
+
void this.run(() => this.history(next, base.value ? Number(base.value) : undefined), true);
|
|
481
|
+
};
|
|
482
|
+
this.output.append(slider);
|
|
483
|
+
}
|
|
484
|
+
else
|
|
485
|
+
this.output.append(e("p", "No currently accessible checkpoints."));
|
|
486
|
+
const projection = doc(data.projection), tasks = rows(projection.tasks);
|
|
487
|
+
this.output.append(this.taskTable(tasks));
|
|
488
|
+
if (previous) {
|
|
489
|
+
const before = rows(doc(previous.projection).tasks), changes = [];
|
|
490
|
+
const all = [
|
|
491
|
+
...tasks,
|
|
492
|
+
...before.filter((old) => !tasks.some((t) => t.task === old.task && t.run === old.run)),
|
|
493
|
+
];
|
|
494
|
+
for (const task of all) {
|
|
495
|
+
const current = tasks.find((t) => t.task === task.task && t.run === task.run);
|
|
496
|
+
const old = before.find((t) => t.task === task.task && t.run === task.run), p = doc(current?.progress), b = doc(old?.progress);
|
|
497
|
+
changes.push({
|
|
498
|
+
task: task.task,
|
|
499
|
+
run: task.run,
|
|
500
|
+
baseline: baseline,
|
|
501
|
+
scope_changed: !current
|
|
502
|
+
? "absent from selected bounded frame"
|
|
503
|
+
: old
|
|
504
|
+
? b.scope_hash !== p.scope_hash
|
|
505
|
+
: "no baseline",
|
|
506
|
+
passed_before: b.passed,
|
|
507
|
+
passed_now: p.passed,
|
|
508
|
+
total_before: b.total,
|
|
509
|
+
total_now: p.total,
|
|
510
|
+
});
|
|
511
|
+
}
|
|
512
|
+
this.output.append(e("h3", "Checkpoint comparison"), e("p", "Changed denominators reflect scope edits. A higher fraction alone is not evidence of progress."), table(changes, [
|
|
513
|
+
"task",
|
|
514
|
+
"run",
|
|
515
|
+
"scope_changed",
|
|
516
|
+
"passed_before",
|
|
517
|
+
"passed_now",
|
|
518
|
+
"total_before",
|
|
519
|
+
"total_now",
|
|
520
|
+
]));
|
|
521
|
+
}
|
|
522
|
+
this.output.append(detail("Full authorized historical projection", data));
|
|
523
|
+
this.exportCurrent(load);
|
|
524
|
+
}
|
|
525
|
+
taskTable(tasks) {
|
|
526
|
+
return table(tasks.map((t) => ({
|
|
527
|
+
...t,
|
|
528
|
+
passed: doc(t.progress).passed,
|
|
529
|
+
total: doc(t.progress).total,
|
|
530
|
+
heartbeat: doc(t.heartbeat).status,
|
|
531
|
+
})), ["task", "run", "revision", "writer", "passed", "total", "heartbeat"]);
|
|
532
|
+
}
|
|
533
|
+
async review() {
|
|
534
|
+
this.reader = () => this.review();
|
|
535
|
+
const bindings = this.scope();
|
|
536
|
+
const knowledge = await this.command("knowledge", "query", {
|
|
537
|
+
bindings,
|
|
538
|
+
diagnostic: true,
|
|
539
|
+
});
|
|
540
|
+
const constraints = await this.command("knowledge", "constraints", {
|
|
541
|
+
bindings,
|
|
542
|
+
});
|
|
543
|
+
const procedures = await this.command("experience", "query", {
|
|
544
|
+
bindings,
|
|
545
|
+
diagnostic: true,
|
|
546
|
+
});
|
|
547
|
+
const ranking = await this.command("experience", "ranking_inspect");
|
|
548
|
+
const held = await this.command("inspection", "held");
|
|
549
|
+
const rules = await this.command("inspection", "trust_list");
|
|
550
|
+
if (this.unchanged(knowledge, constraints, procedures, ranking, held, rules))
|
|
551
|
+
return;
|
|
552
|
+
this.output.replaceChildren(e("h3", "Review queue & evidence quality"), e("p", "Source content is untrusted evidence. Review changes lifecycle authority; procedure activation is separate and grants no execution privileges. A policy change requires a new browser sign-in.", "integrity"));
|
|
553
|
+
for (const [name, data, operation] of [
|
|
554
|
+
["Knowledge", knowledge, "knowledge"],
|
|
555
|
+
["Constraints", constraints, "knowledge"],
|
|
556
|
+
["Procedures", procedures, "experience"],
|
|
557
|
+
]) {
|
|
558
|
+
const section = e("section");
|
|
559
|
+
section.append(e("h3", name), e("p", `Resolution: ${readable(data.status)} · ${readable(data.reason)}`));
|
|
560
|
+
for (const item of rows(data.items)) {
|
|
561
|
+
const card = e("article", "", "review-card"), body = doc(item.body);
|
|
562
|
+
card.append(e("h4", String(body.text ?? body.name ?? item.revision)), e("p", `${readable(item.state ?? item.lifecycle)} · ${readable(item.authority)} · version ${item.family_version}`), detail("Applicability, sources, conflicts and attestations", item));
|
|
563
|
+
const controls = e("div", "", "actions");
|
|
564
|
+
for (const decision of [
|
|
565
|
+
"accept",
|
|
566
|
+
"reject",
|
|
567
|
+
"deprecate",
|
|
568
|
+
"quarantine",
|
|
569
|
+
"release_quarantine",
|
|
570
|
+
])
|
|
571
|
+
controls.append(button(decision.replaceAll("_", " "), () => this.reviewAction(operation, "review", item, {
|
|
572
|
+
decision,
|
|
573
|
+
breadth_reviewed: false,
|
|
574
|
+
})));
|
|
575
|
+
if (operation === "experience") {
|
|
576
|
+
controls.append(button("Activate", () => this.reviewAction(operation, "activate", item, {
|
|
577
|
+
bindings,
|
|
578
|
+
policy: "reviewed-procedure-v1",
|
|
579
|
+
})), button("Suspend", () => this.reviewAction(operation, "suspend", item, {})));
|
|
580
|
+
}
|
|
581
|
+
card.append(controls);
|
|
582
|
+
section.append(card);
|
|
583
|
+
}
|
|
584
|
+
if (!rows(data.items).length)
|
|
585
|
+
section.append(e("p", "No authorized matching revisions."));
|
|
586
|
+
section.append(detail("Resolution and completeness details", data));
|
|
587
|
+
this.output.append(section);
|
|
588
|
+
}
|
|
589
|
+
this.output.append(detail("Active ranking and evaluation evidence", ranking));
|
|
590
|
+
this.output.append(this.heldSection(held, rules));
|
|
591
|
+
const drafting = e("section");
|
|
592
|
+
drafting.append(e("h3", "Draft proposals from repeated evidence"), e("p", "Files a proposal for every name that several independent observations share, with one evidence span per source. Drafts wait here for review like any proposal; nothing becomes knowledge by itself.", "integrity"), button("Draft proposals", () => {
|
|
593
|
+
void this.run(async () => {
|
|
594
|
+
await this.mutate("knowledge", "draft", { limit: 16 });
|
|
595
|
+
});
|
|
596
|
+
}));
|
|
597
|
+
this.output.append(drafting);
|
|
598
|
+
this.composer();
|
|
599
|
+
}
|
|
600
|
+
reviewAction(operation, action, item, extra) {
|
|
601
|
+
const revision = item.revision, expected_version = item.family_version;
|
|
602
|
+
const actionLabel = String(extra.decision ?? action).replaceAll("_", " ");
|
|
603
|
+
const form = e("form", "", "review-confirm");
|
|
604
|
+
form.append(e("h3", `${actionLabel} revision ${revision}`), e("p", `Compare-and-set family version ${expected_version}. Check the source and scope above before confirming. The server rechecks current authority and version.`));
|
|
605
|
+
const reason = field(form, "Decision reason (identifier)", "reviewed_in_dashboard");
|
|
606
|
+
reason.required = true;
|
|
607
|
+
reason.pattern = "[A-Za-z0-9_\\-]{1,96}";
|
|
608
|
+
const breadth = field(form, "I reviewed the applicability breadth", "", "checkbox");
|
|
609
|
+
form.append(e("button", "Confirm " + actionLabel, "primary"), button("Cancel", () => form.remove()));
|
|
610
|
+
form.onsubmit = (event) => {
|
|
611
|
+
event.preventDefault();
|
|
612
|
+
void this.run(async () => {
|
|
613
|
+
const args = {
|
|
614
|
+
revision,
|
|
615
|
+
expected_version,
|
|
616
|
+
...extra,
|
|
617
|
+
reason: reason.value,
|
|
618
|
+
};
|
|
619
|
+
if (action === "review")
|
|
620
|
+
args.breadth_reviewed = breadth.checked;
|
|
621
|
+
await this.mutate(operation, action, args);
|
|
622
|
+
});
|
|
623
|
+
};
|
|
624
|
+
this.output.querySelector(".review-confirm")?.remove();
|
|
625
|
+
this.output.append(form);
|
|
626
|
+
reason.focus();
|
|
627
|
+
}
|
|
628
|
+
/** Held captures from untrusted sources, with release buttons and the trust rules. */
|
|
629
|
+
heldSection(held, rules) {
|
|
630
|
+
const section = e("section");
|
|
631
|
+
const items = rows(held.held);
|
|
632
|
+
section.append(e("h3", "Held captures"), e("p", "Captures from a source marked untrusted are recorded but invisible to every read, briefing, graph and review until released here. Releasing is a journaled policy decision.", "integrity"));
|
|
633
|
+
if (!items.length)
|
|
634
|
+
section.append(e("p", "No held captures in this project."));
|
|
635
|
+
for (const item of items) {
|
|
636
|
+
const card = e("article", "", "review-card");
|
|
637
|
+
card.append(e("h4", String(item.preview)), e("p", `${String(item.observation)} · ${String(item.source)} by ${String(item.captured_by)} · ${readable(item.reason)} · held ${new Date(Number(item.held_ms)).toLocaleString()}`));
|
|
638
|
+
const release = button("Release", () => {
|
|
639
|
+
void this.run(async () => {
|
|
640
|
+
await this.mutate("inspection", "release", {
|
|
641
|
+
observation: String(item.observation),
|
|
642
|
+
});
|
|
643
|
+
});
|
|
644
|
+
});
|
|
645
|
+
card.append(release);
|
|
646
|
+
section.append(card);
|
|
647
|
+
}
|
|
648
|
+
const ruleList = rows(rules.rules);
|
|
649
|
+
section.append(e("h4", "Trust rules"), e("p", ruleList.length
|
|
650
|
+
? ruleList
|
|
651
|
+
.map((r) => `${String(r.project)} · ${String(r.source)} · ${String(r.level)} (by ${String(r.decided_by)})`)
|
|
652
|
+
.join(" · ")
|
|
653
|
+
: "No rules; every source is trusted."));
|
|
654
|
+
const f = e("form", "", "observatory-form"), source = field(f, "Source name or glob"), level = e("select");
|
|
655
|
+
for (const value of ["untrusted", "trusted"]) {
|
|
656
|
+
const option = e("option", value);
|
|
657
|
+
option.value = value;
|
|
658
|
+
level.append(option);
|
|
659
|
+
}
|
|
660
|
+
level.setAttribute("aria-label", "Trust level");
|
|
661
|
+
source.required = true;
|
|
662
|
+
f.append(level, e("button", "Set rule"));
|
|
663
|
+
f.onsubmit = (ev) => {
|
|
664
|
+
ev.preventDefault();
|
|
665
|
+
void this.run(async () => {
|
|
666
|
+
await this.mutate("inspection", "trust", {
|
|
667
|
+
source: source.value,
|
|
668
|
+
level: level.value,
|
|
669
|
+
});
|
|
670
|
+
});
|
|
671
|
+
};
|
|
672
|
+
section.append(f);
|
|
673
|
+
return section;
|
|
674
|
+
}
|
|
675
|
+
async mutate(operation, action, args) {
|
|
676
|
+
if (this.writing)
|
|
677
|
+
throw Error("A command is already pending");
|
|
678
|
+
// Never replay writes or let a background read repaint their result.
|
|
679
|
+
const ticket = ++this.ticket;
|
|
680
|
+
this.cycle = null;
|
|
681
|
+
this.reader = null;
|
|
682
|
+
this.writing = true;
|
|
683
|
+
let result;
|
|
684
|
+
try {
|
|
685
|
+
result = await this.command(operation, action, args, crypto.randomUUID());
|
|
686
|
+
}
|
|
687
|
+
catch (error) {
|
|
688
|
+
if (ticket === this.ticket)
|
|
689
|
+
this.clearResult("Command result unavailable. Reload to reconcile; the command will not be retried automatically.");
|
|
690
|
+
throw error;
|
|
691
|
+
}
|
|
692
|
+
finally {
|
|
693
|
+
this.writing = false;
|
|
694
|
+
}
|
|
695
|
+
this.graph?.clear();
|
|
696
|
+
this.output.replaceChildren(e("h3", "Command acknowledged"), detail("Recorded result", result), e("p", "Reload to reconcile current state. If this command changed authorization, sign in again. Acknowledgment does not approve a phase or start an agent."));
|
|
697
|
+
}
|
|
698
|
+
composer() {
|
|
699
|
+
const d = e("details");
|
|
700
|
+
d.append(e("summary", "Advanced proposal / attestation"), e("p", "Paste the documented command arguments for a knowledge or constraint proposal, an attestation, or a revision review with its expected family version. The preview is inert; confirmation sends one validated command. No source text is executed."));
|
|
701
|
+
const select = e("select");
|
|
702
|
+
select.setAttribute("aria-label", "Advanced command");
|
|
703
|
+
for (const action of ["propose", "attest", "review"]) {
|
|
704
|
+
const o = e("option", action);
|
|
705
|
+
o.value = action;
|
|
706
|
+
select.append(o);
|
|
707
|
+
}
|
|
708
|
+
const input = e("textarea");
|
|
709
|
+
input.rows = 10;
|
|
710
|
+
input.maxLength = 100000;
|
|
711
|
+
input.setAttribute("aria-label", "Command arguments JSON");
|
|
712
|
+
input.placeholder = "Documented arguments excluding project";
|
|
713
|
+
const preview = e("div");
|
|
714
|
+
input.oninput = () => {
|
|
715
|
+
this.confirmed = null;
|
|
716
|
+
preview.replaceChildren();
|
|
717
|
+
};
|
|
718
|
+
select.onchange = () => {
|
|
719
|
+
this.confirmed = null;
|
|
720
|
+
preview.replaceChildren();
|
|
721
|
+
};
|
|
722
|
+
d.append(select, input, button("Preview command", () => {
|
|
723
|
+
try {
|
|
724
|
+
const args = JSON.parse(input.value);
|
|
725
|
+
if (!args || Array.isArray(args) || typeof args !== "object")
|
|
726
|
+
throw Error("Object required");
|
|
727
|
+
this.confirmed = {
|
|
728
|
+
operation: "knowledge",
|
|
729
|
+
action: select.value,
|
|
730
|
+
args,
|
|
731
|
+
};
|
|
732
|
+
preview.replaceChildren(detail("Exact proposed change", {
|
|
733
|
+
...this.confirmed,
|
|
734
|
+
project: this.project.value,
|
|
735
|
+
}), button("Confirm this command", () => void this.run(async () => {
|
|
736
|
+
const c = this.confirmed;
|
|
737
|
+
if (!c)
|
|
738
|
+
throw Error("Preview again");
|
|
739
|
+
this.confirmed = null;
|
|
740
|
+
await this.mutate(String(c.operation), String(c.action), doc(c.args));
|
|
741
|
+
})));
|
|
742
|
+
}
|
|
743
|
+
catch {
|
|
744
|
+
preview.replaceChildren(e("p", "Enter a valid JSON object."));
|
|
745
|
+
}
|
|
746
|
+
}), preview);
|
|
747
|
+
this.output.append(d);
|
|
748
|
+
}
|
|
749
|
+
async cost() {
|
|
750
|
+
this.reader = () => this.cost();
|
|
751
|
+
const load = () => this.command("inspection", "cost"), data = await load(), summary = doc(data.processing);
|
|
752
|
+
if (this.unchanged(data))
|
|
753
|
+
return;
|
|
754
|
+
this.output.replaceChildren(e("h3", "Processing attempts"), e("p", "Known usage is a lower bound when any attempts are unknown. Failed calls, retries and background processing remain included. Provider reports and actor outcomes are not independent metering.", "integrity"));
|
|
755
|
+
const metrics = e("div", "", "metrics");
|
|
756
|
+
for (const [name, value] of [
|
|
757
|
+
["Attempts", summary.attempts],
|
|
758
|
+
["Total tokens", summary.total_tokens],
|
|
759
|
+
["Known token lower bound", summary.known_token_lower_bound],
|
|
760
|
+
["Unknown token attempts", summary.unknown_token_attempts],
|
|
761
|
+
["Full-task cost", data.full_task_cost],
|
|
762
|
+
["Savings", data.savings],
|
|
763
|
+
]) {
|
|
764
|
+
const card = e("div", "", "metric");
|
|
765
|
+
card.append(e("small", String(name)), e("strong", readable(value)));
|
|
766
|
+
metrics.append(card);
|
|
767
|
+
}
|
|
768
|
+
this.output.append(metrics);
|
|
769
|
+
const groups = [];
|
|
770
|
+
for (const provider of rows(summary.providers))
|
|
771
|
+
for (const [stage, value] of Object.entries(doc(provider.stages))) {
|
|
772
|
+
const v = doc(value);
|
|
773
|
+
groups.push({
|
|
774
|
+
provider: provider.provider,
|
|
775
|
+
model: provider.fingerprint,
|
|
776
|
+
stage,
|
|
777
|
+
attempts: v.attempts,
|
|
778
|
+
known_tokens: v.known_token_lower_bound,
|
|
779
|
+
unknown: v.unknown_token_attempts,
|
|
780
|
+
cost: doc(v.cost_microusd).total,
|
|
781
|
+
});
|
|
782
|
+
}
|
|
783
|
+
const chart = e("div", "", "cost-bars"), max = Math.max(1, ...groups.map((g) => Number(g.known_tokens)));
|
|
784
|
+
for (const g of groups) {
|
|
785
|
+
const row = e("div");
|
|
786
|
+
row.append(e("span", `${g.provider} · ${readable(g.stage)}: ≥${g.known_tokens} tokens (${g.unknown} unknown)`));
|
|
787
|
+
const meter = e("meter");
|
|
788
|
+
meter.min = 0;
|
|
789
|
+
meter.max = max;
|
|
790
|
+
meter.value = Number(g.known_tokens);
|
|
791
|
+
meter.setAttribute("aria-label", `${readable(g.stage)} known token lower bound`);
|
|
792
|
+
row.append(meter);
|
|
793
|
+
chart.append(row);
|
|
794
|
+
}
|
|
795
|
+
this.output.append(chart, table(groups, [
|
|
796
|
+
"provider",
|
|
797
|
+
"model",
|
|
798
|
+
"stage",
|
|
799
|
+
"attempts",
|
|
800
|
+
"known_tokens",
|
|
801
|
+
"unknown",
|
|
802
|
+
"cost",
|
|
803
|
+
]), detail("All retained authorized attempts", data.attempts), detail("Actor-reported outcomes, separate from usage", data.outcomes), detail("Coverage and accounting uncertainty", data));
|
|
804
|
+
this.exportCurrent(load);
|
|
805
|
+
}
|
|
806
|
+
async operations() {
|
|
807
|
+
this.reader = () => this.operations();
|
|
808
|
+
const load = () => this.command("inspection", "operations"), data = await load();
|
|
809
|
+
if (this.unchanged(data))
|
|
810
|
+
return;
|
|
811
|
+
this.output.replaceChildren(await this.memoryHealth(), e("h3", "Jobs & primary health"), e("p", readable(data.health)), table(rows(data.jobs), [
|
|
812
|
+
"id",
|
|
813
|
+
"state",
|
|
814
|
+
"position",
|
|
815
|
+
"attempts",
|
|
816
|
+
"fence",
|
|
817
|
+
"lease_until",
|
|
818
|
+
"available",
|
|
819
|
+
"age_ms",
|
|
820
|
+
]), detail("Projection frontiers, coverage and measured fields", data), e("p", "Frontiers are opaque ordering tokens, not item counts. Lock wait, cache churn and recovery qualification remain unknown here. Retry, cancel and schedule controls are unavailable.", "integrity"));
|
|
821
|
+
await this.egress();
|
|
822
|
+
this.exportCurrent(load);
|
|
823
|
+
}
|
|
824
|
+
/** Whether memory is paying for itself: counts the store already keeps, never content. */
|
|
825
|
+
async memoryHealth() {
|
|
826
|
+
const section = e("section", "", "memory-health");
|
|
827
|
+
section.append(e("h3", "Memory health"));
|
|
828
|
+
let data;
|
|
829
|
+
try {
|
|
830
|
+
data = await this.command("inspection", "health");
|
|
831
|
+
}
|
|
832
|
+
catch (error) {
|
|
833
|
+
section.append(e("p", "Memory health unavailable under this session: " +
|
|
834
|
+
(error instanceof Error
|
|
835
|
+
? readable(error.message)
|
|
836
|
+
: "request failed"), "caption"));
|
|
837
|
+
return section;
|
|
838
|
+
}
|
|
839
|
+
const window = doc(data.window), observations = doc(data.observations), briefings = doc(data.briefings), feedback = doc(data.feedback), claims = doc(data.claims), backlog = doc(data.backlog), percent = (ppm) => typeof ppm === "number" ? `${Math.round(ppm / 10000)}%` : "n/a", days = (ms) => typeof ms === "number" ? `${Math.floor(ms / 86400000)} day(s)` : "n/a";
|
|
840
|
+
section.append(e("p", `Last ${readable(window.days)} day(s) of this project.`, "caption"));
|
|
841
|
+
const signals = e("ul", "", "health-signals");
|
|
842
|
+
for (const signal of rows(data.signals)) {
|
|
843
|
+
const item = e("li");
|
|
844
|
+
item.dataset.level = String(signal.level);
|
|
845
|
+
item.append(e("strong", `${readable(signal.level)} · ${readable(signal.name)}`), document.createTextNode(` ${readable(signal.text)}`));
|
|
846
|
+
signals.append(item);
|
|
847
|
+
}
|
|
848
|
+
section.append(signals);
|
|
849
|
+
section.append(table([
|
|
850
|
+
{
|
|
851
|
+
measure: "Helpful share of rated feedback",
|
|
852
|
+
value: `${readable(feedback.helpful)} of ${readable(feedback.rated)} (${percent(feedback.helpful_ppm)})`,
|
|
853
|
+
},
|
|
854
|
+
{
|
|
855
|
+
measure: "Briefings with no relevant memory",
|
|
856
|
+
value: `${readable(briefings.no_relevant_memory)} of ${readable(briefings.total)} (${percent(briefings.no_relevant_memory_ppm)})`,
|
|
857
|
+
},
|
|
858
|
+
{
|
|
859
|
+
measure: "Observations never delivered",
|
|
860
|
+
value: `${readable(observations.never_delivered)} of ${readable(observations.total)} (${percent(observations.never_delivered_ppm)})`,
|
|
861
|
+
},
|
|
862
|
+
{
|
|
863
|
+
measure: "Claims that lost their evidence / were replaced",
|
|
864
|
+
value: `${readable(claims.evidence_purged)} / ${readable(claims.superseded)} of ${readable(claims.families)} families`,
|
|
865
|
+
},
|
|
866
|
+
{
|
|
867
|
+
measure: "Proposals waiting for review",
|
|
868
|
+
value: `${readable(backlog.proposed)}; oldest ${days(backlog.oldest_age_ms)}`,
|
|
869
|
+
},
|
|
870
|
+
{
|
|
871
|
+
measure: "Held and purged observations",
|
|
872
|
+
value: `${readable(observations.held)} held, ${readable(observations.purged)} purged`,
|
|
873
|
+
},
|
|
874
|
+
], ["measure", "value"]));
|
|
875
|
+
const waiting = rows(backlog.items).map((item) => ({
|
|
876
|
+
...item,
|
|
877
|
+
waiting: days(item.age_ms),
|
|
878
|
+
}));
|
|
879
|
+
if (waiting.length)
|
|
880
|
+
section.append(e("h4", "Oldest proposals waiting"), table(waiting, [
|
|
881
|
+
"revision",
|
|
882
|
+
"logical_key",
|
|
883
|
+
"kind",
|
|
884
|
+
"issuer",
|
|
885
|
+
"waiting",
|
|
886
|
+
]));
|
|
887
|
+
section.append(detail("Health counts and coverage", data));
|
|
888
|
+
return section;
|
|
889
|
+
}
|
|
890
|
+
/** What left this store for a model provider, under which policy, and whether it arrived. */
|
|
891
|
+
async egress() {
|
|
892
|
+
const section = e("section");
|
|
893
|
+
section.append(e("h3", "Egress audit"));
|
|
894
|
+
let data;
|
|
895
|
+
try {
|
|
896
|
+
data = await this.command("inference", "audit", { before: null }, undefined, true);
|
|
897
|
+
}
|
|
898
|
+
catch (error) {
|
|
899
|
+
section.append(e("p", "Egress audit unavailable under this session: " +
|
|
900
|
+
(error instanceof Error
|
|
901
|
+
? readable(error.message)
|
|
902
|
+
: "request failed"), "caption"));
|
|
903
|
+
this.output.append(section);
|
|
904
|
+
return;
|
|
905
|
+
}
|
|
906
|
+
const items = rows(data.items).map((item) => ({
|
|
907
|
+
when: new Date(Number(item.evaluated_ms)).toLocaleString(),
|
|
908
|
+
status: item.status,
|
|
909
|
+
provider: item.provider,
|
|
910
|
+
model: item.model,
|
|
911
|
+
host: item.host,
|
|
912
|
+
classification: item.classification,
|
|
913
|
+
bytes: item.request_bytes,
|
|
914
|
+
receipts: Array.isArray(item.receipts) ? item.receipts.length : 0,
|
|
915
|
+
tokens: `${String(item.input_tokens ?? "?")} in / ${String(item.output_tokens ?? "?")} out`,
|
|
916
|
+
permit: item.permit,
|
|
917
|
+
}));
|
|
918
|
+
section.append(e("p", `Policy ${readable(data.policy_revision)}. Each record is one request the daemon authorized for a remote provider: hashes and receipt ids only, never content. A record left pending means the host never reported the outcome.`, "integrity"), items.length
|
|
919
|
+
? table(items, [
|
|
920
|
+
"when",
|
|
921
|
+
"status",
|
|
922
|
+
"provider",
|
|
923
|
+
"model",
|
|
924
|
+
"host",
|
|
925
|
+
"classification",
|
|
926
|
+
"bytes",
|
|
927
|
+
"receipts",
|
|
928
|
+
"tokens",
|
|
929
|
+
"permit",
|
|
930
|
+
])
|
|
931
|
+
: e("p", "Nothing has left this store for a provider in the retention window."));
|
|
932
|
+
this.output.append(section);
|
|
933
|
+
}
|
|
934
|
+
async handoffs() {
|
|
935
|
+
this.reader = () => this.handoffs();
|
|
936
|
+
const data = await this.command("inspection", "handoffs");
|
|
937
|
+
if (this.unchanged(data))
|
|
938
|
+
return;
|
|
939
|
+
this.output.replaceChildren(e("h3", "Handoff lifecycle"), e("p", "Only handoffs involving this principal and a currently accessible checkpoint are shown. Role labels grant no authority. Preview uses the sender–recipient permission intersection; this screen never acknowledges work or changes the active writer."), table(rows(data.items), [
|
|
940
|
+
"id",
|
|
941
|
+
"task",
|
|
942
|
+
"checkpoint",
|
|
943
|
+
"sender",
|
|
944
|
+
"recipient",
|
|
945
|
+
"effective",
|
|
946
|
+
"expires",
|
|
947
|
+
]), detail("Authorized handoff state", data));
|
|
948
|
+
const form = e("form", "", "observatory-form"), handle = field(form, "Handle"), action = e("select");
|
|
949
|
+
action.setAttribute("aria-label", "Handoff action");
|
|
950
|
+
for (const value of ["preview", "materialize", "cancel"]) {
|
|
951
|
+
const option = e("option", value);
|
|
952
|
+
option.value = value;
|
|
953
|
+
action.append(option);
|
|
954
|
+
}
|
|
955
|
+
form.append(action, e("button", "Preview request"));
|
|
956
|
+
const preview = e("div");
|
|
957
|
+
form.onsubmit = (ev) => {
|
|
958
|
+
ev.preventDefault();
|
|
959
|
+
const args = { handle: handle.value };
|
|
960
|
+
if (action.value !== "cancel")
|
|
961
|
+
Object.assign(args, {
|
|
962
|
+
max_output_tokens: 8192,
|
|
963
|
+
tokenizer: "cl100k_base",
|
|
964
|
+
});
|
|
965
|
+
const chosen = action.value;
|
|
966
|
+
preview.replaceChildren(detail("Exact handoff request", { action: chosen, ...args }), button("Confirm " + chosen, () => void this.run(() => this.mutate("handoff", chosen, args))));
|
|
967
|
+
};
|
|
968
|
+
this.output.append(form, preview);
|
|
969
|
+
const prepare = e("details");
|
|
970
|
+
prepare.append(e("summary", "Prepare a handoff from a checkpoint"));
|
|
971
|
+
const f = e("form", "", "observatory-form");
|
|
972
|
+
const fields = Object.fromEntries(["task", "run", "checkpoint", "recipient", "role", "stage"].map((k) => [
|
|
973
|
+
k,
|
|
974
|
+
field(f, k),
|
|
975
|
+
]));
|
|
976
|
+
const ttl = field(f, "Expires in milliseconds", "60000", "number");
|
|
977
|
+
f.append(e("button", "Preview preparation"));
|
|
978
|
+
const p = e("div");
|
|
979
|
+
f.onsubmit = (ev) => {
|
|
980
|
+
ev.preventDefault();
|
|
981
|
+
const args = Object.fromEntries(Object.entries(fields).map(([k, v]) => [k, v.value || null]));
|
|
982
|
+
args.bindings = this.scope();
|
|
983
|
+
args.ttl_ms = Number(ttl.value);
|
|
984
|
+
p.replaceChildren(detail("Exact recipient and scope", args), button("Confirm preparation", () => void this.run(() => this.mutate("handoff", "prepare", args))));
|
|
985
|
+
};
|
|
986
|
+
prepare.append(f, p);
|
|
987
|
+
this.output.append(prepare);
|
|
988
|
+
}
|
|
989
|
+
impact() {
|
|
990
|
+
this.status.textContent =
|
|
991
|
+
"Enter the repository snapshot and paths to check current access.";
|
|
992
|
+
this.output.replaceChildren(e("h3", "Code change impact"), e("p", "Direct evidence links and bounded Python parser relations. Missing files or unsupported languages remain coverage gaps; absence of edges does not prove no impact."));
|
|
993
|
+
const f = e("form", "", "observatory-form"), repository = field(f, "Repository ID"), snapshot = field(f, "Snapshot ID"), paths = field(f, "Changed paths (comma separated)");
|
|
994
|
+
f.append(e("button", "Inspect impact"));
|
|
995
|
+
const result = e("div");
|
|
996
|
+
f.onsubmit = (ev) => {
|
|
997
|
+
ev.preventDefault();
|
|
998
|
+
const args = {
|
|
999
|
+
repository: repository.value,
|
|
1000
|
+
snapshot: snapshot.value,
|
|
1001
|
+
paths: paths.value
|
|
1002
|
+
.split(",")
|
|
1003
|
+
.map((x) => x.trim())
|
|
1004
|
+
.filter(Boolean),
|
|
1005
|
+
}, bindings = this.scope();
|
|
1006
|
+
const read = async () => {
|
|
1007
|
+
const value = await this.command("repository", "impact", {
|
|
1008
|
+
...args,
|
|
1009
|
+
limit: 128,
|
|
1010
|
+
}), coverage = await this.command("repository", "coverage", {
|
|
1011
|
+
...args,
|
|
1012
|
+
bindings,
|
|
1013
|
+
});
|
|
1014
|
+
if (this.unchanged(value, coverage))
|
|
1015
|
+
return;
|
|
1016
|
+
result.replaceChildren(detail("Evidence and affected claims", value), detail("Parser and policy coverage", coverage));
|
|
1017
|
+
const host = e("div");
|
|
1018
|
+
result.prepend(host);
|
|
1019
|
+
this.graph?.clear();
|
|
1020
|
+
this.graph = new AtlasView(host, () => { });
|
|
1021
|
+
this.graph.set({
|
|
1022
|
+
nodes: rows(value.nodes).map((n) => ({
|
|
1023
|
+
...n,
|
|
1024
|
+
id: String(n.id),
|
|
1025
|
+
type: String(n.kind),
|
|
1026
|
+
label: String(n.id),
|
|
1027
|
+
})),
|
|
1028
|
+
edges: rows(value.edges).map((edge, i) => ({
|
|
1029
|
+
...edge,
|
|
1030
|
+
id: "impact-edge-" + i,
|
|
1031
|
+
source: String(edge.source),
|
|
1032
|
+
target: String(edge.target),
|
|
1033
|
+
type: String(edge.kind),
|
|
1034
|
+
provenance: edge,
|
|
1035
|
+
})),
|
|
1036
|
+
coverage: "Direct current evidence dependencies; no similarity inference",
|
|
1037
|
+
truncation: value.truncated ? ["impact_limit"] : [],
|
|
1038
|
+
});
|
|
1039
|
+
};
|
|
1040
|
+
this.reader = read;
|
|
1041
|
+
void this.run(read, true);
|
|
1042
|
+
};
|
|
1043
|
+
this.output.append(f, result);
|
|
1044
|
+
}
|
|
1045
|
+
async timeline(before) {
|
|
1046
|
+
const project = this.project.value;
|
|
1047
|
+
const data = await this.api("/api/timeline/" +
|
|
1048
|
+
encodeURIComponent(project) +
|
|
1049
|
+
(before === undefined ? "" : "/" + String(before)));
|
|
1050
|
+
const items = (data.items ?? []);
|
|
1051
|
+
const rows = items.map((item) => ({
|
|
1052
|
+
position: item.position,
|
|
1053
|
+
when: new Date(Number(item.at_ms)).toLocaleString(),
|
|
1054
|
+
event: item.kind,
|
|
1055
|
+
subject: `${String(item.subject_kind)} ${String(item.subject)}`,
|
|
1056
|
+
actor: item.actor,
|
|
1057
|
+
}));
|
|
1058
|
+
const body = [
|
|
1059
|
+
e("h3", "Timeline"),
|
|
1060
|
+
e("p", "Every recorded event whose subject belongs to this project, newest first: captures, claims, reviews, checkpoints, handoffs and purges, with the principal that caused each.", "integrity"),
|
|
1061
|
+
rows.length
|
|
1062
|
+
? table(rows, ["position", "when", "event", "subject", "actor"])
|
|
1063
|
+
: e("p", "No events recorded for this project yet."),
|
|
1064
|
+
];
|
|
1065
|
+
if (before === undefined)
|
|
1066
|
+
this.output.replaceChildren(...body);
|
|
1067
|
+
else {
|
|
1068
|
+
this.output.querySelector("[data-earlier]")?.remove();
|
|
1069
|
+
this.output.append(...body.slice(2));
|
|
1070
|
+
}
|
|
1071
|
+
if (data.next_before !== null && data.next_before !== undefined) {
|
|
1072
|
+
const more = e("button", "Load earlier");
|
|
1073
|
+
more.type = "button";
|
|
1074
|
+
more.dataset.earlier = "1";
|
|
1075
|
+
more.onclick = () => void this.run(() => this.timeline(Number(data.next_before)));
|
|
1076
|
+
this.output.append(more);
|
|
1077
|
+
}
|
|
1078
|
+
}
|
|
1079
|
+
brief() {
|
|
1080
|
+
this.status.textContent =
|
|
1081
|
+
"Run the same briefing an agent would receive, with its receipt.";
|
|
1082
|
+
this.output.replaceChildren(e("h3", "Ask for a briefing"), e("p", "The query is answered under your current permissions and recorded with a receipt exactly as for an agent. Constraints come first, then cited guidance; sources are evidence, not instructions.", "integrity"));
|
|
1083
|
+
const f = e("form", "", "observatory-form");
|
|
1084
|
+
const query = field(f, "Query");
|
|
1085
|
+
query.required = true;
|
|
1086
|
+
query.maxLength = 2048;
|
|
1087
|
+
const budget = field(f, "Token budget", "6000", "number");
|
|
1088
|
+
budget.min = "256";
|
|
1089
|
+
budget.max = "100000";
|
|
1090
|
+
const asOf = field(f, "As of (optional)", "", "datetime-local");
|
|
1091
|
+
asOf.title =
|
|
1092
|
+
"Brief as the project stood at this moment: only what was recorded by then, with claim validity judged then.";
|
|
1093
|
+
f.append(e("button", "Brief me"));
|
|
1094
|
+
const result = e("div", "", "briefing");
|
|
1095
|
+
f.onsubmit = (event) => {
|
|
1096
|
+
event.preventDefault();
|
|
1097
|
+
void this.run(async () => {
|
|
1098
|
+
result.replaceChildren(e("p", "Checking current permission…"));
|
|
1099
|
+
const instant = asOf.value ? new Date(asOf.value).getTime() : NaN;
|
|
1100
|
+
const packet = await this.command("retrieval", "brief", {
|
|
1101
|
+
query: query.value,
|
|
1102
|
+
bindings: [{}],
|
|
1103
|
+
max_output_tokens: Number(budget.value) || 6000,
|
|
1104
|
+
tokenizer: "utf8-byte-estimate-v1",
|
|
1105
|
+
format: "text",
|
|
1106
|
+
...(Number.isFinite(instant) ? { as_of_ms: instant } : {}),
|
|
1107
|
+
});
|
|
1108
|
+
result.replaceChildren(...markdown(String(packet.text ?? "")));
|
|
1109
|
+
const usage = (packet.usage ?? {});
|
|
1110
|
+
result.append(e("p", `Receipt ${String(packet.receipt)} · status ${String(packet.status)} · ${String(usage.output_tokens ?? "?")} tokens (${String(usage.counting ?? "estimate")})`, "caption"));
|
|
1111
|
+
const sources = (packet.sources ?? []);
|
|
1112
|
+
if (sources.length) {
|
|
1113
|
+
result.append(detail("Citations", sources.map((s) => `[${String(s.ref)}] ${String(s.kind)} ${String(s.id)}`)));
|
|
1114
|
+
}
|
|
1115
|
+
const replay = e("button", "Verify replay");
|
|
1116
|
+
replay.type = "button";
|
|
1117
|
+
replay.onclick = () => void this.run(async () => {
|
|
1118
|
+
const again = await this.command("retrieval", "replay", {
|
|
1119
|
+
receipt: packet.receipt,
|
|
1120
|
+
});
|
|
1121
|
+
replay.textContent =
|
|
1122
|
+
again.text === packet.text
|
|
1123
|
+
? "Replay matched byte for byte"
|
|
1124
|
+
: "Replay differed";
|
|
1125
|
+
});
|
|
1126
|
+
result.append(replay);
|
|
1127
|
+
});
|
|
1128
|
+
};
|
|
1129
|
+
this.output.append(f, result);
|
|
1130
|
+
}
|
|
1131
|
+
influence() {
|
|
1132
|
+
this.status.textContent =
|
|
1133
|
+
"Enter an observation to list every record built from it and who received them.";
|
|
1134
|
+
this.output.replaceChildren(e("h3", "Where did this memory go"), e("p", "The claims that cite the observation, the checkpoints, handoffs, summaries and experience records built on it or on anything derived from it, and the retained briefings, fetches, reruns and graph pages that included it, with the principals they reached. The same recorded dependencies a purge would follow, read without changing anything. Prior exports, provider deliveries and backups leave no record here."));
|
|
1135
|
+
const f = e("form", "", "observatory-form"), observation = field(f, "Observation ID");
|
|
1136
|
+
observation.required = true;
|
|
1137
|
+
f.append(e("button", "Trace"));
|
|
1138
|
+
const result = e("div");
|
|
1139
|
+
observation.oninput = () => result.replaceChildren();
|
|
1140
|
+
f.onsubmit = (ev) => {
|
|
1141
|
+
ev.preventDefault();
|
|
1142
|
+
const id = observation.value;
|
|
1143
|
+
const read = async () => {
|
|
1144
|
+
const value = await this.command("inspection", "influence", {
|
|
1145
|
+
observation: id,
|
|
1146
|
+
});
|
|
1147
|
+
if (this.unchanged(value))
|
|
1148
|
+
return;
|
|
1149
|
+
const counts = doc(value.counts);
|
|
1150
|
+
result.replaceChildren(e("p", `Captured by ${String(value.captured_by)} from ${String(value.source)} · reached ${String(counts.principals)} principal(s): ${value.principals.join(", ") || "none"}`, "eyebrow"));
|
|
1151
|
+
for (const [title, key] of [
|
|
1152
|
+
["Claims citing it", "claims"],
|
|
1153
|
+
["Checkpoints built on it", "checkpoints"],
|
|
1154
|
+
["Handoffs that carried it", "handoffs"],
|
|
1155
|
+
["Summaries derived from it", "summaries"],
|
|
1156
|
+
["Deliveries that included it", "deliveries"],
|
|
1157
|
+
["Experience records", "experience"],
|
|
1158
|
+
]) {
|
|
1159
|
+
const items = rows(value[key]);
|
|
1160
|
+
const truncated = value.truncation.includes(key)
|
|
1161
|
+
? " (truncated)"
|
|
1162
|
+
: "";
|
|
1163
|
+
result.append(detail(`${title}: ${items.length}${truncated}`, items));
|
|
1164
|
+
}
|
|
1165
|
+
result.append(e("p", readable(value.coverage), "caption"));
|
|
1166
|
+
};
|
|
1167
|
+
this.reader = read;
|
|
1168
|
+
void this.run(read, true);
|
|
1169
|
+
};
|
|
1170
|
+
this.output.append(f, result);
|
|
1171
|
+
}
|
|
1172
|
+
retention() {
|
|
1173
|
+
this.status.textContent =
|
|
1174
|
+
"Enter an observation to authorize and preview its consequences.";
|
|
1175
|
+
this.output.replaceChildren(e("h3", "Retention preview"), e("p", "Permanent purge erases the source and the claims, briefings, checkpoints and handoffs that recorded a dependency on it, deletes receipts that list it, retires replay results tenant-wide, and disables ranking when a dependent experience record is retired. It cannot erase prior exports, provider deliveries or backups. Review the server preview before confirming.", "integrity"));
|
|
1176
|
+
const f = e("form", "", "observatory-form"), observation = field(f, "Observation ID");
|
|
1177
|
+
observation.required = true;
|
|
1178
|
+
f.append(e("button", "Preview purge"));
|
|
1179
|
+
const preview = e("div");
|
|
1180
|
+
observation.oninput = () => preview.replaceChildren();
|
|
1181
|
+
f.onsubmit = (ev) => {
|
|
1182
|
+
ev.preventDefault();
|
|
1183
|
+
void this.run(async () => {
|
|
1184
|
+
const id = observation.value, value = await this.command("inspection", "retention_preview", {
|
|
1185
|
+
observation: id,
|
|
1186
|
+
});
|
|
1187
|
+
preview.replaceChildren(detail("Affected records, gaps and irreversible effects", Object.fromEntries(Object.entries(value).filter(([key]) => key !== "preview"))));
|
|
1188
|
+
const confirmForm = e("form"), confirm = field(confirmForm, `Type ${id} to confirm permanent purge`);
|
|
1189
|
+
confirm.required = true;
|
|
1190
|
+
confirmForm.append(e("button", "Permanently purge", "danger"));
|
|
1191
|
+
confirmForm.onsubmit = (event) => {
|
|
1192
|
+
event.preventDefault();
|
|
1193
|
+
void this.run(async () => {
|
|
1194
|
+
if (confirm.value !== id || observation.value !== id)
|
|
1195
|
+
throw Error("Confirmation does not match preview");
|
|
1196
|
+
await this.mutate("inspection", "purge", {
|
|
1197
|
+
observation: id,
|
|
1198
|
+
preview: value.preview,
|
|
1199
|
+
confirm: confirm.value,
|
|
1200
|
+
});
|
|
1201
|
+
});
|
|
1202
|
+
};
|
|
1203
|
+
preview.append(confirmForm);
|
|
1204
|
+
});
|
|
1205
|
+
};
|
|
1206
|
+
this.output.append(f, preview);
|
|
1207
|
+
}
|
|
1208
|
+
}
|