Skip to content

docs: add external checkpoint bridge example - #3342

Open
jw_ond (jw-ond) wants to merge 8 commits into
microsoft:mainfrom
jw-ond:osuite/external-checkpoint-bridge
Open

docs: add external checkpoint bridge example#3342
jw_ond (jw-ond) wants to merge 8 commits into
microsoft:mainfrom
jw-ond:osuite/external-checkpoint-bridge

Conversation

@jw-ond

Copy link
Copy Markdown

Description

Adds a dependency-free examples/external-checkpoint-bridge walkthrough showing how an AGT-style action envelope can be sent to an external checkpoint or verifier before tool execution, then mapped back to local AGT enforcement semantics.

The example demonstrates:

  • deterministic action-envelope hashing
  • local or remote checkpoint review via EXTERNAL_CHECKPOINT_URL
  • allow, require_approval, and deny verdict mapping
  • a small proof object that can be stored alongside an AGT audit trail

This keeps AGT as the runtime enforcement point while allowing an external verifier, ledger, or review service to contribute an independent signal.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update
  • Maintenance (dependency updates, CI/CD, refactoring)
  • Security fix

Package(s) Affected

  • agent-os-kernel
  • agent-mesh
  • agent-runtime
  • agent-sre
  • agent-governance
  • docs / root

Checklist

  • My code follows the project style guidelines (ruff check)
  • I have added tests that prove my fix/feature works
  • All new and existing tests pass (pytest)
  • I have updated documentation as needed
  • I have signed the Microsoft CLA

Attribution & Prior Art

  • This contribution does not contain code copied or derived from other projects without attribution
  • Any external projects that inspired this design are credited in code comments or documentation
  • If this PR implements functionality similar to an existing open-source project, I have listed it below

Prior art / related projects (if any):

External governance checkpoints and verifier services that review proposed actions before runtime execution. The example is intentionally generic and does not depend on a specific external service.

AI Assistance

  • I can explain every meaningful change in this PR: what it does, why, and what tradeoffs were considered
  • I have run tests and verification appropriate for this change
  • No part of this PR was autonomously submitted by an AI agent without my review
  • I have not used AI to generate review comments on others' PRs

If AI tools materially shaped this change, briefly note what was used:

Codex helped draft the example and README; output was reviewed before submission.

IP, Patents, and Licensing

  • This contribution does not implement patent-pending or patent-encumbered techniques
  • This contribution does not require an NDA or licensing agreement to understand or use
  • Any AI tools used have terms compatible with the MIT License

Related Issues

N/A

Verification

  • /tmp/openai-agents-python-ruff/bin/ruff format examples/external-checkpoint-bridge/demo.py
  • /tmp/openai-agents-python-ruff/bin/ruff check examples/external-checkpoint-bridge/demo.py
  • /opt/homebrew/bin/python3.11 -m py_compile examples/external-checkpoint-bridge/demo.py
  • /opt/homebrew/bin/python3.11 examples/external-checkpoint-bridge/demo.py

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

@github-actions

Copy link
Copy Markdown

Welcome to the Agent Governance Toolkit! Thanks for your first pull request.
Please ensure tests pass, code follows style (ruff check), and you have signed the CLA.
See our Contributing Guide.

@github-actions github-actions Bot added the documentation Improvements or additions to documentation label Jul 15, 2026
@github-actions

Copy link
Copy Markdown
🤖 AI Agent: contributor-guide — View details

AI-generated review output. Treat it as untrusted analysis and verify before acting.

Welcome, and thank you for contributing!

Your example is well-documented and demonstrates thoughtful design.

Before merging:

  1. Ensure the new Python file passes all tests (pytest) as indicated in the checklist.
  2. Verify compatibility with the project's style guidelines (ruff check).

For guidance, see CONTRIBUTING.md.

@github-actions

github-actions Bot commented Jul 15, 2026

Copy link
Copy Markdown
🤖 AI Agent: breaking-change-detector — API Compatibility

AI-generated review output. Treat it as untrusted analysis and verify before acting.

API Compatibility

No breaking changes detected.

@github-actions

github-actions Bot commented Jul 15, 2026

Copy link
Copy Markdown
🤖 AI Agent: security-scanner — View details

AI-generated review output. Treat it as untrusted analysis and verify before acting.

No security issues found.

@github-actions github-actions Bot added the size/L Large PR (< 500 lines) label Jul 15, 2026
@github-actions

