Add evidence-backed terminal outcome learning#21
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7327e9f476
ℹ️ 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".
| ); | ||
|
|
||
| CREATE TABLE IF NOT EXISTS terminal_outcomes ( | ||
| goal_id TEXT PRIMARY KEY, |
There was a problem hiding this comment.
Scope terminal outcomes by repository
When the shared event store is used for multiple repositories, this primary key makes goal_id globally unique even though the table also stores repo_id and the MCP server writes the current repository ID. If two repos report the same goal ID (for example a common run/goal name), the second insert is ignored by INSERT OR IGNORE, so that repo silently loses its terminal outcome and any associated learning candidate. Make idempotency apply per repo, e.g. with a composite key including repo_id.
Useful? React with 👍 / 👎.
| const outcome = z.object({ | ||
| goal_id: z.string().min(1), | ||
| status: z.enum(["completed", "failed", "cancelled", "blocked", "budget_exhausted"]), | ||
| evidence: z.array(z.string().min(1)).min(1), | ||
| summary: z.string().min(1), | ||
| }).parse(request.params.arguments); |
There was a problem hiding this comment.
Accept lesson candidates in the MCP outcome tool
The new tool description says it can record an optional review-gated lesson candidate, and recordTerminalOutcome only creates that pending lesson when outcome.candidate is present, but this dispatcher schema parses only goal/status/evidence/summary. As a result, clients using the advertised MCP surface have no way to submit the candidate, so list_learning_candidates remains empty after terminal-outcome recording; include and validate the candidate fields here and in the advertised input schema if this tool is meant to seed review-gated lessons.
Useful? React with 👍 / 👎.
Summary\nAdds idempotent terminal goal outcomes and review-gated lesson candidates, exposed through a dedicated MCP tool.\n\n## Changes\n- Persist one terminal outcome per goal\n- Require evidence and a bounded summary\n- Keep lesson candidates pending until explicit approval\n- Add record_terminal_outcome to the MCP surface\n- Isolate test blackboard and global history writes\n\n## Why\nLearning must consume terminal evidence exactly once and must never inject unapproved lessons into future work.\n\n## Validation\n- TypeScript build passed\n- 53 test files passed\n- 394 tests passed\n- MCP all-tool acceptance passed\n\n## Risks\n- Existing databases receive an additive schema migration\n- The new MCP tool writes terminal metadata but does not auto-approve lessons\n\n## Related\nCAS Loop Engineering milestone v1.\n\n## Reviewer notes\nStart with universal-refiner/src/history/event-store.ts and the new MCP dispatcher case.