Skip to content

reward: scope the oracle read by oracle_identity #455

Description

@abrichr

VerifierOracle.read and JsonDocumentOracle.read in
openadapt_flow/reward/oracles.py take an identity argument, stamp it onto
the observation, and then read the whole collection. VerifierOracle calls
capture_post_state(None) with no selector at all. So current inside
judge_episode holds every record the store will return, including rows
belonging to other subjects.

The subject enters the judgement in one place only: the required effect's own
match selector, resolved against the identity by worker._bind. A load-time
guard in RewardBundle.load now refuses a bundle whose required effects select
no record by a declared oracle.identity_keys entry, so the gap can no longer
be authored by accident.

That guard checks the contract. It does not scope the read, and two costs
remain:

  • Evidence. The observation goes into the receipt's evidence digest, so a
    receipt naming one patient is computed over a snapshot holding many.
  • Volume. On a substrate with a large collection the worker pulls far more of
    the store than the episode needs.

The fix is to pass identity down to the verifier and let each substrate
scope its own read: a path template or query parameter for REST, a WHERE
clause for SQL, a search parameter for FHIR, a path prefix for the file and
document verifiers. That means an identity argument on
EffectVerifier.capture_post_state and, per adapter, a declared mapping from
an identity key to that substrate's query language. An identity key an adapter
cannot map should refuse rather than fall back to the unscoped read.

One question to settle in the same change: whether an oracle read that returns
a record outside the declared identity is itself grounds for refusal, or only
for a narrower observation.

Opened by an agent session, not the founder.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions