Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
test: scope neighbor-volume citations and pin the location-form scan (#4136)
Adam Eivy06d66c9cff9f
diff --git a/server/services/pipeline/arcPlanner/volumeVerifyPromptContract.test.js b/server/services/pipeline/arcPlanner/volumeVerifyPromptContract.test.jsindex d7ca1ab97a..cf93be4215 100644--- a/server/services/pipeline/arcPlanner/volumeVerifyPromptContract.test.js+++ b/server/services/pipeline/arcPlanner/volumeVerifyPromptContract.test.js@@ -18,7 +18,7 @@import { describe, it, expect } from 'vitest';-import { renderVolumeIssue, renderVolumeFields } from './context.js';+import { renderVolumeIssue, renderVolumeFields, sliceSeasonForNeighbor } from './context.js';import { readShippedPrompt, backtickedTokens, namespacedVars } from './promptContractHelpers.js';const PROMPT = 'pipeline-volume-verify.md';@@ -44,26 +44,42 @@ const issueLeafFields = () => new Set([...Object.keys(renderVolumeIssue({ stages: { idea: { input: 'seed synopsis' } } })),]);+const volumeNodeFields = () => new Set(Object.keys(renderVolumeFields({})));++// `neighborsJson` — the immediately-prior/next volumes check #5 reads across the+// boundary. A THIRD renderer feeding this one prompt, and a strict subset of the+// volume node's fields, so the union below can never see it lose one.+const neighborFields = () => new Set(Object.keys(sliceSeasonForNeighbor({})));++// Deliberately NOT unioned with `neighborFields()`: the neighbor shape is a+// subset of the volume node's, so folding it in would only give a dropped volume+// field somewhere else to hide. Scope-specific coverage is `SCOPED_CITATIONS`.const renderableFields = () => new Set([...issueLeafFields(),- ...Object.keys(renderVolumeFields({})),+ ...volumeNodeFields(),]);// Citations the checklist makes in a SPECIFIC scope. The union assertion below-// only proves a cited field is rendered somewhere, which is blind to the case-// codex flagged: `synopsis` exists on both renderers, so either side could drop-// it and the other would mask the loss. These pin the owner. New tokens still-// get caught by the union check — this table only has to carry the names the-// generic scan cannot attribute on its own.+// only proves a cited field is rendered somewhere, which is blind to a name that+// exists on more than one of the three renderers: `synopsis` sits on both the+// issue leaf and the volume node, and `logline`/`endingHook` on both the volume+// node and its neighbors — so any one of them could drop the field and another+// would mask the loss. These pin the owner. New tokens still get caught by the+// union check; this table only carries the names the generic scan cannot+// attribute on its own.const SCOPED_CITATIONS = [// "Each entry has either `beats` … OR just `synopsis`" — the issue leaf.['beats', 'issue leaf', issueLeafFields],['synopsis', 'issue leaf', issueLeafFields],['arcPosition', 'issue leaf', issueLeafFields],// Checks #1/#4/#5 read these off the volume node.- ['logline', 'volume node', () => new Set(Object.keys(renderVolumeFields({})))],- ['synopsis', 'volume node', () => new Set(Object.keys(renderVolumeFields({})))],- ['endingHook', 'volume node', () => new Set(Object.keys(renderVolumeFields({})))],+ ['logline', 'volume node', volumeNodeFields],+ ['synopsis', 'volume node', volumeNodeFields],+ ['endingHook', 'volume node', volumeNodeFields],+ // Check #5 reads the PRIOR volume's `endingHook` and the NEXT volume's+ // `logline` — off the neighbor slice, not the volume under review.+ ['logline', 'neighbor volume', neighborFields],+ ['endingHook', 'neighbor volume', neighborFields],];const unrenderableIn = (markdown, renderable) => [...backtickedTokens(markdown)]@@ -89,23 +105,35 @@ describe('pipeline-volume-verify prompt ↔ buildVolumeVerifyContext contract',expect([...rendered()]).toContain(field);});- it('catches a scoped drop the other renderer would mask (bypass probe)', () => {- // `synopsis` lives on BOTH renderers, so the union assertion alone cannot- // see the issue leaf losing it — the volume node's copy keeps the union- // satisfied while every beat/synopsis-depth check silently loses its input.- const leafWithoutSynopsis = new Set([...issueLeafFields()].filter((f) => f !== 'synopsis'));- const union = new Set([...leafWithoutSynopsis, ...Object.keys(renderVolumeFields({}))]);- expect(union.has('synopsis')).toBe(true); // masked by the volume node…- expect(leafWithoutSynopsis.has('synopsis')).toBe(false); // …but caught here.+ it.each([+ ['issue leaf', 'synopsis', issueLeafFields, volumeNodeFields],+ ['neighbor volume', 'logline', neighborFields, volumeNodeFields],+ ])('catches %s losing %s where another renderer would mask it (bypass probe)', (+ _scope, field, ownFields, maskingFields,+ ) => {+ const stripped = new Set([...ownFields()].filter((f) => f !== field));+ const union = new Set([...stripped, ...maskingFields()]);+ expect(union.has(field)).toBe(true); // masked by the other renderer…+ expect(stripped.has(field)).toBe(false); // …but caught by the scoped check.});it('renders every {{volume.*}} field the prompt interpolates', async () => {const markdown = await readShippedPrompt(PROMPT);- const rendered = new Set(Object.keys(renderVolumeFields({})));+ const rendered = volumeNodeFields();const missing = [...namespacedVars(markdown, 'volume')].filter((v) => !rendered.has(v));expect(missing).toEqual([]);});+ it('reads the field named inside a location form, not just its prefix', () => {+ // `location` values embed a real field on the right of the colon+ // (`episode:<arcPosition>`). Splitting at the colon and stopping there would+ // let a substituted placeholder name a field nothing renders, so the scan+ // has to descend into the angle brackets. Asserted directly because+ // SCOPED_CITATIONS pins `arcPosition` independently and would stay green.+ const tokens = backtickedTokens('Use `episode:<arcPosition>` or `episode:<n>-<n+1>`.');+ expect([...tokens].sort()).toEqual(['arcPosition', 'episode', 'n']);+ });+it('fails when an interpolated volume field is dropped (bypass probe)', () => {// A renamed/removed volume field renders as an empty Mustache slot, so the// prompt silently judges the volume against a blank `endingHook` instead of