The acceptance harness pinned a forge client that has never existed in any
commit or pod (/opt/coordinator/gitea_api.py, digest f0943db4..., GIT/POST
grammar, an askpass helper). Every Gitea-backed check was therefore
unrunnable as merged. Point the harness at the credential-isolated SCM
broker client that actually ships in the agent pod.
- policy: GITEA_CLIENT=/opt/scm/gitea_api.py; trust /opt/scm/ instead of
the phantom /opt/coordinator/; admit the client's real grammar
(`read <api-path>`, exactly one path) with the same atlas/titan-iac pin
and dot-segment rejection; bare HTTP methods are refused in every mode.
The armed POST/PATCH/DELETE windows remain but are documented as
deferred: the deployed client cannot execute them.
- exec: pin the client digest to the sha256 of
services/hermes/scm-common/scripts/gitea_api.py — the exact file the
hermes-scm-boundary-v2 ConfigMap mounts at /opt/scm/gitea_api.py — so
the pin is derivable from merged source and equal to the deployed
client. gitea_api.py gains a narrow /api/v1/user identity read in
_authorize_read (see below), so the pin is the NEW source hash
76efd16dedbeb74425b12fbbdbfaa391854771292077e0463bf22706855ae6dc.
Drop the dangling GIT_ASKPASS (no helper exists; broker git needs
none) and swap /opt/coordinator for /opt/scm in SAFE_PATH.
- checks: all forge/baseline/lineage probes use (client, "read", path).
The SELF-vantage identity checks now truthfully assert the *broker's*
forge identity (the only one the platform can exercise) is not an
administrator and holds push-scoped, non-administrative repository
authority; the administrative-route check asserts the broker read
allowlist's live refusal of branch_protections. The remote-main step
keeps `origin` (the broker remote exists only in pool workspaces and
the broker origin is cluster-local); its rationale now tells the
operator to ensure origin fetchability.
- gitea_api.py/_authorize_read: allow exactly `/api/v1/user` (no query,
no sibling routes) as operation "identity" so the harness can prove
the broker identity is not an administrator. The broker imports the
same module, so one reviewed edit covers both sides of the boundary.
- rules: DENIAL_MARKERS now match the client's real refusal lines
("SCM broker request failed with HTTP 400/403" and the no-credential
rejection) and drop "gitea api returned http 403", which the client
never emits; a broker 404 is deliberately not denial evidence.
- ephemeral: index/verification reads use the real grammar; manual
cleanup guidance now says close/delete require operator forge
credentials (the client exposes no mutation besides create-draft);
armed mode is documented as deferred until the probes are rebuilt on
the broker's bounded mutation surface.
- docs: broker vantage/evidence section, operator prerequisites (broker
healthy, no /vault/secrets/gitea-token anywhere on the harness path,
current ConfigMap mount, operator-side client + origin fetchability),
armed-mode deferral.
- tests: read-grammar accepted / GET refused in every mode, /opt/scm
attestation pin proven equal to the merged source digest, real
denial-marker matching, /api/v1/user identity route bounds; the
repository-pin mutant probe speaks the new grammar. Full handoff +
gitea + broker families pass (952 tests), mutation gate 13/13, per-file
line+branch coverage >=95%, all touched sources within the 500-line cap.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
202 lines
6.5 KiB
Python
202 lines
6.5 KiB
Python
#!/usr/bin/env python3
|
|
"""Declarative acceptance catalog: baseline, identity, routing, scopes, access.
|
|
|
|
The catalog is data on purpose. A reviewer should be able to read what the
|
|
release is asserted to satisfy without reading any plumbing, and the harness
|
|
should be able to prove structural properties over every entry — both vantages
|
|
represented, no impersonation from outside a pod, and no mutation command of
|
|
any kind — before it runs a single command.
|
|
|
|
Catalog drift is a NO_GO, not a pass. If a manifest, a field name, or a workload
|
|
is renamed, the affected checks report ``NOT_RUN`` because the evidence they
|
|
name is not there, and the release stops until either the platform or the
|
|
catalog is corrected.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from collections.abc import Sequence
|
|
from dataclasses import dataclass, field
|
|
from typing import Any
|
|
|
|
from hermes_handoff_model import ALWAYS, READ, CheckSpec, Step
|
|
from hermes_handoff_policy import projection
|
|
|
|
OPERATOR = "operator"
|
|
SELF = "self"
|
|
SWITCHYARD = "switchyard"
|
|
NODE = "node"
|
|
CHAT = "chat"
|
|
VANTAGE_NAMES = (OPERATOR, SELF, SWITCHYARD, NODE, CHAT)
|
|
|
|
# `name<TAB>generation<TAB>observedGeneration<TAB>suspend<TAB>conditions`.
|
|
FLUX_PROJECTION = projection(
|
|
(
|
|
"jsonpath={range .items[*]}{.metadata.namespace}/{.metadata.name}{'\\t'}"
|
|
"{.metadata.generation}{'\\t'}{.status.observedGeneration}{'\\t'}{.spec.suspend}{'\\t'}"
|
|
"{range .status.conditions[*]}{.type}={.status},{end}{'\\n'}{end}"
|
|
).replace("'", '"')
|
|
)
|
|
|
|
ENV_NAME_PROJECTION = projection(
|
|
(
|
|
"jsonpath={range .spec.template.spec.containers[*]}{range .env[*]}{.name}{'\\n'}{end}{end}"
|
|
).replace("'", '"')
|
|
)
|
|
|
|
INIT_NAME_PROJECTION = projection(
|
|
(
|
|
"jsonpath={range .spec.template.spec.initContainers[*]}{.name}{'\\n'}{end}"
|
|
).replace("'", '"')
|
|
)
|
|
|
|
NODE_NAME_PROJECTION = projection(
|
|
"jsonpath={range .items[*]}{.spec.nodeName}{'\\n'}{end}".replace("'", '"')
|
|
)
|
|
|
|
POOL_PROJECTION = projection(
|
|
(
|
|
"jsonpath={range .items[*]}{.metadata.name}{'\\t'}{.spec.nodeName}{'\\t'}"
|
|
"{.status.phase}{'\\t'}{range .status.conditions[?(@.type==\"Ready\")]}{.status}{end}"
|
|
"{'\\t'}{range .spec.volumes[*]}{.persistentVolumeClaim.claimName}{','}{end}{'\\n'}{end}"
|
|
).replace("'", '"')
|
|
)
|
|
|
|
PROVIDER_API_KEY_NAMES = (
|
|
"ANTHROPIC_API_KEY",
|
|
"ANTHROPIC_AUTH_TOKEN",
|
|
"ANTHROPIC_BASE_URL",
|
|
"AZURE_OPENAI_API_KEY",
|
|
"CLAUDE_API_KEY",
|
|
"CLAUDE_CODE_OAUTH_TOKEN",
|
|
"GEMINI_API_KEY",
|
|
"GOOGLE_API_KEY",
|
|
"OPENAI_API_KEY",
|
|
"OPENAI_BASE_URL",
|
|
)
|
|
FORGE_CREDENTIAL_NAMES = (
|
|
"GITEA_PASSWORD",
|
|
"GITEA_TOKEN",
|
|
"GITEA_USERNAME",
|
|
"GIT_PASSWORD",
|
|
)
|
|
|
|
CODEX_HEALTH = "/opt/data/provider-health/codex.json"
|
|
CLAUDE_HEALTH = "/opt/data/provider-health/claude.json"
|
|
CODEX_HEALTH_FIELDS = "authenticated,transport,state,model,effort,latency_ms,checked_at"
|
|
CLAUDE_HEALTH_FIELDS = (
|
|
"authenticated,api_provider,auth_method,transport,state,subscription_type,"
|
|
"model,effort,latency_ms,checked_at"
|
|
)
|
|
ROUTING_LOG = "/var/lib/switchyard/routing.jsonl"
|
|
|
|
|
|
@dataclass(frozen=True)
|
|
class Targets:
|
|
"""Runtime names and expected values the catalog is written against.
|
|
|
|
Everything a site can legitimately rename lives here so the assertions stay
|
|
readable and a rename is a configuration change rather than a code change.
|
|
"""
|
|
|
|
namespace: str = "hermes"
|
|
agent_deployment: str = "hermes-agent"
|
|
agent_container: str = "hermes"
|
|
chat_statefulset: str = "hermes-chat-tenant"
|
|
chat_container: str = "hermes"
|
|
chat_ordinal: int = 0
|
|
chat_router_deployment: str = "hermes-chat-router"
|
|
triage_deployment: str = "hermes"
|
|
triage_container: str = "hermes"
|
|
switchyard_deployment: str = "hermes-switchyard"
|
|
switchyard_container: str = "switchyard"
|
|
node_daemonset: str = "hermes-node-ssh-access"
|
|
node_container: str = "key-reconciler"
|
|
pool_statefulset: str = "hermes-execution-worker"
|
|
pool_replicas: int = 3
|
|
pool_selector: str = "app=hermes-execution-worker"
|
|
coordinator_claims: tuple[str, ...] = (
|
|
"hermes-agent-home",
|
|
"hermes-agent-workspace",
|
|
)
|
|
node_account: str = "hermes-agent"
|
|
node_account_identity: str = "1200:1200:/home/hermes-agent:/bin/bash"
|
|
node_count: int = 3
|
|
repo: str = "atlas/titan-iac"
|
|
remote: str = "origin"
|
|
baseline_commit: str = "ab346f55509d584e457fe26cf90be3078f7a375c"
|
|
dependency_pull_requests: tuple[int, ...] = (12, 14, 15, 16, 17, 18, 20)
|
|
dependency_heads: tuple[tuple[int, str], ...] = ()
|
|
remote_main_sha: str = ""
|
|
reviewed_pr_number: int = 19
|
|
reviewed_head_ref: str = "feature/hermes-full-handoff-acceptance"
|
|
reviewed_head_sha: str = ""
|
|
agent_image: str = ""
|
|
build_sha: str = ""
|
|
deployment_revision: str = ""
|
|
expected_suspensions: tuple[str, ...] = ()
|
|
harbor_namespace: str = "harbor"
|
|
harbor_immutability_job: str = "hermes-agent-immutability"
|
|
builder_namespace: str = "jenkins"
|
|
builder_serviceaccount: str = "hermes-image-builder"
|
|
builder_pipeline: str = "ci/Jenkinsfile.hermes-agent-image"
|
|
builder_capabilities: str = (
|
|
'add: ["CHOWN", "FOWNER", "DAC_OVERRIDE", "SETGID", "SETUID"]'
|
|
)
|
|
agent_init_containers: tuple[str, ...] = ("patch-web-session-activity",)
|
|
chat_init_containers: tuple[str, ...] = ("patch-api-server-sessions",)
|
|
chat_config_revision: str = ""
|
|
pool_worker_env: tuple[str, ...] = ("HERMES_WORKER_NODE", "HERMES_WORKER_ORDINAL")
|
|
max_evidence_age_seconds: int = 86_400
|
|
routing_tail_lines: int = 600
|
|
routing_tail_bytes: int = 512 * 1024
|
|
listing_bytes: int = 512 * 1024
|
|
now: Any = None
|
|
extra: dict[str, Any] = field(default_factory=dict)
|
|
|
|
|
|
def step(
|
|
key: str,
|
|
vantage: str,
|
|
*argv: str,
|
|
kind: str = READ,
|
|
optional: bool = False,
|
|
record: bool = True,
|
|
max_bytes: int | None = None,
|
|
) -> Step:
|
|
"""Return a probe step addressed to one vantage."""
|
|
return Step(
|
|
key=key,
|
|
vantage=vantage,
|
|
argv=tuple(argv),
|
|
kind=kind,
|
|
optional=optional,
|
|
record=record,
|
|
max_bytes=max_bytes,
|
|
)
|
|
|
|
|
|
def check(
|
|
identifier: str,
|
|
title: str,
|
|
group: str,
|
|
rule: str,
|
|
steps: Sequence[Step],
|
|
expect: dict[str, Any] | None = None,
|
|
mandatory: bool = True,
|
|
scope: str = ALWAYS,
|
|
rationale: str = "",
|
|
) -> CheckSpec:
|
|
"""Return one catalog entry."""
|
|
return CheckSpec(
|
|
id=identifier,
|
|
title=title,
|
|
group=group,
|
|
rule=rule,
|
|
steps=tuple(steps),
|
|
expect=expect or {},
|
|
mandatory=mandatory,
|
|
scope=scope,
|
|
rationale=rationale,
|
|
)
|