Skip to content

WS-POL-003-02: add unified project guide agent adapter - #301

Merged
abiorh-claw merged 3 commits into
mainfrom
codex/ws-pol-003-02-unified-agent-adapter
Aug 9, 2026
Merged

WS-POL-003-02: add unified project guide agent adapter#301
abiorh-claw merged 3 commits into
mainfrom
codex/ws-pol-003-02-unified-agent-adapter

Conversation

@Abiorh001

@Abiorh001 Abiorh001 commented Aug 8, 2026

Copy link
Copy Markdown
Collaborator

Chunk

WS-POL-003-02 — Unified project-guide agent adapter.

Goal

Add one hidden compile_project_guide runtime method that sends the merged strict context through exactly one provider call and validates the complete untrusted result before returning.

Intent And Planning Context

  • Initiative: .agent-loop/initiatives/WS-POL-003-unified-project-guide-compilation/PLAN.md
  • Chunk: .agent-loop/initiatives/WS-POL-003-unified-project-guide-compilation/chunks/WS-POL-003-02-unified-agent-adapter.md
  • Dependency: merged WS-POL-003-01 PR WS-POL-003-01: add unified guide compilation contracts #299.

What Changed

  • Added compile_project_guide to the existing project-agent runtime port and OpenAI adapter.
  • Added strict provider schema, one-call execution, trusted context-bound validation, timeout/cancellation, and sanitized failures.
  • Disabled provider tracing and sensitive trace capture for the unified call.
  • Added deterministic single-encoded context serialization and a bounded 16 MiB complete prompt envelope.
  • Added fake-SDK, injection, serialization, prompt-bound, timeout, cancellation, and regression tests.

Why It Changed

The unified guide compiler needs one bounded model attempt over the exact immutable guide and canonical capability projections. This adapter establishes that hidden provider boundary without wiring it into production orchestration.

Design Chosen

Reuse the existing runtime port, OpenAI adapter, and structured-run helper. The unified method opts into strict JSON schema, the dedicated envelope cap, tracing-disabled RunConfig, and the merged trusted validator. Canonical guide JSON is parsed into the outer prompt envelope rather than double-encoded as a JSON string.

Alternatives Rejected

  • A second adapter/runtime or registry: unnecessary competing authority.
  • Production caller rewiring in this chunk: persistence and authorization are not ready.
  • Raising the prompt cap to hide double encoding: retained an avoidable expansion bug.
  • SDK default tracing: creates an unauthorized second persistence path.

Scope Control

Allowed Files Changed

  • Project-agent interface and OpenAI adapter.
  • Focused adapter tests.
  • WS-POL-003 status, contract, and review evidence.

Files Outside Stated Scope

  • None.

Product Behavior

  • No live Workstream product behavior changed. The method is hidden and unused.

No database, migration, authorization, Celery, API, service orchestration, policy persistence/approval, catalogue, checker runtime, dependency, composition-root, or production caller change exists.

Evidence

Commands Run

cd backend
uv run ruff check app/interfaces/project_agents.py app/adapters/project_agents/openai_agent_sdk.py tests/test_agent_runtime.py
uv run pytest -q tests/test_agent_runtime.py tests/test_project_guide_compilation_contracts.py
uv run pytest -q <focused plus legacy adapter regressions> --cov=app.adapters.project_agents.openai_agent_sdk --cov-fail-under=90
uv run docstr-coverage --config .docstr.yaml
uv run --extra agents python -c '<strict schema and RunConfig construction proof>'
python scripts/check_stale_workstream_wording.py
python scripts/check_markdown_links.py
git diff --check origin/main

Result Summary

Ruff: passed
Focused plus adjacent legacy tests: 79 passed
Changed adapter coverage: 91.89%
Repository docstring coverage: 80.5%
Real SDK strict schema and tracing config construction: passed
Stale wording, Markdown links, scope, lane ownership, and diff checks: passed

Acceptance Criteria Proof

  • Exactly one strict Runner.run call consumes the canonical context.
  • Guide/task/catalogue text remains untrusted data separate from instructions.
  • No tools, handoffs, MCP, file search, web search, or equivalent capability is supplied.
  • Provider tracing is disabled and sensitive trace data excluded.
  • Trusted semantic validation rejects invalid provider output before return.
  • Valid near-bound escapable guide material remains within the single-encoded envelope; oversized prompts deny before SDK I/O.
  • Timeout is sanitized and caller cancellation propagates.
  • Existing runtime methods and production callers remain unchanged.

Test Delta

Tests Added

  • Additive unified adapter tests in backend/tests/test_agent_runtime.py.

Tests Modified

  • No existing assertion was weakened.

Tests Removed Or Skipped

  • None.

Internal Reviewer Results

Reviewer Result Blocking Findings Notes
Architecture PASS None Correct port/helper ownership; no rewiring.
Security PASS AFTER FIXES None Strict schema, no tools, no tracing, trusted validation.
QA PASS AFTER FIXES None Prompt cap and double-encoding corrected.
Product/ops PASS None No approval or lifecycle drift.
Senior engineering PASS AFTER FIXES None Near-bound canonical envelope aligned.
Test delta PASS None Additive tests; no skips or weakening.
CI integrity PASS AFTER FIXES None Correct commands/lane; no gate changes.
Docs PASS AFTER FIXES None Status and internal evidence aligned.

External Review

