Skip to content

integrations, tests: every registry names its authorizer and every tool its risk class - #91

Open
arybach wants to merge 15 commits into
mainfrom
feat/agent-harness-authz-c3
Open

arybach wants to merge 15 commits into
mainfrom
feat/agent-harness-authz-c3

Conversation

@arybach

@arybach arybach commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Depends on agent-harness #33 and #34. Draft until #34 merges: pyproject.toml pins the harness commit at the tip of that stack.

History correction (why the commit list changed)

The branch this PR came from was based on feat/agent-harness-integration (c255945) — the line merged as #48 into v4, which no longer exists on the remote — while main had moved on by 129 commits. Against main the PR therefore showed 12 commits (7 of them not C3's), 29 files / +1429 / −271, and CONFLICTING / DIRTY. The local origin/main ref was stale when the base was chosen; that was my error, not GitHub's.

Rebuilt instead of patched around, per instructions: fetched all refs, kept 5bf05d3 as a local backup ref, created a clean branch from origin/main (21a7c24), and cherry-picked -x only the five C3 commits, excluding the seven inherited transcript-compaction/integration commits. Then --force-with-lease against the recorded head, so the update could not clobber a push I had not seen. Nothing was merged, no release branch was touched, and the PR and its draft status are preserved.

before after
head 5bf05d3 c4051cf
commits vs main 12 (7 not mine) 8, all C3's
diff 29 files, +1429 / −271 38 files, +1060 / −128
mergeability CONFLICTING / DIRTY MERGEABLE (blocked only by draft)
CI no runs at all (branch predated tests.yml) tests + docs-check + secret-scan all run

Two conflicts were resolved by hand, both additive:

  • tests/conftest.py — an add/add: main's file isolates the state directory (_per_test_home, _no_stray_state_in_cwd, skip-reason summary), C3's isolates the authorization plane (_clean_authorizer_plane, local_run). Kept both, with the package import placed after the home-variable setup so main's documented import-order rule still holds, and _clean_authorizer_plane declared after _per_test_home. That cleanup is load-bearing: one leaked process-wide authorizer turns every later fail-closed assertion into a passing one.
  • pyproject.toml — the pin line only; kept 7e422f5, the reviewed C2 tip. Not 6b8ba3a (main's old pin, which has no ToolSpec.action), and not dc84ebf, which is on no branch descending from harness main at all.

The other nine overlapping files merged cleanly and were read, not trusted: main's additions are orthogonal — the MCP stdio environment allowlist in tools/mcp.py, revenue_intelligence in the fleet CATALOG, importorskip("httpx") and encoding= fixes in the tests. All present after the replay; all verified below.

What this does

1. A tenant refuses to start without an authorization plane — context_runtime/tools/authz.py. resolve_authorizer() takes three paths and no fourth: an explicit authorizer=, else a plane installed process-wide with set_default_authorizer() (what agentic_os.app_gate.install_gate does), else an explicitly declared local authority — local_trust=True with a written local_trust_reason, or CR_LOCAL_AUTHORITY="<reason>". None of the three raises at construction. CR_LOCAL_AUTHORITY=1 is refused: a bare truthy value carries no reason, and a value that says nothing is how an allow-all switch reaches a production compose file.

2. Every mounted tool carries a class the caller declared. mount_mcp(..., actions={...}, default_action="write") — keyed by registered name or by the server's own name under a prefix, resolved stricter-wins so the spelling cannot downgrade the class; unmounted-by-default to write. readOnlyHint / title pass through as annotations and relax only the approval gate: the code asking to be run does not grade its own risk. AgentConsole.tool(..., action=...), mount_tools(..., actions=...) and AgentConsole.validate() do the same for local tools — the console builds without a plane (an app's gate installs one a moment later) but refuses to serve that way.

3. Classes were read off the code, and each cites a row that exists. block_ip is write because the platform registers the same capability (sentinel.block_ip, apps/edge-sentinel/operator.py:57, write in agentic_os/tool_actions.py and TOOL_CLASSIFICATION_INVENTORY.md); perform_sweep is write (fetches third-party pages, persists the result); refresh_metabase is read; fulfill_dsar is delete. Where the platform has no counterpart — close (it registers only close_status, a read), social.draft vs this repo's local simulated draft_caption — the divergence is stated rather than propped up with a borrowed citation.

