fix: un-collapse evidence gate 1 from gate 2 to close a raw-Error escape
Fix round 2 (review of 9864958):
Round 1's I2 fix made gate 1 (supportsEvidenceKeyIn) read the same
merged catalog gate 2 already checks, so gate 1 stopped asking "does a
real Asset (or the legacy key) back this key" and started asking the
identical question gate 2 asks ("is there any EVIDENCE catalog row for
it"). A real EVIDENCE catalog row that exists for something other than
media (fixtures.ts's row for a QUESTION resolution target) then passed
gate 1 with nothing backing it as evidence. validateDocument reported
VALID; createPreview's resolver -- which only ever knew the legacy key
and real Assets -- threw a raw, unwrapped Error, violating the port's
StudioGatewayError-only contract. I2's disagreement reproduced in the
opposite direction.
Rebuilt gate 1 in all three callers (validate-working-copy.ts,
adapters/mock/project-public-render-model.ts, instant-preview.tsx) as
"legacy key OR an Asset-derived catalog entry only" -- never the
merged document catalog -- while gate 2 keeps reading the merged
catalog as before. Also stopped emitting the real Asset UUID as the
synthesized CatalogEntry's id (prefixed instead), closing a path where
pasting an Asset's real id -- never something the Picker itself
produces -- would have resolved as an evidence key.
Restored content-format.test.ts's domain tests to exercise the same
gate-1 composition production callers now use instead of a bare
hand-injected predicate, and added coverage for: a real non-asset
EVIDENCE row still being rejected, an Asset-backed key being accepted
with no document-catalog row at all, the fixture-UUID case failing
both mock paths with no raw Error crossing the gateway port, and the
EVIDENCE_ALT_REQUIRED decorative-Asset pairing that had no test.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
98649585e6
commit
7ff9728a5c
@@ -9,6 +9,7 @@ import {
|
||||
projectWorkingCopy,
|
||||
resolveCaseEvidenceAssets,
|
||||
} from "../../../domain/content-format/project-public-render-model.ts";
|
||||
import type { SupportsEvidenceKey } from "../../../domain/public-render-content.ts";
|
||||
import { createAssetCatalogResolver } from "../../shared/public-render/asset-resolvers.ts";
|
||||
import { PublicRecordRenderer } from "../../shared/public-render/public-record-renderer.tsx";
|
||||
import { useStudio } from "../use-studio.ts";
|
||||
@@ -19,16 +20,29 @@ type PublicRenderModel = components["schemas"]["PublicRenderModel"];
|
||||
|
||||
/**
|
||||
* The one legacy key predates the Asset gateway entirely: the document
|
||||
* catalog carries a fixture `EVIDENCE` row for it (so the gates above pass
|
||||
* it), but no `Asset` record backs it, so `assets` never resolves it. Kept
|
||||
* narrow and separate from `supportsEvidenceKeyIn` -- that function decides
|
||||
* whether a document is *allowed* to reference a key; this one only fills in
|
||||
* the one pre-existing key's pixels when nothing else can.
|
||||
* catalog carries a fixture `EVIDENCE` row for it, but no `Asset` record
|
||||
* backs it, so `assets` never resolves it. This is also gate 1's "legacy"
|
||||
* half now (fix round 2) -- see `supportsEvidenceKeyForAssets` below.
|
||||
*/
|
||||
function isLegacyStaticEvidenceKey(key: string): boolean {
|
||||
return key === "fetch-strategy-boundary";
|
||||
}
|
||||
|
||||
/**
|
||||
* Gate 1: "may this document reference this key at all" -- the legacy key,
|
||||
* or a `READY` Asset actually backs it. Deliberately narrower than gate 2
|
||||
* (the merged-catalog lookup `projectWorkingCopy` runs internally): fix
|
||||
* round 1 collapsed this into `supportsEvidenceKeyIn(effectiveCatalog)`,
|
||||
* which made gate 1 ask the same question as gate 2 and let any `EVIDENCE`
|
||||
* catalog row backing something other than an Asset (e.g. a QUESTION
|
||||
* resolution-target row) pass gate 1 with no Asset and no legacy key behind
|
||||
* it. See `asset-evidence-catalog.ts`'s module doc for the shared shape.
|
||||
*/
|
||||
function supportsEvidenceKeyForAssets(assets: readonly Asset[]): SupportsEvidenceKey {
|
||||
const assetOnly = supportsEvidenceKeyIn(evidenceCatalogEntriesFromAssets(assets));
|
||||
return (key: string) => isLegacyStaticEvidenceKey(key) || assetOnly(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* `resolveCaseEvidenceAssets` only needs *a* `ResolvedAsset` to turn the authoring
|
||||
* model into a genuine `PublicRenderModel` -- nothing downstream reads `block.asset`
|
||||
@@ -97,7 +111,7 @@ export function InstantPreview({
|
||||
draft,
|
||||
effectiveCatalog,
|
||||
{ mode: "PREVIEW", publishedAt: null },
|
||||
supportsEvidenceKeyIn(effectiveCatalog),
|
||||
supportsEvidenceKeyForAssets(assets),
|
||||
),
|
||||
resolveAssetDescriptor(assets),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user