adk: stamp observation_mode on every capsule (in_path / event_stream) — #33 reference use - #46
Merged
Merged
Conversation
#33 reference use Every ADK capsule now states how its producer observed the action it sealed: - Callback path + manual seals (guard/emit_blocked/emit_denied/ emit_errored) stamp in_path — the emitter executes in the action's own call path and binds input/output from its own position. - Event-stream tap stamps event_stream — the emitter observes the runner's narration after the fact, where id-less pairing is best-effort. This adapter is why the field earns its keep: the same emitter genuinely observes from two different proximities depending on integration shape, and before this stamp the two capsules were indistinguishable. Provenance, not a quality score — the capsule states its vantage, the consumer decides the weight. Two review fixes carried over from PR #27 (thisjody), both mutant-verified: - Stamp last, not first: the four in_path call sites built extra_compute as {"observation_mode": "in_path", **_compute_from_context(ctx)} — literal-then-spread, so a context key literally named observation_mode would silently overwrite the stamp. Vanishingly unlikely given the allow-list _SAFE_CONTEXT_ATTRS enforces, but it's precisely the fail-open pattern #26 (context-hygiene) argues against right next to this PR. Flipped to spread-then-literal so the stamp always wins. - Tests now assert on the parsed capsule structure (model_attestation.compute_attestation.observation_mode) instead of a json.dumps(capsule) substring check. The old check had a dead clause ("in_path" in json.dumps(...)) that would pass even if the field were wrong, so long as the substring appeared anywhere else in the capsule (e.g. an action_id). Confirmed via a constructed capsule with a wrong observation_mode but a substring-colliding action_id: old check passed, new check correctly failed. Original PR #27 (thisjody, fork feat/observation-mode branch) failed the neutrality gate solely because fork PRs don't receive the NEUTRALITY_TERMS secret by design. Rebased as this same-repo branch so the gate can run. Author credit preserved — content and design are Jody's own; only the two review fixes above are new in this rebase. Deliberately small: five emit sites, one stamp each, plus a docstring section. Tests: 28/28 (test_adk.py), 319/319 full suite (excluding the optional agentgateway extra, pre-existing/unrelated grpc dependency gap), ruff clean. Signed-off-by: stevenmih <stevenmih88-3@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Same-repo rebase of #27 (thisjody), which fails
neutralitysolely because fork PRs don't receive theNEUTRALITY_TERMSsecret by design. Author credit preserved — content and design are Jody's own; two review fixes below are new in this rebase.The implementation half of #33, paired with the spec text in action-state-group/agent-action-capsule#35 (merged as #41), which defines the field and the
compute_attestationcontainer it rides in.Every ADK capsule now states how its producer observed the action it sealed:
guard/emit_blocked/emit_denied/emit_errored) stampin_path.event_stream.Two review fixes carried over, both mutant-verified
in_pathcall sites builtextra_computeas{"observation_mode": "in_path", **_compute_from_context(ctx)}— literal-then-spread, so a context key literally namedobservation_modewould silently overwrite the stamp. Flipped to spread-then-literal so the stamp always wins. Confirmed via a constructed collision: old order → silently corrupted; new order → correctly wins.json.dumpssubstring. The old test had a deadorclause that would pass even with a wrong stamp value, so long as"in_path"appeared anywhere else in the capsule (e.g. anaction_id). Confirmed via a constructed capsule with a wrongobservation_modebut a substring-collidingaction_id: old check passed, new check correctly failed.Deliberately small: five emit sites, one stamp each, plus a docstring section. 28/28 (
test_adk.py), 319/319 full suite (excluding the optionalagentgatewayextra — pre-existing/unrelatedgrpcdependency gap, confirmed present on unmodifiedmaintoo), ruff clean.🤖 Generated with Claude Code