Build diary Day 3

Day 3: When the Sandbox Disagrees with the Specification

Built with Giridhar, Venkatakrishna and Preetha

Building the Caladrius PHR with agents Part 3 of 15

14 min read

Hand-drawn sketch of a filing cabinet receiving a message from the ABDM sandbox, with a note reading Callback arrived first

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.

Saturday, 31 October, was the first day the PHR on our QA environment talked to the live ABDM sandbox end to end, with real callbacks arriving from the consent manager. It was also the day I used the app most on my own phone, and the two kinds of feedback arrived together all day: a sandbox answer we didn’t expect, then a screenshot of something that looked wrong on an iPhone, then another sandbox answer.

The numbers: 23 pull requests into dev, 72 commits, and eleven promotions to QA. Eleven promotions in one day says something about how we were working. A fix found on QA went to dev, through CI and the security gates, and back to QA, usually within the hour, so the person testing could check it on the same afternoon.

This post covers four threads: what the first real callbacks taught us, how the app tells a person what is happening while records move, a long fight with the iOS Home Screen, and how an installed app learns that a new version exists.


1. Finishing the night shift: every automatable case on the API build

The day started just after midnight with the last test-only pull request of Day 2’s push. Every mandatory NHA case that needs no human tester, except PHR_LOCKER_50301 and 50302, now ran on the API build against the stub ABDM. Two details are worth sharing, because both were about not cheating.

2. The first real callbacks, and one capital letter

By the evening, the QA API was receiving real traffic from the sandbox: consent on-init, consent notify, artefact on-fetch, health information on-request, each authenticated with ABDM’s real gateway tokens. Unauthenticated calls to the same paths got 401 (checked the next day). The plan’s “first real callback” step moved to done just after midnight, with the request ids as evidence.

First, though, came the first disagreement. A test hospital on the sandbox linked a visit to a tester’s ABHA address, and the hospital side reported success. Our Linked Facility screen refreshed and stored zero facilities. Twice.

There were two possible explanations: ABDM listed nothing, or ABDM answered in a shape our parser didn’t read. We couldn’t tell which, because our logs, correctly, record no response bodies from patient endpoints. So the first fix was a diagnostic, and it had to respect the same rule:

The sync now logs the answer’s shape: field names (with value-like keys dropped) and list lengths. Never a value.

It went to QA within three hours. The next refresh logged the shape, and it showed the cause at once. The specification for the patient-links answer names the top-level field Patient, with a capital P. The sandbox answered with patient, lowercase. Every link was being dropped.

The fix reads either spelling, the specification’s first. The stub ABDM now answers in the sandbox’s spelling, so the functional tests cover the shape that actually arrives. The finding went into the plan and the changelog as a sandbox observation, next to the specification it contradicts. HIP-initiated linking was proven on QA that morning: one hospital, one linked visit, and the screen showed it.

Two things about this episode I’d do again:

  1. Log shape, not content. When you can’t log the body, log its structure. Field names and counts are enough to find a parsing bug, and they carry no personal data. The test for the log line checks that no value gets through.
  2. Make the stub match the sandbox, not the document. The stub exists to catch regressions in what really happens. Where they differ, it follows the sandbox, and the code says why.

3. ABDM creates the locker’s subscription itself

The bigger surprise came in the afternoon, during locker set-up on QA. Step 3 of set-up (“Alerts and automatic retrieval”) failed with “Invalid refUri”. We’d been forwarding a purpose.refUri from the app: an HL7 value-set URL. The API now sets it on the server to the PHR’s public origin, a value ABDM had accepted on a consent request the same day, and ignores whatever the client sends. (The refUri story isn’t over; it comes back on Day 5.)

But that fix exposed something deeper. Setting up a locker returned 200, and then ABDM created the locker’s subscription itself. Its on-init and hiu/notify callbacks reached our bridge about 100 milliseconds before the set-up response did, and the PHR dropped both, because it didn’t yet know what they referred to. The app then raised a second subscription of its own, which ABDM refused. Turning on auto-approval with no locker failed with “Health locker details not found”. The stub ABDM reproduced none of this, so CI had stayed green the whole time.

