Skip to content

Commit 1ad0064

Browse files
Copilotpmcelhaney
andauthored
Address code review feedback on AI agent issue proposals
Agent-Logs-Url: https://github.com/counterfact/api-simulator/sessions/05ee9d02-35a9-4e04-ac53-adbbae4adbdf Co-authored-by: pmcelhaney <51504+pmcelhaney@users.noreply.github.com>
1 parent 3374ad7 commit 1ad0064

File tree

5 files changed

+18
-5
lines changed

5 files changed

+18
-5
lines changed

.github/issue-proposals/agent-openapi-json-endpoint.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,11 @@ Optionally, also add:
2626

2727
```
2828
GET /_counterfact/api/openapi/paths → just the `paths` object
29-
GET /_counterfact/api/openapi/paths/{path} → schema for a single path item
29+
GET /_counterfact/api/openapi/paths?route=<path> → schema for a single path item
30+
(route is URL-encoded, e.g. route=%2Fpet%2F%7BpetId%7D)
3031
```
3132

32-
to allow agents to query narrow slices without fetching the entire spec.
33+
The `route` query parameter avoids the routing ambiguity that would arise from embedding a slash-containing OpenAPI path into URL segments.
3334

3435
## Motivation
3536

.github/issue-proposals/agent-request-history-endpoint.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@ Adding a request-history endpoint to the Admin API gives agents a reliable, stru
1717
1. Add an in-memory ring buffer (e.g. last 100 entries, configurable via a `--history-size` flag or a field in `Config`) to the Koa dispatcher. After each request is handled, append a record:
1818

1919
```ts
20+
interface ValidationError {
21+
location: "query" | "header" | "path" | "body";
22+
name?: string; // parameter name (for query/header/path)
23+
path?: string; // JSON Pointer (for body fields, e.g. "/price")
24+
message: string; // human-readable description
25+
}
26+
2027
interface HistoryEntry {
2128
id: number; // monotonically increasing
2229
timestamp: string; // ISO-8601
@@ -29,7 +36,7 @@ interface HistoryEntry {
2936
responseHeaders: Record<string, string>;
3037
responseBody: unknown;
3138
durationMs: number;
32-
validationErrors: string[]; // from the request-validator
39+
validationErrors: ValidationError[]; // structured errors from the request-validator
3340
}
3441
```
3542

.github/issue-proposals/agent-scenario-save-load.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ interface Scenario {
3838

3939
### Behaviour
4040

41-
- Scenarios are stored **in memory** by default (cleared on restart). Optionally, persist them to a `.counterfact-scenarios.json` file in `basePath` if a `--persist-scenarios` flag is passed.
41+
- Scenarios are stored **in memory** by default (cleared on restart). When `--persist-scenarios` is passed, scenarios are read from `.counterfact-scenarios.json` in `basePath` at startup (if the file exists), and every create/update/delete operation is immediately written back to that file. This means a server restarted with `--persist-scenarios` automatically restores all previously saved scenarios.
4242
- `POST /_counterfact/api/scenarios/:name/load` calls the existing context reset logic, then replays every entry in the scenario's `contexts` map.
4343

4444
### Example workflow

.github/issue-proposals/agent-seeded-random-responses.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ DELETE /_counterfact/api/config/seed → removes the seed, restoring random b
2929

3030
Setting the seed at runtime resets the PRNG state, so the sequence of random values produced by subsequent requests is identical to what would be produced by starting the server with that seed.
3131

32+
The seed must be a non-negative integer (0–2³²−1). Providing a non-integer, a negative number, or a value outside this range returns `400 { "error": "seed must be a non-negative integer ≤ 4294967295" }`.
33+
3234
## Motivation
3335

3436
- Agents running regression tests need stable, assertable values.

.github/issue-proposals/agent-structured-validation-errors.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,10 @@ so agents (or middleware) can inspect validation errors without parsing the resp
4646

4747
### Config option
4848

49-
Add a boolean `strictValidation` config option (default `false`). When `true`, validation errors immediately return `400` before the route handler is called. When `false` (the current default), the handler is still called and may choose to handle invalid input itself — but the `validationErrors` field is populated in the response if any errors exist.
49+
Add a boolean `strictValidation` config option (default `false`).
50+
51+
- When `true`, validation errors immediately return `400` before the route handler is called. The response body is always `{ "error": "Validation failed", "validationErrors": […] }`.
52+
- When `false` (the current default), the handler is still called and its return value is used as the response body. If any validation errors exist, a top-level `validationErrors` key is added to the response body (the handler's own fields are preserved). If the handler's response body is not a JSON object (e.g. a string or array), `validationErrors` is instead delivered only via the `X-Counterfact-Validation-Errors` header to avoid mutating a non-object body.
5053

5154
## Motivation
5255

0 commit comments

Comments
 (0)