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
fix: surface attachment origin/role lineage in the weight-proportionality canon summary (#1624)
[._.]/ Adam Eivy8c2d3191a503
diff --git a/data.reference/prompts/stages/pipeline-editorial-object-weight-proportionality.md b/data.reference/prompts/stages/pipeline-editorial-object-weight-proportionality.mdindex b8b2dea43a..de8064c8da 100644--- a/data.reference/prompts/stages/pipeline-editorial-object-weight-proportionality.md+++ b/data.reference/prompts/stages/pipeline-editorial-object-weight-proportionality.md@@ -25,13 +25,15 @@ no setup at all.## Established objects (canon)-These are the objects the canon records, with the significance and-character attachments already on file. Treat this as the *recorded* weight an-object carries going in; weigh it together with what the prose itself plants and-pays off. An object with deep canon significance and attachments but almost no-presence in the manuscript is a candidate for over-weighting; a manuscript-pivotal-object with thin canon significance and no on-page lineage is a candidate for-under-establishment.+These are the objects the canon records, with the prose significance and each+character attachment already on file — for every attachment, the emotion, its+significance, the **origin** (how that character came to have the object — its+recorded lineage/backstory), and a role archetype. Treat this as the *recorded*+weight an object carries going in; weigh it together with what the prose itself+plants and pays off. An object with deep canon significance, a rich origin, and+attachments but almost no presence in the manuscript is a candidate for+over-weighting; a manuscript-pivotal object with thin canon significance and no+on-page or recorded lineage is a candidate for under-establishment.```{{objects}}diff --git a/server/lib/editorial/checkRegistry.js b/server/lib/editorial/checkRegistry.jsindex 9c8c3c031a..cf0b658e73 100644--- a/server/lib/editorial/checkRegistry.js+++ b/server/lib/editorial/checkRegistry.js@@ -1010,6 +1010,44 @@ function describeObjectAttachments(ctx) {return lines.join('\n') || '(no objects in canon)';}+// A richer per-object weight summary for the weight-proportionality check+// (#1624). Unlike describeObjectAttachments (which the unmotivated-interaction+// check uses to know who already cares about an object), this surfaces the FULL+// recorded weight an object carries going in — the prose significance plus every+// attachment's emotion, per-bond significance, ORIGIN (the lineage/backstory),+// and ROLE archetype — so the model can weigh that recorded backstory against+// how prominent the object actually is in the manuscript. The origin/role fields+// are exactly the "rich recorded backstory for a barely used object" signal the+// over-weighted verdict depends on, which the leaner attachments summary omits.+function describeObjectWeight(ctx) {+ const { objects, nameById } = attachmentCanon(ctx);+ const lines = [];+ for (const o of objects) {+ const atts = Array.isArray(o.attachments) ? o.attachments : [];+ const sig = (o.significance || '').trim();+ const head = `- ${o.name || o.id}${sig ? ` — significance: ${sig}` : ''}`;+ if (!atts.length) {+ lines.push(`${head}\n attachments: none`);+ continue;+ }+ const attLines = atts.map((a) => {+ const who = nameById.get(a.characterId) || a.characterId || 'unknown';+ const emotion = (a.emotion || '').trim();+ const significance = (a.significance || '').trim();+ const origin = (a.origin || '').trim();+ const role = (a.role || '').trim();+ const parts = [+ ` • ${who}${emotion ? ` (${emotion})` : ''}${role ? ` [${role}]` : ''}`,+ ];+ if (significance) parts.push(` significance: ${significance}`);+ if (origin) parts.push(` origin: ${origin}`);+ return parts.join('\n');+ });+ lines.push(`${head}\n${attLines.join('\n')}`);+ }+ return lines.join('\n') || '(no objects in canon)';+}+// The attachment rows whose `origin` can be checked against the attached// character's `background` — both must be present, and the character must// still exist (a dangling characterId is the UI/sanitizer's concern, not this@@ -5118,10 +5156,13 @@ export const EDITORIAL_CHECKS = [],gate: (ctx) => (ctx.manuscript || '').trim().length > 0,run: (ctx) => {- // The per-object canon summary (established significance + attachments) is- // fixed per-call overhead re-sent on each chunk — trimmed by the runner to- // keep the manuscript a budget floor.- const objects = describeObjectAttachments(ctx);+ // The per-object weight summary (prose significance + every attachment's+ // emotion / per-bond significance / origin lineage / role) is fixed per-call+ // overhead re-sent on each chunk — trimmed by the runner to keep the+ // manuscript a budget floor. It surfaces the FULL recorded backstory an+ // object carries (the origin/role fields the leaner attachments summary+ // omits) so the model can weigh that against the object's prose prominence.+ const objects = describeObjectWeight(ctx);return runManuscriptLlmCheck(ctx, {stage: OBJECT_WEIGHT_STAGE,category: 'plot',diff --git a/server/lib/editorial/checkRegistry.test.js b/server/lib/editorial/checkRegistry.test.jsindex 84de5862d3..18aedc5229 100644--- a/server/lib/editorial/checkRegistry.test.js+++ b/server/lib/editorial/checkRegistry.test.js@@ -3507,7 +3507,7 @@ describe('objects.weight-proportionality — LLM check (#1624)', () => {return {manuscript,canon: {- objects: [{ id: 'o1', name: 'Locket', significance: 'an ancestral heirloom', attachments: [{ characterId: 'c1', emotion: 'reverence' }] }],+ objects: [{ id: 'o1', name: 'Locket', significance: 'an ancestral heirloom', attachments: [{ characterId: 'c1', emotion: 'reverence', origin: 'pried from her grandmother\'s coffin', role: 'talisman' }] }],characters: [{ id: 'c1', name: 'Mara' }],},config: { maxFindings: 12 },@@ -3519,7 +3519,7 @@ describe('objects.weight-proportionality — LLM check (#1624)', () => {};};- it('passes the manuscript AND an objects-attachment summary to the model', async () => {+ it('passes the manuscript AND the full per-object weight summary (incl. origin lineage + role) to the model', async () => {let vars = null;await getCheck('objects.weight-proportionality').run(baseCtx({callStagedLLM: async (_stage, v) => { vars = v; return { content: { findings: [] } }; },@@ -3527,6 +3527,9 @@ describe('objects.weight-proportionality — LLM check (#1624)', () => {expect(vars.manuscript).toContain('locket');expect(vars.objects).toContain('Locket');expect(vars.objects).toContain('Mara'); // resolved character name, not the id+ // The recorded lineage/backstory the over-weighted verdict depends on (#1624 review):+ expect(vars.objects).toContain('pried from her grandmother'); // attachment origin+ expect(vars.objects).toContain('talisman'); // attachment role archetype});it('budgets the objects summary as prompt overhead and re-sends it on every chunk', async () => {