pi-braid 0.43.6 → 0.43.7
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 +44 -0
- package/build-info.json +4 -4
- package/dist/extensions/core/skills-tool/applicability.d.ts +134 -0
- package/dist/extensions/core/skills-tool/applicability.js +161 -0
- package/dist/extensions/core/skills-tool/auto-inject.d.ts +10 -0
- package/dist/extensions/core/skills-tool/auto-inject.js +216 -1
- package/dist/extensions/core/skills-tool/index.js +64 -3
- package/dist/extensions/core/skills-tool/loading-guidance.js +2 -1
- package/dist/extensions/core/skills-tool/session-records.d.ts +297 -8
- package/dist/extensions/core/skills-tool/session-records.js +509 -5
- package/dist/extensions/core/skills-tool/skill-families.d.ts +60 -0
- package/dist/extensions/core/skills-tool/skill-families.js +105 -0
- package/docs/LOCAL_DEV.md +1 -1
- package/package.json +1 -1
- package/src/extensions/core/AGENTS.md +1 -0
- package/src/extensions/core/skills-tool/applicability.ts +220 -0
- package/src/extensions/core/skills-tool/auto-inject.ts +274 -0
- package/src/extensions/core/skills-tool/index.ts +75 -2
- package/src/extensions/core/skills-tool/loading-guidance.ts +2 -1
- package/src/extensions/core/skills-tool/session-records.ts +740 -5
- package/src/extensions/core/skills-tool/skill-families.ts +112 -0
|
@@ -34,10 +34,11 @@
|
|
|
34
34
|
import { Type } from "typebox";
|
|
35
35
|
import { createLogger } from "../../../lib/core/logger.js";
|
|
36
36
|
import { getSkillsRankingMode } from "../../../lib/config/braid-settings.js";
|
|
37
|
-
import { registerAutoInject, updateSkillCache, getSkillStats, getDurableSkillStats, resolveDiscoveryMode, rankSkillsDeterministic, } from "./auto-inject.js";
|
|
37
|
+
import { registerAutoInject, updateSkillCache, getSkillStats, getDurableSkillStats, noteObligationListed, resolveDiscoveryMode, rankSkillsDeterministic, } from "./auto-inject.js";
|
|
38
38
|
import { readSkillTriggerEntries } from "./skill-triggers.js";
|
|
39
|
+
import { readGovernedFamilies } from "./skill-families.js";
|
|
39
40
|
import { clampSectionsMax, DEFAULT_SECTIONS_MAX, SECTIONS_MAX_LIMIT, readSkillReach, } from "./reach.js";
|
|
40
|
-
import { getMonthlyAdoptionRollup } from "./session-records.js";
|
|
41
|
+
import { getMonthlyAdoptionRollup, getObligationRate, getSessionApplicability, getSessionObligation, judgeSessionObligations, } from "./session-records.js";
|
|
41
42
|
import { checkArgumentValues } from "../../../lib/utils/argument-report.js";
|
|
42
43
|
const log = createLogger("skills-tool");
|
|
43
44
|
let cachedSkills = [];
|
|
@@ -53,7 +54,15 @@ export function setCachedSkills(skills) {
|
|
|
53
54
|
const triggerSources = {};
|
|
54
55
|
for (const entry of entries)
|
|
55
56
|
triggerSources[entry.phrase] = entry.source;
|
|
56
|
-
return {
|
|
57
|
+
return {
|
|
58
|
+
...s,
|
|
59
|
+
triggers: entries.map((entry) => entry.phrase),
|
|
60
|
+
triggerSources,
|
|
61
|
+
// The families the file says its advice directs, resolved from the same
|
|
62
|
+
// frontmatter read the phrases come from (one extra parse per file per
|
|
63
|
+
// process). An empty list is a declaration of no family, not a miss.
|
|
64
|
+
families: readGovernedFamilies(s.filePath),
|
|
65
|
+
};
|
|
57
66
|
});
|
|
58
67
|
// Sync with auto-inject subsystem (enriched cache — triggers ride along)
|
|
59
68
|
updateSkillCache(cachedSkills);
|
|
@@ -245,6 +254,10 @@ export default function skillsToolExtension(pi) {
|
|
|
245
254
|
// the empty object carried no information the absence does not.
|
|
246
255
|
...(answer.relevance.has(s.name) ? { relevance: answer.relevance.get(s.name) } : {}),
|
|
247
256
|
}));
|
|
257
|
+
// A listed row is one of the session's obligation legs: the catalog is
|
|
258
|
+
// where a body becomes findable without a whisper. Recorded before the
|
|
259
|
+
// response is built so the row and the page describe the same read.
|
|
260
|
+
noteObligationListed(ctx, skills.map((s) => s.name));
|
|
248
261
|
return {
|
|
249
262
|
content: [
|
|
250
263
|
{
|
|
@@ -310,6 +323,41 @@ export default function skillsToolExtension(pi) {
|
|
|
310
323
|
}
|
|
311
324
|
const monthly = getMonthlyAdoptionRollup();
|
|
312
325
|
const discovery = resolveDiscoveryMode(ctx);
|
|
326
|
+
// The session's skill verdicts (read | ignored, plus the not-applicable
|
|
327
|
+
// remainder of the census) from the durable record, never from memory:
|
|
328
|
+
// the point of the record is that it outlives the turn that saw it.
|
|
329
|
+
// Absent when the session wrote none — an older store, or a session that
|
|
330
|
+
// never reached a task text — so an exhausted reader of the old counters
|
|
331
|
+
// keeps byte-identical output. Only the verdict classes are summarized in
|
|
332
|
+
// details; the full evidence stays in the text payload.
|
|
333
|
+
const recorded = getSessionApplicability(ctx);
|
|
334
|
+
const applicability = recorded
|
|
335
|
+
? {
|
|
336
|
+
taskChars: recorded.taskChars,
|
|
337
|
+
evaluated: recorded.evaluated,
|
|
338
|
+
undeclared: recorded.undeclared,
|
|
339
|
+
classes: recorded.classes,
|
|
340
|
+
verdicts: recorded.verdicts,
|
|
341
|
+
updatedAt: recorded.updatedAt,
|
|
342
|
+
}
|
|
343
|
+
: undefined;
|
|
344
|
+
// The session's obligation legs and its boolean: what the session did
|
|
345
|
+
// with the bodies whose conditions held. Absent when the session has no
|
|
346
|
+
// leg row, so a store this build never wrote to reads byte for byte as
|
|
347
|
+
// it did before (the same rule the applicability block above follows).
|
|
348
|
+
const legRecord = getSessionObligation(ctx);
|
|
349
|
+
const judgement = judgeSessionObligations(recorded, legRecord);
|
|
350
|
+
const obligations = judgement && legRecord && legRecord.skills.length
|
|
351
|
+
? {
|
|
352
|
+
allSatisfied: judgement.allSatisfied,
|
|
353
|
+
obligations: judgement.obligations,
|
|
354
|
+
skills: judgement.skills,
|
|
355
|
+
}
|
|
356
|
+
: undefined;
|
|
357
|
+
// Both rates over one population, or absent while the store carries no
|
|
358
|
+
// obligation row at all: a build that predates the leg reads the same
|
|
359
|
+
// sessions and must see the same payload.
|
|
360
|
+
const obligationRate = getObligationRate();
|
|
313
361
|
return {
|
|
314
362
|
content: [
|
|
315
363
|
{
|
|
@@ -329,6 +377,9 @@ export default function skillsToolExtension(pi) {
|
|
|
329
377
|
suggestedEpoch: suggestedMixed === 0 ? "delivered" : "mixed",
|
|
330
378
|
},
|
|
331
379
|
monthly,
|
|
380
|
+
...(applicability ? { applicability } : {}),
|
|
381
|
+
...(obligations ? { obligations } : {}),
|
|
382
|
+
...(obligationRate ? { obligationRate } : {}),
|
|
332
383
|
discovery: {
|
|
333
384
|
// Whether the stock skill catalog sits in the persisted
|
|
334
385
|
// transcript (it re-enters via pi's post-compaction
|
|
@@ -347,6 +398,16 @@ export default function skillsToolExtension(pi) {
|
|
|
347
398
|
allTimeSkills: Object.keys(allTime).length,
|
|
348
399
|
allTimeTotals: { ...totals, suggestedDelivered, suggestedMixed },
|
|
349
400
|
monthly,
|
|
401
|
+
...(applicability ? { applicability: applicability.classes } : {}),
|
|
402
|
+
...(obligations
|
|
403
|
+
? {
|
|
404
|
+
obligations: {
|
|
405
|
+
allSatisfied: obligations.allSatisfied,
|
|
406
|
+
count: obligations.obligations,
|
|
407
|
+
},
|
|
408
|
+
}
|
|
409
|
+
: {}),
|
|
410
|
+
...(obligationRate ? { obligationRate } : {}),
|
|
350
411
|
},
|
|
351
412
|
};
|
|
352
413
|
},
|
|
@@ -36,6 +36,7 @@
|
|
|
36
36
|
* auto-inject.ts and the reasoning stays testable here.
|
|
37
37
|
*/
|
|
38
38
|
import { isAbsolute, relative, resolve, sep } from "node:path";
|
|
39
|
+
import { toolFamilyToken } from "./skill-families.js";
|
|
39
40
|
/**
|
|
40
41
|
* Paragraph 1: what the catalog is, where the bodies live, and the obligation.
|
|
41
42
|
*
|
|
@@ -136,7 +137,7 @@ export function mechanicalTriggerExamples(toolNames, skillNames) {
|
|
|
136
137
|
// Family token (lowercased) -> lexicographically smallest active tool name.
|
|
137
138
|
const familyTool = new Map();
|
|
138
139
|
for (const tool of toolNames) {
|
|
139
|
-
const family = tool
|
|
140
|
+
const family = toolFamilyToken(tool);
|
|
140
141
|
const incumbent = familyTool.get(family);
|
|
141
142
|
if (incumbent === undefined || tool < incumbent)
|
|
142
143
|
familyTool.set(family, tool);
|
|
@@ -1,8 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Durable per-session skill
|
|
2
|
+
* Durable per-session skill records + the monthly adoption rollup.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* The store is one append-only JSONL file with three record kinds, told apart
|
|
5
|
+
* by `kind`:
|
|
6
|
+
*
|
|
7
|
+
* (absent) an ADOPTION record, the older shape:
|
|
8
|
+
* { sessionId, role, month, hadSkillLoad, updatedAt }
|
|
9
|
+
* "applicability" an APPLICABILITY record: the session's skill verdicts
|
|
10
|
+
* (see ApplicabilityRecord)
|
|
11
|
+
* "obligation" an OBLIGATION record: one skill's legs in one session
|
|
12
|
+
* (see ObligationLegRecord)
|
|
13
|
+
*
|
|
14
|
+
* An adoption record exists for every session that reaches an agent turn, so
|
|
15
|
+
* every such session gets ONE logical record (the rollup denominator);
|
|
6
16
|
* `role` carries the session's profile name from the braid config (see
|
|
7
17
|
* lib/config/session-profiles.ts), or the neutral default when no profile
|
|
8
18
|
* matches; `month` is the local-time "YYYY-MM" of the write, and
|
|
@@ -22,6 +32,13 @@
|
|
|
22
32
|
* filesystems; the tolerant reader skips unparseable lines, the window is
|
|
23
33
|
* a single small write, and this is accepted as best-effort telemetry.
|
|
24
34
|
*
|
|
35
|
+
* Each reader reads its own kind and ignores the others. The adoption reader
|
|
36
|
+
* is fail-closed on an unknown `kind`, so a record type added later cannot
|
|
37
|
+
* enter the adoption numbers by looking enough like one; and a build that
|
|
38
|
+
* predates the applicability kind reads those lines as adoption records of
|
|
39
|
+
* the same session, which folds to the same numbers because it carries no
|
|
40
|
+
* new sessions and never sets `hadSkillLoad`.
|
|
41
|
+
*
|
|
25
42
|
* Back-compat: records written before profiles existed carry a role from
|
|
26
43
|
* the retired fixed set; those values pass the profile-name gate
|
|
27
44
|
* unchanged, so older buckets keep folding under their original names.
|
|
@@ -30,6 +47,7 @@
|
|
|
30
47
|
*/
|
|
31
48
|
import type { ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
32
49
|
import { type ResolvedSessionProfile } from "../../../lib/config/session-profiles.js";
|
|
50
|
+
import type { ApplicabilityEvidence, SkillApplicabilityVerdict } from "./applicability.js";
|
|
33
51
|
/** One durable per-session adoption record (a single JSONL line on disk). */
|
|
34
52
|
export interface SkillSessionRecord {
|
|
35
53
|
/** pi session id (from ctx.sessionManager.getSessionId()). */
|
|
@@ -59,11 +77,7 @@ export declare function foldSessionRecords(records: SkillSessionRecord[]): Skill
|
|
|
59
77
|
* throws); corrupt lines are skipped.
|
|
60
78
|
*/
|
|
61
79
|
export declare function readSessionRecords(storePath: string): SkillSessionRecord[];
|
|
62
|
-
/**
|
|
63
|
-
* Append one record. Best-effort: every error is swallowed (this runs on
|
|
64
|
-
* the agent-loop and tool-result paths — a telemetry failure must never
|
|
65
|
-
* break a turn). Returns true when the line landed on disk.
|
|
66
|
-
*/
|
|
80
|
+
/** Append one adoption record (see appendLine for the failure contract). */
|
|
67
81
|
export declare function appendSessionRecord(record: SkillSessionRecord, storePath: string): boolean;
|
|
68
82
|
/**
|
|
69
83
|
* The session's effective profile, resolved from the braid config on first
|
|
@@ -82,6 +96,281 @@ export declare function recordSessionStart(ctx: ExtensionContext, storePath?: st
|
|
|
82
96
|
* numerator of the adoption rate). Claims must NOT route here.
|
|
83
97
|
*/
|
|
84
98
|
export declare function recordSessionSkillLoad(ctx: ExtensionContext, storePath?: string): void;
|
|
99
|
+
/**
|
|
100
|
+
* One skill's applicability verdict for one session.
|
|
101
|
+
*
|
|
102
|
+
* The three classes, as this instrument names them:
|
|
103
|
+
*
|
|
104
|
+
* not-applicable the skill's own declared condition did not meet the
|
|
105
|
+
* session's task text. Derived, never a row: the census's
|
|
106
|
+
* `evaluated` minus the verdict rows. A row per non-match
|
|
107
|
+
* would multiply every session's record by the installed
|
|
108
|
+
* catalog to say "nothing here".
|
|
109
|
+
* ignored the condition held and no detected read followed. This is
|
|
110
|
+
* the class the adoption counters cannot express.
|
|
111
|
+
* read the condition held and a detected SKILL.md read followed.
|
|
112
|
+
*
|
|
113
|
+
* `undeclared` sits outside all three: those skill files state no condition, so
|
|
114
|
+
* no verdict about them is honest (see applicability.ts).
|
|
115
|
+
*/
|
|
116
|
+
/** One verdict row: the skill, its class, and the phrases that decided it. */
|
|
117
|
+
export interface ApplicabilityVerdictRecord {
|
|
118
|
+
kind: "applicability";
|
|
119
|
+
sessionId: string;
|
|
120
|
+
role: string;
|
|
121
|
+
month: string;
|
|
122
|
+
updatedAt: string;
|
|
123
|
+
/** The skill this row answers for. */
|
|
124
|
+
skill: string;
|
|
125
|
+
/** read | ignored — a row exists only where a condition held. */
|
|
126
|
+
applicability: "read" | "ignored";
|
|
127
|
+
evidence: ApplicabilityEvidence[];
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* One session's census row: how much task text was read, how many skills
|
|
131
|
+
* declared a condition, and which ones declared none. Written once per
|
|
132
|
+
* session, so `not-applicable` is derivable without a row per non-match.
|
|
133
|
+
*/
|
|
134
|
+
export interface ApplicabilityCensusRecord {
|
|
135
|
+
kind: "applicability";
|
|
136
|
+
sessionId: string;
|
|
137
|
+
role: string;
|
|
138
|
+
month: string;
|
|
139
|
+
updatedAt: string;
|
|
140
|
+
/** Characters of task text the first evaluation read. */
|
|
141
|
+
taskChars: number;
|
|
142
|
+
/** Installed skills declaring at least one condition phrase. */
|
|
143
|
+
evaluated: number;
|
|
144
|
+
/** Installed skills whose files declare no condition phrase. */
|
|
145
|
+
undeclared: string[];
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* An applicability record. The two shapes share the kind and the session
|
|
149
|
+
* identity, and a reader tells them apart by `skill`: a row with one answers
|
|
150
|
+
* for that skill, a row without one is the session's census. The split is what
|
|
151
|
+
* lets a per-skill record join the sibling compliance record on
|
|
152
|
+
* (sessionId, skill) without either store learning the other's fields.
|
|
153
|
+
*/
|
|
154
|
+
export type ApplicabilityRecord = ApplicabilityVerdictRecord | ApplicabilityCensusRecord;
|
|
155
|
+
/** A session's applicability after folding every record written for it. */
|
|
156
|
+
export interface SessionApplicability {
|
|
157
|
+
sessionId: string;
|
|
158
|
+
role: string;
|
|
159
|
+
month: string;
|
|
160
|
+
updatedAt: string;
|
|
161
|
+
/** Characters of task text the census read. */
|
|
162
|
+
taskChars: number;
|
|
163
|
+
/** Skills that declared a condition. */
|
|
164
|
+
evaluated: number;
|
|
165
|
+
/** Skills that declared none — the blind spot, named. */
|
|
166
|
+
undeclared: string[];
|
|
167
|
+
/** One entry per applicable skill, `read` beating `ignored`. */
|
|
168
|
+
verdicts: SkillApplicabilityVerdict[];
|
|
169
|
+
/** The three classes as counts: read + ignored = applicable. */
|
|
170
|
+
classes: {
|
|
171
|
+
read: number;
|
|
172
|
+
ignored: number;
|
|
173
|
+
notApplicable: number;
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Read the applicability records from the store. Missing or unreadable file →
|
|
178
|
+
* empty (never throws); non-applicability and corrupt lines are skipped.
|
|
179
|
+
*/
|
|
180
|
+
export declare function readApplicabilityRecords(storePath: string): ApplicabilityRecord[];
|
|
181
|
+
/**
|
|
182
|
+
* Fold the store into one logical record per sessionId: the newest census wins
|
|
183
|
+
* the session facts, verdict rows union across writes with `read` beating
|
|
184
|
+
* `ignored`. Pure. The fold is what makes a torn, duplicated or out-of-order
|
|
185
|
+
* append harmless: the record set, not the line order, decides a verdict.
|
|
186
|
+
*/
|
|
187
|
+
export declare function foldApplicabilityRecords(records: ApplicabilityRecord[]): SessionApplicability[];
|
|
188
|
+
/** Fields a caller supplies for the session's census row. */
|
|
189
|
+
export interface ApplicabilityCensusInput {
|
|
190
|
+
taskChars: number;
|
|
191
|
+
evaluated: number;
|
|
192
|
+
undeclared: string[];
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Append the session's census row. Best-effort like every other writer here: a
|
|
196
|
+
* false return means the line did not land, never a thrown turn.
|
|
197
|
+
*/
|
|
198
|
+
export declare function recordApplicabilityCensus(ctx: ExtensionContext, census: ApplicabilityCensusInput, storePath?: string): boolean;
|
|
199
|
+
/**
|
|
200
|
+
* Append one skill's verdict row. The same function writes the `read` upgrade:
|
|
201
|
+
* the fold decides, so no line is ever rewritten.
|
|
202
|
+
*/
|
|
203
|
+
export declare function recordApplicabilityVerdict(ctx: ExtensionContext, verdict: {
|
|
204
|
+
skill: string;
|
|
205
|
+
applicability: "read" | "ignored";
|
|
206
|
+
evidence: ApplicabilityEvidence[];
|
|
207
|
+
}, storePath?: string): boolean;
|
|
208
|
+
/**
|
|
209
|
+
* The folded applicability record for the context's own session, or undefined
|
|
210
|
+
* when the session wrote none. Reader: a refused path or a torn store is a
|
|
211
|
+
* miss, not a throw.
|
|
212
|
+
*/
|
|
213
|
+
export declare function getSessionApplicability(ctx: ExtensionContext, options?: {
|
|
214
|
+
storePath?: string;
|
|
215
|
+
}): SessionApplicability | undefined;
|
|
216
|
+
/**
|
|
217
|
+
* One skill's legs in one session: what the instrument saw happen to the body
|
|
218
|
+
* an obligation names.
|
|
219
|
+
*
|
|
220
|
+
* These are facts about reads and calls, not verdicts. `read` here means a
|
|
221
|
+
* DETECTED SKILL.md read, and it is deliberately not the applicability record's
|
|
222
|
+
* `applicability: "read"` class — that one is a verdict about a skill whose
|
|
223
|
+
* declared condition held, and the applicability record refuses to classify a
|
|
224
|
+
* read whose condition never held. This record states the read and leaves the
|
|
225
|
+
* verdict where it belongs.
|
|
226
|
+
*
|
|
227
|
+
* `called` and `applied` are the applied leg, and they are the reason the
|
|
228
|
+
* record exists:
|
|
229
|
+
* called a tool call in a family this skill declares happened this
|
|
230
|
+
* session, whatever the call's outcome — a refusal fires before the
|
|
231
|
+
* call and cannot know the result.
|
|
232
|
+
* applied the FIRST such call came after a detected read of this body.
|
|
233
|
+
*
|
|
234
|
+
* The pair is decided once, at the first call, because that is the only moment
|
|
235
|
+
* the ordering exists: a later read followed by a later call must not turn an
|
|
236
|
+
* earlier violation into satisfaction. Both stay false when the skill declares
|
|
237
|
+
* no family; most declare none, and an obligation that names no family is
|
|
238
|
+
* satisfied by the read alone.
|
|
239
|
+
*
|
|
240
|
+
* `suggested` and `listed` are the surfaces that made the body findable in
|
|
241
|
+
* this session (a delivered suggestion, a list_skills row); they carry the
|
|
242
|
+
* "was it offered" half of adoption, which the call facts cannot.
|
|
243
|
+
*/
|
|
244
|
+
export interface ObligationLegRecord {
|
|
245
|
+
kind: "obligation";
|
|
246
|
+
sessionId: string;
|
|
247
|
+
role: string;
|
|
248
|
+
month: string;
|
|
249
|
+
updatedAt: string;
|
|
250
|
+
skill: string;
|
|
251
|
+
suggested: boolean;
|
|
252
|
+
listed: boolean;
|
|
253
|
+
read: boolean;
|
|
254
|
+
called: boolean;
|
|
255
|
+
applied: boolean;
|
|
256
|
+
}
|
|
257
|
+
/** A record's five legs, read back as one row per skill. */
|
|
258
|
+
export interface ObligationLegs {
|
|
259
|
+
skill: string;
|
|
260
|
+
suggested: boolean;
|
|
261
|
+
listed: boolean;
|
|
262
|
+
read: boolean;
|
|
263
|
+
called: boolean;
|
|
264
|
+
applied: boolean;
|
|
265
|
+
}
|
|
266
|
+
/** One session's obligation rows, folded. */
|
|
267
|
+
export interface SessionObligation {
|
|
268
|
+
sessionId: string;
|
|
269
|
+
role: string;
|
|
270
|
+
month: string;
|
|
271
|
+
updatedAt: string;
|
|
272
|
+
/** One row per skill seen, in first-seen order. */
|
|
273
|
+
skills: ObligationLegs[];
|
|
274
|
+
}
|
|
275
|
+
/** Normalize a parsed JSON line into an obligation record, or null. */
|
|
276
|
+
export declare function normalizeObligationRecord(raw: unknown): ObligationLegRecord | null;
|
|
277
|
+
/**
|
|
278
|
+
* Read the obligation records from the store. Missing or unreadable file →
|
|
279
|
+
* empty (never throws); other kinds and corrupt lines are skipped.
|
|
280
|
+
*/
|
|
281
|
+
export declare function readObligationRecords(storePath?: string): ObligationLegRecord[];
|
|
282
|
+
/**
|
|
283
|
+
* Fold a session's obligation rows into one record: the five legs OR across
|
|
284
|
+
* every row, so a row that saw one leg never erases a leg a later row did not
|
|
285
|
+
* have. `called`/`applied` are written once per skill, so the OR is exact
|
|
286
|
+
* rather than convenient. A torn or duplicated row folds; a malformed one is
|
|
287
|
+
* dropped at normalize, before this sees it.
|
|
288
|
+
*/
|
|
289
|
+
export declare function foldObligationRecords(records: ObligationLegRecord[]): SessionObligation[];
|
|
290
|
+
/**
|
|
291
|
+
* Append one skill's legs. Best-effort like the sibling writer: a refused or
|
|
292
|
+
* missing store returns false so the caller can retry on a later turn.
|
|
293
|
+
*/
|
|
294
|
+
export declare function recordObligationLegs(ctx: ExtensionContext, legs: ObligationLegs, storePath?: string): boolean;
|
|
295
|
+
/** The current session's obligation rows, folded. Missing store → undefined. */
|
|
296
|
+
export declare function getSessionObligation(ctx: ExtensionContext, options?: {
|
|
297
|
+
storePath?: string;
|
|
298
|
+
}): SessionObligation | undefined;
|
|
299
|
+
/**
|
|
300
|
+
* An obligation is satisfied when the body was read AND, if the session ever
|
|
301
|
+
* called into a family the skill declares, that the first call came after the
|
|
302
|
+
* read. Without a declared family the second clause is vacuous: reading the
|
|
303
|
+
* body is the whole obligation.
|
|
304
|
+
*/
|
|
305
|
+
export declare function obligationSatisfied(legs: ObligationLegs): boolean;
|
|
306
|
+
/** One judged skill: its legs, plus whether it was even an obligation. */
|
|
307
|
+
export interface JudgedSkill extends ObligationLegs {
|
|
308
|
+
/** null when the skill's declared condition never held: no obligation. */
|
|
309
|
+
satisfied: boolean | null;
|
|
310
|
+
}
|
|
311
|
+
/** A session's judgement: every leg it recorded, and the session boolean. */
|
|
312
|
+
export interface SessionJudgement {
|
|
313
|
+
skills: JudgedSkill[];
|
|
314
|
+
allSatisfied: boolean;
|
|
315
|
+
/** Obligations that applied (leg rows whose condition held). */
|
|
316
|
+
obligations: number;
|
|
317
|
+
}
|
|
318
|
+
/**
|
|
319
|
+
* Judge one session against its obligation rows. Pure.
|
|
320
|
+
*
|
|
321
|
+
* A skill is an obligation when the applicability fold carries a verdict for
|
|
322
|
+
* it: the previous record's question was whether the skill applied, and this
|
|
323
|
+
* one takes that answer as given. An obligation is decided by this record's
|
|
324
|
+
* legs alone, which is why the two kinds can be folded independently and
|
|
325
|
+
* joined on (sessionId, skill) without either re-reading the other.
|
|
326
|
+
*/
|
|
327
|
+
export declare function judgeSessionObligations(applicable: SessionApplicability | undefined, obligation: SessionObligation | undefined): SessionJudgement | undefined;
|
|
328
|
+
/**
|
|
329
|
+
* The design's own decision rule: a gap this small makes the rate a duplicate
|
|
330
|
+
* of the read rate, and a duplicate should be deleted rather than shipped.
|
|
331
|
+
*/
|
|
332
|
+
export declare const FALSIFIER_GAP_POINTS = 5;
|
|
333
|
+
/**
|
|
334
|
+
* The two rates and their shared denominator.
|
|
335
|
+
*
|
|
336
|
+
* `sessions` is the population both rates are divided by: sessions with at
|
|
337
|
+
* least one obligation that applied AND at least one obligation row, i.e. the
|
|
338
|
+
* sessions this build's instrument saw. A session whose applicable verdicts
|
|
339
|
+
* predate the instrument is counted in `uninstrumented` instead of scored as
|
|
340
|
+
* unsatisfied — a zero the instrument did not observe is not a zero it found.
|
|
341
|
+
*
|
|
342
|
+
* `readRate` is the older measurement restricted to this population: a session
|
|
343
|
+
* counts when ANY detected read landed in it, which is the adoption counter's
|
|
344
|
+
* own definition (`actual > 0`), so the difference between the two numbers is
|
|
345
|
+
* the satisfaction criterion and nothing else.
|
|
346
|
+
*/
|
|
347
|
+
export interface ObligationRate {
|
|
348
|
+
sessions: number;
|
|
349
|
+
allSatisfied: number;
|
|
350
|
+
/** 0-1, rounded to 4 decimals (a percentage point is 2 of these). */
|
|
351
|
+
allSatisfiedRate: number;
|
|
352
|
+
withRead: number;
|
|
353
|
+
readRate: number;
|
|
354
|
+
/** allSatisfiedRate - readRate, in percentage points, 2 decimals. */
|
|
355
|
+
gapPoints: number;
|
|
356
|
+
/** Obligations that applied, across the population. */
|
|
357
|
+
obligations: number;
|
|
358
|
+
unsatisfied: number;
|
|
359
|
+
/** False when the gap is under FALSIFIER_GAP_POINTS: the metric is a copy. */
|
|
360
|
+
discriminating: boolean;
|
|
361
|
+
/** Sessions with an applicable skill but no obligation row: not scored. */
|
|
362
|
+
uninstrumented: number;
|
|
363
|
+
}
|
|
364
|
+
/** Compute both rates over one store's folds. Pure. */
|
|
365
|
+
export declare function computeObligationRate(sessions: SessionApplicability[], obligations: SessionObligation[]): ObligationRate;
|
|
366
|
+
/**
|
|
367
|
+
* The store-wide rate, or undefined when the store carries no obligation row
|
|
368
|
+
* at all. Undefined is the absent record: a reader of a store this build has
|
|
369
|
+
* not written to sees the payload it always saw, byte for byte.
|
|
370
|
+
*/
|
|
371
|
+
export declare function getObligationRate(options?: {
|
|
372
|
+
storePath?: string;
|
|
373
|
+
}): ObligationRate | undefined;
|
|
85
374
|
/** Adoption numbers for one profile in one month. */
|
|
86
375
|
export interface ProfileAdoption {
|
|
87
376
|
/** Sessions active in the month (records with a turn). */
|