github-actions Bot commented Jul 15, 2026

Copy link
Copy Markdown
🤖 AI Agent: code-reviewer — View details

AI-generated review output. Treat it as untrusted analysis and verify before acting.

TL;DR: 0 blockers, 1 warning. Example implementation is solid but lacks automated tests for critical paths.

# Sev Issue Where
1 Warn Missing tests for remote checkpoint validation examples/external-checkpoint-bridge/demo.py

Action items: Add unit tests for remote checkpoint validation logic, especially for malformed responses and enforcement mapping.

Warnings: Fine as follow-up PRs.

@github-actions

github-actions Bot commented Jul 15, 2026

Copy link
Copy Markdown
🤖 AI Agent: docs-sync-checker — Docs Sync

AI-generated review output. Treat it as untrusted analysis and verify before acting.

Docs Sync

Documentation is in sync.

@github-actions

github-actions Bot commented Jul 15, 2026

Copy link
Copy Markdown
🤖 AI Agent: test-generator — `examples/external-checkpoint-bridge/demo.py`

AI-generated review output. Treat it as untrusted analysis and verify before acting.

examples/external-checkpoint-bridge/demo.py

  • test_action_ref_for_invalid_input -- Validate that action_ref_for handles invalid input gracefully.
  • test_remote_checkpoint_invalid_url -- Ensure remote_checkpoint raises an error for invalid EXTERNAL_CHECKPOINT_URL.
  • test_parse_remote_verdict_invalid_json -- Test parse_remote_verdict with malformed JSON responses.
  • test_parse_remote_verdict_invalid_verdict -- Verify parse_remote_verdict rejects invalid verdict values.
  • test_map_to_enforcement_invalid_verdict -- Confirm map_to_enforcement raises an error for unsupported verdicts.

@github-actions

Copy link
Copy Markdown

PR Review Summary

Check Status Details
🔍 Code Review ⚠️ Missing No current-run comment
🛡️ Security Scan ⚠️ Missing No current-run comment
🔄 Breaking Changes ⚠️ Missing No current-run comment
📝 Docs Sync ⚠️ Missing No current-run comment
🧪 Test Coverage ⚠️ Missing No current-run comment

Verdict: ⚠️ AI review incomplete; ready for human review

AI review comments are untrusted advisory output. The summary reports workflow-generated completion status only, not model-authored pass/fail claims.

@MohammadHaroonAbuomar MohammadHaroonAbuomar left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

  • remote_checkpoint() calls urllib.request.urlopen on EXTERNAL_CHECKPOINT_URL with no scheme check; README says "HTTPS endpoint" but http:// and file:// are accepted. Add if not url.startswith("https://"): raise ValueError(...). This is a security-pattern example in a governance repo and should model transport hygiene, not just hash binding.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Self-contained interop example, correctly scoped and fail-safe (deny/pause mapping, action_hash rebinding check). Consider validating the https scheme on EXTERNAL_CHECKPOINT_URL to match the README.

@jw-ond

Copy link
Copy Markdown
Author

Thanks for the review. Updated in 42f020f to validate EXTERNAL_CHECKPOINT_URL before any remote checkpoint call: the demo now requires an https scheme and a non-empty host, so http://, file://, and malformed https URLs fail closed before urllib.request.urlopen is reached.

I also added focused tests for the URL validation path and the existing action_hash rebinding check.

Local verification run:

  • python3 examples/external-checkpoint-bridge/demo.py
  • python3 -m pytest examples/external-checkpoint-bridge/test_demo.py -q
  • python3 -m py_compile examples/external-checkpoint-bridge/demo.py examples/external-checkpoint-bridge/test_demo.py

@jw-ond

Copy link
Copy Markdown
Author

MohammadHaroonAbuomar thanks again for the security-pattern review. I addressed the transport hygiene point in the latest update: EXTERNAL_CHECKPOINT_URL is now validated before any remote checkpoint call, and the sample fails closed unless the endpoint uses HTTPS with a non-empty host.

I also added focused tests for the URL validation path and the existing action_hash mismatch handling.

Local verification I ran:

  • python3 examples/external-checkpoint-bridge/demo.py
  • python3 -m pytest examples/external-checkpoint-bridge/test_demo.py -q
  • python3 -m py_compile examples/external-checkpoint-bridge/demo.py examples/external-checkpoint-bridge/test_demo.py