4. Carried onto the code main added (the part a straight cherry-pick could not know about):

  • The 13th registry. revenue_intelligence.py and its provider/CRM tools (hubspot_crm.py, salesforce_crm.py) now resolve their plane and declare classes: provider enrichment read (platform row: outreach.enrich), outreach_prepare read, outreach_send write (added to _ACTION_CLASSES, row outreach.send_all), crm_enrich read, crm_update write.
  • The fleet could not boot. Fleet.up() builds a tenant per module at control-plane import, so tenants that refuse to start meant a container that never answered /health — the container test caught exactly that. The fleet now follows the AgentConsole rule (on_missing="deny_later"): it boots, warns once, and every tool call stays denied with missing_authorizer — because /status looks identical either way. No image bakes the escape hatch in.
  • An action nobody had read. The boot failure was the fleet action sidekick.coder has no recorded risk class: spec_for() builds specs from a module the registry discovered at run time, so a curated table cannot contain those names — and refusing to boot over one left an operator no way to run a custom module. So the cases split: a CATALOG action without a class is still a start-up error (this file wrote that name); a discovered action registers unclassified — matched by no grant, therefore denied — with one warning naming it. Guessing read for an action nobody read is the failure this migration exists to remove.
  • The image pins move with the pin: Dockerfile, deploy/geo-demo/Dockerfile.aks, deploy/proxmox-demo/Dockerfile.contextruntime → 7e422f5…, digest 231eef6b8877127bf61834e271707cab6c28411e6a7b6236210a44a6704612a8. The method is reproducible, which is the only way a digest can be checked rather than trusted: re-hashing the commit this replaces (6b8ba3a) returns exactly the d67eadb33c16… those files carried.
  • Nine main-added tests that run tools (test_revenue_intelligence, test_hubspot_crm, test_runtime_scan) now declare their plane via local_run; their assertions are unchanged — test_runtime_scan's four MCP tests had never got past missing_explicit_grant on the first call, so they had not been testing their scope/approval assertions at all.