The fix had four main parts:

  1. Write before you send. The set-up row is written, with the set-up request id, before the call goes out. An on-init naming that request id can then bind ABDM’s subscription request id, however early it arrives.
  2. Recognise ABDM’s own notification. A hiu/notify naming this PHR’s locker as the HIU, for a patient whose ABHA address (matched through a blind index, never in clear) belongs to an account with a set-up in flight, binds and grants the row, and is acknowledged. Callback authentication is unchanged. A callback that still can’t be matched logs only its key names and the HIU id.
  3. No redundant subscription. Locker set-up now returns the subscription ABDM made. When it’s there, the app raises nothing more, and the person’s “yes” or “no” switches that subscription on or off.
  4. Auto-approval goes through the locker. With no locker, the API answers “locker not set up”, and the app sends the person to set one up. With a locker, the locker’s own policy is switched on rather than a new one created.

This answered Day 2’s open question too. The PHR’s own auto-approval policy lives in its locker’s settings, so it needs a locker. The design changed to fit what ABDM actually does.

The lesson for agents. A stub written from the specification will be wrong in exactly the places the specification is silent: ordering, timing, who creates what. An agent can’t infer those from the documents. Only a live run shows them, and once it has, the observation has to go into the stub, the plan and the code comments at the same time, or the next agent writes the same wrong assumption back in.

4. Telling people what is happening while records move

On QA I tapped refresh on Linked Facility and nothing visible happened for several seconds. Then a toast said “Links refreshed”, whether or not anything had changed. I wrote down what I wanted instead, and an agent built it:

State What the person sees
Checking The refresh icon spins (a pulsing dot under reduced motion), “Checking for new records…”, and the list shows a skeleton
Linking / receiving Each facility row gets a chip: “Linking…” while ABDM hasn’t confirmed a link, “Receiving records…” while a pull is in flight. A facility not in the list yet gets a named placeholder card
Done “N new records linked from ", or "Up to date". It fades after about five seconds
Problem A warning and the plain reason. “The health network did not answer. Try again.” with a Try again button, or Sign in again if the session ended. ABDM’s own code and message sit underneath. The previous list stays visible

The status region is an aria-live="polite" status, so a screen reader announces each change. While anything is linking, the screen polls the PHR’s own rows every three seconds; that poll makes no call to ABDM. The demo plays the same states, including an offline browser giving the Problem state.

The same day, every spinner and every premature “not found” in the API build became a skeleton shaped like what will appear: list rows for lists, a card for the ABHA card, a document outline for the PDF viewer, a chat outline for Cally. They come from the Caladrius design system, which got its own fixes in the process: skeletons are now hidden from screen readers and stop animating under reduced motion, and a new group component announces “loading” once with a proper label instead of reading out every grey bar. The local changes are recorded in the design system’s README, so a later refresh from upstream can’t silently undo them.

A screen that showed “Locker not found” for half a second before the locker loaded wasn’t a cosmetic problem. On a health app it reads as “your data is gone”.

5. The iOS Home Screen, round three

On Day 1 we fixed a gap at the bottom of the installed iOS app by sizing the shell from innerHeight instead of 100dvh. On Day 3 my iPhone still showed the glass bottom menu floating about 100 points above the bottom edge, with an empty band under it.

The agent’s investigation is a fair summary of the state of the web platform on iOS:

None of this is in Apple’s documentation. The agent cited bug reports and workarounds from other projects, said that was what they were, and designed the fix not to rely on any reported viewport height. It took three rounds, each checked on the device:

  1. The shell is sized from screen.* in the current orientation (never less than innerHeight), which moves with neither the status bar nor the keyboard.
  2. A readout I could open on the phone showed every height the browser reported. It proved the shell was the full 932 points tall but drawn cut off at 873, because html, body and the root were 100% of the short viewport with clipping on. On installed iOS only, those three are now screen-tall.
  3. Overlays (sheets, drawers, dialogs) got the same treatment: anchored from the top, absolute rather than fixed, screen-tall.