Would appreciate a re-review when you have a chance.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Not ready to approve

The demo’s action_ref derivation and remote checkpoint parsing need tightening to avoid sensitive-data leakage and avoid unclear runtime failures from malformed/invalid remote responses.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

This review doesn't count toward merge requirements. Sign up for the private preview to control whether Copilot approvals count.

Pull request overview

Adds a new dependency-free example under examples/ that demonstrates sending an AGT-style action envelope to an optional external checkpoint/verifier (via EXTERNAL_CHECKPOINT_URL) and mapping its verdict back into local enforcement semantics.

TL;DR: 2 blockers, 2 warnings. Fix action_ref derivation and remote response validation and this ships.

# Sev Issue Where
1 Block action_ref is not hashed and can leak sensitive args; also contradicts “hashing” claim demo.py
2 Block Remote payload assumptions can raise AttributeError/KeyError instead of a clear error demo.py
3 Warn Deterministic JSON serialization should be tightened for canonicalization consistency demo.py
4 Warn Add tests for action_ref determinism + invalid remote verdict handling (fine as follow-up) test_demo.py

Changes:

  • Adds a runnable Python demo implementing local vs. remote checkpoint review and verdict→enforcement mapping.
  • Adds a README walkthrough describing usage, expected output, and scope.
  • Adds pytest coverage for HTTPS URL validation and action_ref mismatch rejection.
File summaries
File Description
examples/external-checkpoint-bridge/demo.py Implements deterministic envelope creation, optional remote checkpoint call, and verdict→enforcement mapping demo.
examples/external-checkpoint-bridge/README.md Documents how to run the example locally or against an HTTPS checkpoint endpoint.
examples/external-checkpoint-bridge/test_demo.py Adds basic pytest coverage for remote URL validation and action_ref mismatch handling.
Review details
  • Files reviewed: 3/3 changed files
  • Comments generated: 4
  • Review effort level: Low

We're testing this review assessment. Please use 👍 or 👎 to tell us if it's correct.

Comment on lines +49 to +51
def stable_json(value: Any) -> str:
"""Serialize JSON deterministically for hashing and checkpoint review."""
return json.dumps(value, sort_keys=True, separators=(",", ":"))
Comment on lines +64 to +75
ref_input = {
"actor": actor,
"runtime": runtime,
"tool_name": tool_name,
"proposed_action": proposed_action,
"arguments": arguments,
"policy_id": policy_id,
}
return {
"action_ref": stable_json(ref_input),
**ref_input,
}
Comment on lines +114 to +130
with urllib.request.urlopen(request, timeout=10) as response:
payload = response.read().decode("utf-8")
verdict = json.loads(payload)

if verdict.get("action_ref") != envelope["action_ref"]:
raise ValueError(
"Remote checkpoint returned a verdict for a different action_ref."
)

return {
"verdict": verdict["verdict"],
"reason": verdict.get("reason", "External checkpoint returned no reason."),
"decision_id": verdict.get(
"decision_id", f"remote-{envelope['tool_name']}"
),
"action_ref": envelope["action_ref"],
}
Comment on lines +81 to +84
assert observed == {
"url": "https://checkpoint.example.com/review",
"timeout": 10,
}
Copilot AI review requested due to automatic review settings July 30, 2026 15:55
@github-actions github-actions Bot added size/XL Extra large PR (500+ lines) and removed size/L Large PR (< 500 lines) labels Jul 30, 2026
@jw-ond

Copy link
Copy Markdown
Author

Addressed the latest Copilot feedback in 5e99cda.

Changes made:

  • Replaced the proof-object action_ref with an opaque deterministic reference so raw tool arguments are not copied into stored proof objects.
  • Kept the full action envelope available to the checkpoint for review while avoiding argument leakage through action_ref.
  • Added strict remote checkpoint response parsing that fails closed for invalid JSON, non-object payloads, action_ref mismatch, unsupported verdicts, empty reason, and empty decision_id.
  • Made map_to_enforcement reject unsupported verdict values instead of implicitly treating unknown values as deny.
  • Updated the README to clarify that this example uses an opaque demo reference and that production cryptographic proof should use approved AGT APIs or an external verifier.

Verification run locally:

  • python3 examples/external-checkpoint-bridge/demo.py
  • python3 -m pytest examples/external-checkpoint-bridge/test_demo.py -q
  • python3 -m py_compile examples/external-checkpoint-bridge/demo.py examples/external-checkpoint-bridge/test_demo.py
  • bash scripts/ci/no-custom-crypto.sh origin/main

