Skip to content

fix(orchestration): address code review findings#48

Open
nerdsane wants to merge 5 commits intomainfrom
fix/orchestration-review-fixes
Open

fix(orchestration): address code review findings#48
nerdsane wants to merge 5 commits intomainfrom
fix/orchestration-review-fixes

Conversation

@nerdsane
Copy link
Owner

Summary

Addresses all 11 findings from the agent-orchestration code review (PR #37):

Critical fixes (C1–C5):

  • C1: Remove args config key from ClaudeCode/Codex adapters (command injection surface)
  • C2: Add SSRF prevention to HTTP webhook adapter — reject private/loopback IPs with allow_private_urls escape hatch for testing
  • C3: Add missing turn_cost_cents and tokens_consumed params to CSDL RecordTurn
  • C4: Add missing budget_consumed_cents param to CSDL RecordCost
  • C5: Change BudgetLedger AmountCents/Tokens from Edm.String to Edm.Int64

Important fixes (I1–I6):

  • I1: Add create Cedar permit for Organization (supervisor/human only)
  • I2: Add IncrementActiveRuns/DecrementActiveRuns to Organization spec + CSDL + Cedar
  • I3: Add agent.wait message to OpenClaw adapter per protocol spec
  • I4: Add // determinism-ok annotations to all adapter Instant::now() calls
  • I5: Scope secrets to only those referenced via {secret:KEY} in integration config
  • I6: Fix ResetBudgetCycle to accept budget_consumed_cents param for reset

Tests:

  • 6 new E2E integration tests proving full orchestration app lifecycle
  • All existing adapter dispatch tests updated for SSRF prevention

Test plan

  • All 6 orchestration E2E tests pass (heartbeat lifecycle, adapter failure, org lifecycle, budget ledger, guard enforcement, cancel)
  • All 3 adapter dispatch tests pass with allow_private_urls config
  • All IOA specs pass L0–L3 verification cascade
  • cargo test --workspace — all tests pass
  • Pre-push pipeline: rustfmt, clippy, readability ratchet, full test suite — all gates pass

🤖 Generated with Claude Code

rita-aga and others added 5 commits March 16, 2026 13:07
… scoping, active-run tracking

- SSRF prevention: http_webhook adapter blocks private/loopback URLs (RFC-1918,
  169.254/16, 0.0.0.0/8, localhost, metadata.google.internal) with opt-out via
  `allow_private_urls = "true"` in integration config
- Secret scoping: adapter dispatch now filters tenant secrets to only those
  referenced via {secret:KEY} in integration config (was leaking full vault)
- Remove `args` splitting in claude_code + codex adapters (command injection risk)
- Add `agent.wait` signal to openclaw adapter after sending agent request
- Organization spec: IncrementActiveRuns / DecrementActiveRuns actions with
  active_runs > 0 guard; ResetBudgetCycle now accepts budget_consumed_cents param
- CSDL: fix BudgetLedger AmountCents/Tokens Edm.String → Edm.Int64; add new
  action bindings for IncrementActiveRuns, DecrementActiveRuns, ResetBudgetCycle
- Cedar: restrict Organization create to supervisor/human; permit new run-count
  actions alongside RecordCost for any principal
- DST: consolidate determinism-ok annotations inline; use BTreeMap for secrets
- Tests: orchestration_e2e.rs — 6 integration tests covering full HeartbeatRun
  lifecycle, adapter failure path, Organization full lifecycle, BudgetLedger
  recording, guard enforcement, and cancellation

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
6 tests covering the full agent-orchestration app lifecycle:
- HeartbeatRun: Schedule → ApproveBudget → CheckIn → StartExecution → adapter callback → Complete
- HeartbeatRun: adapter failure triggers Fail callback
- HeartbeatRun: guard blocks CheckIn without budget approval
- HeartbeatRun: Cancel from Working state
- Organization: full lifecycle including active run tracking
- BudgetLedger: cost entry recording

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The Cedar engine was only creating a principal entity in the entity store,
but not a resource entity. This meant Cedar policies using `resource.Field`
expressions (e.g. `resource.AgentId == principal.id`) always failed because
the resource entity had no attributes to resolve.

Now both the principal and resource entities are added to the entity store
with their respective attributes, enabling `resource.X` references in
Cedar policies to work correctly.

Verified end-to-end: started local Temper, installed agent-orchestration
app, and walked HeartbeatRun through full lifecycle via HTTP API with
Cedar authorization passing for all role-gated actions.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.

2 participants