Source Status Notes
CodeRabbit PASS One finding fixed in aa975ea6 and preserved on integrated head 7f12bd25; zero unresolved threads on exact head.
GitHub checks PASS Agent Gate, all five Backend lanes, and aggregate coverage passed on 7f12bd25f063840531a5f19863977e57b36efcaf.

CI And Gate Integrity

  • No workflow weakening.
  • No lint/test/docstring/coverage threshold weakening.
  • No package-script or dependency change.
  • Existing semantic lane owns the changed test module.

Remaining Risks

The method is intentionally hidden. Later persistence/orchestration chunks must preserve one logical attempt and must not enable tracing, tools, or a second inference path. Future catalogue growth must remain inside the complete-envelope cap.

Follow-Up Work

After human merge, WS-POL-003-03A is the next proposed candidate and requires a separately expanded executable contract and explicit start.

Human Review Focus

Inspect canonical prompt fidelity, no-trace/no-tools boundaries, exact validator use, envelope accounting, cancellation/error semantics, and absence of production rewiring.

Human Merge Ownership

  • Intent, behavior, risks, and evidence are documented.
  • The user explicitly approved this specific PR for merge.

Summary by CodeRabbit

  • New Features
    • Added unified project-guide compilation with structured, validated results.
    • Added support for strict schema-based provider responses and canonical context serialization.
    • Added prompt-size protection, including rejection of oversized requests before processing.
    • Disabled provider tracing for compilation requests.
  • Bug Fixes
    • Improved timeout and cancellation handling with sanitized failures.
  • Tests
    • Added comprehensive coverage for validation, security boundaries, prompt limits, and provider invocation behavior.
  • Documentation
    • Updated rollout status, review evidence, acceptance criteria, and verification guidance.

@coderabbitai

coderabbitai Bot commented Aug 8, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The PR adds unified project-guide compilation to the project-agent runtime. It introduces canonical context serialization, strict structured output, prompt-size enforcement, disabled tracing, result validation, lifecycle tests, and updated rollout evidence.

Changes

Project-guide compilation

Layer / File(s) Summary
Compilation contract and adapter execution
backend/app/interfaces/project_agents.py, backend/app/adapters/project_agents/openai_agent_sdk.py
Adds the compilation runtime contract, canonical UTF-8 context serialization, a 16 MiB prompt limit, strict schema output, disabled tracing, and validated compilation results.
Runtime validation and lifecycle tests
backend/tests/test_agent_runtime.py
Tests instruction boundaries, single-call tool-free execution, prompt limits, semantic result validation, timeout sanitization, and caller cancellation.
Chunk scope and review evidence
.agent-loop/initiatives/WS-POL-003-unified-project-guide-compilation/...
Updates rollout state, chunk scope, acceptance criteria, verification requirements, internal review evidence, and the PR trust bundle.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Caller
  participant Runtime
  participant OpenAI SDK
  participant Result Validator
  Caller->>Runtime: compile_project_guide(context)
  Runtime->>OpenAI SDK: Send canonical context with strict schema
  OpenAI SDK-->>Runtime: Return structured output
  Runtime->>Result Validator: Validate compilation result
  Result Validator-->>Caller: Return validated result
Loading

Possibly related PRs

Suggested reviewers: abiorh-claw

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 61.29% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly identifies the chunk and its primary change: adding the unified project-guide agent adapter.
Description check ✅ Passed The description follows the required trust-bundle structure and provides scope, design, evidence, acceptance proof, risks, and review status.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/ws-pol-003-02-unified-agent-adapter

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Abiorh001

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 8, 2026

Copy link
Copy Markdown
⚠️ Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@Abiorh001

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 8, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
@.agent-loop/initiatives/WS-POL-003-unified-project-guide-compilation/chunks/WS-POL-003-02-unified-agent-adapter.md:
- Around line 14-19: Update the allowed-file list in the chunk contract to
include the changed CHUNK_MAP.md file and each exact changed initiative record
path; replace the broad “review/trust evidence under” directory entry with
explicit paths. Ensure the allowlist exactly matches the PR’s changed files, or
remove any change not covered by it.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 6a91c75b-c919-464a-a48b-6b3770f6ef69

📥 Commits

Reviewing files that changed from the base of the PR and between fb90237 and fa4142a.

📒 Files selected for processing (8)
  • .agent-loop/initiatives/WS-POL-003-unified-project-guide-compilation/CHUNK_MAP.md
  • .agent-loop/initiatives/WS-POL-003-unified-project-guide-compilation/STATUS.md
  • .agent-loop/initiatives/WS-POL-003-unified-project-guide-compilation/chunks/WS-POL-003-02-unified-agent-adapter.md
  • .agent-loop/initiatives/WS-POL-003-unified-project-guide-compilation/reviews/WS-POL-003-02-internal-review-evidence.md
  • .agent-loop/initiatives/WS-POL-003-unified-project-guide-compilation/reviews/WS-POL-003-02-pr-trust-bundle.md
  • backend/app/adapters/project_agents/openai_agent_sdk.py
  • backend/app/interfaces/project_agents.py
  • backend/tests/test_agent_runtime.py

@abiorh-claw
abiorh-claw self-requested a review August 9, 2026 04:18
@abiorh-claw
abiorh-claw merged commit ccdc9af into main Aug 9, 2026
10 checks passed
@abiorh-claw
abiorh-claw deleted the codex/ws-pol-003-02-unified-agent-adapter branch August 9, 2026 04:20
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