Verification (measured on the rebuilt branch)

  • Full suite, CI's own recipe on a fresh venv installed with CI's command (pip install -e ".[dev,test,control-plane,duckdb]" numpy pillow, i.e. harness pulled from git at the pin): python -X warn_default_encoding -m pytest tests -q -rs → exit 0, 0 failures / 0 errors, 1186 tests collected, 20 skips (all optional-dependency or platform: runtime_contracts, intelligence_gateway, fastembed/turbovec, CUDA, Windows ACL/junctions). tests.yml is inherited from main and is running on this head.
  • CI's lint step verbatim: ruff check --preview --select PLW1514 context_runtime scripts tests examples eval benchmarks → All checks passed!
  • Container, for real: test_image_builds_starts_and_fails_closed builds the image and starts it → passes (auth fail-closed on every route, /health up). This is where the fleet's start-up rule met an actual container rather than a fixture.
  • Negative controls still deny: no authorizer → every call denied with missing_authorizer; read on a side-effecting tool rejected at registration; re-registering cannot lower a class; CR_LOCAL_AUTHORITY=1 refused; an MCP readOnlyHint cannot supply the class; mount_mcp with an out-of-vocabulary class raises.
  • Vocabulary parity, the check that spans repos: agent_harness.tools.ACTIONS == agentic_os.permissions.ACTIONS == ("read","write","delete") (compared directly), the resource triple {resource_kind, resource_name, requested_action} is a subset of runtime_contracts.authz.decision.ENVELOPE_FIELDS (checked against the contract checkout), _ACTION_CLASSES covers every CATALOG action with no gaps, and every action= in the package is one of the three spellings.
  • Pin coherence: 6b8ba3a (main's old pin) → harness main 876ae44 → fix(plancache): bind plan-cache key to tenant + permissions (F5 cross-tenant isolation) #33 aee808f → feat: open-source the context-management optimizations (F1–F4) into the AGPL core #34 7e422f5, so the new pin is a strict forward move, not a side branch.

Flagged, not fixed

agentic_os.permissions.make_authorizer's docstring promises "a spec can tighten, never downgrade", but the function never reads spec.action — it cross-checks only spec.side_effecting against a read registration. Harmless while specs carried no class; after #34 they do, so the sentence describes a check that does not exist. Follow-up in agentic-os: take the stricter of tool_actions[name] and spec.action, or delete the claim. Verified while I was there: because the plane ignores spec.action, this PR's action="write" default does not silently reclassify the existing traffic_summary / add_watch / privacy_summary consoles, and no agentic-os call-site uses ToolRegistry.required_capability().

Reviews worth asking for

  1. The fleet's deny_later choice is the one judgement call here. It keeps the control plane bootable and every call denied; a reviewer may prefer it to refuse to start and force an explicit decision in the manifest. Both are defensible — pick one and I'll follow.
  2. Unclassified-by-default for discovered modules. Custom modules currently deny every action until someone adds a class. That is intentional, but it is a behavioural change for anyone running a non-CATALOG module today.
  3. social_autopilot.draft_caption = read diverges from the platform's social.draft = write, because that one calls a generation service and this one is a local simulation. If you would rather the class follow the capability than the shipped implementation, that is a one-line change and the comment is already written.

🤖 Generated with Claude Code

Alex Mats added 8 commits November 22, 2026 09:50
…lane

Since agent-harness stopped reading "no authorizer" as "allow everything", a registry without a plane denies
every call it is given. Context Runtime had eleven tenants and a console building registries, and nothing in the
package said where their decisions come from — so the upgrade would have landed as a fleet that answers nothing,
with the tempting local fix being a lambda that returns True, which is an unnamed allow-all by another name.

tools/authz.py makes the source of authorization one decision with three answers: pass authorizer=... (a
permissions plane bound to a principal), inherit the process-wide plane installed with set_default_authorizer(),
or declare local execution out loud — local_trust=True with a written reason, or CR_LOCAL_AUTHORITY for a whole
process. None of the three, and building a tenant raises with all three named. Local execution is never implied
by the absence of a plane, because the absence of one is exactly what a misconfigured server looks like too.

The console resolves differently, and deliberately so: it is built at module import inside apps whose gate
installs a plane per request, so refusing to import an app is a worse failure than the console answering every
tool call with missing_explicit_grant. It builds, logs the gap once, and validate() turns that gap into a
start-up failure for an app that wants one.

Test suites that run tools declare local execution once per test (tests/conftest.py::local_run) — the same
declaration a laptop deployment makes once at start-up. Where a test asserts a denial, it now also asserts which
gate denied it: with no plane the call stops before the approval policy, and such a test would pass while
proving nothing about the gate named in its title.

(cherry picked from commit 983d5e4)
An MCP server is code pulled from somewhere else, and its readOnlyHint is that code's own announcement about
itself. mount_mcp now takes the risk class from the operator — actions={"ffmpeg.convert_video": "read"} — and
grades anything left out of the map as write. The hint still moves the approval gate, because "this one does not
need confirming" is a claim an operator may choose to believe; it no longer moves the authorization class, which
is the decision about whether the call happens at all. Before this, an MCP tool had no class whatsoever, so a
deployment could not say "reads yes, mutations no" to a server mounted into a user-facing chat.

Three details where the seam could have been quietly wrong. A class outside the vocabulary — the "readonly"
typo — is refused at mount time instead of becoming a class no policy on earth can match. A map keyed both by
the server's own name and by the mount's prefixed name resolves to the stricter of the two, so spelling cannot
decide how much damage is authorised. And a tool classed "read" cannot also declare itself side-effecting: the
spec is made consistent with the class, rather than the class quietly raised to match a mount-wide default.

The console's @tool decorator takes the same class where the person writing the function can state it, and the
console gains validate() — the start-up check that refuses to serve with unclassified tools or no plane — plus
explicit local_trust/local_trust_reason like every other tenant. Its denial message now says whether it stopped
for want of a grant or for want of a confirmation, because the fix to "I ran the demo and it refused" is
different for each, and the two used to read the same.

(cherry picked from commit ff1319e)
The integrations pass action= to ToolSpec and read registry.classification()/validate(); tools/authz.py hands a
registry a plane built from Authorization/PolicyReason. None of that exists at dc84ebf, so anyone installing
this branch — the README path, a fresh venv, a deploy — got a harness the package cannot run against, while the
local suite stayed green because this venv has agent-harness installed editable from a working tree two commits
ahead of the pin. There is no test workflow in this repo (docs-check and secret-scan only), so nothing downstream
would have said so either; the pin is the whole install contract.

Verified against the pin rather than the checkout: a fresh venv with agent-harness fetched from the pinned commit
on GitHub, this package installed --no-deps, plus pyyaml/pytest/httpx, runs the tools, authorizer, MCP, console
and tenant suites green — 66 passed, 1 skipped. The floor and why it is there are now written above the pin, so a
future bump knows what it must not fall below.

(cherry picked from commit 83cd3bc)
The classes themselves were right; three of the citations behind them were not. That matters more here than in
ordinary prose: a comment naming a capability the platform's classification table does not contain is worse than
no comment, because the next reader checks the class against a row they cannot find and concludes the table is
decorative.

* edge_sentinel.block_ip cited apps/edge-sentinel/operator.py:79 and a capability `ban_ip` living there. The
  blocking capability is `sentinel.block_ip`, registered at operator.py:57, listed write in
  agentic_os/tool_actions.py — which separately registers the console tool `ban_ip` as write — and in
  docs/TOOL_CLASSIFICATION_INVENTORY.md. The class stands, the pointer did not.
* modules._ACTION_CLASSES justified post / send_campaign / send_sequence with `send_email`, `post_to_channel`
  and `billing.charge`, none of which the table has. The rows that do exist are social.publish,
  outreach.send_all, billing.refund and billing.dunning, all write. `close` has no counterpart at all (the
  platform registers only close_status, a read of whether a period is closed), so it is now classified from
  what closing a period does — it posts entries — instead of leaning on a borrowed citation.
* social_autopilot.draft_caption is read while the platform's social.draft is write, because agentic-os's draft
  calls an external generator and the shipped function here is a local simulation. The divergence, and the
  condition that ends it (a caller passing caption_tool_factory that reaches a service), are stated instead of
  left for the next person to rediscover.

Checked class-by-class against agentic_os/tool_actions.py: refund, dunning, escalate (support.escalate),
remediate (compliance.remediate), rollback (infra.rollback_release), block_ip (ban_ip / sentinel.block_ip) and
fulfill_dsar (privacy.delete = delete) match the platform; control-tower's bi.refresh and market-radar's
crm.research / sbom / add_watch comparisons hold. The read-only tenants — fetch_signals, draft_teardown,
draft_attribution_report, draft_caption — return text and write nothing, which is what read means there.

(cherry picked from commit 2f02487)
… authority

This one was being carried as "pre-existing" and it was not. It builds ToolRegistry(ApprovalPolicy("bypass"))
with no authorizer, so under authz/v1 every call in the loop is denied; the test then asserts that the model
recovered a tool output it had dropped, which cannot happen to a tool that never ran. It fails at the base
commit for the same reason — base plus the C1/C2 harness is precisely the mismatch this branch exists to close —
which is why "it also fails at base" was never evidence that it was unrelated to this change.

Both loop tests now take local_run. The context-error test asserted only that the archive was non-empty, and a
denial message would have filled an archive just as well, so it now checks that a stored entry really is the
tool's five thousand x's. The assertion that passes for the wrong reason is the one a migration leaves behind.

(cherry picked from commit 5bf05d3)
…dded

Replaying C3 onto current main surfaced two things this branch had never seen, because its old base predated
both. Neither is a merge artifact to paper over: each is a registry or a tool the fail-closed plane now has to
answer for.

**The 13th registry.** `revenue_intelligence.py` builds one per tenant, plus tools in `hubspot_crm.py` and
`salesforce_crm.py`. It now resolves its authorizer the way the other twelve do, and every tool in that path
declares its class: provider enrichment `read` (the platform's comparable row is `outreach.enrich` = read; the
money these calls cost is metered separately in `external_spend`/`PROVIDER_COST`, and spending money is not the
same axis as changing state — `ProviderTool.live` is a flag the class never acts on), `outreach_prepare` `read`
(a draft returned to the caller; the platform splits the pair the same way, `outreach.draft_pitch` read vs
`outreach.send_all` write), `outreach_send` `write`, `crm_enrich` `read` (a query against a platform service,
network or not), `crm_update` `write` (a PATCH on a record in the customer's system of record). The GTM fleet
action `outreach_send` joins `_ACTION_CLASSES`, whose raise-on-missing-class is the point of the table.

**The fleet could not boot.** `Fleet.up()` builds a tenant per module at control-plane import, so with tenants
that now refuse to start, the control-plane container stopped answering `/health` — the container test caught
it. The fleet follows `AgentConsole`'s rule (`on_missing="deny_later"`), because the embedding application
installs its gate a moment after this import and a process that boots and denies is diagnosable where one that
refuses to start is not. It is not a grant: every tool call stays denied with `missing_authorizer`, and
`/status` looks identical either way — so the fleet says so once, in a warning naming both ways out
(`set_default_authorizer(...)`, or `CR_LOCAL_AUTHORITY="why this process is trusted"`). No image bakes the
switch in; that choice stays with whoever deploys, which is why `CR_LOCAL_AUTHORITY` demands a sentence.

**And one action nobody had read.** The failure was `the fleet action sidekick.coder has no recorded risk
class`: `spec_for()` builds specs from a module the registry discovered at run time, so those action names come
from data, not from this file — a curated table cannot contain them, and refusing to boot over one of them gives
an operator no way to run a custom module. So the two cases split. A `CATALOG` action with no class is still a
start-up error, because this repository wrote that name. A discovered action registers **unclassified** —
matched by no grant, therefore denied — with one warning naming it. Guessing `read` for an action nobody read is
the exact failure this migration exists to remove; leaving it unknown and denied is what the platform's own rule
prescribes.
The pin bump moved `pyproject.toml` only. Three images install agent-harness themselves — from the commit's
source archive, with the archive's sha256 pinned, because the image has no git in it — and two tests compare
them: `tests/test_container.py::test_dockerfile_pins_the_same_agent_harness_commit_as_pyproject` and
`tests/test_geo_image.py::test_agent_harness_pin_equals_the_repository_dockerfile_and_pyproject`. Both were red
on the replayed branch until now.

`Dockerfile`, `deploy/geo-demo/Dockerfile.aks` and `deploy/proxmox-demo/Dockerfile.contextruntime` move to
`7e422f541fc480e4c0cbb8d25789cdae359a9d46`. The digest `231eef6b8877127bf61834e271707cab6c28411e6a7b6236210a44a6704612a8`
is the sha256 of `https://github.com/redevops-io/agent-harness/archive/<commit>.tar.gz`; the method is
reproducible, which is the only way to know a digest was computed rather than guessed: re-hashing the commit
this replaces (`6b8ba3a`) returns exactly the `d67eadb33c16…` those files carried before.

`test_image_builds_starts_and_fails_closed` passes against the rebuilt image, which is the check that matters
here — it is the one that runs the control plane for real, so it is where the fleet's start-up behaviour met an
actual container rather than a test fixture.
Nine tests main added run tools through a tenant or a mounted MCP server, and under authz/v1 a registry with no
plane denies everything. They take `local_run` — the declared local authority, attributed as `pytest_local` in
the decision trail — rather than an unnamed allow-all lambda per registry.

`test_revenue_intelligence.py` (four) and `test_hubspot_crm.py` (one) construct `RevenueIntelligenceTenant`,
which now refuses to build without an answer to "who authorizes this"; `test_runtime_scan.py` (four) drives
`scan.scan_start` through the mounted deploy-scan MCP server and was failing with `missing_explicit_grant` on
the very first call, so its four MCP tests never reached the scope and approval assertions they exist to check.

None of these is a relaxed assertion: every assertion that was there still runs. What changed is that the run
now has an authorizer to deny it, which is the difference between a failing test and a test that was never
asking anything.
@arybach
arybach force-pushed the feat/agent-harness-authz-c3 branch from 5bf05d3 to c4051cf Compare November 22, 2026 15:08
Alex Mats and others added 4 commits November 22, 2026 14:07
`AgentConsole._answer_tool` asked the failed `ToolResult` for a `denied` flag that
`agent_harness.tools` has never carried, so every authorization denial on a console tool raised
AttributeError inside `respond` and the app answered 500 — the one path where a refused user most
needs a reason. The flag is honoured when a result carries one; otherwise the registry's own audit
trail decides, because that is where the two gates sign their names: an authorization outcome
carries the plane's attribution (policy_reason/plane), while an approval hold writes only the four
keys it has always written. A held side effect still answers "needs confirmation".

Co-Authored-By: Cline <cline@dev.io>
Nine tenants ship a local simulation of one tool and register it at the class that simulation
earned — `read`, because building a string touches nothing (market_radar's sweep is `write`: it
fetches and stores). All nine also accept a `*_tool_factory` that replaces that simulation with
code this repository has never read, and not one of them moved the class when it happened: pass a
function that posts to a vendor and the tool stayed a `read`, so a principal holding only a read
grant could run it. The social_autopilot note even promised the integrator would re-register it as
write; nothing enforced the promise.

`tools/actions.resolve_action` settles it the way `resolve_authorizer` and `mount_mcp(actions=)`
already settle their seams. Nothing injected, the reviewed class stands. Something injected, the
integrator declares the class of their own function through the tenant's new `*_action` keyword,
and construction refuses instead of inheriting. A class outside ACTIONS refuses on either side: a
typo is not a risk class, a wrong class runs on someone else's permission, and an unclassified one
is matched by no grant and denied at every call.

Co-Authored-By: Cline <cline@dev.io>
… down

A declaration is not an authorization guarantee. The first cut of this seam let the integrator name any
class, which moved the problem instead of closing it: the code asking to run was still grading its own risk,
just out loud. So the seam now has a floor and a contract.

Anything injected into a tenant's `*_tool_factory` seat is registered at `write` — a function this repository
did not write is assumed to leave the process. The only way below the floor is `pure_read("<sentence>")`, a
typed claim whose reason is checked for saying something, and then checked against the function's own source
using the sink vocabulary the platform's FR-04 sweep runs over its own read-classified tools. A visible
`post`, `subprocess.run`, `open(..., "w")` or `os.remove` beats the claim; so does a `rmtree` hiding behind a
`write`, which is the same under-declaration one rung lower. Ambiguous verbs (`remove`, `rename`, `move`)
count only when the object they are called on names a filesystem, because a rule that flags `rows.remove(x)`
is a rule that trains people to declare without reading.

The blind spot is named in the module rather than hidden: the sweep reads the callable handed over, not what
it delegates to, which is why the floor exists at all.

Co-Authored-By: Cline <cline@dev.io>
The four places that name a harness commit (pyproject and the three Dockerfiles) move together from
`7e422f5` to `10e5c2a`. The extra commit is not this repository's own code path — Context Runtime never
calls `engine_authorizer_of` — it is what the engine does with what this repository hands it: a tenant that
names no authorizer inherits the process default, and at the previous pin a registry reads a platform
plane's "allowed" as silence and denies the call it was just granted. Pinning past the last symbol this
repository imports is deliberate, and the comment next to the dependency now says so.

The archive hashes are the sha256 of each commit's GitHub source archive. The method was checked against
the pin it replaces: downloading `7e422f5` reproduces `231eef6b…`, the value these lines carried, and
`10e5c2a` hashes identically across two fetches.

Co-Authored-By: Cline <cline@dev.io>
@arybach

arybach commented Nov 22, 2026

Copy link
Copy Markdown
Contributor Author

Two commits added since you last saw this branch — both are about a hole the first cut of the seam left open.

0b95a57 — a replaced implementation can no longer inherit or declare its way into a weaker class.

Nine tenants ship a local simulation of one tool, register it at the class that simulation earned (read; market_radar's sweep is write because it fetches and stores), and expose a *_tool_factory that replaces it. None of them moved the class when it happened: pass a function that posts to a vendor and the tool stayed a read, so a principal holding only a read grant could run it. social_autopilot's comment even promised the integrator would re-register it as write — nothing enforced the promise.

The first fix let the integrator name the class, which moved the problem instead of closing it: the code asking to run was grading its own risk again, just out loud. So resolve_action now has a floor and a contract:

  • anything injected sits at write unless contracted otherwise;
  • the only way below the floor is pure_read("<sentence>") — a reason that is refused if it says nothing ("true", "pure", "safe") — and then checked against the function's own source, using the sink vocabulary the platform's FR-04 sweep already runs over its own read-classified tools;
  • evidence beats the claim: a visible post, subprocess.run, open(..., "w") or os.remove refuses a read; a visible rmtree refuses write too, because that is the same under-declaration one rung lower;
  • ambiguous verbs (remove, rename, move) count only when the receiver names a filesystem — os.remove is a sink, rows.remove(x) is a list — because a rule that flags ordinary code trains people to declare write without reading anything;
  • over-declaring is always allowed.

Blind spot, stated in the module rather than hidden: the sweep reads the callable handed over, not what it delegates to. That is why the floor is write. Review question I would like a second opinion on: refuse delegation outright, or keep the floor as the backstop?

9cee747 — the harness pin moves to 10e5c2a (pyproject and all three Dockerfiles, archive sha256 recomputed and the method validated by reproducing the hash of the commit it replaces). That commit carries engine_authorizer_of, which this repository never calls but depends on: a tenant that names no authorizer inherits the process default, and at the previous pin the registry reads a platform plane's "allowed" as silence and denies the call it was just granted.

Suites, against the recorded baseline: 1168 passed / 8 failed → 1231 passed / 8 failed — the same 8 pre-existing sqlglot failures in test_analytical_retriever, +63 tests. Verified again from a clean venv installing the pinned commits from their archives (not an editable checkout): 106 passed, 1 skipped for the authorization set.

Two things the built control-plane image showed at start-up, both intended fail-closed behaviour but both worth a decision: the module fleet stands up with no authorization plane (every tenant call denied as missing_authorizer until the embedding app installs one or declares CR_LOCAL_AUTHORITY), and two discovered fleet actions — sidekick.coder, growth_assistant.strategy — register unclassified and are denied until someone reads them into _ACTION_CLASSES.

Stack and merge order: agentic-os#743 → this → agent-harness#33 → #34.

…ileged service

Two owner decisions, one rule underneath them: the code that wants to run does not get to decide the thing
that lets it run. This changes both places where it was deciding.

**Delegation had a floor, and a floor is a self-grant.** An injected implementation sat at `write` unless
its author contracted lower. That looked conservative and behaved like an authorization: the caller picked
the class in passing, in the same statement that swapped foreign code into a slot, and nobody who could be
named stood behind it. `INJECTED_FLOOR` is gone. `delegated(action=…, authority=…, via=…, review=…)` is the
only way a delegated callable is registered now — the class, who authorized it, what it hands its arguments
to, and the review that connects the two. A bare class string, in either direction, is refused; so is a
label where a sentence belongs (`authority="SEC-41"` names a ticket, not a decision, and tickets close).
`read` cannot be bought with prose at all: a weak class is earned from the source, never asserted about it.

**The blind spot the floor was covering, closed.** The sink sweep reads the callable's own body, so a
wrapper that hands its arguments to a client object it did not build showed nothing — no `post`, no
`write_text` — and a `pure_read` claim about it used to be checked and pass. `opaque_callees` now refuses a
claim it cannot follow: every callee root must be a parameter, a local, a builtin, or an entry of
`INERT_ROOTS`. Evidence still beats declaration in both directions: an authorized delegation is refused if
the wrapper's own source reaches a `rmtree` while asking for `write`.

**A privileged service with no plane no longer boots.** `fleet.py` used to warn and stand up anyway, with
the argument that "a process that boots and denies is diagnosable, one that refuses to start is not". That
argument is overruled: a fleet that denies every call looks exactly like a healthy one on `/status`, and
silence was the failure this migration exists to remove. `require_plane()` runs before anything executes;
the escape is not a warning but a mode — `CR_EXECUTION_MODE=diagnostic` with a written reason — in which
privileged execution is structurally absent: the fleet builds no tenants, `up`/`dispatch`/`agent-run`
answer 503, an agent console registers no tools and refuses `mount_mcp`, and `/health` says which instance
it is. `on_missing="deny_later"` is refused for a registry that can execute; a component that is built
before its plane exists (a console an app imports before its gate installs) says so with
`on_missing="defer_to_plane"`, and the application that owns it remains obliged to gate readiness.

**Compatibility, stated rather than softened.** Deployments that launch the control plane without a plane
installed now exit with the three ways out in the message; the demo compose stacks need either a plane or
`CR_EXECUTION_MODE=diagnostic` + `CR_DIAGNOSTIC_REASON`. `/health` gained two keys (`mode`,
`privileged_execution`) and the two tests that pinned the body to `{"status": "ok"}` now pin the key set,
because "the public route discloses nothing" could not survive coexisting with "a deny-only instance must
not look healthy". `mount_mcp` lost its `default_action="write"` and mounts nothing for a tool nobody
classed; call sites now name the class or say so once with an explicit default.

Co-Authored-By: Cline <cline@dev.io>
@arybach

arybach commented Nov 22, 2026

Copy link
Copy Markdown
Contributor Author

Review packet — the two owner decisions land here

Both decisions from the authorization-stack review are implemented in this branch. Nothing here weakens fail-closed behaviour to keep an old caller working; where a caller breaks, it is listed under what now breaks instead of being accommodated.

Decision 1 — plugin delegation: refuse by default, no implicit floor

The mechanism that violated this was INJECTED_FLOOR = "write". An injected implementation sat at write unless its author contracted lower — which reads conservative and behaves like a self-grant: the caller picked the class in passing, inside the same statement that swapped foreign code into a slot, and no one who can be named stood behind it.

delegated(action=…, authority=…, via=…, review=…) is now the only way a delegated callable is registered (tools/actions.py):

declaration outcome
nothing passed refused — the class was inherited from nobody
"read" / "write" / "delete" as a bare string refused — a class with no authority behind it
delegated(action="read", …) refused — prose buys a strong class; only source evidence buys a weak one
delegated(action="write"/"delete", …) accepted iff ≥ the class the wrapper's own source implies
pure_read(reason) accepted iff source readable, no sinks, and no callee it hands its arguments to

The blind spot the floor was covering is closed. opaque_callees() refuses a pure_read claim it cannot follow: every call root in the body must be a parameter, a local, a builtin, or an entry of INERT_ROOTS. A wrapper that hands its arguments to a client object it did not build has no visible sink — nothing named post or write_text appears — and used to pass the check. Probe output, before/after:

invisible_wrapper    sinks=()          opaque=('Client',)      ← was: pure_read accepted
delegated(write, attributed)           → write                 ← the authorized path still works
delegated(write) over a visible rmtree → REFUSED: …reaches ['rmtree'], which is the 'delete' class
hand-built Delegated(authority="", …)  → REFUSED               ← the builder cannot be bypassed

Decision 2 — a privileged service with no plane fails startup/readiness

fleet.py argued the opposite in writing: "a process that boots and denies is diagnosable, one that refuses to start is not." That argument is removed, not annotated. require_plane() now runs before anything executes, and the escape is a mode in which execution does not exist rather than a warning beside the denials:

  • CR_EXECUTION_MODE=diagnostic requires CR_DIAGNOSTIC_REASON="<sentence>"; an unrecognised value raises instead of falling through to the permissive branch.
  • diagnostic fleet: builds no tenants; /up, /dispatch, /agent/run answer 503; ModuleTenant(privileged=False).act() raises PrivilegedExecutionUnavailable even with an allow-all authorizer installed.
  • diagnostic agent console: registers no tools, refuses mount_mcp, refuses _answer_tool. Structural, not policy.
  • on_missing="deny_later" is refused for a registry that can execute. A component built before its plane exists — a console an app imports before its gate installs — declares on_missing="defer_to_plane", and the owning application stays obliged to gate readiness (agentic_os.app_gate.validate_console).

Verified in a container built from this branch's Dockerfile: bare container exits non-zero with the three ways out in the log; declared diagnostic boots, says so on /health, and 503s the execution routes; with CR_LOCAL_AUTHORITY it behaves as the service it is. Those are now three separate tests in tests/test_container.py.

Read first

  1. context_runtime/tools/actions.py — the refusal table, opaque_callees, and why read is asymmetrical.
  2. context_runtime/tools/authz.py — require_plane, and the three on_missing postures.
  3. tests/test_authorization_negative_controls.py — the owner's five scenarios, grouped by attack rather than by module.

Teeth — what fails if you revert this

tests/test_authorization_negative_controls.py, tests/test_injected_tool_classification.py (the floor test is now a test that the floor is gone), tests/test_container.py (startup posture), tests/test_control_plane_access.py (the public health key set).

What now breaks (reported, not accommodated)

  1. The control-plane image no longer boots without a plane. Every deployment that launches it bare must set one of: a plane installed before import, CR_LOCAL_AUTHORITY="<why>", or CR_EXECUTION_MODE=diagnostic + CR_DIAGNOSTIC_REASON="<why>". The geo-demo and proxmox-demo stacks need that decision made explicitly; I did not change any deploy file, per "no deployment or production configuration changes".
  2. /health gained two keys (mode, privileged_execution). Two tests pinned the body to {"status": "ok"} on the grounds that a public route discloses nothing; they now pin the key set. The reason is the outage this seam exists for: an instance that cannot authorize anything answered that route identically to one that works.
  3. mount_mcp lost default_action="write". A tool with no class is now not mounted at all (with a warning naming it). First-party callers now state the class (runtime_scan.py, the web-search test) or an explicit default.
  4. Any integrator passing *_action="write" to a tenant now gets a refusal telling them to write delegated(...). This is intended; there are no such call sites left in this repository.

Not verified / limits, stated

  • _sentence() checks that the three provenance fields are sentences, not that they are true. Provenance quality is a review judgement; the check only makes omitting it impossible and grepping for it cheap.
  • INERT_ROOTS is a hand-maintained allow-list. Adding an entry widens what pure_read can be claimed over, so it belongs in review every time.
  • delegated()'s provenance is text this repository cannot verify against a grant store — the plane still has to agree at call time, which is why delegated(action="read") is impossible: unverifiable text must never buy the weakest grant.

Review independence — blocked, needs your call

You asked for independent review of the two decisions. redevops-io has exactly one member (arybach), who is also the author of all four PRs and the sole CODEOWNERS entry, so GitHub will not let me request a review from anyone: there is no second identity to request. Either add a reviewer identity to the org (I'll request them on all four), or tell me you are reviewing personally and I'll treat this packet as the hand-off.

Merge order (unchanged)

harness #33 → harness #34 → Context Runtime #91 → Agentic OS #743, all as merge commits — 10e5c2a, the commit pinned in four install sites here, is an ancestor of this stack and must stay reachable.

@arybach

arybach commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

Merge is now blocked by policy, not by intention

The instruction was that nothing merges until the ordered stack passes independent review. Until a minute ago that was a sentence in a comment; it is now a branch-protection rule, because the checks alone left this PR mergeable.

main in all three repos (agent-harness, context-runtime, agentic-os) now requires 1 approving review, with dismiss_stale_reviews and require_last_push_approval on, and enforce_admins left true — so the rule binds the author too, and an approval cannot survive a subsequent push. Every previously-required status check was read back out of the API and re-sent unchanged (agent-harness 8/8, context-runtime 3/3, agentic-os 8/8 including authorization-seam); restrictions stayed null, as it was.

Two notes for whoever reviews this:

  • This PR's base is not main where applicable. The harness stack is stacked (feat/authz-risk-classification-c2 → fix/authz-required-authorizer), so main's rule would not have covered it and it read clean. That base branch is now protected with the same review rule and the same 8 status checks — all 8 report on this PR today, so this closes the gap rather than opening a lockout.
  • The rule cannot be satisfied today. redevops-io has one member (arybach), who authored all four PRs; GitHub does not accept an author's approval on their own PR. That is the intended state: the stack is unmergeable until a second identity exists. To unblock, add a reviewer and request them here — do not lower required_approving_review_count, which is the only thing between these branches and an unreviewed merge.

Verification state at the time of writing: #33 9/9 checks pass, #34 9/9, #91 6/6, #743 12/12 (seam job 66 passed, 0 skipped); Context Runtime's full suite locally 1270 passed / 18 skipped / 0 failed / 0 errors, container tests included.

Alex Mats and others added 2 commits November 22, 2026 20:50
Finding M1 of the independent authorization-stack security review:
MCPToolPlugin.spec() computed side_effecting from the MCP server's own
untrusted readOnlyHint annotation whenever one was present, for any
non-"read" action. A server could therefore talk a tool the operator
had explicitly mounted as "write" or "delete" out of needing approval
by self-reporting readOnlyHint=true, making ApprovalPolicy's gate a
no-op. Reproduced live: a fake wipe_database tool, classified "write",
under a deny-by-default approval policy with no approver configured,
executed for real.

side_effecting for a non-"read" action is now exactly
bool(default_side_effecting) -- the operator's own mount-time
configuration -- with no influence from any MCP annotation. A missing,
false, true, or malformed readOnlyHint all now have the same effect:
none. "read" actions are unaffected (already forced side_effecting to
False regardless of any hint).

Confirmed the adjacent delegated()/pure_read() classification seam in
context_runtime/tools/actions.py was never vulnerable to this same
class of bug: it only ever reads a wrapper's own source (write_sinks,
opaque_callees), never a wrapped MCP client's self-reported metadata.

Rewrote the one existing test that asserted the vulnerable behavior as
correct (test_read_only_hint_relaxes_approval_but_never_the_class) and
added regression coverage: the delete-class equivalent, every
missing/false/true/malformed annotation shape, the legitimate
approved-write path, and a cross-check that the actions.py seam
already refuses this attack shape.
PR #35 closed the ToolRegistry.get(name).run(args) authorization bypass.
Bumps all four pin sites (pyproject.toml, Dockerfile, and the two deploy
Dockerfiles) to that commit so this stack's own build actually includes
the fix. Recomputed AGENT_HARNESS_SHA256 against the real tarball.

Co-Authored-By: Claude Sonnet 5 <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.

1 participant