piroboros 0.0.0-stage → 0.2.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/CHANGELOG.md +43 -0
- package/LICENSE +21 -0
- package/NOTICE +39 -0
- package/README.md +140 -2
- package/agents/astrelia.md +31 -0
- package/agents/avaritia.md +31 -0
- package/agents/elaria.md +31 -0
- package/agents/nytheria.md +32 -0
- package/agents/raskreia.md +32 -0
- package/agents/samaela.md +40 -0
- package/agents/vaelia.md +35 -0
- package/agents/vesperia.md +45 -0
- package/bin/piroboros.mjs +17 -0
- package/dist/auth.js +105 -0
- package/dist/base.js +19 -0
- package/dist/chat/budget.js +87 -0
- package/dist/chat/compactloop.js +63 -0
- package/dist/chat/compactor.js +530 -0
- package/dist/chat/extension.js +36 -0
- package/dist/chat/hook.js +40 -0
- package/dist/chat/log.js +317 -0
- package/dist/chat/outbound.js +114 -0
- package/dist/chat/plan.js +64 -0
- package/dist/chat/prompt.js +115 -0
- package/dist/chat/status.js +37 -0
- package/dist/chat/stuck.js +83 -0
- package/dist/chat/tools.js +163 -0
- package/dist/chat/tree.js +73 -0
- package/dist/chat/turn.js +305 -0
- package/dist/chat/view.js +163 -0
- package/dist/conclave/agents.js +113 -0
- package/dist/conclave/pipeline.js +715 -0
- package/dist/conclave/report.js +43 -0
- package/dist/config.js +614 -0
- package/dist/durable.js +177 -0
- package/dist/guard.js +346 -0
- package/dist/lock.js +56 -0
- package/dist/main.js +348 -0
- package/dist/memory/akashic/api.js +121 -0
- package/dist/memory/akashic/confusables.js +41 -0
- package/dist/memory/akashic/scanner.js +67 -0
- package/dist/memory/akashic/snapshot.js +31 -0
- package/dist/memory/akashic/store.js +1254 -0
- package/dist/memory/akashic/tools.js +168 -0
- package/dist/memory/akashic/vault.js +984 -0
- package/dist/memory/host.js +124 -0
- package/dist/memory/mnemosia/adapters/akashic-memories.js +180 -0
- package/dist/memory/mnemosia/adapters/contract.js +219 -0
- package/dist/memory/mnemosia/agents.js +387 -0
- package/dist/memory/mnemosia/brief.js +890 -0
- package/dist/memory/mnemosia/claims.js +609 -0
- package/dist/memory/mnemosia/conflicts.js +769 -0
- package/dist/memory/mnemosia/escalation.js +257 -0
- package/dist/memory/mnemosia/feedback.js +108 -0
- package/dist/memory/mnemosia/filters.js +248 -0
- package/dist/memory/mnemosia/intent.js +221 -0
- package/dist/memory/mnemosia/open.js +34 -0
- package/dist/memory/mnemosia/orchestrator.js +926 -0
- package/dist/memory/mnemosia/plan.js +266 -0
- package/dist/memory/mnemosia/policy.js +426 -0
- package/dist/memory/mnemosia/progressive.js +550 -0
- package/dist/memory/mnemosia/provenance.js +458 -0
- package/dist/memory/mnemosia/qualifiers.js +428 -0
- package/dist/memory/mnemosia/rank.js +525 -0
- package/dist/memory/mnemosia/relations.js +156 -0
- package/dist/memory/mnemosia/requirements.js +138 -0
- package/dist/memory/mnemosia/rerank.js +253 -0
- package/dist/memory/mnemosia/retention.js +174 -0
- package/dist/memory/mnemosia/rollback.js +337 -0
- package/dist/memory/mnemosia/select.js +607 -0
- package/dist/memory/mnemosia/similarity.js +164 -0
- package/dist/memory/mnemosia/situation.js +251 -0
- package/dist/memory/mnemosia/task.js +418 -0
- package/dist/memory/mnemosia/temporal.js +136 -0
- package/dist/memory/mnemosia/tokens.js +66 -0
- package/dist/memory/mnemosia/tools.js +160 -0
- package/dist/memory/mnemosia/trace.js +306 -0
- package/dist/memory/mnemosia/types.js +298 -0
- package/dist/models.js +360 -0
- package/dist/paths.js +103 -0
- package/dist/redact.js +79 -0
- package/dist/runtime.js +378 -0
- package/dist/search-format.js +102 -0
- package/dist/search.js +351 -0
- package/dist/setup.js +366 -0
- package/dist/shell.js +110 -0
- package/dist/skills.js +311 -0
- package/dist/telemetry.js +84 -0
- package/dist/tui/app.js +1011 -0
- package/dist/tui/commands.js +121 -0
- package/dist/tui/keys.js +83 -0
- package/dist/tui/pane.js +387 -0
- package/dist/tui/panel.js +60 -0
- package/dist/tui/picker.js +25 -0
- package/dist/tui/sanitize.js +59 -0
- package/dist/tui/settings.js +198 -0
- package/dist/tui/setup.js +256 -0
- package/dist/tui/theme.js +26 -0
- package/dist/tui/thinking/parse.js +1094 -0
- package/dist/tui/thinking/select.js +86 -0
- package/dist/tui/thinking/state.js +137 -0
- package/dist/tui/thinking/types.js +3 -0
- package/dist/tui/thinking/view.js +74 -0
- package/dist/tui/viewport.js +208 -0
- package/dist/undo.js +258 -0
- package/dist/web.js +933 -0
- package/docs/conclave.md +21 -0
- package/docs/configuration.md +48 -0
- package/docs/development.md +25 -0
- package/docs/interface.md +33 -0
- package/docs/memory.md +11 -0
- package/docs/privacy.md +13 -0
- package/docs/tools.md +20 -0
- package/docs/web.md +38 -0
- package/models.json.example +34 -0
- package/package.json +76 -4
- package/settings.json.example +29 -0
- package/skills/conclave/SKILL.md +76 -0
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
// Ported from mnemosia/intent.ts @ f0a8ad4 (MIT; see NOTICE)
|
|
2
|
+
/**
|
|
3
|
+
* Phase B stage 2 — intent hypothesis sets (spec "Stage 3: Intent-Aware Retrieval").
|
|
4
|
+
*
|
|
5
|
+
* A task verb under-determines the task. "Fix Phase 5" could mean correct a bug, repair a
|
|
6
|
+
* regression, resolve an architectural flaw, or finish an unfinished migration — and each reading
|
|
7
|
+
* retrieves different evidence. This module turns that ambiguity into a **bounded, explicit,
|
|
8
|
+
* competing** set of hypotheses with probabilities over them, plus a clarification policy that asks
|
|
9
|
+
* the caller only when getting it wrong is expensive.
|
|
10
|
+
*
|
|
11
|
+
* Three properties carry the spec's fine print:
|
|
12
|
+
*
|
|
13
|
+
* - **Not calibrated truth.** `calibrated` is hard-coded `false`; no calibration evaluation has run
|
|
14
|
+
* (spec: "must not be presented as calibrated truth unless calibration has been evaluated").
|
|
15
|
+
* - **Guardrail against over-investigation.** Clarification fires only when the top two hypotheses
|
|
16
|
+
* are within 0.15 *and* the ambiguity is consequential — a mutation verb is present. Exploratory
|
|
17
|
+
* tasks (research/review/recall) proceed with the leading hypothesis even when it is a close call:
|
|
18
|
+
* there, wrong retrieval costs one wasted query, while clarification costs a round trip.
|
|
19
|
+
* - **Model-assisted seam, interface only.** `IntentProposalSource` is where future model-generated
|
|
20
|
+
* hypotheses plug in; they would flow through the same validator and bounds. No LLM call here.
|
|
21
|
+
*/
|
|
22
|
+
import { SCHEMA_VERSION } from "./types.js";
|
|
23
|
+
/* ------------------------------------------------------------------------------------------------
|
|
24
|
+
* Types
|
|
25
|
+
* ---------------------------------------------------------------------------------------------- */
|
|
26
|
+
export const MAX_INTENT_HYPOTHESES = 5;
|
|
27
|
+
/** Spec's threshold: below this margin between the top two, ambiguity *may* be worth a question. */
|
|
28
|
+
export const CLARIFICATION_MARGIN = 0.15;
|
|
29
|
+
/** `selected` — the run proceeds on this hypothesis; `uncertain` — leading but clarify recommended; `alternative` — recorded competitor. */
|
|
30
|
+
export const INTENT_STATUSES = ["selected", "uncertain", "alternative"];
|
|
31
|
+
/**
|
|
32
|
+
* The hypothesis catalog, phrased from the spec's own example list for "Fix Phase 5". Patterns are
|
|
33
|
+
* stem-anchored (`\bimplement`, not `\bimplement\b`) so "implementing" matches.
|
|
34
|
+
*/
|
|
35
|
+
const HYPOTHESIS_CATALOG = [
|
|
36
|
+
{
|
|
37
|
+
hypothesisId: "incomplete-implementation",
|
|
38
|
+
description: "complete an unfinished implementation",
|
|
39
|
+
patterns: [/\bimplement/iu, /\b(continue|resume|finish|complete|unfinished|pick ?up)\b/iu],
|
|
40
|
+
discriminatingEvidence: ["project state records showing the milestone partially done", "open TODOs naming exactly this work"],
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
hypothesisId: "bug-correction",
|
|
44
|
+
description: "correct a bug in existing behaviour",
|
|
45
|
+
patterns: [/\b(fix|repair|correct)\b/iu, /\b(bug|crash|error|broken|incorrect|wrong)\b/iu],
|
|
46
|
+
discriminatingEvidence: ["a failure report describing reproducible misbehaviour"],
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
hypothesisId: "regression-repair",
|
|
50
|
+
description: "repair a regression something used to work and now does not",
|
|
51
|
+
patterns: [/\b(fix|repair|correct)\b/iu, /\b(regression|used to work|worked before|broke)\b/iu],
|
|
52
|
+
discriminatingEvidence: ["a record of the behaviour holding at an earlier commit or phase"],
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
hypothesisId: "test-failure",
|
|
56
|
+
description: "resolve failing tests rather than product behaviour",
|
|
57
|
+
patterns: [/\b(test|suite|spec)\b/iu, /\bfail/iu],
|
|
58
|
+
discriminatingEvidence: ["a recent test-run record or failing test names"],
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
hypothesisId: "architecture-correction",
|
|
62
|
+
description: "resolve a flaw in design or structure rather than a local defect",
|
|
63
|
+
patterns: [/\b(fix|repair|restructur|refactor)/iu, /\b(architect|design|approach|structure)\b/iu],
|
|
64
|
+
discriminatingEvidence: ["an architecture decision record covering the affected boundary"],
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
hypothesisId: "performance-improvement",
|
|
68
|
+
description: "improve performance rather than correctness",
|
|
69
|
+
patterns: [/\b(slow|latency|faster|speed ?up|optimiz|performance)\b/iu],
|
|
70
|
+
discriminatingEvidence: ["a measured latency or throughput baseline"],
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
hypothesisId: "documentation-correction",
|
|
74
|
+
description: "correct documentation rather than behaviour",
|
|
75
|
+
patterns: [/\b(doc|readme|comment|guide|changelog)/iu],
|
|
76
|
+
discriminatingEvidence: ["the stale passage itself, in docs the corpus indexes"],
|
|
77
|
+
},
|
|
78
|
+
];
|
|
79
|
+
/** Situation items that corroborate specific hypotheses — situation shapes intent, never replaces it. */
|
|
80
|
+
const SITUATION_BOOSTS = {
|
|
81
|
+
"known-failures": { "bug-correction": 0.5, "test-failure": 1 },
|
|
82
|
+
"resume-open-work": { "incomplete-implementation": 1 },
|
|
83
|
+
"active-milestone-definition": { "incomplete-implementation": 0.5 },
|
|
84
|
+
};
|
|
85
|
+
/** Verbs whose wrong reading costs a real write or a real diagnosis — the consequential class. */
|
|
86
|
+
const CONSEQUENTIAL_VERBS = /\b(fix|repair|correct|implement|migrate|refactor|deploy|delete|remove|change|modify|write|build|ship)\b/iu;
|
|
87
|
+
/* ------------------------------------------------------------------------------------------------
|
|
88
|
+
* Inference
|
|
89
|
+
* ---------------------------------------------------------------------------------------------- */
|
|
90
|
+
/**
|
|
91
|
+
* Infers the bounded hypothesis set for a task in its situation. Pure and deterministic.
|
|
92
|
+
*/
|
|
93
|
+
export function inferIntentHypotheses(task, situation) {
|
|
94
|
+
const trimmed = task.trim();
|
|
95
|
+
const scored = HYPOTHESIS_CATALOG.map((entry) => {
|
|
96
|
+
let score = 0;
|
|
97
|
+
const evidenceFor = [];
|
|
98
|
+
for (const pattern of entry.patterns) {
|
|
99
|
+
if (!pattern.test(trimmed))
|
|
100
|
+
continue;
|
|
101
|
+
score += 1;
|
|
102
|
+
evidenceFor.push(`task matches /${pattern.source}/${pattern.flags}`);
|
|
103
|
+
}
|
|
104
|
+
for (const item of situation.items) {
|
|
105
|
+
const boost = SITUATION_BOOSTS[item.id]?.[entry.hypothesisId];
|
|
106
|
+
if (boost === undefined)
|
|
107
|
+
continue;
|
|
108
|
+
if (item.tier === "unknown")
|
|
109
|
+
continue;
|
|
110
|
+
score += boost;
|
|
111
|
+
evidenceFor.push(`situation item "${item.id}" (${item.tier})`);
|
|
112
|
+
}
|
|
113
|
+
return { entry, score, evidenceFor };
|
|
114
|
+
});
|
|
115
|
+
const positive = scored.filter((candidate) => candidate.score > 0).sort((a, b) => b.score - a.score || a.entry.hypothesisId.localeCompare(b.entry.hypothesisId));
|
|
116
|
+
// Nothing matched: the honest set is one weak hypothesis — execute the objective literally —
|
|
117
|
+
// rather than five invented competitors amplifying noise into fake ambiguity.
|
|
118
|
+
const pool = positive.length > 0 ? positive : [{ entry: HYPOTHESIS_CATALOG[0], score: 1, evidenceFor: ["no intent signal matched; defaulting to literal execution"] }];
|
|
119
|
+
const chosen = pool.slice(0, MAX_INTENT_HYPOTHESES);
|
|
120
|
+
const total = chosen.reduce((sum, candidate) => sum + candidate.score, 0);
|
|
121
|
+
// Round to 2dp, then give any rounding residue to the leader so the sum lands on ≤ 1 exactly.
|
|
122
|
+
const rounded = chosen.map((candidate) => ({ ...candidate, probability: Math.round((candidate.score / total) * 100) / 100 }));
|
|
123
|
+
const sumBeforeFix = rounded.reduce((sum, candidate) => sum + candidate.probability, 0);
|
|
124
|
+
const residue = Math.round((1 - sumBeforeFix) * 100) / 100;
|
|
125
|
+
if (rounded.length > 0 && residue !== 0)
|
|
126
|
+
rounded[0].probability = Math.max(0, Math.min(1, rounded[0].probability + residue));
|
|
127
|
+
const sorted = [...rounded].sort((a, b) => b.probability - a.probability || a.entry.hypothesisId.localeCompare(b.entry.hypothesisId));
|
|
128
|
+
const margin = sorted.length >= 2 ? Math.round((sorted[0].probability - sorted[1].probability) * 100) / 100 : sorted[0].probability;
|
|
129
|
+
const consequential = CONSEQUENTIAL_VERBS.test(trimmed);
|
|
130
|
+
const recommendClarify = sorted.length >= 2 && margin < CLARIFICATION_MARGIN && consequential;
|
|
131
|
+
const rationale = recommendClarify
|
|
132
|
+
? `top two hypotheses are within ${CLARIFICATION_MARGIN} (margin ${margin}) and the task carries a mutation verb, so retrieving for the wrong reading costs a wrong edit; ask before retrieving`
|
|
133
|
+
: sorted.length < 2
|
|
134
|
+
? "a single hypothesis dominates; nothing to disambiguate"
|
|
135
|
+
: consequential
|
|
136
|
+
? `leading hypothesis leads by ${margin} ≥ ${CLARIFICATION_MARGIN}; proceed and let discriminating evidence update the assessment`
|
|
137
|
+
: `ambiguity is harmless here: no mutation verb, so wrong retrieval costs one query while clarification costs a round trip`;
|
|
138
|
+
const hypotheses = sorted.map((candidate, index) => ({
|
|
139
|
+
hypothesisId: candidate.entry.hypothesisId,
|
|
140
|
+
description: candidate.entry.description,
|
|
141
|
+
probability: candidate.probability,
|
|
142
|
+
evidenceFor: candidate.evidenceFor,
|
|
143
|
+
evidenceAgainst: index === 0 && sorted.length > 1 ? [`alternative "${sorted[1].entry.hypothesisId}" scored ${sorted[1].score}`] : [],
|
|
144
|
+
discriminatingEvidence: [...candidate.entry.discriminatingEvidence],
|
|
145
|
+
status: index === 0 ? (recommendClarify ? "uncertain" : "selected") : "alternative",
|
|
146
|
+
}));
|
|
147
|
+
return validateIntentHypothesisSet({
|
|
148
|
+
schemaVersion: SCHEMA_VERSION.intentHypothesisSet,
|
|
149
|
+
task: trimmed,
|
|
150
|
+
hypotheses,
|
|
151
|
+
probabilitiesSum: Math.round(hypotheses.reduce((sum, hypothesis) => sum + hypothesis.probability, 0) * 100) / 100,
|
|
152
|
+
calibrated: false,
|
|
153
|
+
recommendation: { action: recommendClarify ? "clarify" : "proceed", margin, consequential, rationale },
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Query-vocabulary hints for the leading hypothesis — the terms retrieval would add for the reading
|
|
158
|
+
* it currently believes in. Deterministic; empty when the leading hypothesis has none to offer.
|
|
159
|
+
*/
|
|
160
|
+
const LEADING_QUERY_TERMS = {
|
|
161
|
+
"incomplete-implementation": ["implementation"],
|
|
162
|
+
"regression-repair": ["regression"],
|
|
163
|
+
"test-failure": ["fail"],
|
|
164
|
+
"performance-improvement": ["performance"],
|
|
165
|
+
};
|
|
166
|
+
export function leadingQueryTerms(intent) {
|
|
167
|
+
const leading = intent.hypotheses.find((hypothesis) => hypothesis.status === "selected");
|
|
168
|
+
return leading ? [...(LEADING_QUERY_TERMS[leading.hypothesisId] ?? [])] : [];
|
|
169
|
+
}
|
|
170
|
+
/* ------------------------------------------------------------------------------------------------
|
|
171
|
+
* Validation
|
|
172
|
+
* ---------------------------------------------------------------------------------------------- */
|
|
173
|
+
/**
|
|
174
|
+
* Schema-validates and bounds a hypothesis set. Drops malformed hypotheses, caps at
|
|
175
|
+
* MAX_INTENT_HYPOTHESES, clamps probabilities to [0,1] and re-scales down if the sum exceeds 1.
|
|
176
|
+
*/
|
|
177
|
+
export function validateIntentHypothesisSet(value) {
|
|
178
|
+
const seen = new Set();
|
|
179
|
+
const hypotheses = [];
|
|
180
|
+
for (const hypothesis of value.hypotheses) {
|
|
181
|
+
if (hypotheses.length >= MAX_INTENT_HYPOTHESES)
|
|
182
|
+
break;
|
|
183
|
+
if (typeof hypothesis.hypothesisId !== "string" || hypothesis.hypothesisId.length === 0 || seen.has(hypothesis.hypothesisId))
|
|
184
|
+
continue;
|
|
185
|
+
if (typeof hypothesis.probability !== "number" || !Number.isFinite(hypothesis.probability))
|
|
186
|
+
continue;
|
|
187
|
+
if (typeof hypothesis.description !== "string" || hypothesis.description.length === 0)
|
|
188
|
+
continue;
|
|
189
|
+
if (!INTENT_STATUSES.includes(hypothesis.status))
|
|
190
|
+
continue;
|
|
191
|
+
seen.add(hypothesis.hypothesisId);
|
|
192
|
+
hypotheses.push({
|
|
193
|
+
...hypothesis,
|
|
194
|
+
probability: Math.min(1, Math.max(0, hypothesis.probability)),
|
|
195
|
+
evidenceFor: strings(hypothesis.evidenceFor),
|
|
196
|
+
evidenceAgainst: strings(hypothesis.evidenceAgainst),
|
|
197
|
+
discriminatingEvidence: strings(hypothesis.discriminatingEvidence).slice(0, 4),
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
const total = hypotheses.reduce((sum, hypothesis) => sum + hypothesis.probability, 0);
|
|
201
|
+
if (total > 1) {
|
|
202
|
+
for (const hypothesis of hypotheses)
|
|
203
|
+
hypothesis.probability = Math.round((hypothesis.probability / total) * 100) / 100;
|
|
204
|
+
// Rounding can leave the rescaled sum just above or below 1; give the residue to the leader
|
|
205
|
+
// exactly as inferIntentHypotheses does, so probabilitiesSum lands on ≤ 1 exactly.
|
|
206
|
+
const sumAfterRescale = hypotheses.reduce((sum, hypothesis) => sum + hypothesis.probability, 0);
|
|
207
|
+
const residue = Math.round((1 - sumAfterRescale) * 100) / 100;
|
|
208
|
+
if (hypotheses.length > 0 && residue !== 0) {
|
|
209
|
+
const leader = hypotheses.reduce((a, b) => (b.probability > a.probability ? b : a));
|
|
210
|
+
leader.probability = Math.max(0, Math.min(1, leader.probability + residue));
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
return {
|
|
214
|
+
...value,
|
|
215
|
+
hypotheses,
|
|
216
|
+
probabilitiesSum: Math.round(hypotheses.reduce((sum, hypothesis) => sum + hypothesis.probability, 0) * 100) / 100,
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
function strings(values) {
|
|
220
|
+
return Array.isArray(values) ? values.filter((value) => typeof value === "string") : [];
|
|
221
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// Ported from mnemosia/extension.ts @ f0a8ad4 (MIT; see NOTICE)
|
|
2
|
+
// This is openFoundations. It opens what a briefing needs: one source adapter over the curated memories, the scanner, the tokenizer and the redactor.
|
|
3
|
+
// The store is the one the akashic tool uses; this file never opens a second connection to it. Paths are explicit.
|
|
4
|
+
import { join } from "node:path";
|
|
5
|
+
import { createMemoryApi } from "../akashic/api.js";
|
|
6
|
+
import { redactSensitive, tokenizeSearch, validateMemorySafety } from "../akashic/store.js";
|
|
7
|
+
import { createAkashicMemoriesAdapter } from "./adapters/akashic-memories.js";
|
|
8
|
+
import { applyTraceRotation, enableRetention, planTraceRotation } from "./retention.js";
|
|
9
|
+
/** `${home}/mnemosia/traces` and `${home}/mnemosia/feedback.jsonl`. Opening the foundations prunes old traces (see openFoundations). */
|
|
10
|
+
export const mnemosiaPaths = (home) => ({ traceRoot: join(home, "mnemosia", "traces"), feedbackPath: join(home, "mnemosia", "feedback.jsonl") });
|
|
11
|
+
/**
|
|
12
|
+
* Trace rotation was a human-approval item in the port (retention.ts, design 19 item 4). The user
|
|
13
|
+
* approved it for piroboros with the retention.ts defaults: a trace is kept while it is under 90 days
|
|
14
|
+
* old or among the 500 newest. The feedback log is capped separately, in submitFeedback.
|
|
15
|
+
*/
|
|
16
|
+
const TRACE_ROTATION_GATE = enableRetention("piroboros host", "user-approved review fix: traces were never rotated; keep 90 days or the 500 newest");
|
|
17
|
+
export function openFoundations(store, paths, warn = () => { }) {
|
|
18
|
+
// Housekeeping must not stop startup: a traces path that is a file, an unreadable folder or a failed delete is reported and skipped.
|
|
19
|
+
try {
|
|
20
|
+
const { failed } = applyTraceRotation(planTraceRotation({ root: paths.traceRoot }), TRACE_ROTATION_GATE);
|
|
21
|
+
if (failed.length > 0)
|
|
22
|
+
warn(`trace rotation could not remove ${failed.length} file(s): ${failed[0].error}`);
|
|
23
|
+
}
|
|
24
|
+
catch (error) {
|
|
25
|
+
warn(`trace rotation skipped: ${error instanceof Error ? error.message : String(error)}`);
|
|
26
|
+
}
|
|
27
|
+
return {
|
|
28
|
+
...paths,
|
|
29
|
+
adapters: [createAkashicMemoriesAdapter({ api: createMemoryApi(store) })],
|
|
30
|
+
scan: validateMemorySafety,
|
|
31
|
+
tokenize: tokenizeSearch,
|
|
32
|
+
redact: redactSensitive,
|
|
33
|
+
};
|
|
34
|
+
}
|