@vortex-os/ontos 0.1.0 → 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/README.md +32 -17
- package/dist/actions/index.d.ts +28 -1
- package/dist/actions/index.d.ts.map +1 -1
- package/dist/actions/index.js +12 -0
- package/dist/actions/index.js.map +1 -1
- package/dist/enrich/domain-range.d.ts +25 -0
- package/dist/enrich/domain-range.d.ts.map +1 -0
- package/dist/enrich/domain-range.js +60 -0
- package/dist/enrich/domain-range.js.map +1 -0
- package/dist/enrich/index.d.ts +50 -0
- package/dist/enrich/index.d.ts.map +1 -0
- package/dist/enrich/index.js +67 -0
- package/dist/enrich/index.js.map +1 -0
- package/dist/enrich/tier.d.ts +27 -0
- package/dist/enrich/tier.d.ts.map +1 -0
- package/dist/enrich/tier.js +38 -0
- package/dist/enrich/tier.js.map +1 -0
- package/dist/enrich/types.d.ts +101 -0
- package/dist/enrich/types.d.ts.map +1 -0
- package/dist/enrich/types.js +11 -0
- package/dist/enrich/types.js.map +1 -0
- package/dist/enrich/validate.d.ts +32 -0
- package/dist/enrich/validate.d.ts.map +1 -0
- package/dist/enrich/validate.js +104 -0
- package/dist/enrich/validate.js.map +1 -0
- package/dist/extract/deterministic.d.ts.map +1 -1
- package/dist/extract/deterministic.js +20 -0
- package/dist/extract/deterministic.js.map +1 -1
- package/dist/extract/types.d.ts +1 -1
- package/dist/extract/types.d.ts.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/sqlite/index.d.ts +1 -1
- package/dist/sqlite/index.d.ts.map +1 -1
- package/dist/sqlite/schema.d.ts +1 -1
- package/dist/sqlite/schema.d.ts.map +1 -1
- package/dist/sqlite/schema.js +38 -0
- package/dist/sqlite/schema.js.map +1 -1
- package/dist/sqlite/store.d.ts +70 -1
- package/dist/sqlite/store.d.ts.map +1 -1
- package/dist/sqlite/store.js +244 -1
- package/dist/sqlite/store.js.map +1 -1
- package/dist/writeback.d.ts +60 -0
- package/dist/writeback.d.ts.map +1 -0
- package/dist/writeback.js +138 -0
- package/dist/writeback.js.map +1 -0
- package/package.json +4 -2
- package/scripts/enrich-ontos.mjs +182 -0
- package/scripts/rebuild-ontos.mjs +1 -0
package/dist/sqlite/store.js
CHANGED
|
@@ -3,6 +3,28 @@ import { mkdirSync } from "node:fs";
|
|
|
3
3
|
import { dirname } from "node:path";
|
|
4
4
|
import Database from "better-sqlite3";
|
|
5
5
|
import { SCHEMA } from "./schema.js";
|
|
6
|
+
import { domainRangeViolated } from "../enrich/domain-range.js";
|
|
7
|
+
function dbToProposal(r) {
|
|
8
|
+
return {
|
|
9
|
+
relId: r.rel_id,
|
|
10
|
+
rel: r.rel,
|
|
11
|
+
sourceId: r.source_id,
|
|
12
|
+
targetId: r.target_id,
|
|
13
|
+
sourceResolved: r.source_resolved === 1,
|
|
14
|
+
targetResolved: r.target_resolved === 1,
|
|
15
|
+
trust: r.trust,
|
|
16
|
+
trustRank: r.trust_rank,
|
|
17
|
+
verifiedBy: r.verified_by,
|
|
18
|
+
confidence: r.confidence,
|
|
19
|
+
evidencePath: r.evidence_path ?? "",
|
|
20
|
+
evidenceSpan: r.evidence_span,
|
|
21
|
+
sourceRecordHash: r.source_record_hash,
|
|
22
|
+
proposedAt: r.proposed_at,
|
|
23
|
+
confirmed: r.confirmed,
|
|
24
|
+
rejectedAt: r.rejected_at,
|
|
25
|
+
askedAt: r.asked_at,
|
|
26
|
+
};
|
|
27
|
+
}
|
|
6
28
|
/**
|
|
7
29
|
* §5-bis relation-id recipe. Stable over the (source, relation, target) triple,
|
|
8
30
|
* so re-accepting the same relation is idempotent (never duplicates).
|
|
@@ -40,6 +62,24 @@ export class OntosStore {
|
|
|
40
62
|
this.db.pragma("journal_mode = WAL");
|
|
41
63
|
this.db.pragma("foreign_keys = ON");
|
|
42
64
|
this.db.exec(SCHEMA);
|
|
65
|
+
this.migrate();
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Additive column migration: `CREATE TABLE IF NOT EXISTS` does NOT add new
|
|
69
|
+
* columns to a table that already exists from an earlier schema, so an index
|
|
70
|
+
* built by a prior 0.2.0-dev build would lack newer columns and crash on query.
|
|
71
|
+
* Add any missing column here (the index is regenerable, so additive-only is
|
|
72
|
+
* enough — no data backfill). Idempotent.
|
|
73
|
+
*/
|
|
74
|
+
migrate() {
|
|
75
|
+
const cols = (table) => new Set(this.db.prepare(`PRAGMA table_info(${table})`).all().map((r) => r.name));
|
|
76
|
+
const ensure = (table, column, decl) => {
|
|
77
|
+
if (!cols(table).has(column)) {
|
|
78
|
+
this.db.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${decl}`);
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
ensure("relation_proposals", "rejected_at", "TEXT");
|
|
82
|
+
ensure("relation_proposals", "asked_at", "TEXT");
|
|
43
83
|
}
|
|
44
84
|
close() {
|
|
45
85
|
this.db.close();
|
|
@@ -72,8 +112,18 @@ export class OntosStore {
|
|
|
72
112
|
source: obj.source ?? null,
|
|
73
113
|
});
|
|
74
114
|
}
|
|
75
|
-
/**
|
|
115
|
+
/**
|
|
116
|
+
* Idempotent on relId (§5-bis): re-accepting the same relation updates, never
|
|
117
|
+
* duplicates. SAFETY GUARD (0.2.0): an UNCONFIRMED `llm` relation must never
|
|
118
|
+
* enter the trusted graph — LLM output lives in `relation_proposals` until a
|
|
119
|
+
* human confirms it (a confirmed llm relation, with a `confirmed` date, is the
|
|
120
|
+
* promotion path and is allowed). This makes "proposals never influence
|
|
121
|
+
* why()/guard" structural, not caller-dependent (Codex review 2026-06-18).
|
|
122
|
+
*/
|
|
76
123
|
upsertRelation(rel) {
|
|
124
|
+
if (rel.provenance === "llm" && !rel.confirmed) {
|
|
125
|
+
throw new Error(`refusing to write an unconfirmed llm relation into the trusted graph (${rel.relId}); use upsertProposal — confirm to promote`);
|
|
126
|
+
}
|
|
77
127
|
this.db
|
|
78
128
|
.prepare(`INSERT INTO relations (rel_id, rel, source_id, target_id, provenance, confidence, confirmed, evidence)
|
|
79
129
|
VALUES (@relId, @rel, @sourceId, @targetId, @provenance, @confidence, @confirmed, @evidence)
|
|
@@ -119,6 +169,19 @@ export class OntosStore {
|
|
|
119
169
|
source: row.source,
|
|
120
170
|
};
|
|
121
171
|
}
|
|
172
|
+
/** Index health snapshot (for `vortex ontos check` / the session-start ambient line). */
|
|
173
|
+
counts() {
|
|
174
|
+
const n = (sql) => this.db.prepare(sql).get().n;
|
|
175
|
+
return {
|
|
176
|
+
objects: n("SELECT COUNT(*) n FROM objects"),
|
|
177
|
+
relations: n("SELECT COUNT(*) n FROM relations"),
|
|
178
|
+
proposals: n("SELECT COUNT(*) n FROM relation_proposals WHERE confirmed IS NULL AND rejected_at IS NULL"),
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
/** All canonical object ids (for the enrichment request's knownObjectIds — reuse, don't invent). */
|
|
182
|
+
allObjectIds() {
|
|
183
|
+
return this.db.prepare(`SELECT id FROM objects ORDER BY id`).all().map((r) => r.id);
|
|
184
|
+
}
|
|
122
185
|
/** Outgoing relations from an object, optionally filtered by relation type. */
|
|
123
186
|
neighbors(id, rels) {
|
|
124
187
|
const rows = (rels && rels.length
|
|
@@ -158,6 +221,186 @@ export class OntosStore {
|
|
|
158
221
|
path: r.path.split("\n").filter(Boolean),
|
|
159
222
|
}));
|
|
160
223
|
}
|
|
224
|
+
/** Provenance of a relation in the TRUSTED graph, or null if absent (tier HIGH check). */
|
|
225
|
+
relationProvenance(relId) {
|
|
226
|
+
const row = this.db.prepare(`SELECT provenance FROM relations WHERE rel_id = ?`).get(relId);
|
|
227
|
+
return row ? row.provenance : null;
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Store an LLM enrichment proposal (0.2.0) — into `relation_proposals`, NEVER
|
|
231
|
+
* into the trusted `relations` graph. Idempotent on relId AND monotonic: a
|
|
232
|
+
* re-proposal upgrades trust (e.g. self LOW → cross-model MEDIUM) but never
|
|
233
|
+
* downgrades it. Returns "inserted" | "upgraded" | "kept".
|
|
234
|
+
*/
|
|
235
|
+
upsertProposal(p) {
|
|
236
|
+
const before = this.getProposal(p.relId);
|
|
237
|
+
this.db
|
|
238
|
+
.prepare(`INSERT INTO relation_proposals
|
|
239
|
+
(rel_id, rel, source_id, target_id, source_resolved, target_resolved,
|
|
240
|
+
trust, trust_rank, verified_by, confidence, evidence_path, evidence_span,
|
|
241
|
+
source_record_hash, proposed_at, confirmed)
|
|
242
|
+
VALUES
|
|
243
|
+
(@relId, @rel, @sourceId, @targetId, @sourceResolved, @targetResolved,
|
|
244
|
+
@trust, @trustRank, @verifiedBy, @confidence, @evidencePath, @evidenceSpan,
|
|
245
|
+
@sourceRecordHash, @proposedAt, @confirmed)
|
|
246
|
+
ON CONFLICT(rel_id) DO UPDATE SET
|
|
247
|
+
trust = excluded.trust, trust_rank = excluded.trust_rank,
|
|
248
|
+
verified_by = excluded.verified_by, confidence = excluded.confidence,
|
|
249
|
+
source_resolved = excluded.source_resolved, target_resolved = excluded.target_resolved,
|
|
250
|
+
evidence_path = excluded.evidence_path, evidence_span = excluded.evidence_span,
|
|
251
|
+
source_record_hash = excluded.source_record_hash, proposed_at = excluded.proposed_at
|
|
252
|
+
WHERE excluded.trust_rank >= relation_proposals.trust_rank`)
|
|
253
|
+
.run({
|
|
254
|
+
relId: p.relId,
|
|
255
|
+
rel: p.rel,
|
|
256
|
+
sourceId: p.sourceId,
|
|
257
|
+
targetId: p.targetId,
|
|
258
|
+
sourceResolved: p.sourceResolved ? 1 : 0,
|
|
259
|
+
targetResolved: p.targetResolved ? 1 : 0,
|
|
260
|
+
trust: p.trust,
|
|
261
|
+
trustRank: p.trustRank,
|
|
262
|
+
verifiedBy: p.verifiedBy,
|
|
263
|
+
confidence: p.confidence,
|
|
264
|
+
evidencePath: p.evidencePath ?? null,
|
|
265
|
+
evidenceSpan: p.evidenceSpan ?? null,
|
|
266
|
+
sourceRecordHash: p.sourceRecordHash ?? null,
|
|
267
|
+
proposedAt: p.proposedAt ?? null,
|
|
268
|
+
confirmed: p.confirmed ?? null,
|
|
269
|
+
});
|
|
270
|
+
if (!before)
|
|
271
|
+
return "inserted";
|
|
272
|
+
if (p.trustRank > before.trustRank)
|
|
273
|
+
return "upgraded"; // higher trust replaced the old row
|
|
274
|
+
if (p.trustRank === before.trustRank)
|
|
275
|
+
return "refreshed"; // same trust: confidence/evidence updated
|
|
276
|
+
return "kept"; // lower trust: ON CONFLICT WHERE blocked the write, row unchanged
|
|
277
|
+
}
|
|
278
|
+
getProposal(relId) {
|
|
279
|
+
const r = this.db
|
|
280
|
+
.prepare(`SELECT * FROM relation_proposals WHERE rel_id = ?`)
|
|
281
|
+
.get(relId);
|
|
282
|
+
return r ? dbToProposal(r) : null;
|
|
283
|
+
}
|
|
284
|
+
/** Proposals at or above a minimum trust rank (default all), highest trust first. */
|
|
285
|
+
listProposals(minRank = 0) {
|
|
286
|
+
const rows = this.db
|
|
287
|
+
.prepare(`SELECT * FROM relation_proposals WHERE trust_rank >= ? ORDER BY trust_rank DESC, rel_id`)
|
|
288
|
+
.all(minRank);
|
|
289
|
+
return rows.map(dbToProposal);
|
|
290
|
+
}
|
|
291
|
+
/** Drop all proposals (the deliberate `enrich --rebuild`; NOT the deterministic rebuild). */
|
|
292
|
+
clearProposals() {
|
|
293
|
+
this.db.exec("DELETE FROM relation_proposals;");
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* Unconfirmed, un-rejected proposals touching an object — the "possible (unverified)"
|
|
297
|
+
* hint surface for the actions to weave in. Confirmed proposals are already trusted
|
|
298
|
+
* edges in `relations`; rejected ones are suppressed. Highest trust first.
|
|
299
|
+
*/
|
|
300
|
+
proposalsFor(objectId) {
|
|
301
|
+
const rows = this.db
|
|
302
|
+
.prepare(`SELECT * FROM relation_proposals
|
|
303
|
+
WHERE (source_id = ? OR target_id = ?) AND confirmed IS NULL AND rejected_at IS NULL
|
|
304
|
+
ORDER BY trust_rank DESC, rel_id`)
|
|
305
|
+
.all(objectId, objectId);
|
|
306
|
+
return rows.map(dbToProposal);
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* Promote a proposal into the TRUSTED graph — the in-context "yes, that's right"
|
|
310
|
+
* (NOT a batch curation chore). Writes the relation with provenance="llm" + a
|
|
311
|
+
* `confirmed` date (the upsertRelation guard allows a CONFIRMED llm relation), and
|
|
312
|
+
* marks the proposal confirmed. Refuses unless BOTH endpoints already exist as
|
|
313
|
+
* objects (you can only confirm a link between known things). Returns true on promote.
|
|
314
|
+
*/
|
|
315
|
+
confirmProposal(relId, date) {
|
|
316
|
+
const p = this.getProposal(relId);
|
|
317
|
+
if (!p || p.confirmed || p.rejectedAt)
|
|
318
|
+
return false;
|
|
319
|
+
const src = this.getObject(p.sourceId);
|
|
320
|
+
const tgt = this.getObject(p.targetId);
|
|
321
|
+
if (!src || !tgt)
|
|
322
|
+
return false; // unresolved ends — can't promote a link between unknown things
|
|
323
|
+
// Re-check domain/range against the objects' STORED types (not the id prefix):
|
|
324
|
+
// upsertObject does not enforce prefix==type, so a mismatched/corrupt object
|
|
325
|
+
// must not let a wrong-type relation into the trusted graph at promote time
|
|
326
|
+
// (Codex review — the id-prefix invariant is conventional, not enforced).
|
|
327
|
+
if (domainRangeViolated(p.rel, src.type, tgt.type))
|
|
328
|
+
return false;
|
|
329
|
+
this.transaction(() => {
|
|
330
|
+
// Never overwrite a relation already in the trusted graph — a deterministic
|
|
331
|
+
// (or already-confirmed) edge for this triple stays as-is; converting it to
|
|
332
|
+
// provenance="llm" would corrupt it and break HIGH detection (Codex review).
|
|
333
|
+
// The trusted edge already exists, so confirmation just records the proposal.
|
|
334
|
+
if (this.relationProvenance(p.relId) === null) {
|
|
335
|
+
this.upsertRelation({
|
|
336
|
+
relId: p.relId,
|
|
337
|
+
rel: p.rel,
|
|
338
|
+
sourceId: p.sourceId,
|
|
339
|
+
targetId: p.targetId,
|
|
340
|
+
provenance: "llm",
|
|
341
|
+
confidence: p.confidence,
|
|
342
|
+
confirmed: date,
|
|
343
|
+
evidence: p.evidencePath || null,
|
|
344
|
+
});
|
|
345
|
+
}
|
|
346
|
+
this.db.prepare(`UPDATE relation_proposals SET confirmed = ? WHERE rel_id = ?`).run(date, relId);
|
|
347
|
+
});
|
|
348
|
+
return true;
|
|
349
|
+
}
|
|
350
|
+
/** Reject a proposal (sticky): it is never promoted, surfaced as a hint, or re-asked. */
|
|
351
|
+
rejectProposal(relId, date) {
|
|
352
|
+
const r = this.db
|
|
353
|
+
.prepare(`UPDATE relation_proposals SET rejected_at = ? WHERE rel_id = ? AND confirmed IS NULL`)
|
|
354
|
+
.run(date, relId);
|
|
355
|
+
return r.changes > 0;
|
|
356
|
+
}
|
|
357
|
+
/** Stamp that a proposal was just surfaced as an in-context question (re-ask cooldown). */
|
|
358
|
+
markAsked(relId, date) {
|
|
359
|
+
this.db.prepare(`UPDATE relation_proposals SET asked_at = ? WHERE rel_id = ?`).run(date, relId);
|
|
360
|
+
}
|
|
361
|
+
// ---- GC / reconcile (the documented orphan cleanup) ----
|
|
362
|
+
// The store can't read the filesystem (it's pure sqlite); the caller (the
|
|
363
|
+
// `enrich-ontos --gc` walk) decides which record paths are dead (no longer on
|
|
364
|
+
// disk) and passes them here. We only ever drop UNCONFIRMED, UN-rejected
|
|
365
|
+
// proposals: a confirmed proposal was promoted into the trusted graph and a
|
|
366
|
+
// rejected one is a human decision — both are kept.
|
|
367
|
+
/** All record paths that have an enrichment_state row (for the GC liveness check). */
|
|
368
|
+
allEnrichmentPaths() {
|
|
369
|
+
return this.db.prepare(`SELECT record_path FROM enrichment_state`).all().map((r) => r.record_path);
|
|
370
|
+
}
|
|
371
|
+
/** Drop the enrichment_state row for a vanished record (so it re-enriches if it returns). */
|
|
372
|
+
deleteEnrichmentState(recordPath) {
|
|
373
|
+
return this.db.prepare(`DELETE FROM enrichment_state WHERE record_path = ?`).run(recordPath).changes > 0;
|
|
374
|
+
}
|
|
375
|
+
/** Distinct evidence_path values across UNCONFIRMED, UN-rejected proposals (GC candidates). */
|
|
376
|
+
pendingProposalEvidencePaths() {
|
|
377
|
+
return this.db
|
|
378
|
+
.prepare(`SELECT DISTINCT evidence_path FROM relation_proposals
|
|
379
|
+
WHERE confirmed IS NULL AND rejected_at IS NULL AND evidence_path IS NOT NULL`)
|
|
380
|
+
.all().map((r) => r.evidence_path);
|
|
381
|
+
}
|
|
382
|
+
/** Drop UNCONFIRMED, UN-rejected proposals whose evidence record vanished. Returns count dropped. */
|
|
383
|
+
dropPendingProposalsByEvidence(evidencePath) {
|
|
384
|
+
return this.db
|
|
385
|
+
.prepare(`DELETE FROM relation_proposals
|
|
386
|
+
WHERE evidence_path = ? AND confirmed IS NULL AND rejected_at IS NULL`)
|
|
387
|
+
.run(evidencePath).changes;
|
|
388
|
+
}
|
|
389
|
+
/** Change detection: the extraction hash last enriched for a record, or null. */
|
|
390
|
+
getExtractionHash(recordPath) {
|
|
391
|
+
const row = this.db
|
|
392
|
+
.prepare(`SELECT extraction_hash FROM enrichment_state WHERE record_path = ?`)
|
|
393
|
+
.get(recordPath);
|
|
394
|
+
return row ? row.extraction_hash : null;
|
|
395
|
+
}
|
|
396
|
+
setExtractionState(recordPath, extractionHash, enrichedAt) {
|
|
397
|
+
this.db
|
|
398
|
+
.prepare(`INSERT INTO enrichment_state (record_path, extraction_hash, enriched_at)
|
|
399
|
+
VALUES (?, ?, ?)
|
|
400
|
+
ON CONFLICT(record_path) DO UPDATE SET
|
|
401
|
+
extraction_hash = excluded.extraction_hash, enriched_at = excluded.enriched_at`)
|
|
402
|
+
.run(recordPath, extractionHash, enrichedAt ?? null);
|
|
403
|
+
}
|
|
161
404
|
/** §5A helper: how many failures recur as (share a pattern with) this one. */
|
|
162
405
|
recurrenceCount(problemId) {
|
|
163
406
|
const row = this.db
|
package/dist/sqlite/store.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"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;+EACuE,CACxE;aACA,GAAG,CAAC,YAAY,CAAC,CAAC,OAAO,CAAC;IAC/B,CAAC;IAED,iFAAiF;IACjF,iBAAiB,CAAC,UAAkB;QAClC,MAAM,GAAG,GAAG,IAAI,CAAC,EAAE;aAChB,OAAO,CAAC,oEAAoE,CAAC;aAC7E,GAAG,CAAC,UAAU,CAA4C,CAAC;QAC9D,OAAO,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC,CAAC,IAAI,CAAC;IAC1C,CAAC;IAED,kBAAkB,CAAC,UAAkB,EAAE,cAAsB,EAAE,UAA0B;QACvF,IAAI,CAAC,EAAE;aACJ,OAAO,CACN;;;0FAGkF,CACnF;aACA,GAAG,CAAC,UAAU,EAAE,cAAc,EAAE,UAAU,IAAI,IAAI,CAAC,CAAC;IACzD,CAAC;IAED,8EAA8E;IAC9E,eAAe,CAAC,SAAiB;QAC/B,MAAM,GAAG,GAAG,IAAI,CAAC,EAAE;aAChB,OAAO,CACN,kGAAkG,CACnG;aACA,GAAG,CAAC,SAAS,EAAE,SAAS,CAAkB,CAAC;QAC9C,OAAO,GAAG,CAAC,CAAC,CAAC;IACf,CAAC;CACF"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* §5-bis frontmatter writeback — persist a CONFIRMED relation into the source
|
|
3
|
+
* record's dedicated `ontos:` frontmatter block, so confirmed knowledge survives
|
|
4
|
+
* cross-machine via git (the index is machine-local).
|
|
5
|
+
*
|
|
6
|
+
* SAFETY (why this was deferred — these are the USER's files):
|
|
7
|
+
* - only CONFIRMED relations reach here;
|
|
8
|
+
* - we edit ONLY the `ontos:` key, via `yaml.parseDocument` (a format/comment-
|
|
9
|
+
* preserving round-trip) — NOT regex splicing, which mis-handles column-0 YAML
|
|
10
|
+
* lists and can corrupt frontmatter (Codex review);
|
|
11
|
+
* - if the frontmatter does not parse, or `ontos:` already exists as something
|
|
12
|
+
* that is NOT our list of {relId,…} entries (a user's own key), we ABORT and
|
|
13
|
+
* touch nothing — never destroy user data on a collision/malformed file;
|
|
14
|
+
* - idempotent by relId; the file's CRLF/LF style is preserved; atomic write.
|
|
15
|
+
*/
|
|
16
|
+
import type { RelationType } from "./types.js";
|
|
17
|
+
import type { OntosStore } from "./sqlite/store.js";
|
|
18
|
+
/** One confirmed relation to persist (the §5-bis entry shape). */
|
|
19
|
+
export interface WritebackEntry {
|
|
20
|
+
readonly rel: RelationType;
|
|
21
|
+
readonly target: string;
|
|
22
|
+
readonly relId: string;
|
|
23
|
+
readonly source: "deterministic" | "llm" | "wikilink-promoted";
|
|
24
|
+
readonly confidence: number;
|
|
25
|
+
readonly confirmed: string;
|
|
26
|
+
}
|
|
27
|
+
export type WritebackStatus = "added" | "present" | "created-frontmatter" | "skipped-unparseable" | "skipped-ontos-collision";
|
|
28
|
+
/**
|
|
29
|
+
* Add (idempotently) a confirmed relation to a record's `ontos:` block. Pure: takes
|
|
30
|
+
* the file text, returns the new text + what happened. Uses parseDocument so user
|
|
31
|
+
* keys, comments, and formatting round-trip; aborts (touches nothing) on a
|
|
32
|
+
* malformed frontmatter or an `ontos:` key that is not ours.
|
|
33
|
+
*/
|
|
34
|
+
export declare function writebackRelation(fileText: string, entry: WritebackEntry): {
|
|
35
|
+
text: string;
|
|
36
|
+
status: WritebackStatus;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Atomic fs wrapper: read → transform → write (same-dir temp + rename). Skips the
|
|
40
|
+
* write when nothing changed (present / skipped-*). Returns the status.
|
|
41
|
+
*/
|
|
42
|
+
export declare function writebackToFile(path: string, entry: WritebackEntry): WritebackStatus;
|
|
43
|
+
export interface ConfirmWritebackResult {
|
|
44
|
+
readonly confirmed: boolean;
|
|
45
|
+
readonly writeback: WritebackStatus | "skipped-no-record" | "skipped-out-of-scope" | "error" | null;
|
|
46
|
+
readonly recordPath: string | null;
|
|
47
|
+
readonly message?: string;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Confirm a proposal AND persist it to the source record's `ontos:` block (the
|
|
51
|
+
* user's chosen auto-on-confirm). The store confirm is the durable step; the file
|
|
52
|
+
* writeback is best-effort — a missing/unreadable/out-of-scope record never fails
|
|
53
|
+
* the confirm (the relation is still in the index), it is reported instead. Pass
|
|
54
|
+
* `dataRoot` to bound writes under the data dir (defense against a record path that
|
|
55
|
+
* somehow points outside it). The agent calls THIS, not bare confirmProposal.
|
|
56
|
+
*/
|
|
57
|
+
export declare function confirmAndWriteback(store: OntosStore, relId: string, date: string, opts?: {
|
|
58
|
+
readonly dataRoot?: string;
|
|
59
|
+
}): ConfirmWritebackResult;
|
|
60
|
+
//# sourceMappingURL=writeback.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"writeback.d.ts","sourceRoot":"","sources":["../src/writeback.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAMH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAKpD,kEAAkE;AAClE,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,GAAG,EAAE,YAAY,CAAC;IAC3B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,eAAe,GAAG,KAAK,GAAG,mBAAmB,CAAC;IAC/D,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B;AAED,MAAM,MAAM,eAAe,GACvB,OAAO,GACP,SAAS,GACT,qBAAqB,GACrB,qBAAqB,GACrB,yBAAyB,CAAC;AAW9B;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,cAAc,GACpB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,eAAe,CAAA;CAAE,CA0C3C;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,cAAc,GAAG,eAAe,CAepF;AAED,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,SAAS,EAAE,eAAe,GAAG,mBAAmB,GAAG,sBAAsB,GAAG,OAAO,GAAG,IAAI,CAAC;IACpG,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IACnC,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,UAAU,EACjB,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,MAAM,EACZ,IAAI,CAAC,EAAE;IAAE,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,GACpC,sBAAsB,CAgCxB"}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* §5-bis frontmatter writeback — persist a CONFIRMED relation into the source
|
|
3
|
+
* record's dedicated `ontos:` frontmatter block, so confirmed knowledge survives
|
|
4
|
+
* cross-machine via git (the index is machine-local).
|
|
5
|
+
*
|
|
6
|
+
* SAFETY (why this was deferred — these are the USER's files):
|
|
7
|
+
* - only CONFIRMED relations reach here;
|
|
8
|
+
* - we edit ONLY the `ontos:` key, via `yaml.parseDocument` (a format/comment-
|
|
9
|
+
* preserving round-trip) — NOT regex splicing, which mis-handles column-0 YAML
|
|
10
|
+
* lists and can corrupt frontmatter (Codex review);
|
|
11
|
+
* - if the frontmatter does not parse, or `ontos:` already exists as something
|
|
12
|
+
* that is NOT our list of {relId,…} entries (a user's own key), we ABORT and
|
|
13
|
+
* touch nothing — never destroy user data on a collision/malformed file;
|
|
14
|
+
* - idempotent by relId; the file's CRLF/LF style is preserved; atomic write.
|
|
15
|
+
*/
|
|
16
|
+
import { createHash } from "node:crypto";
|
|
17
|
+
import { existsSync, readFileSync, writeFileSync, renameSync } from "node:fs";
|
|
18
|
+
import { resolve, relative, isAbsolute } from "node:path";
|
|
19
|
+
import { parseDocument, Document, isSeq } from "yaml";
|
|
20
|
+
const FENCE = /^(---\r?\n)([\s\S]*?)(\r?\n---\r?\n?)/;
|
|
21
|
+
const BOM = "";
|
|
22
|
+
function entryNode(e) {
|
|
23
|
+
return { rel: e.rel, target: e.target, relId: e.relId, source: e.source, confidence: e.confidence, confirmed: e.confirmed };
|
|
24
|
+
}
|
|
25
|
+
/** Does the existing `ontos` value look like OUR list (a seq of objects carrying relId)? */
|
|
26
|
+
function isOurOntos(value) {
|
|
27
|
+
return Array.isArray(value) && value.every((e) => e && typeof e === "object" && "relId" in e);
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Add (idempotently) a confirmed relation to a record's `ontos:` block. Pure: takes
|
|
31
|
+
* the file text, returns the new text + what happened. Uses parseDocument so user
|
|
32
|
+
* keys, comments, and formatting round-trip; aborts (touches nothing) on a
|
|
33
|
+
* malformed frontmatter or an `ontos:` key that is not ours.
|
|
34
|
+
*/
|
|
35
|
+
export function writebackRelation(fileText, entry) {
|
|
36
|
+
const bom = fileText.startsWith(BOM) ? BOM : "";
|
|
37
|
+
const text = bom ? fileText.slice(BOM.length) : fileText;
|
|
38
|
+
const m = text.match(FENCE);
|
|
39
|
+
if (!m) {
|
|
40
|
+
// An opener with no clean fence match (e.g. empty `---\n---\n`, or a malformed
|
|
41
|
+
// fence) is AMBIGUOUS — adding our own fence would double-fence and corrupt the
|
|
42
|
+
// file. Only synthesize a fence when there is genuinely no leading fence at all.
|
|
43
|
+
if (/^---\r?\n/.test(text)) {
|
|
44
|
+
return { text: fileText, status: "skipped-unparseable" };
|
|
45
|
+
}
|
|
46
|
+
// No frontmatter — synthesize a minimal fence holding only our block.
|
|
47
|
+
const doc = new Document({ ontos: [entryNode(entry)] });
|
|
48
|
+
const block = doc.toString().replace(/\n+$/, "");
|
|
49
|
+
return { text: `${bom}---\n${block}\n---\n${text}`, status: "created-frontmatter" };
|
|
50
|
+
}
|
|
51
|
+
const open = m[1] ?? "---\n";
|
|
52
|
+
const close = m[3] ?? "\n---\n";
|
|
53
|
+
const fmText = m[2] ?? "";
|
|
54
|
+
const body = text.slice(m[0].length);
|
|
55
|
+
const crlf = /\r\n/.test(open) || /\r\n/.test(fmText);
|
|
56
|
+
const doc = parseDocument(fmText);
|
|
57
|
+
if (doc.errors.length > 0) {
|
|
58
|
+
return { text: fileText, status: "skipped-unparseable" }; // never edit a file we can't parse
|
|
59
|
+
}
|
|
60
|
+
const curNode = doc.get("ontos");
|
|
61
|
+
const cur = curNode == null ? undefined : (isSeq(curNode) ? curNode.toJSON() : curNode);
|
|
62
|
+
if (cur !== undefined && !isOurOntos(cur)) {
|
|
63
|
+
return { text: fileText, status: "skipped-ontos-collision" }; // a user's own `ontos:` — don't clobber
|
|
64
|
+
}
|
|
65
|
+
const existing = cur ?? [];
|
|
66
|
+
if (existing.some((e) => e["relId"] === entry.relId)) {
|
|
67
|
+
return { text: fileText, status: "present" }; // idempotent
|
|
68
|
+
}
|
|
69
|
+
doc.set("ontos", [...existing, entryNode(entry)]);
|
|
70
|
+
let newFm = doc.toString().replace(/\n+$/, "");
|
|
71
|
+
if (crlf)
|
|
72
|
+
newFm = newFm.replace(/\r?\n/g, "\r\n"); // keep the file's line-ending style
|
|
73
|
+
return { text: `${bom}${open}${newFm}${close}${body}`, status: "added" };
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Atomic fs wrapper: read → transform → write (same-dir temp + rename). Skips the
|
|
77
|
+
* write when nothing changed (present / skipped-*). Returns the status.
|
|
78
|
+
*/
|
|
79
|
+
export function writebackToFile(path, entry) {
|
|
80
|
+
const before = readFileSync(path, "utf8");
|
|
81
|
+
const { text, status } = writebackRelation(before, entry);
|
|
82
|
+
if (text === before)
|
|
83
|
+
return status; // present / skipped-* — nothing to write
|
|
84
|
+
// Lost-update guard: if the file changed since we read it (a concurrent edit or
|
|
85
|
+
// writeback), abort rather than clobber it. Shrinks the read-transform-write
|
|
86
|
+
// window to the gap between this re-read and the rename (single-agent use makes
|
|
87
|
+
// even that practically nil); full cross-process safety would need a lock.
|
|
88
|
+
if (readFileSync(path, "utf8") !== before) {
|
|
89
|
+
throw new Error("record changed on disk during writeback — aborted to avoid overwriting it");
|
|
90
|
+
}
|
|
91
|
+
const tmp = `${path}.ontos-${createHash("sha1").update(text).digest("hex").slice(0, 8)}.tmp`;
|
|
92
|
+
writeFileSync(tmp, text, "utf8");
|
|
93
|
+
renameSync(tmp, path); // atomic on the same filesystem
|
|
94
|
+
return status;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Confirm a proposal AND persist it to the source record's `ontos:` block (the
|
|
98
|
+
* user's chosen auto-on-confirm). The store confirm is the durable step; the file
|
|
99
|
+
* writeback is best-effort — a missing/unreadable/out-of-scope record never fails
|
|
100
|
+
* the confirm (the relation is still in the index), it is reported instead. Pass
|
|
101
|
+
* `dataRoot` to bound writes under the data dir (defense against a record path that
|
|
102
|
+
* somehow points outside it). The agent calls THIS, not bare confirmProposal.
|
|
103
|
+
*/
|
|
104
|
+
export function confirmAndWriteback(store, relId, date, opts) {
|
|
105
|
+
const p = store.getProposal(relId);
|
|
106
|
+
const ok = store.confirmProposal(relId, date);
|
|
107
|
+
if (!ok || !p) {
|
|
108
|
+
return { confirmed: ok, writeback: null, recordPath: null, message: ok ? "" : "not confirmed (already confirmed/rejected, unresolved ends, or domain/range)" };
|
|
109
|
+
}
|
|
110
|
+
const recordPath = p.evidencePath || null;
|
|
111
|
+
if (!recordPath || !existsSync(recordPath)) {
|
|
112
|
+
return { confirmed: true, writeback: "skipped-no-record", recordPath, message: "confirmed in the index; source record absent — no writeback" };
|
|
113
|
+
}
|
|
114
|
+
if (opts?.dataRoot) {
|
|
115
|
+
// resolve() collapses `..` and normalizes separators, so `<root>/../outside`
|
|
116
|
+
// can't sneak past a lexical prefix check; a `relative` path that starts with
|
|
117
|
+
// `..` (or is absolute, e.g. a different Windows drive) is outside the root.
|
|
118
|
+
const rel = relative(resolve(opts.dataRoot), resolve(recordPath));
|
|
119
|
+
if (rel.startsWith("..") || isAbsolute(rel)) {
|
|
120
|
+
return { confirmed: true, writeback: "skipped-out-of-scope", recordPath, message: "confirmed in the index; record is outside the data dir — no writeback" };
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
try {
|
|
124
|
+
const status = writebackToFile(recordPath, {
|
|
125
|
+
rel: p.rel,
|
|
126
|
+
target: p.targetId,
|
|
127
|
+
relId: p.relId,
|
|
128
|
+
source: "llm",
|
|
129
|
+
confidence: p.confidence,
|
|
130
|
+
confirmed: date,
|
|
131
|
+
});
|
|
132
|
+
return { confirmed: true, writeback: status, recordPath };
|
|
133
|
+
}
|
|
134
|
+
catch (e) {
|
|
135
|
+
return { confirmed: true, writeback: "error", recordPath, message: `confirmed in the index; writeback failed: ${e?.message ?? String(e)}` };
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
//# sourceMappingURL=writeback.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"writeback.js","sourceRoot":"","sources":["../src/writeback.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAC9E,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AAItD,MAAM,KAAK,GAAG,uCAAuC,CAAC;AACtD,MAAM,GAAG,GAAG,GAAG,CAAC;AAmBhB,SAAS,SAAS,CAAC,CA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AAM,GAAG,GAAG,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC;QAClE,IAAI,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;YAC5C,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE,sBAAsB,EAAE,UAAU,EAAE,OAAO,EAAE,uEAAuE,EAAE,CAAC;QAC9J,CAAC;IACH,CAAC;IACD,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,eAAe,CAAC,UAAU,EAAE;YACzC,GAAG,EAAE,CAAC,CAAC,GAAG;YACV,MAAM,EAAE,CAAC,CAAC,QAAQ;YAClB,KAAK,EAAE,CAAC,CAAC,KAAK;YACd,MAAM,EAAE,KAAK;YACb,UAAU,EAAE,CAAC,CAAC,UAAU;YACxB,SAAS,EAAE,IAAI;SAChB,CAAC,CAAC;QACH,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC;IAC5D,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,6CAA8C,CAAW,EAAE,OAAO,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;IACzJ,CAAC;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vortex-os/ontos",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Add-on — a lightweight ontology of your operational world (objects, typed relations, multi-hop traversal) built from VortEX records, layered on @vortex-os/base. Phase 1 is text-first and sqlite-backed; no formal OWL/RDF reasoner.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "vortex-os-project",
|
|
@@ -26,10 +26,12 @@
|
|
|
26
26
|
"files": [
|
|
27
27
|
"dist",
|
|
28
28
|
"scripts/rebuild-ontos.mjs",
|
|
29
|
+
"scripts/enrich-ontos.mjs",
|
|
29
30
|
"README.md"
|
|
30
31
|
],
|
|
31
32
|
"bin": {
|
|
32
|
-
"rebuild-ontos": "scripts/rebuild-ontos.mjs"
|
|
33
|
+
"rebuild-ontos": "scripts/rebuild-ontos.mjs",
|
|
34
|
+
"enrich-ontos": "scripts/enrich-ontos.mjs"
|
|
33
35
|
},
|
|
34
36
|
"scripts": {
|
|
35
37
|
"build": "tsc -p tsconfig.json",
|