---
title: 'Day 5: What Only the Live Sandbox Shows'
series: Building the Caladrius PHR with agents
part: 5
series_total: 15
date: '2026-11-22'
reading_time: 13 min
description: 'A full day of P2 and P4 runs on the ABDM sandbox: three tries at one
  URL field, a data push the PHR kept refusing, and a consent lost to a five-second
  timeout. Almost nothing found that day could have been found by a test against a
  stub.'
canonical_url: https://caladriushealth.ai/solutions/phr-build-diary/day-5-what-only-the-live-sandbox-shows/
publisher: Caladrius Health AI Studio
---

# Day 5: What Only the Live Sandbox Shows

A full day of P2 and P4 runs on the ABDM sandbox: three tries at one URL field, a data push the PHR kept refusing, and a consent lost to a five-second timeout. Almost nothing found that day could have been found by a test against a stub.

*The PHR is built by a small Caladrius team (Giri, Krishna, Preetha and me) working with AI agents; each post ends with what the day meant for each of our areas.*

Monday, 2 November, was a testing day. A tester spent it on QA running NHA's P2 and P4 cases against the live
[ABDM](https://caladriushealth.ai/what-is-abdm/) sandbox, one case at a time, and agents fixed what each case turned up
while the tester moved on to the next. Fourteen pull requests went into `dev` and twelve promotions went to QA: about one
promotion per fix, so the tester could re-run the failing case within the hour.

Almost nothing else found that day could have been found by our regression suite. The suite runs against a stub written
from ABDM's specification, and most bugs on Monday lived where the specification was silent, ambiguous or different
from the sandbox. This post groups the fixes by what they teach, rather than by the order they arrived.

---

## 1. The rhythm of a testing day

Every fix followed the same loop:

1. The tester runs a case on QA and it fails. The screen shows our message and, under it, ABDM's code and filtered
   message (the project's one exception to "generic errors only").
2. An agent reads the QA API's logs for that request (statuses, codes, request ids, never bodies of patient calls),
   finds the cause, and checks the plugin's section for the case.
3. A small pull request names the NHA case ids, the plugin source, the change class and, where the sandbox contradicts
   the specification, the observation as evidence.
4. CI and the [security gates](https://caladriushealth.ai/platform/brief/#security) run. The fix merges to `dev` and is promoted to QA.
5. The tester re-runs the case.

The pull requests that day were short, often one finding each. That was deliberate. A small fix can be reviewed in
minutes and promoted alone, and when one is wrong it can be reverted without taking three others with it.

## 2. Sessions that end on success

Day 4 found that ABDM ends the person's session after an ABHA number is linked, and that we were reporting the
successful link as an error. The first fix on Monday morning applied the same lesson to the **mobile number**.

When ABDM accepts a new mobile, it ends the token. We re-read the profile with the ended token and reported the
accepted change as an error. Now both routes (link a number, change a mobile) share one helper: on that specific
refusal, the account's ABDM tokens are cleared and the route answers 200 with `signInAgain: true`. Any other refusal is
still an error. The app shows NHA's message, "Mobile Number linked successfully", now a cited rule in the rules file,
with a **Sign in again** button.

The pull request said what was inferred rather than observed: ABDM's message after a link named the link, and we were
assuming the message after a mobile change would name the mobile. It asked the tester to re-run those two cases to
confirm.

The next run then found a real product bug behind it. After changing the mobile and signing in again, the profile still
showed the **old** number, for anyone who had once signed in by mobile OTP. The full mobile stored at that sign-in was
preferred over ABDM's current one and was never cleared. The fix is narrow, and it is S1 because it touches stored
personal data:

- When ABDM's profile names a mobile whose last four digits contradict the stored one, that patient's stale phone
  record is removed, in the same transaction, for that patient only.
- The profile prefers ABDM's current mobile over the earlier sign-in mobile.
- Nothing is merged, and a missing or short mobile from ABDM keeps what is stored.

Only the full suite exposed it, because the sign-in specs sign the test people in by mobile OTP before the profile
specs run. Test order isn't supposed to matter. Here it was the only reason the bug showed up.

## 3. Three tries at one field

The most instructive thread of the day was about a single field: `purpose.refUri` on subscription calls. The
specification types it as a URI string with a published pattern. ABDM validates it against something it doesn't publish.

| Try | Value sent | ABDM's answer |
|---|---|---|
| Before | an HL7 PurposeOfUse value-set URL, from the app | "Invalid refUri" |
| 1 | the PHR's own public HTTPS origin, set by the server (accepted on a consent request on Day 3) | "Invalid refUri" on edit |
| 2 | `www.abdm.gov.in`, the value in the plugin's worked example for approve | accepted |

Try 2 was my decision, with its uncertainty stated in the pull request: the plugin uses that value in an example, which
is not the same as a rule. We sent it, re-ran the case on QA, and added the question to the list we keep for NHA. The
PHR's own subscription init kept its value for now.

Getting past the refUri only revealed the next refusal: "Invalid subscription edit payload". The agent compared our
edit body with ABDM's schema and the plugin's example and found two differences. Our edit ran the period past the
subscription's own end date (which ABDM had set at locker set-up), and it sent the facility without a `type` and with
`status: null`. An edit now stays inside the held period (it can narrow it, not widen it) and names the type and
status as the example does.

ABDM still refused it. So in the evening I did something that is easy with a web app and hard to do any other way: I
sent different edit bodies through the app on QA, rewriting the request in the browser, and recorded each answer.

| Variant | Result |
|---|---|
| `isApplicableForAllHIPs: true`, with each of: full period, status null, status granted, one facility, no change, a different purpose, excluded sources | refused |
| `isApplicableForAllHIPs: false`, with a full period or a narrower one | **202**, and the edit reads back from ABDM |

So the app now always sends `false` on an edit, because every edited source names its facility anyway. The probe found
a sandbox behaviour worth knowing too: after an edit, ABDM's read-back shows only the **first** source. An edit narrows
the locker's "all facilities" subscription to the facilities sent. That went on the NHA question list as well.

Two smaller fixes belong to the same thread. The edit screen listed **the requester itself** as one of the
subscription's sources, because once the locker had linked an upload as a HIP, it was one of the person's linked
facilities. It is now left out. And a consent grant failed with "Date must be a present/before date", because the app
sent the end of the chosen day, 23:59:59 IST, which is in the future when that day is today. A grant's range now ends
no later than the request's own end **or now**, whichever is first, and starts no earlier than the request's start.
Narrower days still narrow the grant.

**What this thread teaches** is method more than any single fix. A specification that types a field as a string tells
you nothing about what the server accepts. The fastest way to find out is a controlled probe: change one thing, record
the answer, and keep the table. The table goes into the pull request, so the reviewer sees the evidence and not just
the conclusion.

## 4. The data push we kept refusing

The most important fix of the day was in the P4 pull run, and it took the QA logs and the hospital side's logs read
together to find it.

When the PHR fetches records, it sends the hospital a data request containing a `dataPushUrl`. The hospital encrypts the
records and posts them to that URL. On QA, every push to the PHR was refused with **401**: three that day, each one a
hospital trying to deliver records the person had consented to.

The cause was our own callback authentication. Every path under the PHR's ABDM callback prefix demanded a gateway
token and the HIU header. That is right for callbacks, which come through the gateway. It is wrong for the data push:
the M2 skill says plainly that a HIP posts the push **straight to the HIU, not through the gateway**, and the published
schema for the push lists no authorization. A hospital that correctly sends no gateway token to a third party's URL
could never deliver to us.

The fix is S1, and I asked for it explicitly. The push is authenticated **by its
binding**, which was already in the pipeline: an open transfer we started, a live consent, and a key only we hold.

The next push got past authentication and was refused with 400, by our own schema. The hospital's public key was about
500 characters long and our schema capped it at 400. Fidelius peers often send the key as an X.509
SubjectPublicKeyInfo with the curve's **explicit parameters**; a bare point is 88 characters. ABDM's schema sets no
maximum. Raising the cap is safe because we read the key's trailing point and check it is on Curve25519, so the length
only bounds the size. The new cap is 2,048 characters, applied to the push and to the requests the locker serves as a
HIP, the same field for the same reason. Then the records arrived.

## 5. A consent lost to a five-second timeout

That evening, the consent manager delivered `on-init` and `notify` for a locker pull, and the PHR refused both
with "jwks unavailable". Our JWT library refetches ABDM's signing keys on a ten-minute cache; that refetch timed out at
five seconds. The consent manager doesn't retry, so the consent was dead, and the person would have had to start over.

The fix keeps the last fetched key set. When a refetch **fails** (timeout, network error, a non-200 answer), the API
verifies with those keys for a limited time and logs a warning. It is still fail-closed everywhere it matters:

- no keys fetched yet: refuse;
- a key id the last keys don't hold: refuse (that's a rotation, not a fetch failure);
- a bad signature: refuse;
- the grace period over: refuse.

This is a judgement about availability against freshness, and it's the kind of judgement that belongs in the pull
request in plain words, for review. A network blip shouldn't cost a person their consent, and a rotated key shouldn't
be bypassed by a cache.

## 6. Small things the tester's phone found

Some findings were small and only a real device and a real person would hit them:

- **A real selfie was too big.** Saving a 75 KB phone photo on the profile failed with 413, and the screen said
  "Something went wrong". Edit profile accepted photos up to 2 MB, but the API's request size limit is lower. The API
  limit stayed the same. The app now draws the photo at most 512 px on its longest side and saves it as a JPEG under
  40 KB, stepping quality and then size down until it fits. The test selfie came out at 288×512, about 25 KB.
- **A mobile number at ABDM's limit.** ABDM refuses a mobile that is already linked to the maximum number of accounts,
  and our error catalogue didn't know that code, so the person saw a 500. It is now a named conflict with a clear
  message. A later fix corrected the wording, because two ABDM codes share our message and one counts ABHA numbers
  while the other counts self-declared addresses. The message now says "ABHA accounts".
- **"Your tokens today" showed "Counter:" with nothing after it.** The counter was stored with each share but not
  returned. Now it is, and the line hides when no counter is known.
- **A failed share was titled "No response from facility"**, which suggests a timeout. A failure now has its own title.
- **A locker opened directly showed "Locker not found"**, then "Records held (0)". The first was data that only the
  list screen loaded. The second was subtler: the app wrote the lockers to its store and read them back in the same
  tick, before React had applied the change. It now uses the lockers it fetched.
- **The upload screen said linking "comes in a later release"**, while the API had been linking uploads as a HIP since
  Day 2. On the sandbox the locker appeared under Linked Facility about a minute after an upload. The screen now has
  three states: linked, linking under way, and not linked.
- **Consents said auto-approval was "Off"** right after set-up had turned it on, because only the auto-approval screen
  loaded the policy. Consents reads it now.

Each of these came with a functional test change where one was possible. The locker set-up case now reloads the locker
page and expects the locker and its switch, and opens Consents directly and expects "On for 1".

## 7. One review note worth keeping

One pull request carried a note for the reviewer that had nothing to do with its fix. While reading an error path, the
agent noticed that the code and one of our written rules about what an error response may contain didn't agree. It
didn't change either one on its own. It wrote, in effect: one of the two needs to change, and that's the owner's call.

That is the behaviour I want from an agent: notice the conflict between the code and the rule, say so where a person
will read it, and don't resolve a policy question by editing code.

## 8. What I learned on Day 5

- **The stub can't find these bugs.** Almost every finding on Monday was about what ABDM accepts, when it ends a session, how
  it reads a body, or how a real hospital sends a key. A stub written from the specification shares the
  specification's blind spots. Plan for a testing day on the live sandbox, with a person, and keep the fixes small.
- **Probe, don't guess.** When a refusal gives no reason, vary one thing at a time and keep the table. It took one
  evening to find the flag that four guesses had missed.
- **Authenticate by binding when the channel has no token.** A data push carries no gateway token by design. It is
  authenticated by what it must match: a transfer we opened, a live consent, and a key only we hold.
- **Fail closed, but not on a blip.** Keeping the last good keys through a failed refetch, and only then, will save a
  consent without letting a rotated key through.

*Next, Day 6 (3 November): hospital-linked visits, a locker that stores each document once, and one consent decision
at a time.*

## The team behind Day 5

The PHR is built by a small Caladrius team working with AI agents:

- **Giri**: CEO; Cally taxonomy and intent framework
- **Krishna**: development, infrastructure and go-live
- **Preetha**: narrative engineer, personas
- **Manish** (me): CTO and CPO, enabling the Caladrius Health AI PHR and the AI Studio framework

### Cally: taxonomy and intent (Giri)

Day 5 had no Cally work, but it applied how the PHR explains a refusal: our own text first, then ABDM's code and its
filtered message, and nothing more, and surfaced one place (request ids in error details) where the code didn't yet
follow it. Any answer Cally later gives about an error will need to follow the same rule.
Sessions that end on success, such as a new mobile number, became a named case with NHA's own message.

One review note from the day reads like a guardrail for Giri's area. An agent noticed that the code and a written rule
disagreed, and instead of picking one, it said so where a person would read it. That is the behaviour the intent
framework asks for when a request and a rule conflict: say so, and don't settle a policy question alone.

### Development, infrastructure and go-live (Krishna)

Day 5 was a testing day on QA: fourteen pull requests into `dev` and twelve promotions, about one per fix, so the tester
could re-run a failing case within the hour. The loop depended on this area's tooling: QA API logs that hold statuses,
codes and request ids but never the bodies of patient calls, and CI and the security gates on every small change.

The data push we kept refusing took the QA logs and the hospital side's logs read together. The callback key cache
now rides out a failed refetch for a bounded time, still failing closed where it matters. The API's body limit stayed
as it was; the app now resizes a photo to fit it instead.

### Narrative and personas (Preetha)

The people in Day 5 are a tester working case by case, and the patients those cases stand for: someone saving a real
selfie on their profile, someone who changed their mobile number and still saw the old one, someone whose number had
reached ABDM's limit and saw a 500 instead of an explanation.

Much of the day was wording. "Your tokens today" no longer shows "Counter:" with nothing after it. A failed share no
longer says "No response from facility". The upload screen stopped saying linking "comes in a later release" when it
was already happening, and Consents stopped saying auto-approval was "Off" right after it was turned on. Each change
made the screen tell the person what is true.

### Product and technology direction (Manish)

The second `refUri` value was my decision, with its uncertainty stated in the pull request, and the question added to
our list for NHA. In the evening I probed the edit body myself through the app, one change at a time, and kept the
table. I asked for the data-push fix explicitly, as an S1 change for review.

The judgement I'd point to is availability against freshness: a network blip shouldn't cost a person their consent,
and a rotated key shouldn't be bypassed by a cache. I kept the pull requests small, one to three findings each, so any one could
be reviewed in minutes or reverted alone.

## Further reading

- [Caladrius Health](https://caladriushealth.ai/), the company behind the PHR
- [The Caladrius platform brief](https://caladriushealth.ai/platform/brief/): AI Studio, [Cally](https://caladriushealth.ai/platform/brief/#cally), the [Health Vault](https://caladriushealth.ai/platform/brief/#vault), the [design system](https://caladriushealth.ai/platform/brief/#design-system) and [security by design](https://caladriushealth.ai/platform/brief/#security)
- [Caladrius Pulse](https://caladriushealth.ai/blog/), our blog, including the ABDM series ([What is ABDM?](https://caladriushealth.ai/what-is-abdm/)) and the NHCX series ([What is NHCX?](https://caladriushealth.ai/what-is-nhcx/))
