feat(test): rendered commands at the cli-dispatch proof level (#253) - #266
Conversation
🦋 Changeset detectedLatest commit: 113aba9 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
commit: |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 113aba92f5
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (!Number.isInteger(record['sequence'])) { | ||
| throw new SyntaxError('NDJSON render events must carry an integer sequence.'); | ||
| } | ||
| switch (record['type']) { |
There was a problem hiding this comment.
Validate NDJSON event payloads before casting
When stdout contains an object such as {"sequence":0,"type":"complete"}—for example from a plain command or a truncated stream—this switch accepts it and casts it to CliRenderedEvent even though the required document is absent. Consumers can then trust the exported union type and fail while accessing its fields; validate the required payload for each discriminator before returning the events.
Useful? React with 👍 / 👎.
| modulePath: firstDescriptor.source, | ||
| relativePath: firstDescriptor.relativePath, |
There was a problem hiding this comment.
Derive provenance from the executed rendered command
In a project with multiple rendered commands, this host permanently takes modulePath and relativePath from the first rendered command. When a later command has an invalid default export or missing schema, prepareCliRenderHost replaces only routeId, so the resulting diagnostic names the invoked route but points to the first route's source file; construct provenance from the current command's manifest descriptor instead.
Useful? React with 👍 / 👎.
Closes #253. Consumer-harness follow-up to #102 stage 3 (#186): the public
agent-bundle/testharness now proves rendered (.tsx) CLI commands at thecli-dispatchproof level.What changed
invokeClidispatches rendered commands through the product's own shell (runGeneratedCliEntry): when the manifest carries rendered commands, the harness preloads their route modules and installs an in-process render session mirroring the generated executable's worker-backed one — same invocation shape ({ kind: 'cli', props: { args, command } }), same request scope (operationId/surface, cwd-derived workspace per fix(test): honest registry version gate, binary-faithful CLI cwd, README field #206), samevalidate(resultSchema.parse), and the same synchronousinputSchema.parseinside the render factory so an input rejection stays a usage failure (exit 2), exactly like the generatedrenderbridge inentry-shell.ts.render.tsgains one shared Flight-dispatcher wiring (createFlightDispatcher+prepareCliRenderHost) used by bothrenderRoute/renderRouteEventsand the CLI session, includingmountManifestStateparity with the generated rendered worker (pinned by the fixture'sstateMounted: z.literal(true)).InvokeCliOptions.tty(explicit interactive mode; piped stays the deterministic default) andcliNdjson(invocation)— the orderedCliRenderedEvent[]a--ndjsonrun wrote, with honestAgentTestErrordiagnostics when stdout is not an event stream.CliRenderedEventis re-exported.route-harness/src/cli/report.tsx, a rendered command switchable across success / render-error / invalid-result / wait-for-abort.tests/projection/cli-dispatch-rendered.test.ts, in-process pool — zero cost added to the packed pool): piped Markdown (progress never on stdout), explicit TTY progress-in-place (\r\x1b[2K), canonical--jsonvalue,--ndjsonwith monotonic sequences + terminalcomplete+ nojsonrpckey (CLI dialect purity), mid-render cancellation (Aborted., exit 1), component render error, resultSchema rejection, rendered inputSchema rejection (exit 2 + usage hint),--ndjsonon a plain command and--json --ndjsonconflicts (exit 2), and honestcliJson/cliNdjsonfailures on Markdown output.src/test/cli.tsheader no longer says rendered routes are an AB4816 compiler error; the module states honestly what this level does not prove (no worker thread, no process framing, no chunk-by-chunk Flight timing — the packed CLI suite owns that). README proof-level table + example and the cli-tool scaffolder template now explain plain vs rendered proof levels.agent-bundle.Provenance
Every rendered dispatch stamps
proofLevel: 'cli-dispatch'; a pass here is not packed-executable evidence —cli-routes-build.test.tskeeps that claim.Local gates (all run on this branch)
pnpm test:projection— pass (includes the 10 new rendered-dispatch tests)pnpm test:unit— 2366 passed, 5 skipped, 0 failedpnpm test:route-unit— 15 passedpnpm typecheck— clean (root, workbench, create-agent-bundle)pnpm lint— 0 errors, 0 warnings (912 files)