A layout guard script now encodes each of these rules, so a later change can’t quietly reintroduce one of the earlier bugs. The diagnostic readout was the turning point. Asking me to describe what I saw got us nowhere. Getting the device to report its own numbers got us there in two rounds.

The same day brought a run of visible polish, most items previewed on screenshots before they merged:

6. How does an installed app learn it is out of date?

Testers kept reporting bugs we’d already fixed. The reason: iOS checks for a new service worker only when a Home Screen app is launched, so an app resumed from the background kept the old build for days.

The fix has three parts:

The caching scope didn’t change: the service worker caches the app shell only, never health data. The version also appears in the footer after the legal links.

Getting the version stamp itself right took two pull requests. QA first showed dev · dev: the self-hosted runners seemed to have reused a workspace without an up-to-date origin/dev. The next run logged the script’s error instead of swallowing it, and the error was node: command not found, because the deploy jobs had never set up Node. A step that swallows its own errors costs you a deploy cycle every time.

7. A process change: NHA checks on demand

By the afternoon, the screen-change NHA check was running on every small pull request into dev, on our self-hosted runners. A one-line CSS fix waited behind a functional run. I decided to pause that gate on dev: NHA cases now run on demand, while CI and the security workflow still gate every pull request.

The pause is a repository variable, not a workflow edit. Unset it and the gate is back. I also had three small pull requests consolidated into one, to share a single CI and security run. On a constrained set of runners, batching is a real lever.

There was also some branch housekeeping. Promotions to qa require the head branch to be up to date with qa, and qa held only merge commits from earlier promotions. Four times that day a no-content sync brought those merge commits back into dev. It’s a small tax, and worth knowing about before you protect your branches this way.

8. What I learned on Day 3

Next, Day 4 (1 November): a test run that crossed midnight finds a time-zone bug, and the first plugin-driven NHA functional run finds the rest.

The team behind Day 3

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

Cally: taxonomy and intent (Giri)

Day 3 gave Cally a place in the app: it became one of five tabs (Home, Records, Cally, Consents and Me), with a chat outline among the new loading skeletons. The rest of the day was groundwork for Giri’s area. Records moving between a hospital and the PHR now have four named states, Checking, Linking or receiving, Done and Problem, each with its own wording.

A question like “where are my records from this hospital?” has honest answers that are exactly those states, so the intent framework can use them rather than invent its own. The day’s logging rule matters here too: when an answer’s content can’t be logged, log its shape. Anything Cally handles about records will need the same discipline.

Development, infrastructure and go-live (Krishna)

Day 3 ran at a pace this area made possible: 23 pull requests into dev, 72 commits and eleven promotions to QA, with a fix usually reaching QA within the hour. The QA API received its first real sandbox callbacks, each authenticated with ABDM’s gateway tokens, and unauthenticated calls got 401 (checked the next day).

Installed apps now learn they are out of date: every build writes a small version file, checked on launch, on return and every 30 minutes, while the service worker still caches the app shell only. Getting the version stamp right exposed a missing Node set-up on the self-hosted runners. The NHA screen check on dev was paused through a repository variable, and small pull requests were batched to share CI runs.

Narrative and personas (Preetha)

Day 3’s story is someone tapping refresh and seeing nothing for several seconds, then a message that may not be true. Now they see what is happening, in words: “Checking for new records…”, a chip per facility, then “Up to date” or the plain reason something failed. A screen that said “Locker not found” for half a second wasn’t cosmetic; on a health app it reads as “your data is gone”.

The day also served people on iPhones, people who use a screen reader or prefer reduced motion, and testers who kept meeting fixed bugs on an old build and now see “Updated to” a new version. The new Me tab carries the person’s photo and KYC badge.

Product and technology direction (Manish)

I wrote down the states I wanted on refresh and had an agent build them, because the screen is where trust in a health app is won or lost. When ABDM turned out to create the locker’s subscription itself, I chose to change our design to fit what ABDM does, and to make the stub follow the sandbox, not the document.

I also changed the process: NHA cases on dev run on demand, while CI and the security workflow still gate every pull request. Eleven promotions in a day only works because the gates are automated and each fix is small.

Further reading

See all 16 parts