cleandataengineering.aiAgent Harness, drawn simply
You are here: End to end › Checks › 5 · The tool itself › only his rows

Agent Harness Tutorial · End to end · Zoom level 3

How we take care of it: only his rows

only his rows catches another customer's claim.

Open: 11before loopopen ›Open: 22before modelopen ›Open: 33after modelopen ›Open: 44before toolopen ›Open: 55the toolopen ›Open: 66after toolopen ›Open: 77after loopopen ›Open: 88before replyopen ›It readsthe policyholder id in the tokenonly his rowsrule · claims systempassCarries onfailIf it failsnot foundWHERE IN THE CODE: claims_system/server.py
The strip at the top shows every check point where this check runs, in dark.

How we took care of it.

  1. Every query adds WHERE policyholder_id = the token's holder.
  2. "Not yours" and "doesn't exist" give the same answer.
It readsthe policyholder id in the token
Kindrule
Provided byclaims system
If it failsnot found
Where in the codeclaims_system/server.py
Runs at5 · The tool itself
Real exampleFlow 14: Rohan asked about Meera's CLM-019001: "I could not find CLM-019001 among your policies and claims."

More on this: 14 · Someone else's claim.

How it is done: the real code

Cut from the live repositories each time the site is built, so it always matches what runs.

@dataclass(frozen=True)
class _Gate:
    """Who is asking, and whether money may move: this system's checks."""

    store: Store
    authorise: Authorise
    approvals: ApprovalRecordReader | None
    clock: Callable[[], float]
    limits: Settings

    async def record(self, meta: Mapping[str, object]) -> ApprovalRecord | None:
        named = meta.get(APPROVAL_META)
        if self.approvals is None or not isinstance(named, str):
            return None
        return await self.approvals.approval(named)

    async def holder(
        self, operation: str, arguments: dict[str, Any], ctx: Context | None
    ) -> str | None:
        meta = _meta(ctx)
        call = Call(operation, SCOPES.get(operation, READ_SCOPE), _bearer(ctx, meta), meta)
        try:
            caller = await self.authorise(call)
        except CallRefused as exc:
            raise NotAuthorised(f"{operation} refused: {exc}") from None
        if caller.holder is not None or not _workflow(caller):
            return caller.holder
        return _on_approval(await self.record(meta), operation, arguments)

    async def payable(self, claim_id: str, who: str, ctx: Context | None) -> None:
        """The far end's own check on money moving (AHC-0057)."""
        claim = await self.store.get_claim(who, claim_id)
        if not claim.get("found"):
            return  # answered as unknown by the store, never as refused