@vellumai/assistant 0.9.0-dev.202606170116.ccd16ef → 0.9.0-dev.202606170550.30c1642
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/package.json +1 -1
- package/src/__tests__/skills.test.ts +51 -0
- package/src/config/bundled-skills/workflows/SKILL.md +14 -7
- package/src/config/skills.ts +21 -0
- package/src/memory/v2/__tests__/skill-content.test.ts +30 -0
- package/src/memory/v2/skill-content.ts +25 -7
- package/src/memory/v2/skill-store.ts +7 -1
- package/src/plugins/defaults/memory-v3-shadow/__tests__/orchestrate.test.ts +31 -4
- package/src/plugins/defaults/memory-v3-shadow/orchestrate.ts +32 -20
- package/src/plugins/defaults/memory-v3-shadow/shadow-plugin.ts +23 -1
package/package.json
CHANGED
|
@@ -691,6 +691,57 @@ describe("category frontmatter parsing", () => {
|
|
|
691
691
|
});
|
|
692
692
|
});
|
|
693
693
|
|
|
694
|
+
describe("always-candidate frontmatter parsing", () => {
|
|
695
|
+
beforeEach(() => {
|
|
696
|
+
mkdirSync(join(TEST_DIR, "skills"), { recursive: true });
|
|
697
|
+
});
|
|
698
|
+
|
|
699
|
+
afterEach(() => {
|
|
700
|
+
const skillsDir = join(TEST_DIR, "skills");
|
|
701
|
+
if (existsSync(skillsDir))
|
|
702
|
+
rmSync(skillsDir, { recursive: true, force: true });
|
|
703
|
+
});
|
|
704
|
+
|
|
705
|
+
function writeSkillWithAlwaysCandidate(skillId: string, value: string): void {
|
|
706
|
+
const skillDir = join(TEST_DIR, "skills", skillId);
|
|
707
|
+
mkdirSync(skillDir, { recursive: true });
|
|
708
|
+
const metadata = `{"vellum":{"always-candidate":${value}}}`;
|
|
709
|
+
writeFileSync(
|
|
710
|
+
join(skillDir, "SKILL.md"),
|
|
711
|
+
`---\nname: "${skillId}"\ndescription: "test"\nmetadata: ${metadata}\n---\n\nBody.\n`,
|
|
712
|
+
);
|
|
713
|
+
}
|
|
714
|
+
|
|
715
|
+
test("parses always-candidate: true from metadata.vellum", () => {
|
|
716
|
+
writeSkillWithAlwaysCandidate("pinned", "true");
|
|
717
|
+
const skill = loadUserSkillCatalog().find((s) => s.id === "pinned");
|
|
718
|
+
expect(skill!.alwaysCandidate).toBe(true);
|
|
719
|
+
});
|
|
720
|
+
|
|
721
|
+
test("parses always-candidate: false", () => {
|
|
722
|
+
writeSkillWithAlwaysCandidate("unpinned", "false");
|
|
723
|
+
const skill = loadUserSkillCatalog().find((s) => s.id === "unpinned");
|
|
724
|
+
expect(skill!.alwaysCandidate).toBe(false);
|
|
725
|
+
});
|
|
726
|
+
|
|
727
|
+
test("returns undefined for a non-boolean always-candidate", () => {
|
|
728
|
+
writeSkillWithAlwaysCandidate("bad", '"yes"');
|
|
729
|
+
const skill = loadUserSkillCatalog().find((s) => s.id === "bad");
|
|
730
|
+
expect(skill!.alwaysCandidate).toBeUndefined();
|
|
731
|
+
});
|
|
732
|
+
|
|
733
|
+
test("skill without always-candidate has undefined", () => {
|
|
734
|
+
writeSkill("plain", "Plain", "Test");
|
|
735
|
+
const skill = loadUserSkillCatalog().find((s) => s.id === "plain");
|
|
736
|
+
expect(skill!.alwaysCandidate).toBeUndefined();
|
|
737
|
+
});
|
|
738
|
+
|
|
739
|
+
test("the bundled workflows skill is flagged always-candidate", () => {
|
|
740
|
+
const wf = loadSkillCatalog().find((s) => s.id === "workflows");
|
|
741
|
+
expect(wf?.alwaysCandidate).toBe(true);
|
|
742
|
+
});
|
|
743
|
+
});
|
|
744
|
+
|
|
694
745
|
describe("bundled skill categories", () => {
|
|
695
746
|
test("every bundled skill declares a valid category slug", () => {
|
|
696
747
|
const yamlPath = join(
|
|
@@ -1,18 +1,22 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: workflows
|
|
3
|
-
description:
|
|
3
|
+
description: Delegate a big or high-stakes job to a fleet of parallel subagents, orchestrated deterministically; runs unattended and reports back
|
|
4
4
|
compatibility: "Designed for Vellum personal assistants"
|
|
5
5
|
metadata:
|
|
6
6
|
emoji: "⚙️"
|
|
7
7
|
vellum:
|
|
8
8
|
display-name: "Workflows"
|
|
9
9
|
category: "system"
|
|
10
|
+
always-candidate: true
|
|
10
11
|
activation-hints:
|
|
11
|
-
- "
|
|
12
|
-
- "
|
|
12
|
+
- "Batch — apply one operation to each of MANY items (score / rate / rank / classify / extract / summarize each of a large set)"
|
|
13
|
+
- "Comprehensive coverage — exhaustively sweep, audit, or find EVERY instance across a large surface"
|
|
14
|
+
- "Research & synthesize — gather across many sources or pages and combine into one answer"
|
|
15
|
+
- "Confidence — generate several independent attempts and judge them, or adversarially verify findings before trusting the result"
|
|
16
|
+
- "Scale — work too large to finish well in one inline pass"
|
|
13
17
|
avoid-when:
|
|
14
|
-
- "
|
|
15
|
-
- "
|
|
18
|
+
- "A single inline answer, a quick lookup, or a small one-off"
|
|
19
|
+
- "Interactive, conversational back-and-forth rather than unattended fan-out"
|
|
16
20
|
---
|
|
17
21
|
|
|
18
22
|
A workflow is a short JS/TS script you author that runs in a sandbox and fans work
|
|
@@ -21,8 +25,11 @@ one with `run_workflow` (inline `script` OR saved `name`, exactly one). It retur
|
|
|
21
25
|
`runId` immediately; the run is asynchronous and you are notified in this
|
|
22
26
|
conversation when it completes — **do NOT poll**.
|
|
23
27
|
|
|
24
|
-
Reach for one when a
|
|
25
|
-
|
|
28
|
+
Reach for one when a job is too big, too parallel, or too important for one inline
|
|
29
|
+
pass. That is more than batch/map-reduce over many items — it also covers exhaustively
|
|
30
|
+
sweeping or auditing a large surface, researching across many sources and synthesizing,
|
|
31
|
+
and generating several independent attempts to judge or adversarially verify before
|
|
32
|
+
trusting the result. For a single task or a quick lookup, do it inline.
|
|
26
33
|
|
|
27
34
|
## The script model
|
|
28
35
|
|
package/src/config/skills.ts
CHANGED
|
@@ -47,6 +47,7 @@ const VellumMetadataSchema = z
|
|
|
47
47
|
"activation-hints": z.array(z.string()).optional(),
|
|
48
48
|
"avoid-when": z.array(z.string()).optional(),
|
|
49
49
|
category: z.string().optional(),
|
|
50
|
+
"always-candidate": z.boolean().optional(),
|
|
50
51
|
})
|
|
51
52
|
.passthrough();
|
|
52
53
|
|
|
@@ -109,6 +110,13 @@ export interface SkillSummary {
|
|
|
109
110
|
avoidWhen?: string[];
|
|
110
111
|
/** Category slug declared in frontmatter, used as a fallback when the skill is not in the Vellum catalog. */
|
|
111
112
|
category?: string;
|
|
113
|
+
/**
|
|
114
|
+
* When true, this skill is pinned into the memory-v3 selector's stable-prefix
|
|
115
|
+
* candidate pool every turn (so the selector can choose it even when no
|
|
116
|
+
* retrieval lane surfaces it). For cross-cutting capabilities whose relevance
|
|
117
|
+
* the model must judge, not embedding similarity.
|
|
118
|
+
*/
|
|
119
|
+
alwaysCandidate?: boolean;
|
|
112
120
|
/** Parsed inline command expansion descriptors (`!\`command\``) found in the skill body. */
|
|
113
121
|
inlineCommandExpansions?: InlineCommandExpansion[];
|
|
114
122
|
}
|
|
@@ -227,6 +235,7 @@ interface ParsedFrontmatter {
|
|
|
227
235
|
activationHints?: string[];
|
|
228
236
|
avoidWhen?: string[];
|
|
229
237
|
category?: string;
|
|
238
|
+
alwaysCandidate?: boolean;
|
|
230
239
|
inlineCommandExpansions?: InlineCommandExpansion[];
|
|
231
240
|
}
|
|
232
241
|
|
|
@@ -342,6 +351,11 @@ function parseFrontmatter(
|
|
|
342
351
|
? vellum.category.trim()
|
|
343
352
|
: undefined;
|
|
344
353
|
|
|
354
|
+
const alwaysCandidate =
|
|
355
|
+
typeof vellum?.["always-candidate"] === "boolean"
|
|
356
|
+
? vellum["always-candidate"]
|
|
357
|
+
: undefined;
|
|
358
|
+
|
|
345
359
|
const strippedBody = stripCommentLines(body);
|
|
346
360
|
|
|
347
361
|
// Parse inline command expansions from the body (after frontmatter/comment stripping)
|
|
@@ -366,6 +380,7 @@ function parseFrontmatter(
|
|
|
366
380
|
activationHints,
|
|
367
381
|
avoidWhen,
|
|
368
382
|
category,
|
|
383
|
+
alwaysCandidate,
|
|
369
384
|
inlineCommandExpansions,
|
|
370
385
|
};
|
|
371
386
|
}
|
|
@@ -523,6 +538,7 @@ function readSkillFromDirectory(
|
|
|
523
538
|
activationHints: parsed.activationHints,
|
|
524
539
|
avoidWhen: parsed.avoidWhen,
|
|
525
540
|
category: parsed.category,
|
|
541
|
+
alwaysCandidate: parsed.alwaysCandidate,
|
|
526
542
|
inlineCommandExpansions: parsed.inlineCommandExpansions,
|
|
527
543
|
};
|
|
528
544
|
} catch (err) {
|
|
@@ -576,6 +592,7 @@ function readBundledSkillFromDirectory(
|
|
|
576
592
|
activationHints: parsed.activationHints,
|
|
577
593
|
avoidWhen: parsed.avoidWhen,
|
|
578
594
|
category: parsed.category,
|
|
595
|
+
alwaysCandidate: parsed.alwaysCandidate,
|
|
579
596
|
inlineCommandExpansions: parsed.inlineCommandExpansions,
|
|
580
597
|
};
|
|
581
598
|
} catch (err) {
|
|
@@ -637,6 +654,7 @@ function loadBundledSkills(): SkillSummary[] {
|
|
|
637
654
|
activationHints: skill.activationHints,
|
|
638
655
|
avoidWhen: skill.avoidWhen,
|
|
639
656
|
category: skill.category,
|
|
657
|
+
alwaysCandidate: skill.alwaysCandidate,
|
|
640
658
|
inlineCommandExpansions: skill.inlineCommandExpansions,
|
|
641
659
|
});
|
|
642
660
|
}
|
|
@@ -764,6 +782,7 @@ function skillSummaryFromDefinition(
|
|
|
764
782
|
activationHints: skill.activationHints,
|
|
765
783
|
avoidWhen: skill.avoidWhen,
|
|
766
784
|
category: skill.category,
|
|
785
|
+
alwaysCandidate: skill.alwaysCandidate,
|
|
767
786
|
inlineCommandExpansions: skill.inlineCommandExpansions,
|
|
768
787
|
};
|
|
769
788
|
}
|
|
@@ -818,6 +837,7 @@ export function loadSkillCatalog(
|
|
|
818
837
|
activationHints: parsed.activationHints,
|
|
819
838
|
avoidWhen: parsed.avoidWhen,
|
|
820
839
|
category: parsed.category,
|
|
840
|
+
alwaysCandidate: parsed.alwaysCandidate,
|
|
821
841
|
inlineCommandExpansions: parsed.inlineCommandExpansions,
|
|
822
842
|
});
|
|
823
843
|
} catch (err) {
|
|
@@ -954,6 +974,7 @@ export function loadSkillCatalog(
|
|
|
954
974
|
activationHints: parsed.activationHints,
|
|
955
975
|
avoidWhen: parsed.avoidWhen,
|
|
956
976
|
category: parsed.category,
|
|
977
|
+
alwaysCandidate: parsed.alwaysCandidate,
|
|
957
978
|
inlineCommandExpansions: parsed.inlineCommandExpansions,
|
|
958
979
|
};
|
|
959
980
|
|
|
@@ -45,6 +45,36 @@ describe("buildSkillContent", () => {
|
|
|
45
45
|
const out = buildSkillContent(input);
|
|
46
46
|
expect(out.length).toBeLessThanOrEqual(500);
|
|
47
47
|
});
|
|
48
|
+
|
|
49
|
+
test("respects a larger maxChars budget", async () => {
|
|
50
|
+
const { buildSkillContent } = await import("../skill-content.js");
|
|
51
|
+
const input: SkillCapabilityInput = {
|
|
52
|
+
id: "example-skill",
|
|
53
|
+
displayName: "Example Skill",
|
|
54
|
+
description: "x".repeat(1000),
|
|
55
|
+
};
|
|
56
|
+
const out = buildSkillContent(input, 900);
|
|
57
|
+
expect(out.length).toBeLessThanOrEqual(900);
|
|
58
|
+
expect(out.length).toBeGreaterThan(500);
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
test("renders hints as a bulleted list when the budget is enlarged", async () => {
|
|
62
|
+
const { buildSkillContent } = await import("../skill-content.js");
|
|
63
|
+
const input: SkillCapabilityInput = {
|
|
64
|
+
id: "wf",
|
|
65
|
+
displayName: "Workflows",
|
|
66
|
+
description: "Delegate a big job",
|
|
67
|
+
activationHints: ["Batch many items", "Exhaustive sweep"],
|
|
68
|
+
avoidWhen: ["A single lookup"],
|
|
69
|
+
};
|
|
70
|
+
const rich = buildSkillContent(input, 900);
|
|
71
|
+
expect(rich).toContain("Use when:\n- Batch many items\n- Exhaustive sweep");
|
|
72
|
+
expect(rich).toContain("Avoid when:\n- A single lookup");
|
|
73
|
+
// The default (500) budget keeps the compact inline form.
|
|
74
|
+
expect(buildSkillContent(input)).toContain(
|
|
75
|
+
"Use when: Batch many items; Exhaustive sweep.",
|
|
76
|
+
);
|
|
77
|
+
});
|
|
48
78
|
});
|
|
49
79
|
|
|
50
80
|
describe("augmentMcpSetupDescription", () => {
|
|
@@ -1,22 +1,40 @@
|
|
|
1
1
|
import { getConfig } from "../../config/loader.js";
|
|
2
2
|
import type { SkillCapabilityInput } from "../../skills/skill-memory.js";
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Character budget for an always-candidate skill's capability statement. Larger
|
|
6
|
+
* than the default so a cross-cutting skill (pinned into the selector pool every
|
|
7
|
+
* turn) can describe its full range of uses rather than a single mode — see
|
|
8
|
+
* `buildSkillContent`'s `maxChars` and `skill-store.ts`'s seeding loop.
|
|
9
|
+
*/
|
|
10
|
+
export const ALWAYS_CANDIDATE_CARD_CHARS = 900;
|
|
11
|
+
|
|
4
12
|
/**
|
|
5
13
|
* Render the prose-style capability statement embedded into the unified
|
|
6
14
|
* `memory_v2_concept_pages` Qdrant collection (under the `skills/<id>` slug
|
|
7
|
-
* prefix) and rendered in `### Skills You Can Use
|
|
8
|
-
*
|
|
15
|
+
* prefix) and rendered in `### Skills You Can Use` / the memory-v3 selector
|
|
16
|
+
* card. Capped at `maxChars` (default 500). A larger budget switches the hints
|
|
17
|
+
* to a bulleted list — easier for the selector to parse one mode per line — so
|
|
18
|
+
* always-candidate skills can carry a fuller, multi-mode description.
|
|
9
19
|
*/
|
|
10
|
-
export function buildSkillContent(
|
|
20
|
+
export function buildSkillContent(
|
|
21
|
+
input: SkillCapabilityInput,
|
|
22
|
+
maxChars = 500,
|
|
23
|
+
): string {
|
|
24
|
+
const list = maxChars > 500;
|
|
11
25
|
let content = `The "${input.displayName}" skill (${input.id}) is available. ${input.description}.`;
|
|
12
26
|
if (input.activationHints && input.activationHints.length > 0) {
|
|
13
|
-
content +=
|
|
27
|
+
content += list
|
|
28
|
+
? `\nUse when:\n${input.activationHints.map((h) => `- ${h}`).join("\n")}`
|
|
29
|
+
: ` Use when: ${input.activationHints.join("; ")}.`;
|
|
14
30
|
}
|
|
15
31
|
if (input.avoidWhen && input.avoidWhen.length > 0) {
|
|
16
|
-
content +=
|
|
32
|
+
content += list
|
|
33
|
+
? `\nAvoid when:\n${input.avoidWhen.map((a) => `- ${a}`).join("\n")}`
|
|
34
|
+
: ` Avoid when: ${input.avoidWhen.join("; ")}.`;
|
|
17
35
|
}
|
|
18
|
-
if (content.length >
|
|
19
|
-
content = content.slice(0,
|
|
36
|
+
if (content.length > maxChars) {
|
|
37
|
+
content = content.slice(0, maxChars);
|
|
20
38
|
}
|
|
21
39
|
return content;
|
|
22
40
|
}
|
|
@@ -41,6 +41,7 @@ import {
|
|
|
41
41
|
upsertConceptPageEmbedding,
|
|
42
42
|
} from "./qdrant.js";
|
|
43
43
|
import {
|
|
44
|
+
ALWAYS_CANDIDATE_CARD_CHARS,
|
|
44
45
|
augmentMcpSetupDescription,
|
|
45
46
|
buildSkillContent,
|
|
46
47
|
} from "./skill-content.js";
|
|
@@ -188,7 +189,12 @@ async function runSeedV2SkillEntries(generation: number): Promise<void> {
|
|
|
188
189
|
if (flagKey && !isAssistantFeatureFlagEnabled(flagKey, config)) continue;
|
|
189
190
|
|
|
190
191
|
const augmented = augmentMcpSetupDescription(fromSkillSummary(summary));
|
|
191
|
-
|
|
192
|
+
// Always-candidate skills are pinned into the selector pool every turn, so
|
|
193
|
+
// they get a larger budget for a fuller, multi-mode capability statement.
|
|
194
|
+
const content = buildSkillContent(
|
|
195
|
+
augmented,
|
|
196
|
+
summary.alwaysCandidate ? ALWAYS_CANDIDATE_CARD_CHARS : undefined,
|
|
197
|
+
);
|
|
192
198
|
seeds.push({ id: summary.id, content });
|
|
193
199
|
}
|
|
194
200
|
|
|
@@ -128,11 +128,11 @@ function depsOf(
|
|
|
128
128
|
const coreSlugs = overrides.coreSlugs ?? [];
|
|
129
129
|
const hotSlugs = overrides.hotSlugs ?? [];
|
|
130
130
|
const freshSlugs = overrides.freshSlugs ?? [];
|
|
131
|
+
const alwaysCandidateSlugs = overrides.alwaysCandidateSlugs ?? [];
|
|
131
132
|
const prefixCards = new Map<Slug, string>(
|
|
132
|
-
[...coreSlugs, ...hotSlugs, ...freshSlugs].map(
|
|
133
|
-
slug,
|
|
134
|
-
|
|
135
|
-
]),
|
|
133
|
+
[...coreSlugs, ...hotSlugs, ...freshSlugs, ...alwaysCandidateSlugs].map(
|
|
134
|
+
(slug) => [slug, renderCard(slug, RAW[slug] ?? "")],
|
|
135
|
+
),
|
|
136
136
|
);
|
|
137
137
|
return {
|
|
138
138
|
sectionIndex: lanes.sectionIndex,
|
|
@@ -307,6 +307,33 @@ describe("orchestrate — candidate pool composition", () => {
|
|
|
307
307
|
expect(lastPool).toContain(CAP);
|
|
308
308
|
});
|
|
309
309
|
|
|
310
|
+
test("always-candidate slugs are pinned into the stable prefix and are selectable", async () => {
|
|
311
|
+
const lanes = await buildLanes();
|
|
312
|
+
const WF: Slug = "skills/workflows";
|
|
313
|
+
// No retrieval lane surfaces WF for "apple" (hits topic-a/b/d) — it reaches
|
|
314
|
+
// the selector ONLY because it is an always-candidate.
|
|
315
|
+
providerStub = selectProvider([WF]);
|
|
316
|
+
const result = await orchestrate(
|
|
317
|
+
makeTurn(1, "apple"),
|
|
318
|
+
depsOf(lanes, { alwaysCandidateSlugs: [WF] }),
|
|
319
|
+
);
|
|
320
|
+
|
|
321
|
+
expect(lastPool).toContain(WF);
|
|
322
|
+
expect(result.selections.map((s) => s.slug)).toContain(WF);
|
|
323
|
+
});
|
|
324
|
+
|
|
325
|
+
test("an always-candidate slug already in core is not double-listed", async () => {
|
|
326
|
+
const lanes = await buildLanes();
|
|
327
|
+
const WF: Slug = "skills/workflows";
|
|
328
|
+
providerStub = selectProvider([]);
|
|
329
|
+
await orchestrate(
|
|
330
|
+
makeTurn(1, "apple"),
|
|
331
|
+
depsOf(lanes, { coreSlugs: [WF], alwaysCandidateSlugs: [WF] }),
|
|
332
|
+
);
|
|
333
|
+
|
|
334
|
+
expect(lastPool.filter((s) => s === WF)).toHaveLength(1);
|
|
335
|
+
});
|
|
336
|
+
|
|
310
337
|
test("edge curated link description becomes the edge candidate's descriptor", async () => {
|
|
311
338
|
const lanes = await buildLanes();
|
|
312
339
|
providerStub = selectProvider([]);
|
|
@@ -18,9 +18,10 @@
|
|
|
18
18
|
* Each lane only ever ADDS candidates, so the pool is recall-safe by
|
|
19
19
|
* construction.
|
|
20
20
|
* 2. Build the candidate pool in CACHE ORDER: the stable prefix —
|
|
21
|
-
* `[...core (file order), ...hot (score order), ...fresh (recency
|
|
22
|
-
*
|
|
23
|
-
* candidates (needle → dense → edge
|
|
21
|
+
* `[...core (file order), ...hot (score order), ...fresh (recency order),
|
|
22
|
+
* ...always-candidate (skills pinned every turn)]`, all computed at lane
|
|
23
|
+
* init — followed by the finder candidates (needle → dense → edge
|
|
24
|
+
* surfacing order). The stable prefix
|
|
24
25
|
* is identical across consecutive turns while the lanes are unchanged
|
|
25
26
|
* (lane invalidation at consolidation is the recompute cadence), so the
|
|
26
27
|
* selector input's leading segment rides the provider KV cache (the
|
|
@@ -82,6 +83,10 @@ export interface OrchestrateDeps {
|
|
|
82
83
|
/** The modification-recency fresh set in recency order (computed at lane
|
|
83
84
|
* init with core and hot excluded). Follows hot in the stable prefix. */
|
|
84
85
|
freshSlugs: Slug[];
|
|
86
|
+
/** Skills pinned into the candidate pool every turn regardless of retrieval
|
|
87
|
+
* (existence-filtered and core/hot/fresh-excluded at lane init). Follow fresh
|
|
88
|
+
* in the stable prefix so the selector always sees them. */
|
|
89
|
+
alwaysCandidateSlugs?: Slug[];
|
|
85
90
|
/** Pre-rendered FULL cards for the stable-prefix slugs, keyed by slug.
|
|
86
91
|
* Rendered ONCE at lane init so the selector's stable prefix is
|
|
87
92
|
* byte-identical across turns (the cache contract). Every core/hot/fresh
|
|
@@ -172,14 +177,19 @@ export async function orchestrate(
|
|
|
172
177
|
const { sections } = deps.sectionIndex;
|
|
173
178
|
|
|
174
179
|
// The stable prefix: core (file order), hot (score order), fresh (recency
|
|
175
|
-
// order). Hot is computed with core excluded at
|
|
176
|
-
//
|
|
177
|
-
//
|
|
180
|
+
// order), then always-candidate skills. Hot is computed with core excluded at
|
|
181
|
+
// lane init, fresh with both excluded, always-candidate with all three
|
|
182
|
+
// excluded; the filters here are a cheap defensive dedup so a misbehaving lane
|
|
183
|
+
// can never double-list a slug.
|
|
178
184
|
const core = deps.coreSlugs;
|
|
179
185
|
const hot = deps.hotSlugs.filter((slug) => !core.includes(slug));
|
|
180
186
|
const coreHot = new Set<Slug>([...core, ...hot]);
|
|
181
187
|
const fresh = deps.freshSlugs.filter((slug) => !coreHot.has(slug));
|
|
182
|
-
const
|
|
188
|
+
const coreHotFresh = new Set<Slug>([...coreHot, ...fresh]);
|
|
189
|
+
const always = (deps.alwaysCandidateSlugs ?? []).filter(
|
|
190
|
+
(slug) => !coreHotFresh.has(slug),
|
|
191
|
+
);
|
|
192
|
+
const stablePrefix = new Set<Slug>([...coreHotFresh, ...always]);
|
|
183
193
|
|
|
184
194
|
// Step 1: needle (sync BM25) and dense (async embed + Qdrant) lanes run in
|
|
185
195
|
// parallel. Both return distinct articles each tagged with their best-scoring
|
|
@@ -342,19 +352,21 @@ export async function orchestrate(
|
|
|
342
352
|
// its own snippet line so its CURRENT relevance stays visible; `selectPool`
|
|
343
353
|
// dedupes selections by slug. Finder candidates with no match text fall
|
|
344
354
|
// back to the page's lead-section snippet.
|
|
345
|
-
const stable: StableCandidate[] = [...core, ...hot, ...fresh].map(
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
355
|
+
const stable: StableCandidate[] = [...core, ...hot, ...fresh, ...always].map(
|
|
356
|
+
(slug) => {
|
|
357
|
+
const card = deps.prefixCards.get(slug);
|
|
358
|
+
if (card === undefined) {
|
|
359
|
+
// Lane init renders a card for every core/hot slug; a hole here means
|
|
360
|
+
// the lanes and the card map are out of sync. Throw rather than render
|
|
361
|
+
// a degraded card — the caller (observeTurn) logs and skips the turn,
|
|
362
|
+
// which is better than silently breaking the byte-stable prefix.
|
|
363
|
+
throw new Error(
|
|
364
|
+
`memory-v3: no pre-rendered card for stable-prefix slug "${slug}"`,
|
|
365
|
+
);
|
|
366
|
+
}
|
|
367
|
+
return { slug, card };
|
|
368
|
+
},
|
|
369
|
+
);
|
|
358
370
|
const finderTail: PoolCandidate[] = finder.map((c) => ({
|
|
359
371
|
slug: c.slug,
|
|
360
372
|
lane: c.lane,
|
|
@@ -34,6 +34,7 @@ import { existsSync, readFileSync } from "node:fs";
|
|
|
34
34
|
import { isAssistantFeatureFlagEnabled } from "../../../config/assistant-feature-flags.js";
|
|
35
35
|
import { getConfig } from "../../../config/loader.js";
|
|
36
36
|
import type { AssistantConfig } from "../../../config/schema.js";
|
|
37
|
+
import { loadSkillCatalog } from "../../../config/skills.js";
|
|
37
38
|
import { getMessages } from "../../../memory/conversation-crud.js";
|
|
38
39
|
import { getDb, getSqliteFrom } from "../../../memory/db-connection.js";
|
|
39
40
|
import { stringifyMessageContent } from "../../../memory/message-content.js";
|
|
@@ -107,6 +108,9 @@ export interface ShadowLanes {
|
|
|
107
108
|
/** Modification-recency fresh set in recency order: core and hot excluded,
|
|
108
109
|
* filtered to pages in the section index. */
|
|
109
110
|
freshSlugs: string[];
|
|
111
|
+
/** Skills pinned into the stable prefix every turn (`always-candidate: true`
|
|
112
|
+
* in SKILL.md), existence-filtered and core/hot/fresh-excluded. */
|
|
113
|
+
alwaysCandidateSlugs: string[];
|
|
110
114
|
/** Learned-edge graph: co-selection NPMI associations over the selection
|
|
111
115
|
* log, rebuilt with the lanes (the consolidation cadence). */
|
|
112
116
|
learnedGraph: EdgeGraph;
|
|
@@ -216,6 +220,18 @@ async function initLanes(config: AssistantConfig): Promise<ShadowLanes> {
|
|
|
216
220
|
excludeSlugs: new Set([...coreSlugs, ...hotSlugs]),
|
|
217
221
|
}).filter((slug) => sectionIndex.byArticle.has(slug));
|
|
218
222
|
|
|
223
|
+
// Always-candidate skills are pinned into the stable prefix every turn so the
|
|
224
|
+
// selector can choose a cross-cutting capability (e.g. workflows) even when no
|
|
225
|
+
// retrieval lane surfaces it — its relevance is a judgment the model makes,
|
|
226
|
+
// not something embedding similarity finds. Filtered to skills present in the
|
|
227
|
+
// section index and excluded from core/hot/fresh so the prefix never
|
|
228
|
+
// double-lists a slug.
|
|
229
|
+
const prefixSet = new Set([...coreSlugs, ...hotSlugs, ...freshSlugs]);
|
|
230
|
+
const alwaysCandidateSlugs = loadSkillCatalog()
|
|
231
|
+
.filter((summary) => summary.alwaysCandidate === true)
|
|
232
|
+
.map((summary) => `skills/${summary.id}`)
|
|
233
|
+
.filter((slug) => sectionIndex.byArticle.has(slug) && !prefixSet.has(slug));
|
|
234
|
+
|
|
219
235
|
// Pre-render the stable-prefix cards ONCE per lane build: the selector's
|
|
220
236
|
// stable prefix must be byte-identical across turns to ride the provider KV
|
|
221
237
|
// cache, so the cards are frozen here (lane invalidation at consolidation is
|
|
@@ -228,7 +244,10 @@ async function initLanes(config: AssistantConfig): Promise<ShadowLanes> {
|
|
|
228
244
|
const modifiedAtBySlug = new Map(
|
|
229
245
|
pageIndex.entries.map((entry) => [entry.slug, entry.modifiedAt]),
|
|
230
246
|
);
|
|
231
|
-
const laneAnnotation = (
|
|
247
|
+
const laneAnnotation = (
|
|
248
|
+
slug: Slug,
|
|
249
|
+
lane: "core" | "hot" | "fresh" | "always",
|
|
250
|
+
) => {
|
|
232
251
|
if (lane !== "fresh") return `[lane: ${lane}]`;
|
|
233
252
|
const modifiedAt = modifiedAtBySlug.get(slug);
|
|
234
253
|
if (
|
|
@@ -249,6 +268,7 @@ async function initLanes(config: AssistantConfig): Promise<ShadowLanes> {
|
|
|
249
268
|
["core", coreSlugs],
|
|
250
269
|
["hot", hotSlugs],
|
|
251
270
|
["fresh", freshSlugs],
|
|
271
|
+
["always", alwaysCandidateSlugs],
|
|
252
272
|
] as const) {
|
|
253
273
|
for (const slug of slugs) {
|
|
254
274
|
const raw = await capabilityOrDiskBody(
|
|
@@ -303,6 +323,7 @@ async function initLanes(config: AssistantConfig): Promise<ShadowLanes> {
|
|
|
303
323
|
coreSlugs,
|
|
304
324
|
hotSlugs,
|
|
305
325
|
freshSlugs,
|
|
326
|
+
alwaysCandidateSlugs,
|
|
306
327
|
prefixCards,
|
|
307
328
|
};
|
|
308
329
|
}
|
|
@@ -545,6 +566,7 @@ export async function observeTurn(
|
|
|
545
566
|
coreSlugs: lanes.coreSlugs,
|
|
546
567
|
hotSlugs: lanes.hotSlugs,
|
|
547
568
|
freshSlugs: lanes.freshSlugs,
|
|
569
|
+
alwaysCandidateSlugs: lanes.alwaysCandidateSlugs,
|
|
548
570
|
prefixCards: lanes.prefixCards,
|
|
549
571
|
needleK: v3.needleK,
|
|
550
572
|
denseK: v3.denseK,
|