Skip to content

feat(pve): add agent-facing approval/execution status contract - #20

Open
mikomiel wants to merge 2 commits into
mainfrom
task/pve-agent-status-contract
Open

mikomiel wants to merge 2 commits into
mainfrom
task/pve-agent-status-contract

Conversation

@mikomiel

Copy link
Copy Markdown
Owner

Change and reason

Implement OpenSpec task 3.3: the agent-facing status view now exposes a documented contract that keeps approval and execution states distinct. One decision: add a closed execution_state vocabulary to the mTLS status read and document that the broker only ever reports not_executed until a trusted executor boundary exists.

  • GET /v1/broker/requests/{request_id} (mTLS, original identity and source only) returns execution_state alongside the unchanged approval lifecycle status (pending/approved/denied/expired/cancelled).
  • execution_state vocabulary is closed: not_executed, executing, succeeded, failed, uncertain. The broker reports only not_executed; approval, lease fetch and certificate issuance are authorization events, never execution evidence.
  • Unknown stored states fail closed (_agent_status_view rejects them); cross-identity reads stay 403 with no field disclosure.
  • Contract and limits documented in docs/architecture.md; OpenSpec task 3.3 ticked with the issue link.

Linked issues

Closes #7

Verification

Source head: ccd5b20b9b82c98e966f244322bf11b295921c2d.

  • PASS — uv sync --frozen
  • PASS — uv run ruff check . and uv run ruff format --check .
  • PASS — uv run python -m pytest -q: 269 tests, including 7 new TestAgentStatusContract tests
  • PASS — uv run python examples/pve_authorization.py
  • PASS — uv build
  • PASS — uv run python scripts/check_estate_identifiers.py
  • PASS — openspec validate extract-pve-foundation --strict --no-interactive
  • PASS — git diff --check
  • PASS — Gitleaks 8.30.1 (SHA-256-pinned archive) over git history, tracked blobs and commit messages: no leaks; estate-identifier scan over patch and messages: clean
  • Negative control — test_status_view_fails_closed_on_unknown_state rejects a stored succeeded/completed status; test_approved_is_authorized_but_not_executed proves approval plus the certificate gate never report execution.

Limits and risk

  • No executor exists in this source yet, so execution_state is always not_executed; outcome ingestion lands with tasks 4.x/5.1 through a trusted boundary. No agent-supplied execution evidence is accepted.

  • Approval lifecycle wire values are unchanged; existing PVE request, lease and certificate contracts are preserved.

  • This PR touches broker code and tests, so it requires exact-head CI, independent Gandalf review and a human merge; no merge, protection change or release is performed here.

  • Tests and documentation match the change.

  • Public-content scans cover the intended commits, blobs and messages.

  • No production credentials or real deployment identifiers are included.

  • Source, merge, release and deployment states remain distinct.

Implement OpenSpec task 3.3 (issue #7): the mTLS status view now exposes a documented contract that keeps approval and execution states distinct.

- GET /v1/broker/requests/{request_id} returns execution_state alongside the unchanged approval lifecycle status; the vocabulary is closed (not_executed, executing, succeeded, failed, uncertain) and the broker reports only not_executed, so approval, lease fetch and certificate issuance never imply execution.
- Unknown stored states fail closed; cross-identity reads stay refused without field disclosure.
- Contract and limits documented in docs/architecture.md; task 3.3 ticked with the issue link.

Verification: uv sync --frozen, ruff check/format --check, pytest (269 passed), examples/pve_authorization.py, uv build, check_estate_identifiers.py, openspec validate --strict, git diff --check: all PASS.

@ecomwizards-gandalf ecomwizards-gandalf 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.

Independent snapshot review of f8a766accbf7...e3e0feee95cd in mikomiel/privilege-broker by pi on codex-lb (gpt-6.1-sol).

Verdict: APPROVE

Reviewer output

Findings

No concrete reachable failure found in the reviewed change.

  • privilege_broker/pve/service.py:1069–1095 preserves existing approval wire values and adds a separate execution_state, always not_executed. Unknown stored approval states are rejected rather than exposed.
  • privilege_broker/pve/service.py:1269–1273 checks both original identity and source before constructing the status view, preserving the nondisclosing 403 response.
  • The change is focused, introduces no dependency or database migration, and leaves lease/certificate authorization paths unchanged. Documentation accurately limits the execution claim. No secret values were apparent in the diff.
  • The supplied PR title follows Conventional Commits.

Optional test improvements

  1. Exercise actual certificate issuance and lease retrieval.
    tests/test_pve_service.py:828–851 uses the default client without a certificate signer, so its certificate call reaches the not_ready gate rather than issuance. The test at lines 917–925 modifies only a copied row. Extend the existing real-issuance test to read status after successful lease retrieval and certificate issuance, asserting certificate_fetched is True and execution_state == "not_executed".

  2. Exercise fail-closed behavior through HTTP.
    tests/test_pve_service.py:905–915 tests the helper directly. Add an invalid stored status and verify the original client receives a generic 409 without request fields, while another identity still receives exactly the nondisclosing 403. This would cover route wiring and authorization ordering as well as helper validation.

Review scope and limitations

Read the complete supplied diff, the full service implementation, relevant fixtures and certificate tests, and the applicable repository standards and OpenSpec design.

Tests, lint, builds, scanners and OpenSpec validation were not run; no command-execution tool was available. Commit messages/history and exact-head CI evidence were not available in the supplied material, so I could not independently verify Conventional Commit compliance across the range or the PR’s validation claims. No relevant source file requested for inspection remained unread because of an access failure.

VERDICT: APPROVE

Evidence: not written. This review is evidence, not merge authorization.

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.

Expose authenticated approval and execution states to the requesting agent

1 participant