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 (claude): cap corrective-description schema to the real per-kind limit

[._.]/ Adam Eivyf2da4e37f693
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index 5883df328f..424b75d551 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -13,3 +13,4 @@
## Universe canon corrective reference images
- [issue-3103] Any Cast, Place, or Object entry in a Universe's bible can now take a corrective reference image: upload or pick a photo/render that shows what it should actually look like, and a vision model compares it against the entry's current description and proposes a correction. Reviewing and applying it both fixes the description and pins the image as that entry's reference image, so future renders for it are visually anchored to the correction instead of starting from scratch each time.
+- Reference-image pinning (the star toggle on a canon entry's thumbnail) now feeds every future render of that entry, not just its thumbnail — if you'd already pinned a reference image before this update, its next render will be visually anchored to that image too.
diff --git a/client/src/components/universe/CorrectiveReferenceModal.jsx b/client/src/components/universe/CorrectiveReferenceModal.jsx
index ac01c52033..e471c945e6 100644
--- a/client/src/components/universe/CorrectiveReferenceModal.jsx
+++ b/client/src/components/universe/CorrectiveReferenceModal.jsx
@@ -161,6 +161,7 @@ export default function CorrectiveReferenceModal({
value={proposedText}
onChange={(e) => setProposedText(e.target.value)}
rows={6}
+ maxLength={2000}
className="w-full rounded border border-port-accent/30 p-2 text-xs text-gray-200 whitespace-pre-wrap bg-port-bg"
/>
</div>
diff --git a/server/routes/universeBuilder.js b/server/routes/universeBuilder.js
index dff80e67dc..417a83c5a8 100644
--- a/server/routes/universeBuilder.js
+++ b/server/routes/universeBuilder.js
@@ -810,8 +810,12 @@ router.post('/:id/canon/:kind/:entryId/correct-from-image', asyncHandler(async (
// descriptor field with the reviewed text AND pins the analyzed image as the
// entry's `primaryImageRef` — assigning it as that noun's style/reference
// image so subsequent renders (client-side i2i seeding) use it.
+// Cap at the largest per-kind descriptor limit (canonSvc.DESC_LIMIT) rather
+// than the unrelated NOTES_MAX — applyCanonImageCorrection silently trims to
+// the per-kind limit before persisting, so a looser schema cap here would let
+// a request pass validation only to have its tail silently dropped on write.
const applyImageCorrectionSchema = z.object({
- description: z.string().trim().min(1).max(BIBLE_LIMITS.NOTES_MAX),
+ description: z.string().trim().min(1).max(Math.max(...Object.values(canonSvc.DESC_LIMIT))),
imageFilename: z.string().trim().min(1).max(300),
});
router.post('/:id/canon/:kind/:entryId/apply-image-correction', asyncHandler(async (req, res) => {
diff --git a/server/routes/universeBuilder.test.js b/server/routes/universeBuilder.test.js
index aa4ab3e448..0cab0ed9aa 100644
--- a/server/routes/universeBuilder.test.js
+++ b/server/routes/universeBuilder.test.js
@@ -4,6 +4,7 @@ import { request } from '../lib/testHelper.js';
import { errorMiddleware } from '../lib/errorHandler.js';
import { enqueueJob } from '../services/mediaJobQueue/index.js';
import { mockNoPeers, mockNoPeerSync } from '../lib/mockPathsDataRoot.js';
+import * as canonSvc from '../services/universeCanon.js';
const fileStore = new Map();
@@ -1301,6 +1302,16 @@ describe('universe-builder routes', () => {
expect(res.status).toBe(400);
expect(applyCanonImageCorrectionMock).not.toHaveBeenCalled();
});
+
+ it('rejects a description over the largest per-kind descriptor limit, so it 400s instead of silently truncating on write', async () => {
+ applyCanonImageCorrectionMock.mockClear();
+ const tooLong = 'x'.repeat(Math.max(...Object.values(canonSvc.DESC_LIMIT)) + 1);
+ const res = await request(buildApp())
+ .post('/api/universe-builder/uni-1/canon/character/chr-1/apply-image-correction')
+ .send({ description: tooLong, imageFilename: 'g.png' });
+ expect(res.status).toBe(400);
+ expect(applyCanonImageCorrectionMock).not.toHaveBeenCalled();
+ });
});
describe('POST /refine-prompts (style-reference image)', () => {