feat(workflow-mount): run-scoped routes and agent tools accept metadata - #19
Merged
TheGreatAxios merged 1 commit intoSep 20, 2026
Conversation
…tools Run-scoped create/binary/revise and the artifact_create/artifact_write tool definitions carried no metadata field, forcing a workflow run to lose whatever project/stage context the browser mount already lets a human attach. Reuse mount.ts's exact metadata shape and semantics: omitted carries the prior version forward on revise, explicit null clears it, anything else must be a JSON object. source and generatedBy stay server-stamped from the resolved run scope regardless of what a body sends. createFileArtifact (uploads.ts) gained an optional metadata pass-through so the binary create route can stamp it on version 1 without a second write or duplicating the single MIME/content-store choke point it already guards.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
CL-8722.
mount.ts(the browser-facing mount) already accepts optionalmetadataonPOST /artifactsandPOST /artifacts/:id/versions, but the run-scoped mount (workflow-mount.ts) and the agent tool definitions intools.tshad no metadata surface at all — a workflow run had no way to attach application metadata (e.g. which project/stage an artifact belongs to) the way a human caller already can.Change
workflow-mount.ts:CreateWorkflowArtifactBody,CreateWorkflowBinaryArtifactBody, andReviseWorkflowArtifactBodyall gain an optionalmetadatafield, reusing the exactMetadataShape.or("null")shapemount.tsvalidates with.ReviseWorkflowArtifactBodyalso gains a.narrowrequiring at least one of title/content/metadata, matchingReviseArtifactRequest.uploads.ts:createFileArtifactgains an optionalmetadatapass-through tocreateArtifact, soPOST /artifacts/binarycan stamp metadata on version 1 in the same transaction, rather than bypassing the single MIME/content-store choke point the module's doc comment calls out as the "ONE way a file becomes an artifact."tools.ts:artifact_createandartifact_writeinARTIFACT_TOOL_DEFINITIONSgain an optionalmetadataobject parameter with a one-line description.sidecar-bundle.ts:requestForforwardsmetadatato theartifact_create/artifact_writerequests unchanged when present, omitted otherwise.Semantics (unchanged from
mount.ts)metadataomitted or explicitnullboth storenull; an object is stored as-is.nullclears it; an object replaces it.400.source({ origin: "workflow", runId }) andgeneratedByare always built from the resolved run scope in the handler, never read off the request body — a body field namedsource,runId, orgeneratedByhas no effect, same as before this change.Verification
Ran locally (no local Postgres, per repo policy):
bun run typecheck— cleanbun run build— cleanbun run scripts/check-deps.ts— cleanbun test src/sidecar-bundle.test.ts src/destructive-tests-gate.test.ts— 30 pass (the only Postgres-free suites touched)Postgres-backed suites (
workflow-mount.test.ts,uploads.test.ts,tools.test.ts,mount.test.tsunchanged) fail closed locally by design (ALLOW_DESTRUCTIVE_ARTIFACT_TESTSunset) and run only in CI: new tests cover metadata persisting on version 1 (text + binary create), revise carry-forward/clear/reject, the tool-definition schema, sidecar pass-through, and a body that tries to smugglesource/runId/generatedByon create (asserts the storedsourcestays server-stamped).Reference CL-8722.