Skip to content

Commit 78b8509

Browse files
dmealingclaude
andcommitted
chore(ai): P0 review nits — drop dead optional-payloadRef branch + fix stale trace-helper concept
@payloadRef is loader-required on template.prompt, so the generator's optional-payloadRef fallback (`?? "unknown"`) was dead — add a guard and drop it. Update the registry-conformance fixture's stale "wrapping recordLlmCall" concept to the current extract+buildLlmCallRow+persist description. Emitted output byte-identical for all fixtures (codegen-ts 825/0). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 982e438 commit 78b8509

2 files changed

Lines changed: 9 additions & 9 deletions

File tree

fixtures/generator-registry-conformance/registry.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
"ports": ["typescript"]
7979
},
8080
"trace-helper": {
81-
"concept": "Per-entity typed record<Entity> helper wrapping recordLlmCall (LlmCallBase-derived entities only).",
81+
"concept": "Per-entity typed record<Entity>/call<Entity> trace helpers (extract + buildLlmCallRow + persist; LlmCallBase-derived entities only).",
8282
"tier": "native",
8383
"ports": ["typescript"]
8484
},

server/typescript/packages/codegen-ts/src/generators/trace-helper-file.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,12 @@ export const traceHelperFile = function traceHelperFile(opts?: TraceHelperOpts):
7878
const payloadRef = prompt.ownAttr(TEMPLATE_ATTR_PAYLOAD_REF);
7979
const responseRef = prompt.ownAttr(TEMPLATE_ATTR_RESPONSE_REF);
8080

81-
// Need at least @responseRef to type the result; @payloadRef types the request.
81+
// @responseRef types the result; @payloadRef types the request. @payloadRef
82+
// is loader-required on template.prompt, so this guard is belt-and-suspenders:
83+
// it keeps us from ever emitting a voRequest write for a column that
84+
// deriveTraceFields (which also keys off @payloadRef) didn't inject.
8285
if (typeof responseRef !== "string") return [];
86+
if (typeof payloadRef !== "string") return [];
8387

8488
const entityName = entity.name;
8589
const fnName = `record${pascal(entityName)}`;
@@ -111,14 +115,10 @@ export const traceHelperFile = function traceHelperFile(opts?: TraceHelperOpts):
111115
: "Format.JSON";
112116

113117
// Collect VO names for interface emission (dedupe via batch emitter).
114-
const voNames: string[] = [];
115-
if (typeof payloadRef === "string") voNames.push(payloadRef);
116-
voNames.push(responseRef);
118+
// Both refs are guaranteed strings by the guards above.
119+
const interfaces = generatePayloadInterfacesBatch(ctx.loadedRoot, [payloadRef, responseRef]);
117120

118-
// Emit the shared payload interfaces inline (same approach as prompt-render-file).
119-
const interfaces = generatePayloadInterfacesBatch(ctx.loadedRoot, voNames);
120-
121-
const requestType = typeof payloadRef === "string" ? payloadRef : "unknown";
121+
const requestType = payloadRef;
122122

123123
// A renderable prompt (carries @textRef) gets an additional call<Entity> helper
124124
// that renders the prompt text, calls the LLM, then parses + persists a trace row.

0 commit comments

Comments
 (0)