-
Notifications
You must be signed in to change notification settings - Fork 0
fix(test,workbench): closed-issue audit G1 follow-ups — harness provider mounting and deterministic examples-real edits #399
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
a496a86
feat(test): mount conventional providers in the agent-bundle/test har…
ScriptedAlchemy 459c3e5
test(workbench): wait on the watcher rebuild instead of retrying exam…
ScriptedAlchemy b0255d8
test(route-unit): reconcile the #371 provider seam pin with harness a…
ScriptedAlchemy b86acd9
test(workbench): replace the logs-real source edit atomically
ScriptedAlchemy a60c298
fix(test): derive executable surface for harness invocations and bump…
ScriptedAlchemy c54dc98
fix(test): pin the tooling tool in the packed projection and ignore e…
ScriptedAlchemy 81e3437
fix(build): mount the compiled event route id as operationId in the F…
ScriptedAlchemy 0cf800f
fix(test): scope the harness process lifetime to each simulated execu…
ScriptedAlchemy 8143cda
fix(test): snapshot the process hit count before awaiting provider lo…
ScriptedAlchemy 3e08601
fix(build,test): snapshot the process hit synchronously before state …
ScriptedAlchemy a366054
fix(test): keep harness context optional under provider typegen and d…
ScriptedAlchemy 34b0230
test(typegen): pin that harness calls stay legal without context unde…
ScriptedAlchemy 7887b13
fix(test,changeset): scale the watcher e2e outer timeouts and rewrite…
ScriptedAlchemy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "agent-bundle": patch | ||
| --- | ||
|
|
||
| Mount conventional request context providers (`src/providers/*`) in the `agent-bundle/test` harness for every manifest-backed call — `renderRoute`, `renderRouteEvents`, `invokeCli` (plain, rendered, and projected MCP commands), `openInMemoryMcpServer`, and `invokeMcpTool` — exactly as the generated request scopes do: same deterministic key order, same surface-specific `invocation`, same fail-closed factory errors, and a `providers.processLifetime` scoped like the artifact's (fresh per `invokeCli` call and per `renderRoute` render, shared across one open in-memory MCP session). Pass `context.providers` to mount an explicit fixture map instead; `context` and its `providers` stay optional even once the generated `.agent-bundle/routes.d.ts` augmentation declares provider keys (`HarnessOptionsArguments`, `RenderRouteContextInit`), while an explicit map must carry every declared key and a direct `runAgentRequest` still requires `providers`. Provider modules are evaluated once per test worker, so module-level provider state is shared across simulated executables; prove cold state through the proof levels that spawn the artifact. Hand `renderRoute` providers and the request scope the executable surface the artifact records (a routed CLI command's space-joined path, a script's path-derived name) instead of the route id, and mount an event route's compiled id (`event:tool/after`) as `invocation.operationId` in the generated Flight worker, matching the hook shell, lifecycle replay, and harness. The test manifest gains `providers`, the generated Rstest setup registers provider loaders (test registry version 4), and a project whose setup predates that registration fails with the `manifest-unavailable` harness error naming the provider. (#399) |
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
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
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
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
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
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
24 changes: 24 additions & 0 deletions
24
packages/agent-bundle/fixtures/route-harness/src/cli/tooling/inspect.ts
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| import { agent } from '@agent-bundle/runtime'; | ||
| import type { CliRouteConfig, CliRouteProps } from 'agent-bundle'; | ||
| import { z } from 'zod'; | ||
|
|
||
| export const config = { | ||
| description: 'Reports the request providers a plain command observes.', | ||
| } satisfies CliRouteConfig; | ||
|
|
||
| export const inputSchema = z.object({}).strict(); | ||
|
|
||
| export const resultSchema = z.object({ | ||
| keys: z.array(z.string()), | ||
| libraryTooling: z.unknown().optional(), | ||
| processLifetime: z.object({ hits: z.number().int().min(1), instanceId: z.string(), pid: z.number().int() }).strict(), | ||
| }).strict(); | ||
|
|
||
| export default async function inspect(_props: CliRouteProps<typeof inputSchema>) { | ||
| const { providers } = await agent(); | ||
| return { | ||
| keys: Object.keys(providers).sort(), | ||
| libraryTooling: providers['libraryTooling'], | ||
| processLifetime: providers['processLifetime'], | ||
| }; | ||
| } |
24 changes: 24 additions & 0 deletions
24
packages/agent-bundle/fixtures/route-harness/src/cli/tooling/report.tsx
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| import { Agent, agent, type JsonValue } from '@agent-bundle/runtime'; | ||
| import type { CliRouteConfig, CliRouteProps } from 'agent-bundle'; | ||
| import { z } from 'zod'; | ||
|
|
||
| export const config = { | ||
| description: 'Renders the request providers a rendered command observes.', | ||
| } satisfies CliRouteConfig; | ||
|
|
||
| export const inputSchema = z.object({}).strict(); | ||
|
|
||
| export const resultSchema = z.object({ | ||
| keys: z.array(z.string()), | ||
| libraryTooling: z.unknown().optional(), | ||
| }).strict(); | ||
|
|
||
| export default async function ToolingReport(_props: CliRouteProps<typeof inputSchema>) { | ||
| const { providers } = await agent(); | ||
| const value = { keys: Object.keys(providers).sort(), libraryTooling: providers['libraryTooling'] as JsonValue }; | ||
| return ( | ||
| <Agent.Result value={value}> | ||
| <Agent.Text>{`tooling: ${JSON.stringify(providers['libraryTooling'])}`}</Agent.Text> | ||
| </Agent.Result> | ||
| ); | ||
| } |
34 changes: 34 additions & 0 deletions
34
packages/agent-bundle/fixtures/route-harness/src/mcp/harness/tools/tooling.tsx
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| import { Agent, agent, type JsonValue } from '@agent-bundle/runtime'; | ||
| import { z } from 'zod'; | ||
|
|
||
| export const config = { | ||
| annotations: { readOnlyHint: true }, | ||
| description: 'Reports the request providers an MCP tool observes.', | ||
| title: 'Tooling', | ||
| }; | ||
|
|
||
| export const inputSchema = z.object({ | ||
| /** Makes the `library-tooling` provider throw, to prove the request fails closed. */ | ||
| failProvider: z.boolean().optional(), | ||
| }).strict(); | ||
|
|
||
| export const resultSchema = z.object({ | ||
| keys: z.array(z.string()), | ||
| libraryTooling: z.unknown().optional(), | ||
| processLifetime: z.object({ hits: z.number(), instanceId: z.string(), pid: z.number() }).optional(), | ||
| }).strict(); | ||
|
|
||
| export default async function Tooling() { | ||
| const { providers } = await agent(); | ||
| const { processLifetime } = providers; | ||
| const value = { | ||
| keys: Object.keys(providers).sort(), | ||
| libraryTooling: providers['libraryTooling'] as JsonValue, | ||
| ...(processLifetime === undefined ? {} : { processLifetime: { ...processLifetime } }), | ||
| }; | ||
| return ( | ||
| <Agent.Result value={value}> | ||
| <Agent.Text>{`tooling: ${JSON.stringify(providers['libraryTooling'])}`}</Agent.Text> | ||
| </Agent.Result> | ||
| ); | ||
| } |
25 changes: 25 additions & 0 deletions
25
packages/agent-bundle/fixtures/route-harness/src/providers/library-tooling.ts
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| import type { AgentProviderContext } from 'agent-bundle'; | ||
|
|
||
| /** | ||
| * A conventional request context provider. The harness mounts it for every | ||
| * manifest request scope exactly as the generated entries do, so routes on | ||
| * every surface observe `providers.libraryTooling` with the surface-specific | ||
| * invocation kind the provider saw. | ||
| */ | ||
| export default async function libraryTooling({ invocation, signal }: AgentProviderContext) { | ||
| if (signal.aborted) throw new DOMException('aborted', 'AbortError'); | ||
| const input = invocation.kind === 'tool' ? invocation.props.input : undefined; | ||
| if (typeof input === 'object' && input !== null && (input as { readonly failProvider?: unknown }).failProvider === true) { | ||
| throw new Error('ffprobe is not installed'); | ||
| } | ||
| const surface = invocation.kind === 'tool' | ||
| ? invocation.props.operationId | ||
| : invocation.kind === 'cli' | ||
| ? invocation.props.command | ||
| : invocation.kind === 'script' | ||
| ? invocation.props.name | ||
| : invocation.kind === 'event' | ||
| ? invocation.props.event | ||
| : invocation.props.view; | ||
| return { kind: invocation.kind, surface, tool: 'ffprobe 6.1' }; | ||
| } |
26 changes: 26 additions & 0 deletions
26
packages/agent-bundle/fixtures/route-harness/src/scripts/tooling-summary.tsx
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| import { Agent, agent, type JsonValue } from '@agent-bundle/runtime'; | ||
| import { z } from 'zod'; | ||
|
|
||
| export const resultSchema = z.object({ | ||
| arguments: z.number().int().nonnegative(), | ||
| keys: z.array(z.string()), | ||
| libraryTooling: z.unknown().optional(), | ||
| }).strict(); | ||
|
|
||
| export default async function ToolingSummary({ argv, signal }: { | ||
| readonly argv: readonly string[]; | ||
| readonly signal: AbortSignal; | ||
| }) { | ||
| if (signal.aborted) throw new DOMException('aborted', 'AbortError'); | ||
| const { providers } = await agent(); | ||
| const value = { | ||
| arguments: argv.length, | ||
| keys: Object.keys(providers).sort(), | ||
| libraryTooling: providers['libraryTooling'] as JsonValue, | ||
| }; | ||
| return ( | ||
| <Agent.Result value={value}> | ||
| <Agent.Text>{`Summarized ${String(argv.length)} arguments.`}</Agent.Text> | ||
| </Agent.Result> | ||
| ); | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This new automatic-mounting behavior directly contradicts the user-facing
docs/framework-mode.mdguidance at lines 105–107, which still says route-unit and CLI-dispatch tests inject fixtures and that the harness never executes provider modules. A user following the linked one-screen authoring guide can therefore omit a stub and unexpectedly run a provider that accesses the network or filesystem; update that guide alongside this new contract.Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in f083391.
docs/framework-mode.mdnow describes the auto-mount contract (real providers run unlesscontext.providersstubs them, which is exactly how a test avoids a provider that reaches the network or file system) and links the harness section for the module-evaluation caveat.Chasing this also surfaced a real type conflict with #409, which landed on main during this PR:
HarnessOptionsArguments/RenderRouteContextInitturnedoptionsandcontext.providersmandatory once the augmentation declares provider keys — reasonable when the harness never ran providers, but it made auto-mounting unreachable for any typed project. Both are optional again in the harness (an explicit map still must carry every declared key; a directrunAgentRequeststill requiresproviders, since nothing else would supply them).docs/entry-conventions.md, the README, and the changeset record the reconciled rule;pnpm typecheck,pnpm lint, route-unit, and the providers/cli-dispatch projection tests pass.