daftari 3.7.0 → 3.9.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 +40 -0
- package/README.md +4 -0
- package/dist/access/rbac.d.ts +1 -0
- package/dist/access/rbac.d.ts.map +1 -1
- package/dist/access/rbac.js +8 -0
- package/dist/access/rbac.js.map +1 -1
- package/dist/board/board.d.ts +37 -0
- package/dist/board/board.d.ts.map +1 -0
- package/dist/board/board.js +233 -0
- package/dist/board/board.js.map +1 -0
- package/dist/board/board.test.d.ts +2 -0
- package/dist/board/board.test.d.ts.map +1 -0
- package/dist/board/board.test.js +753 -0
- package/dist/board/board.test.js.map +1 -0
- package/dist/board/dormancy.test.d.ts +2 -0
- package/dist/board/dormancy.test.d.ts.map +1 -0
- package/dist/board/dormancy.test.js +79 -0
- package/dist/board/dormancy.test.js.map +1 -0
- package/dist/board/identity.d.ts +5 -0
- package/dist/board/identity.d.ts.map +1 -0
- package/dist/board/identity.js +146 -0
- package/dist/board/identity.js.map +1 -0
- package/dist/board/identity.test.d.ts +2 -0
- package/dist/board/identity.test.d.ts.map +1 -0
- package/dist/board/identity.test.js +291 -0
- package/dist/board/identity.test.js.map +1 -0
- package/dist/board/ledger.d.ts +41 -0
- package/dist/board/ledger.d.ts.map +1 -0
- package/dist/board/ledger.js +197 -0
- package/dist/board/ledger.js.map +1 -0
- package/dist/board/ledger.test.d.ts +2 -0
- package/dist/board/ledger.test.d.ts.map +1 -0
- package/dist/board/ledger.test.js +873 -0
- package/dist/board/ledger.test.js.map +1 -0
- package/dist/board/principals.d.ts +4 -0
- package/dist/board/principals.d.ts.map +1 -0
- package/dist/board/principals.js +37 -0
- package/dist/board/principals.js.map +1 -0
- package/dist/board/principals.test.d.ts +2 -0
- package/dist/board/principals.test.d.ts.map +1 -0
- package/dist/board/principals.test.js +296 -0
- package/dist/board/principals.test.js.map +1 -0
- package/dist/board/reconcile.d.ts +12 -0
- package/dist/board/reconcile.d.ts.map +1 -0
- package/dist/board/reconcile.js +293 -0
- package/dist/board/reconcile.js.map +1 -0
- package/dist/board/reconcile.test.d.ts +2 -0
- package/dist/board/reconcile.test.d.ts.map +1 -0
- package/dist/board/reconcile.test.js +788 -0
- package/dist/board/reconcile.test.js.map +1 -0
- package/dist/board/sources/index.d.ts +24 -0
- package/dist/board/sources/index.d.ts.map +1 -0
- package/dist/board/sources/index.js +64 -0
- package/dist/board/sources/index.js.map +1 -0
- package/dist/board/sources/lint.d.ts +3 -0
- package/dist/board/sources/lint.d.ts.map +1 -0
- package/dist/board/sources/lint.js +218 -0
- package/dist/board/sources/lint.js.map +1 -0
- package/dist/board/sources/lint.test.d.ts +2 -0
- package/dist/board/sources/lint.test.d.ts.map +1 -0
- package/dist/board/sources/lint.test.js +616 -0
- package/dist/board/sources/lint.test.js.map +1 -0
- package/dist/board/sources/staged.d.ts +3 -0
- package/dist/board/sources/staged.d.ts.map +1 -0
- package/dist/board/sources/staged.js +116 -0
- package/dist/board/sources/staged.js.map +1 -0
- package/dist/board/sources/staged.test.d.ts +2 -0
- package/dist/board/sources/staged.test.d.ts.map +1 -0
- package/dist/board/sources/staged.test.js +418 -0
- package/dist/board/sources/staged.test.js.map +1 -0
- package/dist/board/sources/staleness.d.ts +43 -0
- package/dist/board/sources/staleness.d.ts.map +1 -0
- package/dist/board/sources/staleness.js +346 -0
- package/dist/board/sources/staleness.js.map +1 -0
- package/dist/board/sources/staleness.test.d.ts +2 -0
- package/dist/board/sources/staleness.test.d.ts.map +1 -0
- package/dist/board/sources/staleness.test.js +923 -0
- package/dist/board/sources/staleness.test.js.map +1 -0
- package/dist/board/sources/tension.d.ts +3 -0
- package/dist/board/sources/tension.d.ts.map +1 -0
- package/dist/board/sources/tension.js +152 -0
- package/dist/board/sources/tension.js.map +1 -0
- package/dist/board/sources/tension.test.d.ts +2 -0
- package/dist/board/sources/tension.test.d.ts.map +1 -0
- package/dist/board/sources/tension.test.js +440 -0
- package/dist/board/sources/tension.test.js.map +1 -0
- package/dist/board/sources/tier2.d.ts +17 -0
- package/dist/board/sources/tier2.d.ts.map +1 -0
- package/dist/board/sources/tier2.js +233 -0
- package/dist/board/sources/tier2.js.map +1 -0
- package/dist/board/sources/tier2.test.d.ts +2 -0
- package/dist/board/sources/tier2.test.d.ts.map +1 -0
- package/dist/board/sources/tier2.test.js +480 -0
- package/dist/board/sources/tier2.test.js.map +1 -0
- package/dist/board/types.d.ts +161 -0
- package/dist/board/types.d.ts.map +1 -0
- package/dist/board/types.js +37 -0
- package/dist/board/types.js.map +1 -0
- package/dist/canon/index.d.ts +3 -1
- package/dist/canon/index.d.ts.map +1 -1
- package/dist/canon/index.js +35 -8
- package/dist/canon/index.js.map +1 -1
- package/dist/canon/types.d.ts +3 -0
- package/dist/canon/types.d.ts.map +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +9 -0
- package/dist/cli.js.map +1 -1
- package/dist/consolidate/birth.d.ts +1 -1
- package/dist/consolidate/birth.d.ts.map +1 -1
- package/dist/consolidate/birth.js +22 -0
- package/dist/consolidate/birth.js.map +1 -1
- package/dist/consolidate/edge-write.d.ts +11 -0
- package/dist/consolidate/edge-write.d.ts.map +1 -1
- package/dist/consolidate/edge-write.js +41 -0
- package/dist/consolidate/edge-write.js.map +1 -1
- package/dist/consolidate/index.js +5 -2
- package/dist/consolidate/index.js.map +1 -1
- package/dist/consolidate/revision.d.ts +4 -2
- package/dist/consolidate/revision.d.ts.map +1 -1
- package/dist/consolidate/revision.js +23 -0
- package/dist/consolidate/revision.js.map +1 -1
- package/dist/curation/edge-staleness.d.ts +4 -2
- package/dist/curation/edge-staleness.d.ts.map +1 -1
- package/dist/curation/edge-staleness.js +36 -3
- package/dist/curation/edge-staleness.js.map +1 -1
- package/dist/curation/edges.d.ts +7 -0
- package/dist/curation/edges.d.ts.map +1 -1
- package/dist/curation/edges.js +13 -7
- package/dist/curation/edges.js.map +1 -1
- package/dist/curation/tension-access.d.ts +1 -0
- package/dist/curation/tension-access.d.ts.map +1 -1
- package/dist/curation/tension-access.js +18 -1
- package/dist/curation/tension-access.js.map +1 -1
- package/dist/curation/tension.d.ts +3 -0
- package/dist/curation/tension.d.ts.map +1 -1
- package/dist/curation/tension.js +36 -0
- package/dist/curation/tension.js.map +1 -1
- package/dist/curation/vault-docs.d.ts +1 -0
- package/dist/curation/vault-docs.d.ts.map +1 -1
- package/dist/curation/vault-docs.js +1 -0
- package/dist/curation/vault-docs.js.map +1 -1
- package/dist/distill/cli.d.ts.map +1 -1
- package/dist/distill/cli.js +6 -0
- package/dist/distill/cli.js.map +1 -1
- package/dist/distill/cost.d.ts +6 -0
- package/dist/distill/cost.d.ts.map +1 -1
- package/dist/distill/cost.js +2 -3
- package/dist/distill/cost.js.map +1 -1
- package/dist/distill/extract.d.ts +52 -0
- package/dist/distill/extract.d.ts.map +1 -1
- package/dist/distill/extract.js +24 -2
- package/dist/distill/extract.js.map +1 -1
- package/dist/distill/propose.d.ts +44 -1
- package/dist/distill/propose.d.ts.map +1 -1
- package/dist/distill/propose.js +84 -2
- package/dist/distill/propose.js.map +1 -1
- package/dist/distill/reader-fingerprint.d.ts +69 -0
- package/dist/distill/reader-fingerprint.d.ts.map +1 -0
- package/dist/distill/reader-fingerprint.js +145 -0
- package/dist/distill/reader-fingerprint.js.map +1 -0
- package/dist/distill/receipt-store.d.ts +5 -0
- package/dist/distill/receipt-store.d.ts.map +1 -0
- package/dist/distill/receipt-store.js +24 -0
- package/dist/distill/receipt-store.js.map +1 -0
- package/dist/eval/llm-openrouter.d.ts.map +1 -1
- package/dist/eval/llm-openrouter.js +4 -0
- package/dist/eval/llm-openrouter.js.map +1 -1
- package/dist/eval/llm.d.ts +22 -0
- package/dist/eval/llm.d.ts.map +1 -1
- package/dist/eval/llm.js +94 -24
- package/dist/eval/llm.js.map +1 -1
- package/dist/federation/classification.d.ts.map +1 -1
- package/dist/federation/classification.js +3 -0
- package/dist/federation/classification.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +31 -0
- package/dist/index.js.map +1 -1
- package/dist/search/coverage.d.ts +5 -1
- package/dist/search/coverage.d.ts.map +1 -1
- package/dist/search/coverage.js +47 -15
- package/dist/search/coverage.js.map +1 -1
- package/dist/search/hybrid.d.ts +7 -1
- package/dist/search/hybrid.d.ts.map +1 -1
- package/dist/search/hybrid.js +31 -8
- package/dist/search/hybrid.js.map +1 -1
- package/dist/search/retrieval-metrics.d.ts +5 -0
- package/dist/search/retrieval-metrics.d.ts.map +1 -0
- package/dist/search/retrieval-metrics.js +60 -0
- package/dist/search/retrieval-metrics.js.map +1 -0
- package/dist/search/suppression.d.ts +9 -0
- package/dist/search/suppression.d.ts.map +1 -0
- package/dist/search/suppression.js +107 -0
- package/dist/search/suppression.js.map +1 -0
- package/dist/serve/index.d.ts +11 -0
- package/dist/serve/index.d.ts.map +1 -1
- package/dist/serve/index.js +547 -8
- package/dist/serve/index.js.map +1 -1
- package/dist/serve/session.d.ts +9 -0
- package/dist/serve/session.d.ts.map +1 -0
- package/dist/serve/session.js +65 -0
- package/dist/serve/session.js.map +1 -0
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +4 -6
- package/dist/server.js.map +1 -1
- package/dist/tools/board.d.ts +32 -0
- package/dist/tools/board.d.ts.map +1 -0
- package/dist/tools/board.js +615 -0
- package/dist/tools/board.js.map +1 -0
- package/dist/tools/board.test.d.ts +2 -0
- package/dist/tools/board.test.d.ts.map +1 -0
- package/dist/tools/board.test.js +964 -0
- package/dist/tools/board.test.js.map +1 -0
- package/dist/tools/edge-staleness.d.ts.map +1 -1
- package/dist/tools/edge-staleness.js +18 -4
- package/dist/tools/edge-staleness.js.map +1 -1
- package/dist/tools/read.d.ts +2 -0
- package/dist/tools/read.d.ts.map +1 -1
- package/dist/tools/read.js +43 -13
- package/dist/tools/read.js.map +1 -1
- package/dist/tools/search.d.ts.map +1 -1
- package/dist/tools/search.js +79 -17
- package/dist/tools/search.js.map +1 -1
- package/dist/tools/write.d.ts.map +1 -1
- package/dist/tools/write.js +172 -2
- package/dist/tools/write.js.map +1 -1
- package/dist/utils/config.d.ts +24 -0
- package/dist/utils/config.d.ts.map +1 -1
- package/dist/utils/config.js +151 -1
- package/dist/utils/config.js.map +1 -1
- package/dist/version.d.ts +2 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +8 -0
- package/dist/version.js.map +1 -0
- package/dist/view/board-page.d.ts +4 -0
- package/dist/view/board-page.d.ts.map +1 -0
- package/dist/view/board-page.js +339 -0
- package/dist/view/board-page.js.map +1 -0
- package/dist/view/board-page.test.d.ts +2 -0
- package/dist/view/board-page.test.d.ts.map +1 -0
- package/dist/view/board-page.test.js +548 -0
- package/dist/view/board-page.test.js.map +1 -0
- package/dist/view/pages.d.ts.map +1 -1
- package/dist/view/pages.js +13 -2
- package/dist/view/pages.js.map +1 -1
- package/dist/view/render.d.ts.map +1 -1
- package/dist/view/render.js +2 -1
- package/dist/view/render.js.map +1 -1
- package/package.json +2 -2
|
@@ -1,5 +1,30 @@
|
|
|
1
1
|
import type { LlmClient } from "../eval/llm.js";
|
|
2
2
|
import type { Chunk } from "./chunk.js";
|
|
3
|
+
/**
|
|
4
|
+
* Per-claim LLM extraction run metadata (6mf.6). Attached to every claim by
|
|
5
|
+
* the producing chunk's `completeJson` call, so a later bead (f3h) can stamp
|
|
6
|
+
* each emitted belief with the run that compiled it.
|
|
7
|
+
*
|
|
8
|
+
* Optional on ExtractedClaim and every field carries its own source's value —
|
|
9
|
+
* two claims from different chunks may carry different metadata (e.g. one chunk
|
|
10
|
+
* salvaged via retry at temp 0.2, another a clean first-try at 0). Additive and
|
|
11
|
+
* consumed by nothing in this bead: propose.ts only needs to be able to READ
|
|
12
|
+
* it; it does NOT yet write frontmatter from it.
|
|
13
|
+
*/
|
|
14
|
+
export interface ClaimRunMeta {
|
|
15
|
+
/** Model the provider actually served (distinct from requestedModel). */
|
|
16
|
+
servedModel?: string;
|
|
17
|
+
/** Temperature actually sent for the producing call (0.2 iff salvaged via retry). */
|
|
18
|
+
effectiveTemperature?: number;
|
|
19
|
+
/** True iff the producing call went through completeJsonWithRetry's retry branch. */
|
|
20
|
+
viaRetry?: boolean;
|
|
21
|
+
/** The model this run requested (ExtractOpts.model). */
|
|
22
|
+
requestedModel: string;
|
|
23
|
+
/** Number of messages in the producing chunk's window. */
|
|
24
|
+
chunkWindow: number;
|
|
25
|
+
/** The per-call input character cap in effect for this run (ExtractOpts.inCallInputCap). */
|
|
26
|
+
inputCap: number;
|
|
27
|
+
}
|
|
3
28
|
/** One extracted claim, keyed for idempotent upsert (U5). */
|
|
4
29
|
export interface ExtractedClaim {
|
|
5
30
|
/** Stable within-source key: `<chunk anchor>:<statement slug>-<hash8>`. */
|
|
@@ -13,6 +38,13 @@ export interface ExtractedClaim {
|
|
|
13
38
|
proposed_frontmatter: {
|
|
14
39
|
title: string;
|
|
15
40
|
};
|
|
41
|
+
/**
|
|
42
|
+
* Optional per-claim LLM extraction run metadata (6mf.6). Populated by
|
|
43
|
+
* extractClaims from the producing chunk's call; flows unchanged through the
|
|
44
|
+
* upsert join into proposeAllClaims' inputs so a later bead can stamp it.
|
|
45
|
+
* Optional so every existing constructor / mock stays valid.
|
|
46
|
+
*/
|
|
47
|
+
run_meta?: ClaimRunMeta;
|
|
16
48
|
}
|
|
17
49
|
export interface ExtractOutcome {
|
|
18
50
|
claims: ExtractedClaim[];
|
|
@@ -34,6 +66,26 @@ export interface ExtractOpts {
|
|
|
34
66
|
/** Max characters of rendered transcript per call (bounds token spend). */
|
|
35
67
|
inCallInputCap: number;
|
|
36
68
|
}
|
|
69
|
+
export declare const EXTRACT_SYSTEM = "You extract discrete claims from a chat transcript window.\n\nA claim is a decision, commitment, factual statement, or stated preference that\nwould be worth remembering after the conversation ends. Each claim must be a\nsingle self-contained sentence, understandable without the transcript. Ground\nevery claim in what participants actually said \u2014 do not speculate, do not merge\nunrelated points, and return an empty list when the window contains nothing\nworth keeping (greetings, logistics chatter, media placeholders).\n\nParaphrase in your own words by default: a claim is a compiled belief, not a\ntranscript excerpt. Do not copy long verbatim spans from the window. If a short\nexact quote is genuinely necessary, keep it brief and enclose only the quoted\nwords in double quotes.";
|
|
70
|
+
export declare const EXTRACT_SCHEMA: {
|
|
71
|
+
readonly type: "object";
|
|
72
|
+
readonly properties: {
|
|
73
|
+
readonly claims: {
|
|
74
|
+
readonly type: "array";
|
|
75
|
+
readonly items: {
|
|
76
|
+
readonly type: "object";
|
|
77
|
+
readonly properties: {
|
|
78
|
+
readonly statement: {
|
|
79
|
+
readonly type: "string";
|
|
80
|
+
readonly description: "One self-contained claim sentence.";
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
readonly required: readonly ["statement"];
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
};
|
|
87
|
+
readonly required: readonly ["claims"];
|
|
88
|
+
};
|
|
37
89
|
/**
|
|
38
90
|
* Extract claims from `chunks` — one LLM call per chunk, stopping early when
|
|
39
91
|
* `maxClaims` is reached or the call budget is exhausted. `llm` should be the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extract.d.ts","sourceRoot":"","sources":["../../src/distill/extract.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEhD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAIxC,6DAA6D;AAC7D,MAAM,WAAW,cAAc;IAC7B,2EAA2E;IAC3E,SAAS,EAAE,MAAM,CAAC;IAClB,sDAAsD;IACtD,SAAS,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,oBAAoB,EAAE;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"extract.d.ts","sourceRoot":"","sources":["../../src/distill/extract.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEhD,OAAO,KAAK,EAAE,KAAK,EAAE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KAAK,EAAE,EACf,GAAG,EAAE,SAAS,EACd,IAAI,EAAE,WAAW,GAChB,OAAO,CAAC,cAAc,CAAC,CAoEzB"}
|
package/dist/distill/extract.js
CHANGED
|
@@ -14,7 +14,10 @@
|
|
|
14
14
|
import { isBudgetExhaustedError } from "../consolidate/call-budget.js";
|
|
15
15
|
import { sha256Hex } from "../utils/hash.js";
|
|
16
16
|
// --- prompt ------------------------------------------------------------------
|
|
17
|
-
|
|
17
|
+
// Exported so the reader-provenance fingerprint (src/distill/reader-fingerprint.ts)
|
|
18
|
+
// can hash the EFFECTIVE extraction prompt contract — a change to this system
|
|
19
|
+
// text revs reader_prompt_version. Do not inline this back to a bare const.
|
|
20
|
+
export const EXTRACT_SYSTEM = `You extract discrete claims from a chat transcript window.
|
|
18
21
|
|
|
19
22
|
A claim is a decision, commitment, factual statement, or stated preference that
|
|
20
23
|
would be worth remembering after the conversation ends. Each claim must be a
|
|
@@ -27,7 +30,12 @@ Paraphrase in your own words by default: a claim is a compiled belief, not a
|
|
|
27
30
|
transcript excerpt. Do not copy long verbatim spans from the window. If a short
|
|
28
31
|
exact quote is genuinely necessary, keep it brief and enclose only the quoted
|
|
29
32
|
words in double quotes.`;
|
|
30
|
-
|
|
33
|
+
// Exported alongside EXTRACT_SYSTEM: this schema object is what llm.ts's
|
|
34
|
+
// completeJsonWithRetry injects verbatim into the system prompt
|
|
35
|
+
// (`Return JSON matching:\n${JSON.stringify(opts.schema, null, 2)}`), so it is
|
|
36
|
+
// part of the effective prompt contract the reader fingerprint hashes. A schema
|
|
37
|
+
// change here revs reader_prompt_version.
|
|
38
|
+
export const EXTRACT_SCHEMA = {
|
|
31
39
|
type: "object",
|
|
32
40
|
properties: {
|
|
33
41
|
claims: {
|
|
@@ -134,6 +142,19 @@ export async function extractClaims(chunks, llm, opts) {
|
|
|
134
142
|
});
|
|
135
143
|
continue;
|
|
136
144
|
}
|
|
145
|
+
// 6mf.6: capture the producing call's run metadata once per chunk and
|
|
146
|
+
// attach it to every claim this chunk produced. servedModel /
|
|
147
|
+
// effectiveTemperature / viaRetry come off the CompleteJsonResult (undefined
|
|
148
|
+
// on mocks that don't set them); requestedModel / chunkWindow / inputCap are
|
|
149
|
+
// the run's own knobs.
|
|
150
|
+
const runMeta = {
|
|
151
|
+
servedModel: res.value.servedModel,
|
|
152
|
+
effectiveTemperature: res.value.effectiveTemperature,
|
|
153
|
+
viaRetry: res.value.viaRetry,
|
|
154
|
+
requestedModel: opts.model,
|
|
155
|
+
chunkWindow: chunk.endIndex - chunk.startIndex + 1,
|
|
156
|
+
inputCap: opts.inCallInputCap,
|
|
157
|
+
};
|
|
137
158
|
for (const statement of statements) {
|
|
138
159
|
if (claims.length >= opts.maxClaims)
|
|
139
160
|
break;
|
|
@@ -145,6 +166,7 @@ export async function extractClaims(chunks, llm, opts) {
|
|
|
145
166
|
claim_key: key,
|
|
146
167
|
statement,
|
|
147
168
|
proposed_frontmatter: { title: titleOf(statement) },
|
|
169
|
+
run_meta: runMeta,
|
|
148
170
|
});
|
|
149
171
|
}
|
|
150
172
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extract.js","sourceRoot":"","sources":["../../src/distill/extract.ts"],"names":[],"mappings":"AAAA,yBAAyB;AACzB,EAAE;AACF,uEAAuE;AACvE,4EAA4E;AAC5E,yEAAyE;AACzE,4EAA4E;AAC5E,oEAAoE;AACpE,qDAAqD;AACrD,EAAE;AACF,wEAAwE;AACxE,4EAA4E;AAC5E,4EAA4E;AAC5E,4DAA4D;AAE5D,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AAEvE,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"extract.js","sourceRoot":"","sources":["../../src/distill/extract.ts"],"names":[],"mappings":"AAAA,yBAAyB;AACzB,EAAE;AACF,uEAAuE;AACvE,4EAA4E;AAC5E,yEAAyE;AACzE,4EAA4E;AAC5E,oEAAoE;AACp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EAAE,KAAK,EAAE,OAAO,CAAC,SAAS,CAAC,EAAE;gBACnD,QAAQ,EAAE,OAAO;aAClB,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAE,eAAe,EAAE,QAAQ,EAAE,WAAW,EAAE,CAAC;AAC9E,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { AccessContext } from "../access/rbac.js";
|
|
2
2
|
import { type StageOutcome } from "../curation/staged-actions.js";
|
|
3
|
-
import type { ExtractedClaim } from "./extract.js";
|
|
3
|
+
import type { ClaimRunMeta, ExtractedClaim } from "./extract.js";
|
|
4
|
+
import { type LineageOp } from "./reader-fingerprint.js";
|
|
4
5
|
/** Target collection for all distill proposals. */
|
|
5
6
|
export declare const DISTILL_COLLECTION = "distill";
|
|
6
7
|
/** The proposing agent identity, recorded on every proposal. */
|
|
@@ -88,6 +89,48 @@ export interface ProposeOutcome {
|
|
|
88
89
|
error: string;
|
|
89
90
|
}>;
|
|
90
91
|
}
|
|
92
|
+
/**
|
|
93
|
+
* The reader_* frontmatter fields stamped from a claim's run_meta. Every field
|
|
94
|
+
* is a DECLARED-OPTIONAL schema extension (see docs/schema-extensions.md); the
|
|
95
|
+
* fields land typed in a vault whose config declares them, untyped-but-preserved
|
|
96
|
+
* otherwise, and never block a write (optional, advisory).
|
|
97
|
+
*
|
|
98
|
+
* null is never written for any field — a null on a declared extension DELETES
|
|
99
|
+
* it (serializeDocument treats null as absent). So a value that would be null is
|
|
100
|
+
* either given a sentinel (served_model → "unreported") or the field is OMITTED
|
|
101
|
+
* (temperature, which is a number and cannot carry a sentinel).
|
|
102
|
+
*/
|
|
103
|
+
export interface ReaderFrontmatter {
|
|
104
|
+
reader_model: string;
|
|
105
|
+
reader_served_model: string;
|
|
106
|
+
reader_temperature?: number;
|
|
107
|
+
reader_via_retry: boolean;
|
|
108
|
+
reader_prompt_version: string;
|
|
109
|
+
reader_chunk_window: number;
|
|
110
|
+
reader_input_cap: number;
|
|
111
|
+
readers: string[];
|
|
112
|
+
/** Append-only lineage (6mf.4 R1). Raw-only; never enters typed Frontmatter. */
|
|
113
|
+
reader_lineage: string[];
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Build the reader_* frontmatter fields from a claim's run_meta. The prompt
|
|
117
|
+
* version is READER_PROMPT_VERSION (the hash of the effective extraction prompt
|
|
118
|
+
* contract at this build). `readers` carries exactly ONE entry at ingest — the
|
|
119
|
+
* parentage SET a later merge bead unions. `reader_lineage` carries the first
|
|
120
|
+
* append-only provenance entry for this belief (6mf.4 R1).
|
|
121
|
+
*
|
|
122
|
+
* Locked field rules (see the bead spec):
|
|
123
|
+
* - reader_served_model uses the "unreported" sentinel when servedModel is
|
|
124
|
+
* undefined — NEVER null (null deletes the field).
|
|
125
|
+
* - reader_temperature is OMITTED when effectiveTemperature is undefined — a
|
|
126
|
+
* number field cannot hold a sentinel.
|
|
127
|
+
* - reader_via_retry defaults to false when viaRetry is undefined.
|
|
128
|
+
*
|
|
129
|
+
* @param runMeta The extraction run metadata.
|
|
130
|
+
* @param op The lineage op for this write. Defaults to `"ingest"` (new
|
|
131
|
+
* belief). Pass `"update"` for update-in-place re-distillations.
|
|
132
|
+
*/
|
|
133
|
+
export declare function buildReaderFrontmatter(runMeta: ClaimRunMeta, op?: LineageOp): ReaderFrontmatter;
|
|
91
134
|
/**
|
|
92
135
|
* Emit each claim as a `write` staged-action proposal at draft/low/synthesized.
|
|
93
136
|
* Routes through `stageActionWithConflictCheck` so inter-proposal conflicts
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"propose.d.ts","sourceRoot":"","sources":["../../src/distill/propose.ts"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAE,KAAK,YAAY,EAAgC,MAAM,+BAA+B,CAAC;AAGhG,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,c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4C;IAC5C,QAAQ,EAAE,MAAM,CAAC;IACjB,mEAAmE;IACnE,OAAO,EAAE,mBAAmB,EAAE,CAAC;IAC/B,oFAAoF;IACpF,MAAM,EAAE,KAAK,CAAC;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACrD;AA+CD;;;;;;;;;;GAUG;AACH,MAAM,WAAW,iBAAiB;IAChC,YAAY,EAAE,MAAM,CAAC;IACrB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,gBAAgB,EAAE,OAAO,CAAC;IAC1B,qBAAqB,EAAE,MAAM,CAAC;IAC9B,mBAAmB,EAAE,MAAM,CAAC;IAC5B,gBAAgB,EAAE,MAAM,CAAC;IACzB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,gFAAgF;IAChF,cAAc,EAAE,MAAM,EAAE,CAAC;CAC1B;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,YAAY,EACrB,EAAE,GAAE,SAAoB,GACvB,iBAAiB,CAmBnB;AA6GD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAsB,gBAAgB,CACpC,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,cAAc,EAAE,EACxB,GAAG,EAAE,UAAU,EACf,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EACtC,aAAa,CAAC,EAAE,eAAe,GAC9B,OAAO,CAAC,cAAc,CAAC,CA8FzB"}
|
package/dist/distill/propose.js
CHANGED
|
@@ -22,6 +22,7 @@ import { stageActionWithConflictCheck } from "../curation/staged-actions.js";
|
|
|
22
22
|
import { slugifyKey } from "../import/langgraph-store.js";
|
|
23
23
|
import { vaultSearch } from "../tools/search.js";
|
|
24
24
|
import { refuseRawDistillOutput } from "./output-fence.js";
|
|
25
|
+
import { encodeLineageEntry, encodeReader, READER_PROMPT_VERSION, } from "./reader-fingerprint.js";
|
|
25
26
|
// ---------------------------------------------------------------------------
|
|
26
27
|
// Public constants
|
|
27
28
|
// ---------------------------------------------------------------------------
|
|
@@ -102,10 +103,74 @@ function derivePath(claim, sourceId) {
|
|
|
102
103
|
const titleSlug = title.trim() ? slugifyKey(title) : slugifyKey(claim.claim_key);
|
|
103
104
|
return join(DISTILL_COLLECTION, sourceGroup, `${titleSlug}--${hash8}.md`);
|
|
104
105
|
}
|
|
106
|
+
/**
|
|
107
|
+
* Build the reader_* frontmatter fields from a claim's run_meta. The prompt
|
|
108
|
+
* version is READER_PROMPT_VERSION (the hash of the effective extraction prompt
|
|
109
|
+
* contract at this build). `readers` carries exactly ONE entry at ingest — the
|
|
110
|
+
* parentage SET a later merge bead unions. `reader_lineage` carries the first
|
|
111
|
+
* append-only provenance entry for this belief (6mf.4 R1).
|
|
112
|
+
*
|
|
113
|
+
* Locked field rules (see the bead spec):
|
|
114
|
+
* - reader_served_model uses the "unreported" sentinel when servedModel is
|
|
115
|
+
* undefined — NEVER null (null deletes the field).
|
|
116
|
+
* - reader_temperature is OMITTED when effectiveTemperature is undefined — a
|
|
117
|
+
* number field cannot hold a sentinel.
|
|
118
|
+
* - reader_via_retry defaults to false when viaRetry is undefined.
|
|
119
|
+
*
|
|
120
|
+
* @param runMeta The extraction run metadata.
|
|
121
|
+
* @param op The lineage op for this write. Defaults to `"ingest"` (new
|
|
122
|
+
* belief). Pass `"update"` for update-in-place re-distillations.
|
|
123
|
+
*/
|
|
124
|
+
export function buildReaderFrontmatter(runMeta, op = "ingest") {
|
|
125
|
+
const readerStr = encodeReader(runMeta, READER_PROMPT_VERSION);
|
|
126
|
+
const ts = new Date().toISOString();
|
|
127
|
+
const fm = {
|
|
128
|
+
reader_model: runMeta.requestedModel,
|
|
129
|
+
reader_served_model: runMeta.servedModel ?? "unreported",
|
|
130
|
+
reader_via_retry: runMeta.viaRetry ?? false,
|
|
131
|
+
reader_prompt_version: READER_PROMPT_VERSION,
|
|
132
|
+
reader_chunk_window: runMeta.chunkWindow,
|
|
133
|
+
reader_input_cap: runMeta.inputCap,
|
|
134
|
+
readers: [readerStr],
|
|
135
|
+
reader_lineage: [encodeLineageEntry(ts, op, readerStr)],
|
|
136
|
+
};
|
|
137
|
+
// Omit reader_temperature entirely when unknown: a number can't hold a
|
|
138
|
+
// sentinel and null would delete a declared extension.
|
|
139
|
+
if (runMeta.effectiveTemperature !== undefined) {
|
|
140
|
+
fm.reader_temperature = runMeta.effectiveTemperature;
|
|
141
|
+
}
|
|
142
|
+
return fm;
|
|
143
|
+
}
|
|
105
144
|
// ---------------------------------------------------------------------------
|
|
106
145
|
// Note assembly (mirrors langgraph-store.ts deriveNotes)
|
|
107
146
|
// ---------------------------------------------------------------------------
|
|
108
|
-
|
|
147
|
+
// Human-readable "Reader" subsection of the Provenance body, mirroring the
|
|
148
|
+
// reader_* frontmatter. Returns [] (no subsection) when the claim carries no
|
|
149
|
+
// run_meta, so a claim without reader provenance produces the original body.
|
|
150
|
+
function readerProvenanceLines(reader) {
|
|
151
|
+
if (reader === null)
|
|
152
|
+
return [];
|
|
153
|
+
return [
|
|
154
|
+
"",
|
|
155
|
+
"### Reader",
|
|
156
|
+
"",
|
|
157
|
+
`- **Model (requested):** \`${reader.reader_model}\``,
|
|
158
|
+
`- **Model (served):** \`${reader.reader_served_model}\``,
|
|
159
|
+
...(reader.reader_temperature !== undefined
|
|
160
|
+
? [`- **Effective temperature:** \`${reader.reader_temperature}\``]
|
|
161
|
+
: []),
|
|
162
|
+
`- **Via retry:** \`${reader.reader_via_retry}\``,
|
|
163
|
+
`- **Prompt version:** \`${reader.reader_prompt_version}\``,
|
|
164
|
+
`- **Chunk window:** \`${reader.reader_chunk_window}\``,
|
|
165
|
+
`- **Input cap:** \`${reader.reader_input_cap}\``,
|
|
166
|
+
`- **Readers:** \`${reader.readers.join(", ")}\``,
|
|
167
|
+
"",
|
|
168
|
+
"_This fingerprint identifies the run configuration; it does not guarantee " +
|
|
169
|
+
"bit-identical re-extraction (temperature 0 is not seeded; provider/quantization " +
|
|
170
|
+
"variance)._",
|
|
171
|
+
];
|
|
172
|
+
}
|
|
173
|
+
function assembleBody(claim, frontmatter, ids, reader) {
|
|
109
174
|
return [
|
|
110
175
|
"---",
|
|
111
176
|
dump(frontmatter).trimEnd(),
|
|
@@ -119,6 +184,7 @@ function assembleBody(claim, frontmatter, ids) {
|
|
|
119
184
|
`- **Claim key:** \`${claim.claim_key}\``,
|
|
120
185
|
`- **Run id:** \`${ids.runId}\``,
|
|
121
186
|
`- **Source ref:** \`distill:${ids.sourceId}#${claim.claim_key}\``,
|
|
187
|
+
...readerProvenanceLines(reader),
|
|
122
188
|
"",
|
|
123
189
|
].join("\n");
|
|
124
190
|
}
|
|
@@ -231,7 +297,23 @@ export async function proposeAllClaims(vaultRoot, claims, ids, pathOverrides, ov
|
|
|
231
297
|
errors.push({ claim_key: claim.claim_key, error: fence.error.message });
|
|
232
298
|
continue;
|
|
233
299
|
}
|
|
234
|
-
|
|
300
|
+
// f3h: the producing extraction call's run metadata reaches this point as
|
|
301
|
+
// `claim.run_meta` (ClaimRunMeta | undefined) — servedModel,
|
|
302
|
+
// effectiveTemperature, viaRetry, requestedModel, chunkWindow, inputCap. When
|
|
303
|
+
// present, stamp the reader fingerprint onto the belief's frontmatter as
|
|
304
|
+
// declared-optional schema_extensions (reader_*/readers/reader_lineage). When
|
|
305
|
+
// ABSENT (older paths, mocks that omit it), skip every reader field entirely —
|
|
306
|
+
// they are optional and must not crash or write empty/null placeholders.
|
|
307
|
+
//
|
|
308
|
+
// 6mf.4: the op is "update" iff this claim has a path override (meaning it is
|
|
309
|
+
// an update-in-place re-distillation of an existing landed belief), else "ingest".
|
|
310
|
+
// The land-time union (Task 2) merges the incoming lineage with the existing one.
|
|
311
|
+
const isUpdate = pathOverrides?.[claim.claim_key] !== undefined;
|
|
312
|
+
const lineageOp = isUpdate ? "update" : "ingest";
|
|
313
|
+
const reader = claim.run_meta ? buildReaderFrontmatter(claim.run_meta, lineageOp) : null;
|
|
314
|
+
if (reader)
|
|
315
|
+
Object.assign(frontmatter, reader);
|
|
316
|
+
const body = assembleBody(claim, frontmatter, ids, reader);
|
|
235
317
|
// U8/R5 + R7: overlap-hint. Attach top-K likely-collision neighbor paths to
|
|
236
318
|
// the rationale so the ratifier can see possible overlaps at a glance, and
|
|
237
319
|
// stamp the top neighbor's fused search score as `corroboration`. No LLM or
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"propose.js","sourceRoot":"","sources":["../../src/distill/propose.ts"],"names":[],"mappings":"AAAA,yBAAyB;AACzB,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,+EAA+E;AAC/E,4EAA4E;AAC5E,6BAA6B;AAC7B,EAAE;AACF,4CAA4C;AAC5C,yEAAyE;AACzE,8EAA8E;AAC9E,6EAA6E;AAC7E,+EAA+E;AAC/E,+DAA+D;AAC/D,EAAE;AACF,cAAc;AACd,2EAA2E;AAC3E,yEAAyE;AAEzE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAE/B,OAAO,EAAqB,4BAA4B,EAAE,MAAM,+BAA+B,CAAC;AAChG,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEjD,OAAO,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"propose.js","sourceRoot":"","sources":["../../src/distill/propose.ts"],"names":[],"mappings":"AAAA,yBAAyB;AACzB,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,+EAA+E;AAC/E,4EAA4E;AAC5E,6BAA6B;AAC7B,EAAE;AACF,4CAA4C;AAC5C,yEAAyE;AACzE,8EAA8E;AAC9E,6EAA6E;AAC7E,+EAA+E;AAC/E,+DAA+D;AAC/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,EAAE,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;YACzE,SAAS;QACX,CAAC;QAED,OAAO,CAAC,IAAI,CAAC;YACX,GAAG,MAAM,CAAC,KAAK;YACf,SAAS,EAAE,KAAK,CAAC,SAAS;YAC1B,UAAU;SACX,CAAC,CAAC;IACL,CAAC;IAED,OAAO,EAAE,QAAQ,EAAE,OAAO,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC;AACvD,CAAC"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import type { ClaimRunMeta } from "./extract.js";
|
|
2
|
+
/** First 8 hex chars of sha256(text). The short, stable version token form. */
|
|
3
|
+
export declare function hash8(text: string): string;
|
|
4
|
+
/**
|
|
5
|
+
* The 8-hex-char version token of the effective extraction prompt contract.
|
|
6
|
+
* Computed once at module load — it is a pure function of two module constants,
|
|
7
|
+
* so it is a stable constant for a given build. Changing EXTRACT_SYSTEM or
|
|
8
|
+
* EXTRACT_SCHEMA changes this value.
|
|
9
|
+
*/
|
|
10
|
+
export declare const READER_PROMPT_VERSION: string;
|
|
11
|
+
/**
|
|
12
|
+
* Encode one reader as a compact, stable, single-line string suitable as an
|
|
13
|
+
* element of the `readers` parentage SET. Shape:
|
|
14
|
+
*
|
|
15
|
+
* `${requestedModel}@${effTempOrNA}|prompt=${promptVersion}|retry=${viaRetry}`
|
|
16
|
+
*
|
|
17
|
+
* - requestedModel is always present on ClaimRunMeta.
|
|
18
|
+
* - effTempOrNA is the effective temperature, or "na" when undefined.
|
|
19
|
+
* - promptVersion is the caller-supplied version token (READER_PROMPT_VERSION at
|
|
20
|
+
* ingest) — passed in rather than read from the module constant so a future
|
|
21
|
+
* caller stamping historical content can encode against the version that
|
|
22
|
+
* actually produced it.
|
|
23
|
+
* - viaRetry defaults to false when undefined (mirrors reader_via_retry).
|
|
24
|
+
*
|
|
25
|
+
* One belief carries exactly ONE reader at ingest; the SET grows only when a
|
|
26
|
+
* merge unions parents. The encoding is intentionally free of characters that a
|
|
27
|
+
* later parser would need to escape (no commas, no newlines).
|
|
28
|
+
*/
|
|
29
|
+
export declare function encodeReader(runMeta: ClaimRunMeta, promptVersion: string): string;
|
|
30
|
+
/** Discriminant for the operation that produced a lineage entry. */
|
|
31
|
+
export type LineageOp = "ingest" | "update" | "revision";
|
|
32
|
+
/** A parsed lineage entry. `reader` is the full `encodeReader` string (may contain pipes). */
|
|
33
|
+
export interface ParsedLineageEntry {
|
|
34
|
+
ts: string;
|
|
35
|
+
op: string;
|
|
36
|
+
reader: string;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Encode one lineage entry as `<ts>|<op>|<reader>`.
|
|
40
|
+
* `reader` is an already-encoded reader string (may itself contain pipes);
|
|
41
|
+
* the first two pipes are the field delimiters — all further pipes belong to reader.
|
|
42
|
+
*/
|
|
43
|
+
export declare function encodeLineageEntry(ts: string, op: LineageOp, reader: string): string;
|
|
44
|
+
/**
|
|
45
|
+
* Parse a lineage entry produced by `encodeLineageEntry`.
|
|
46
|
+
* Splits on the FIRST two `|` only so the reader (which may contain pipes) is preserved.
|
|
47
|
+
* Returns null for malformed input (fewer than 2 separators or empty string).
|
|
48
|
+
*/
|
|
49
|
+
export declare function parseLineageEntry(entry: string): ParsedLineageEntry | null;
|
|
50
|
+
/**
|
|
51
|
+
* Materialise the SET-projection of a lineage: the deduplicated list of reader
|
|
52
|
+
* strings, in first-seen order. Malformed entries are silently skipped.
|
|
53
|
+
*/
|
|
54
|
+
export declare function readersFromLineage(lineage: string[]): string[];
|
|
55
|
+
/**
|
|
56
|
+
* Append-only union of two lineages.
|
|
57
|
+
* Starts from `existing` (order preserved, never re-sorted).
|
|
58
|
+
* For each entry in `incoming`, appends iff no existing entry shares the same `(op, reader)` pair
|
|
59
|
+
* (timestamp is ignored for dedup — a duplicate re-append is declined).
|
|
60
|
+
*/
|
|
61
|
+
export declare function unionLineage(existing: string[], incoming: string[]): string[];
|
|
62
|
+
/**
|
|
63
|
+
* Encode a revision-panel reader fingerprint.
|
|
64
|
+
* Shape: `<model>@na|prompt=<hash8(SYSTEM_BASE+templates)>|retry=false`
|
|
65
|
+
* The prompt hash here is the READER_PROMPT_VERSION (extraction contract),
|
|
66
|
+
* re-used as the closest stable contract identifier for the revision panel.
|
|
67
|
+
*/
|
|
68
|
+
export declare function encodeRevisionReader(model: string): string;
|
|
69
|
+
//# sourceMappingURL=reader-fingerprint.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reader-fingerprint.d.ts","sourceRoot":"","sources":["../../src/distill/reader-fingerprint.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAGjD,+EAA+E;AAC/E,wBAAgB,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE1C;AAgBD;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,EAAE,MAAoD,CAAC;AAQzF;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,GAAG,MAAM,CAKjF;AAMD,oEAAoE;AACpE,MAAM,MAAM,SAAS,GAAG,QAAQ,GAAG,QAAQ,GAAG,UAAU,CAAC;AAEzD,8FAA8F;AAC9F,MAAM,WAAW,kBAAkB;IACjC,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAEpF;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,kBAAkB,GAAG,IAAI,CAW1E;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAY9D;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAkB7E;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE1D"}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
// src/distill/reader-fingerprint.ts
|
|
2
|
+
//
|
|
3
|
+
// Reader provenance fingerprint (f3h). A "reader" is the LLM run configuration
|
|
4
|
+
// that compiled a distilled belief: which model was requested/served, at what
|
|
5
|
+
// effective temperature, whether it went through the retry branch, and a short
|
|
6
|
+
// hash of the effective extraction prompt contract. propose.ts stamps these
|
|
7
|
+
// onto each belief's frontmatter (as declared-optional schema_extensions) at
|
|
8
|
+
// ingest; later merge/tension/canon beads UNION the `readers` set, so the
|
|
9
|
+
// encoder here is the single shared source of truth for that set's element
|
|
10
|
+
// format. Keep it stable — a change to encodeReader's shape re-keys every
|
|
11
|
+
// parentage entry those beads compare.
|
|
12
|
+
import { sha256Hex } from "../utils/hash.js";
|
|
13
|
+
import { EXTRACT_SCHEMA, EXTRACT_SYSTEM } from "./extract.js";
|
|
14
|
+
/** First 8 hex chars of sha256(text). The short, stable version token form. */
|
|
15
|
+
export function hash8(text) {
|
|
16
|
+
return sha256Hex(text).slice(0, 8);
|
|
17
|
+
}
|
|
18
|
+
// The effective extraction prompt contract, serialized exactly as llm.ts's
|
|
19
|
+
// completeJsonWithRetry injects the schema into the system prompt
|
|
20
|
+
// (`JSON.stringify(opts.schema, null, 2)`). We hash EXTRACT_SYSTEM concatenated
|
|
21
|
+
// with that serialization so ANY change to either the system text or the JSON
|
|
22
|
+
// schema revs the version. We deliberately do NOT fold in the retry-prompt
|
|
23
|
+
// suffix (the "Your previous reply was NOT valid JSON…" reprompt): reader_via_retry
|
|
24
|
+
// already captures whether a belief came off the retry path, so the fingerprint
|
|
25
|
+
// stays keyed to the base contract rather than splitting into two versions.
|
|
26
|
+
const EFFECTIVE_EXTRACTION_PROMPT_CONTRACT = `${EXTRACT_SYSTEM}${JSON.stringify(EXTRACT_SCHEMA, null, 2)}`;
|
|
27
|
+
/**
|
|
28
|
+
* The 8-hex-char version token of the effective extraction prompt contract.
|
|
29
|
+
* Computed once at module load — it is a pure function of two module constants,
|
|
30
|
+
* so it is a stable constant for a given build. Changing EXTRACT_SYSTEM or
|
|
31
|
+
* EXTRACT_SCHEMA changes this value.
|
|
32
|
+
*/
|
|
33
|
+
export const READER_PROMPT_VERSION = hash8(EFFECTIVE_EXTRACTION_PROMPT_CONTRACT);
|
|
34
|
+
// Sentinel used when effectiveTemperature is undefined, only inside the compact
|
|
35
|
+
// `readers` set string (a single-line encoding that cannot carry `undefined`).
|
|
36
|
+
// The typed `reader_temperature` frontmatter field is OMITTED entirely in that
|
|
37
|
+
// case — a number field cannot hold a sentinel — so this "na" lives only here.
|
|
38
|
+
const TEMP_NA = "na";
|
|
39
|
+
/**
|
|
40
|
+
* Encode one reader as a compact, stable, single-line string suitable as an
|
|
41
|
+
* element of the `readers` parentage SET. Shape:
|
|
42
|
+
*
|
|
43
|
+
* `${requestedModel}@${effTempOrNA}|prompt=${promptVersion}|retry=${viaRetry}`
|
|
44
|
+
*
|
|
45
|
+
* - requestedModel is always present on ClaimRunMeta.
|
|
46
|
+
* - effTempOrNA is the effective temperature, or "na" when undefined.
|
|
47
|
+
* - promptVersion is the caller-supplied version token (READER_PROMPT_VERSION at
|
|
48
|
+
* ingest) — passed in rather than read from the module constant so a future
|
|
49
|
+
* caller stamping historical content can encode against the version that
|
|
50
|
+
* actually produced it.
|
|
51
|
+
* - viaRetry defaults to false when undefined (mirrors reader_via_retry).
|
|
52
|
+
*
|
|
53
|
+
* One belief carries exactly ONE reader at ingest; the SET grows only when a
|
|
54
|
+
* merge unions parents. The encoding is intentionally free of characters that a
|
|
55
|
+
* later parser would need to escape (no commas, no newlines).
|
|
56
|
+
*/
|
|
57
|
+
export function encodeReader(runMeta, promptVersion) {
|
|
58
|
+
const effTemp = runMeta.effectiveTemperature === undefined ? TEMP_NA : String(runMeta.effectiveTemperature);
|
|
59
|
+
const retry = runMeta.viaRetry ?? false;
|
|
60
|
+
return `${runMeta.requestedModel}@${effTemp}|prompt=${promptVersion}|retry=${retry}`;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Encode one lineage entry as `<ts>|<op>|<reader>`.
|
|
64
|
+
* `reader` is an already-encoded reader string (may itself contain pipes);
|
|
65
|
+
* the first two pipes are the field delimiters — all further pipes belong to reader.
|
|
66
|
+
*/
|
|
67
|
+
export function encodeLineageEntry(ts, op, reader) {
|
|
68
|
+
return `${ts}|${op}|${reader}`;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Parse a lineage entry produced by `encodeLineageEntry`.
|
|
72
|
+
* Splits on the FIRST two `|` only so the reader (which may contain pipes) is preserved.
|
|
73
|
+
* Returns null for malformed input (fewer than 2 separators or empty string).
|
|
74
|
+
*/
|
|
75
|
+
export function parseLineageEntry(entry) {
|
|
76
|
+
if (!entry)
|
|
77
|
+
return null;
|
|
78
|
+
const first = entry.indexOf("|");
|
|
79
|
+
if (first === -1)
|
|
80
|
+
return null;
|
|
81
|
+
const second = entry.indexOf("|", first + 1);
|
|
82
|
+
if (second === -1)
|
|
83
|
+
return null;
|
|
84
|
+
const ts = entry.slice(0, first);
|
|
85
|
+
const op = entry.slice(first + 1, second);
|
|
86
|
+
const reader = entry.slice(second + 1);
|
|
87
|
+
if (!ts || !op || !reader)
|
|
88
|
+
return null;
|
|
89
|
+
return { ts, op, reader };
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Materialise the SET-projection of a lineage: the deduplicated list of reader
|
|
93
|
+
* strings, in first-seen order. Malformed entries are silently skipped.
|
|
94
|
+
*/
|
|
95
|
+
export function readersFromLineage(lineage) {
|
|
96
|
+
const seen = new Set();
|
|
97
|
+
const result = [];
|
|
98
|
+
for (const entry of lineage) {
|
|
99
|
+
const parsed = parseLineageEntry(entry);
|
|
100
|
+
if (!parsed)
|
|
101
|
+
continue;
|
|
102
|
+
if (!seen.has(parsed.reader)) {
|
|
103
|
+
seen.add(parsed.reader);
|
|
104
|
+
result.push(parsed.reader);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
return result;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Append-only union of two lineages.
|
|
111
|
+
* Starts from `existing` (order preserved, never re-sorted).
|
|
112
|
+
* For each entry in `incoming`, appends iff no existing entry shares the same `(op, reader)` pair
|
|
113
|
+
* (timestamp is ignored for dedup — a duplicate re-append is declined).
|
|
114
|
+
*/
|
|
115
|
+
export function unionLineage(existing, incoming) {
|
|
116
|
+
// Build a set of (op,reader) keys from existing
|
|
117
|
+
const existingKeys = new Set();
|
|
118
|
+
for (const entry of existing) {
|
|
119
|
+
const parsed = parseLineageEntry(entry);
|
|
120
|
+
if (parsed)
|
|
121
|
+
existingKeys.add(`${parsed.op}\x00${parsed.reader}`);
|
|
122
|
+
}
|
|
123
|
+
const result = [...existing];
|
|
124
|
+
for (const entry of incoming) {
|
|
125
|
+
const parsed = parseLineageEntry(entry);
|
|
126
|
+
if (!parsed)
|
|
127
|
+
continue;
|
|
128
|
+
const key = `${parsed.op}\x00${parsed.reader}`;
|
|
129
|
+
if (!existingKeys.has(key)) {
|
|
130
|
+
existingKeys.add(key);
|
|
131
|
+
result.push(entry);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
return result;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Encode a revision-panel reader fingerprint.
|
|
138
|
+
* Shape: `<model>@na|prompt=<hash8(SYSTEM_BASE+templates)>|retry=false`
|
|
139
|
+
* The prompt hash here is the READER_PROMPT_VERSION (extraction contract),
|
|
140
|
+
* re-used as the closest stable contract identifier for the revision panel.
|
|
141
|
+
*/
|
|
142
|
+
export function encodeRevisionReader(model) {
|
|
143
|
+
return `${model}@${TEMP_NA}|prompt=${READER_PROMPT_VERSION}|retry=false`;
|
|
144
|
+
}
|
|
145
|
+
//# sourceMappingURL=reader-fingerprint.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reader-fingerprint.js","sourceRoot":"","sources":["../../src/distill/reader-fingerprint.ts"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,EAAE;AACF,+EAA+E;AAC/E,8EAA8E;AAC9E,+EAA+E;AAC/E,4EAA4E;AAC5E,6EAA6E;AAC7E,0EAA0E;AAC1E,2EAA2E;AAC3E,0EAA0E;AAC1E,uCAAuC;AAEvC,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE7C,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9D,+EAA+E;AAC/E,MAAM,UAAU,KAAK,CAAC,IAAY;IAChC,OAAO,SAAS,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AACrC,CAAC;AAED,2EAA2E;AAC3E,kEAAkE;AAClE,gFAAgF;AAChF,8EAA8E;AAC9E,2EAA2E;AAC3E,oFAAoF;AACpF,gFAAgF;AAChF,4EAA4E;AAC5E,MAAM,oCAAoC,GAAG,GAAG,cAAc,GAAG,IAAI,CAAC,SAAS,CAC7E,cAAc,EACd,IAAI,EACJ,CAAC,CACF,EAAE,CAAC;AAEJ;;;;;GAKG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAW,KAAK,CAAC,oCAAoC,CAAC,CAAC;AAEzF,gFAAgF;AAChF,+EAA+E;AAC/E,+EAA+E;AAC/E,+EAA+E;AAC/E,MAAM,OAAO,GAAG,IAAI,CAAC;AAErB;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,YAAY,CAAC,OAAqB,EAAE,aAAqB;IACvE,MAAM,OAAO,GACX,OAAO,CAAC,oBAAoB,KAAK,SAAS,CAAC,CAAC,CAAC,O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YACtB,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACrB,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB,CAAC,KAAa;IAChD,OAAO,GAAG,KAAK,IAAI,OAAO,WAAW,qBAAqB,cAAc,CAAC;AAC3E,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type Result } from "../frontmatter/types.js";
|
|
2
|
+
import type { DistillReceipt } from "./cost.js";
|
|
3
|
+
export declare function distillReceiptsPath(vaultRoot: string): string;
|
|
4
|
+
export declare function appendDistillReceipt(vaultRoot: string, receipt: DistillReceipt): Promise<Result<void, Error>>;
|
|
5
|
+
//# sourceMappingURL=receipt-store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"receipt-store.d.ts","sourceRoot":"","sources":["../../src/distill/receipt-store.ts"],"names":[],"mappings":"AAQA,OAAO,EAAW,KAAK,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAEhD,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAE7D;AAED,wBAAsB,oBAAoB,CACxC,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,cAAc,GACtB,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,CAS9B"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// Operator-side persistence for distill receipts (#423). Append-only JSONL at
|
|
2
|
+
// .daftari/distill-receipts.jsonl, keyed by the artifact runId so a run's
|
|
3
|
+
// provider/ZDR/cost facts join to the claims it produced. Machine-local and
|
|
4
|
+
// gitignored — these are operator telemetry (R10), NEVER exposed through an MCP
|
|
5
|
+
// tool or CLI read path.
|
|
6
|
+
import { mkdirSync } from "node:fs";
|
|
7
|
+
import { appendFile } from "node:fs/promises";
|
|
8
|
+
import { join } from "node:path";
|
|
9
|
+
import { err, ok } from "../frontmatter/types.js";
|
|
10
|
+
export function distillReceiptsPath(vaultRoot) {
|
|
11
|
+
return join(vaultRoot, ".daftari", "distill-receipts.jsonl");
|
|
12
|
+
}
|
|
13
|
+
export async function appendDistillReceipt(vaultRoot, receipt) {
|
|
14
|
+
try {
|
|
15
|
+
mkdirSync(join(vaultRoot, ".daftari"), { recursive: true });
|
|
16
|
+
await appendFile(distillReceiptsPath(vaultRoot), `${JSON.stringify(receipt)}\n`);
|
|
17
|
+
return ok(undefined);
|
|
18
|
+
}
|
|
19
|
+
catch (e) {
|
|
20
|
+
const reason = e instanceof Error ? e.message : String(e);
|
|
21
|
+
return err(new Error(`cannot persist distill receipt: ${reason}`));
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=receipt-store.js.map
|