The latest remote checks are also green. The remaining AI code-review output is a warning only and lists no action items.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Not ready to approve

parse_remote_verdict() can currently throw TypeError on malformed remote payloads, which breaks the intended fail-closed error handling.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

This review doesn't count toward merge requirements. Sign up for the private preview to control whether Copilot approvals count.

Review details

Comments suppressed due to low confidence (2)

examples/external-checkpoint-bridge/test_demo.py:127

  • Add a regression case where verdict is a non-string (e.g., []) to ensure malformed remote payloads produce a ValueError (and don’t regress back to TypeError from set membership checks).
    [
        ("not-json", "invalid JSON"),
        ("[]", "JSON object"),
        (
            json.dumps(
                {
                    "verdict": "escalate",
                    "reason": "Unsupported verdict.",
                    "decision_id": "dec_test",
                    "action_ref": "use-envelope-ref",
                }
            ),
            "verdict must be one of",
        ),

examples/external-checkpoint-bridge/demo.py:165

  • parse_remote_verdict() can raise a TypeError instead of the intended ValueError when the remote payload contains a non-string verdict (e.g., a JSON array), because set membership on ALLOWED_VERDICTS requires a hashable value. This undermines the “fail closed with a clear error” goal.
    verdict = raw_verdict.get("verdict")
    if verdict not in ALLOWED_VERDICTS:
        raise ValueError(
            "Remote checkpoint verdict must be one of: allow, require_approval, deny."
        )
  • Files reviewed: 3/3 changed files
  • Comments generated: 0 new
  • Review effort level: Low

We're testing this review assessment. Please use 👍 or 👎 to tell us if it's correct.

Copilot AI review requested due to automatic review settings July 30, 2026 16:28
@github-actions github-actions Bot added the tests label Jul 30, 2026
Copilot AI previously approved these changes Jul 30, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Ready to approve

The change is isolated to a self-contained example plus tests, with only minor best-practice follow-ups identified.

This review doesn't count toward merge requirements. Sign up for the private preview to control whether Copilot approvals count.

Review details

Comments suppressed due to low confidence (2)

tests/test_external_checkpoint_bridge.py:23

  • The dynamic import should assert that the module spec and loader are not None (matching existing test patterns in tests/ci/*). Without these asserts, a missing/invalid path would fail with less-informative AttributeError/TypeError at import time.
_spec = importlib.util.spec_from_file_location(
    "external_checkpoint_bridge_demo", _EXAMPLE_DIR / "demo.py"
)
demo = importlib.util.module_from_spec(_spec)  # type: ignore[arg-type]
sys.modules["external_checkpoint_bridge_demo"] = demo

examples/external-checkpoint-bridge/demo.py:131

  • Use the standard "Content-Type" header casing for the JSON payload. While header names are case-insensitive per HTTP, some intermediary tooling/server frameworks are buggy and may not recognize non-standard casing.
        headers={"content-type": "application/json"},
  • Files reviewed: 3/3 changed files
  • Comments generated: 0 new
  • Review effort level: Low

We're testing this review assessment. Please use 👍 or 👎 to tell us if it's correct.

Copilot AI review requested due to automatic review settings July 30, 2026 16:34
Copilot AI dismissed their stale review, a newer Copilot review was requested July 30, 2026 16:36
Copilot AI previously approved these changes Jul 30, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Ready to approve

Only a minor test-loading convention issue was found; the example logic and validation behavior are well-covered by the added tests.

This review doesn't count toward merge requirements. Sign up for the private preview to control whether Copilot approvals count.

Review details

Comments suppressed due to low confidence (1)

tests/test_external_checkpoint_bridge.py:23

  • The dynamic module load should assert the spec/loader are present (as done in other tests under tests/ci/) instead of relying on type: ignore; this avoids obscure AttributeError failures during pytest collection if the example path changes or the loader is unavailable.
_spec = importlib.util.spec_from_file_location(
    "external_checkpoint_bridge_demo", _EXAMPLE_DIR / "demo.py"
)
demo = importlib.util.module_from_spec(_spec)  # type: ignore[arg-type]
sys.modules["external_checkpoint_bridge_demo"] = demo
_spec.loader.exec_module(demo)  # type: ignore[union-attr]
  • Files reviewed: 3/3 changed files
  • Comments generated: 0 new
  • Review effort level: Low

We're testing this review assessment. Please use 👍 or 👎 to tell us if it's correct.

Copilot AI review requested due to automatic review settings July 30, 2026 16:48
Copilot AI dismissed their stale review, a newer Copilot review was requested July 30, 2026 16:51

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Ready to approve

The change is self-contained (new example + tests), follows existing repo conventions, and introduces no risky behavior into production code paths.

This review doesn't count toward merge requirements. Sign up for the private preview to control whether Copilot approvals count.

Review details
  • Files reviewed: 3/3 changed files
  • Comments generated: 0 new
  • Review effort level: Low

We're testing this review assessment. Please use 👍 or 👎 to tell us if it's correct.

@jw-ond

Copy link
Copy Markdown
Author

Update on the previous review items:

  • EXTERNAL_CHECKPOINT_URL now fails closed unless it is an HTTPS endpoint with a non-empty host.
  • action_ref is now an opaque deterministic reference, so proof objects do not copy raw tool arguments.
  • Remote checkpoint responses are strictly parsed and fail closed for invalid JSON, non-object payloads, unsupported verdicts, missing reason/decision_id, and action_ref mismatch.
  • Detailed coverage now lives in tests/test_external_checkpoint_bridge.py rather than under examples/, including local verdict branches, remote URL review, deterministic action_ref behavior, stable JSON canonicalization, malformed remote payloads, and enforcement mapping.
  • Latest Copilot review on 8809b651 is approved, and all remote checks are green.

Local verification run:

  • python3 -m pytest tests/test_external_checkpoint_bridge.py -q
  • python3 examples/external-checkpoint-bridge/demo.py
  • python3 -m py_compile examples/external-checkpoint-bridge/demo.py tests/test_external_checkpoint_bridge.py
  • bash scripts/ci/no-custom-crypto.sh origin/main

MohammadHaroonAbuomar the transport-hygiene concern from your changes-requested review should be addressed now; a re-review would unblock the stale review state.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.

jw_ond (jw-ond) and others added 8 commits August 9, 2026 18:21
Signed-off-by: jw_ond <THU-Tokyo@outlook.com>
Signed-off-by: jw_ond <THU-Tokyo@outlook.com>
Signed-off-by: jw_ond <THU-Tokyo@outlook.com>
Signed-off-by: jw_ond <THU-Tokyo@outlook.com>
Signed-off-by: jw_ond <THU-Tokyo@outlook.com>
Signed-off-by: jw_ond <THU-Tokyo@outlook.com>
Signed-off-by: jw_ond <THU-Tokyo@outlook.com>
Signed-off-by: jw_ond <THU-Tokyo@outlook.com>
@jw-ond
jw_ond (jw-ond) force-pushed the osuite/external-checkpoint-bridge branch from 156a597 to 71e709c Compare August 9, 2026 10:34
@jw-ond

Copy link
Copy Markdown
Author

Rebased this branch onto current main to remove the stale-base CI noise that was affecting the spell/link jobs.

What changed in this update:

  • PR branch is now 0 commits behind main; the PR diff is back to the 3 intended files.
  • Re-ran the spell-check added-lines flow locally against current main; it passes.
  • Re-ran the example tests and guards locally.

Local verification:

  • python3 -m pytest tests/test_external_checkpoint_bridge.py -q -> 20 passed
  • python3 examples/external-checkpoint-bridge/demo.py
  • python3 -m py_compile examples/external-checkpoint-bridge/demo.py tests/test_external_checkpoint_bridge.py
  • bash scripts/ci/no-custom-crypto.sh origin/main
  • python3 scripts/ci/changed_lines.py --base origin/main --extensions ".md,.txt,.rst,.py,.ts,.js,.go,.rs,.cs,.yml,.yaml" --mode added-lines --output ci-diff/spell-check-added-lines.txt followed by npx cspell@8.17.3 ci-diff/spell-check-added-lines.txt --config .cspell.json --no-progress --no-summary

I also checked #3620 and #3613. #3620 explains the previous markdown-link-check failure mode: the job was checking files changed on main since the branch point, not only files changed by this PR. #3613 references this PR as an external-checkpoint/verifier example, but it is a separate MAF execution-identity RFC rather than a duplicate of this example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/XL Extra large PR (500+ lines) tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants