Skip to content

feat(core): approval gate, real OpenAI-compatible provider, cora_search tool (E4) - #18

Merged
ajianaz merged 3 commits into
developfrom
feat/e4-real-provider
Aug 26, 2026
Merged

ajianaz merged 3 commits into
developfrom
feat/e4-real-provider

Conversation

@ajianaz

@ajianaz ajianaz commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

What

  • Approval gate: AllowlistApprover + Decision/Verdict types. ToolRegistry now refuses to register Write/Destructive tools unless an approver is wired in — enforcement at the earliest possible point, stricter than the spec minimum. Turn loop consults the approver on execution: Deny produces a durable ERROR record and aborts with ApprovalRequired.
  • Real provider: OpenAiProvider over ureq 3 (sync, Phase 1) for any OpenAI-compatible endpoint (OpenAI, Groq, OpenRouter, vLLM, LiteLLM). Config via CORAGENT_* env vars. API key lives only in the outbound Authorization header: scrub() strips it from errors, safe_description() never includes it, and a test proves the key cannot appear in any Display/error path.
  • cora_search tool: ReadOnly search over the project symbol index via cora brain <query> --json --limit. Subprocess wrapped in run_with_timeout (30s ceiling, poll + kill) with stdout/stderr drained on dedicated reader threads so a >64KB output can't deadlock the pipe and a hung CLI can't freeze the turn loop.
  • Wire transcript: request_body flattens actual message entries (role/text) in order, filters non-message kinds and unknown roles. Optional system prompt via with_system_prompt — explicit opt-in, never invented by the provider.

Why

Closes #4 (E4). Three acceptance criteria:

  1. Registry refuses write tools without an approval gate — enforced at registration, not execution.
  2. Real provider reads config from env, and the API key is never logged: error scrubbing + leak-proof Display + regression tests.
  3. Tier B tests stay network-optional: all provider tests run offline (env resolution, request body shape, scrubbing, subprocess timeout via sleep 30 kill test).

Testing

  • 53/53 tests green (9 unit core → now 15 unit, 13 E1 jsonl, 11 E2 state machine, 14 E3 turn loop)
  • clippy: 0 warnings
  • cora pre-commit review: clean (2 MAJOR found earlier — placeholder transcript, subprocess hang — fixed in later commits with regression tests)
  • CI: full matrix on push

…ol (E4)

- AllowlistApprover + Decision/Verdict types; ToolRegistry refuses
  Write/Destructive registration unless an approver is wired in
- turn loop consults the approver before executing non-ReadOnly tools
- OpenAiProvider (ureq 3, sync): env-resolved config (CORAGENT_*),
  scrubbed errors, structurally-leak-proof Display
- CoraSearchTool: ReadOnly hybrid search via 'cora brain --json'
- 47/47 tests green (9 unit + 38 integration), clippy clean
- request_body now flattens actual message entries (role/text) instead
  of sending a placeholder; non-message kinds and unknown roles are
  filtered out
- cora_search subprocess wrapped in run_with_timeout: poll + kill after
  30s ceiling so a hung 'cora brain' can no longer freeze the turn loop
- regression tests: timeout kills 'sleep 30' in <5s, fast commands pass
  through, flattening preserves order and filters odd kinds/roles
…prompt

- run_with_timeout now takes ownership of stdout/stderr pipes and drains
  them on dedicated threads; a child writing >64KB can no longer block
  on a full pipe and trigger a bogus timeout
- system prompt becomes an explicit provider option (with_system_prompt),
  prepended as the first message; default is absent, never invented
@github-actions

Copy link
Copy Markdown

🔍 Cora AI Code Review

✅ No issues found. Code looks good!


Review powered by cora-code · BYOK · MIT

@ajianaz
ajianaz merged commit 833be3c into develop Aug 26, 2026
11 checks passed
@ajianaz
ajianaz deleted the feat/e4-real-provider branch August 26, 2026 11:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

E4: cora search tool (ReadOnly) + real LLM provider

1 participant