Skip to content

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

address review (codex): exempt name-form POV character from reveal-gating

[._.]/ Adam Eivy2a925d3458a4
diff --git a/server/services/pipeline/perspectiveRewrite.js b/server/services/pipeline/perspectiveRewrite.js
index 36d24016dc..9ae0c45602 100644
--- a/server/services/pipeline/perspectiveRewrite.js
+++ b/server/services/pipeline/perspectiveRewrite.js
@@ -115,17 +115,20 @@ function shapeCastEntry(char) {
// writer-facing GENERATIVE prompt (it grounds regenerated prose in the cast's
// full canon, incl. background/personality), so it must reveal-gate the canon
// exactly like `buildStageContext` (#2178) — a later-reveal character's secret
-// must not leak into an earlier issue's rewrite. `keepFullId` (the POV
+// must not leak into an earlier issue's rewrite. `keepFullPov` (the POV
// character being rewritten FROM) is exempt: the narrator knows their own
-// secrets, so they keep their full record even when gated. Absent
-// `issueNumber` = no gate (backward compatible).
-async function resolveCast(series, issueNumber, keepFullId = null) {
+// secrets, so they keep their full record even when gated. The exemption
+// matches the SAME id-OR-name identity the caller resolves the POV with
+// (`c.id === keepFullPov || c.name === keepFullPov`) — otherwise a name-form
+// POV request on a reveal-gated narrator would surface/drop them and either
+// lose their private canon or return `unknown-character`. Absent `issueNumber`
+// = no gate (backward compatible).
+async function resolveCast(series, issueNumber, keepFullPov = null) {
const canon = series ? await getSeriesCanon(series).catch(() => ({ characters: [] })) : { characters: [] };
const chars = Array.isArray(canon.characters) ? canon.characters : [];
+ const isPov = (c) => keepFullPov != null && ((c?.id && c.id === keepFullPov) || (c?.name && c.name === keepFullPov));
const gated = Number.isFinite(issueNumber)
- ? chars.map((c) => (c?.id && c.id === keepFullId
- ? c
- : filterCanonListForIssue([c], 'character', issueNumber)[0]))
+ ? chars.map((c) => (isPov(c) ? c : filterCanonListForIssue([c], 'character', issueNumber)[0]))
.filter(Boolean)
: chars;
return gated.map(shapeCastEntry).filter(Boolean);
diff --git a/server/services/pipeline/perspectiveRewrite.test.js b/server/services/pipeline/perspectiveRewrite.test.js
index f531346663..b638cbfc23 100644
--- a/server/services/pipeline/perspectiveRewrite.test.js
+++ b/server/services/pipeline/perspectiveRewrite.test.js
@@ -143,6 +143,36 @@ describe('generatePerspectiveRewrite', () => {
expect(result.status).toBe('unknown-character');
});
+ it('exempts a reveal-gated POV character from gating even when selected by NAME (#2178)', async () => {
+ // Ada is reveal-gated to a later issue than this one (#3), so without the
+ // name-form exemption she'd be surfaced/dropped and a name-form POV request
+ // would either return unknown-character or lose her full private canon.
+ canonChars = [
+ { id: 'char-ada', name: 'Ada', role: 'protagonist', personality: 'driven', physicalDescription: 'tall', revealIssue: 8, surfaceDescriptor: 'a quiet stranger' },
+ { id: 'char-bly', name: 'Bly', role: 'rival', revealIssue: 8 },
+ ];
+ seedIssue();
+ analysisQueue.push({ oneLine: 'tense' });
+
+ const result = await svc.generatePerspectiveRewrite('iss-1', { povCharacterId: 'Ada' });
+
+ expect(result.status).toBe('complete');
+ expect(result.rewrite.povCharacterName).toBe('Ada');
+ // The POV narrator keeps her full private canon: the rewrite prompt's
+ // povCharacter descriptor still carries her personality (which a surfaced
+ // view would strip). Without the name-form exemption this request would
+ // have returned unknown-character or lost this private context.
+ const povCtx = llmCalls.find((c) => c.stage === 'pipeline-pov-rewrite').ctx.povCharacter;
+ expect(povCtx.name).toBe('Ada');
+ expect(povCtx.descriptor).toContain('Personality: driven');
+ // The prompt's rendered cast roster (gated to this issue) keeps the full POV
+ // narrator but reduces Bly (gated, no surfaceDescriptor, not the POV) — she is
+ // dropped, so her name doesn't appear in the drafting roster.
+ const roster = llmCalls.find((c) => c.stage === 'pipeline-pov-rewrite').ctx.series.characters;
+ expect(roster.map((c) => c.name)).toContain('Ada');
+ expect(roster.map((c) => c.name)).not.toContain('Bly');
+ });
+
it('caps stored rewrites and keeps newest first', async () => {
seedIssue();
for (let i = 0; i < 14; i++) {