---
title: 'Day 6: The QA Runs Write the Backlog'
series: Building the Caladrius PHR with agents
part: 6
series_total: 15
date: '2026-11-23'
reading_time: 15 min
description: The question stopped being whether the PHR was built and became whether
  it survives NHA's test cases on a real server, against a real consent manager. Almost
  every fix that day came from a QA run, from an error that fell through to 464 stored
  rows for 49 visits.
canonical_url: https://caladriushealth.ai/solutions/phr-build-diary/day-6-the-qa-runs-write-the-backlog/
publisher: Caladrius Health AI Studio
---

# Day 6: The QA Runs Write the Backlog

The question stopped being whether the PHR was built and became whether it survives NHA's test cases on a real server, against a real consent manager. Almost every fix that day came from a QA run, from an error that fell through to 464 stored rows for 49 visits.

*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.*

By the morning of 3 November the PHR did almost everything P1 to P4 asks of it, at least on paper. Every screen existed,
every call had a route, and the API build talked to the [ABDM](https://caladriushealth.ai/what-is-abdm/) sandbox. The question was no longer "is it built?" but
"does it survive NHA's test cases run by hand, on a real server, against a real consent manager?"

Day 6 is the day that question took over. Fourteen pull requests merged into `dev` and eleven promotions went to QA,
nearly one round trip per fix. None of them was a feature anyone had planned that morning. Almost every one came from a test
run on QA or a deploy: an NHA case that didn't pass, a log line that didn't look right, or a number in the database that was too
big. This post is about that loop, and about the one bug of the day that taught me the most: a health locker that
stored the same record twelve times.

---

## 1. The loop

The working rhythm on Day 6 was simple, and it's worth writing down because it is the rhythm of most of the series from
here on:

1. A QA build goes out. Every build has a number, so a finding can name the build it was seen on.
2. Someone runs a block of NHA cases against it: the P1 KYC cases with a fresh Aadhaar, the P2 deep-link cases, the
   locker cases. Our other product, [AI Studio](https://caladriushealth.ai/platform/brief/#platform), sits on the far side of the sandbox as the hospital (HIP) and the
   requester (HIU), so the PHR has a real counterpart to link with, share with and receive from. Its QA logs gave us the
   view from the other end of the wire.
3. A finding becomes a pull request. The PR template asks, among other things, for the change class (S1, S2 or S3), the **NHA
   cases affected**, the **plugin source** the fix rests on (a skill file and section, or a `doc_url`), and the checks
   that were run.
4. CI runs. (The check that re-runs a touched screen's NHA cases was paused on dev; NHA cases ran on demand.)
5. The fix is promoted to QA, and the case is run again.

Agents did steps 3 and 4, and most of step 5. My part was deciding which findings mattered, approving the S1 changes
(several PRs that day say "owner-approved 2026-11-03" because they change the consent lifecycle or how health records
are stored), and reading the explanations.

The explanations were the part I came to rely on. A good agent PR on Day 6 reads like an incident note: what was seen,
on which build, why it happened, what changed, what *didn't* change and why, and which test now proves it. When the
next fix touches the same code, that note is the first thing the next agent reads.

## 2. P1: when ABDM's answer differs from ABDM's specification

The P1 KYC run (creating an ABHA with a fresh Aadhaar) found four things.

**Resending the Aadhaar OTP.** NHA's case says a resend reuses the first send's transaction id, and our client did
exactly that. The sandbox refused it ("Invalid Transaction Id"), and the API then treated the whole flow as broken and
deleted it, so the person had to start again. The fix keeps the specified behaviour first and adds a narrow fallback:
only when *that* refusal comes back, the API sends the OTP afresh, with an empty transaction id and the Aadhaar
ciphertext it stored on the first send. The Aadhaar number itself is never re-entered or re-sent in clear, and a test
asserts that it appears in no resend input. Any other refusal fails as before.

**An error that fell through.** One UIDAI refusal ("maximum number of attempts, or OTP not generated") arrived wrapped
in an ABDM code we had mapped only for another UIDAI error, and became a generic 500. It now reads as an expired OTP with a clear next step: ask
for a new one.

**An address that is really a number.** When ABDM creates an ABHA number, it gives it a default ABHA address that is the
14-digit number itself. Our address lists showed it in full. At the time our rule was to mask identifiers, so lists now
showed it as `xxxxxxxxxx1234@sbx` (the end-to-end specs that expected the full value were updated the same morning).
Six days later, on Day 10, NHA's guidance changed that rule: a person's *own* ABHA number and address are shown to
them in full. I'll come back to it then; the point here is that the masking was a rule in `AGENTS.md`, so changing it
later was one documented decision, not a hunt through the screens.

**A long button.** "I still want to create a new ABHA address" ran off the edge of a phone. It wraps now. Small, but it
was in a case's evidence screenshot, so it mattered.

The resend fix is a pattern I'd see again and again: **follow the specification, and when the sandbox disagrees,
handle the observed answer narrowly, with the sandbox response as the evidence in the PR**. Never replace the specified
behaviour with the observed one wholesale.

## 3. A security gate blocks the deploy, and we remove instead of suppress

The first promotion of the day failed, and not because of a test. The container image scan, one of the [security gates](https://caladriushealth.ai/platform/brief/#security) every
deploy passes through, found two high-severity advisories in an XML parsing library inside the FHIR validator image.
The base image's upstream hadn't published a fixed package yet, so "upgrade" wasn't available.

There were two easy ways out, and both are forbidden by `AGENTS.md`: disable the gate, or suppress the finding without
a reason. The agent took the third way and asked a better question: *why is that library in the image at all?*

- In the validator image, the library was needed only by the font configuration package.
- The FHIR validator draws nothing. The agent scanned every class in the validator's JAR (checksum verified) and found
  font users only in components validation never calls. The one graphics path it does use writes images through
  ImageIO, which needs no fonts.
- With the fonts removed, headless Java still loads the validation engine and writes a PNG.

So the fix removes the fonts, which takes the library with them; adds a **build guard** that fails if either comes
back; and runs the JVM headless. About an hour later the same advisory blocked the *app* image. Same question, same
answer: the library came in through nginx's optional image-filter module, which our `nginx.conf` never loads. Removing
the module purged 38 packages, nginx still passed its config test and served the app, and a second build guard went in.

The lesson isn't about the library. It's that **a gate is only worth having if nobody is allowed to walk around it**,
and that an agent told "never disable a gate" will find the fix that a hurried human might skip. The smaller image is a
bonus.

## 4. P2: records that never arrived

The P2 deep-link run (NHA's 1901–1908 cases) and a review of QA logs found the most user-visible gaps of the day.

**Hospital-linked visits never reached the app.** When a hospital links a visit to a person itself (HIP-initiated
linking), the PHR learns about it only by reading ABDM's list of the person's links. Nothing read that list
automatically. One test account had three hospital-linked visits and no rows at all, so pulling records failed.

- Records and Linked Facility now ask the API to sync links automatically when they open.
- An automatic sync goes to ABDM **at most once per account every few minutes**. Within that window the API answers
  from its own rows and says so (`throttled: true`). A refresh the person asks for always goes to ABDM.
- A migration adds the timestamp the throttle needs, with its down migration.

This is a design choice I like: be eager when the person asks, and polite when the app asks on their behalf.

**Discovery feedback.** An empty discovery at a facility the person is already linked to now says "No new health record
to link" rather than "No health records found". ABDM's "duplicate discovery request" refusal becomes a clear wait
message, and Fetch records is disabled for three minutes instead of inviting the same refusal again.

**A deep link through registration.** NHA's deep-link cases send a person from an SMS straight to a facility's link
screen. If they had no account yet, the link was lost during registration and they landed on Home. The `next` target is
now carried through every registration step and handed to sign-in.

**Programme ids.** NHA asks that a government programme's id be labelled for that programme: "PMJAY ID" for AB-PMJAY,
the registered mobile number for CoWIN. ABDM's programme list carries no label, so the app names the id from the
programme's own id, sends CoWIN's 10-digit mobile to discovery as `MOBILE` rather than a record number, and uses NHA's
wording word for word when a programme can't be reached.

**"Check for new records".** Home gained a refresh button that reads the links from ABDM and then asks every linked
facility for its records, the same pull as on a single facility. The first QA run of it showed it asking the PHR's *own*
locker as if it were a hospital, which the API refuses by design, so every refresh ended with "some facilities could not
be asked". The next PR left the locker out of the count.

## 5. Consent lifecycle: what to do with a request nobody will ever answer

The locker (P4) works by asking for consent, as any requester would, and then pulling records from each hospital
under that consent. Day 6 found three ways that could stall.

**Events without the field the specification requires.** When a locker is set up, ABDM sends it notifications of new
records through its subscription. The specification lists `subscriptionId` as required; the sandbox left it out. The API
was dropping every such event as malformed. Now, when it's absent, the event is matched to this PHR's own *granted*
subscription over the patient the event names, located through the address's blind index (a keyed hash; the address is
never stored in clear). Events still missing an event id, category, facility, patient or care contexts are refused, as
before. This changes how an ABDM callback is attributed to an account, so it went in as S1, with a security changelog
entry.

**A set-up that took longer than the app would wait.** Setting up a locker took about 30 seconds on the server; the app
gave up at 20. The call now waits much longer, and if the network still drops it, the screen asks whether the
locker became active before declaring failure. A refusal is still shown as a refusal.

**Consent requests stuck forever.** The locker had consent requests from the day before that were "awaiting" and would
have stayed so for 30 days:

| What happened | What the PHR now does |
|---|---|
| ABDM never answered the request with an id, so the patient had nothing to approve | After a set time, close it as failed, audit it, and raise a fresh request on the next pull |
| ABDM gave an id, but the consent manager never listed the request for the patient | After a set time, ask the consent manager (with the patient's token, through a call we already used). Not listed: close it. Listed as expired, denied or revoked: close it with that status. Listed as requested: keep it, it's still the patient's to decide. Couldn't ask: keep it |

The last row is the important design rule: **a failure to check never drops a live request.** A sandbox wobble must
not cost a patient a consent they were about to grant. Every close and every check is audited, with the facility id and
status in the metadata and no personal data.

**One decision at a time.** Granting a consent reads every chosen facility's references first, which took a few
seconds with no sign of work. A tester tapped Grant three times; ABDM received three approvals and held four artefacts
instead of two. Grant, Deny and Revoke now show a busy state and ignore taps until ABDM answers.

**Never invent an id.** The consent detail screen listed "artefacts" with ids made up from the request id and a
suffix. It now lists the consent manager's own artefacts, with ABDM's ids and statuses, and shows the granted
facilities *without* an id until those load. A screen in a certified app should show what the system of record says,
or nothing.

## 6. The locker that kept everything twice (or twelve times)

The best bug of the day was found by reading the QA database. A test locker held **464 records from one hospital over
49 distinct visits**: 118 groups of duplicates, up to twelve copies of a single record. Worse, the locker, acting as a
facility itself, had linked those visits to the consent manager under hundreds of references, because every pull stored
the records again and linked them again.

There *was* a unique index meant to stop this: on the hash of the raw FHIR bundle. It never matched, because the
sending hospital rebuilds each document on every transfer. The agent measured what changes between two transfers of the
same record: the bundle id, the bundle identifier, every entry's `fullUrl` and resource id, and therefore every
reference. What stays the same: the content, the document bytes, and the Composition's identifier.

The fix on Day 6:

1. **Store each document once.** Two HMACs per record, both keyed per account so nothing about the document is
   readable from them:
   - a *source key* over the facility, the care context and the document's identity;
   - a *content hash* over a **normalised** body, with per-build ids dropped, references rewritten to entry positions
     and keys sorted.

   Same key and same content: a duplicate, not stored.
2. **Link once.** A duplicate is never stored, so it is never linked again.
3. **One transfer at a time.** A pull under a consent whose transfer is still open queues nothing new. A subscription
   event (new data the open transfer didn't ask for) still fetches; an existing test caught that case when the first
   version got it wrong.
4. **Clean up what's already there.** A background job keys the older rows, oldest first, erases later copies (bundle
   cleared, row soft-deleted), drops their unsent links, and audits each erasure.

The tests read like a specification of the behaviour: a re-pull stores nothing; two documents of one visit are kept
apart; the backfill keeps the earliest copy; a second tap waits for the open transfer.

I'd like to say that was the end of it. It wasn't. The "document's identity" in step 1 used the Composition identifier,
and on Day 7 we found out what happens when a sender gives many different documents the same one. That's the next post.

## 7. What a day of fixes looks like in numbers

| | Day 6 |
|---|---|
| PRs merged into `dev` | 14 |
| Promotions to QA | 11 |
| Commits | 31 |
| Migrations | 2 (links-sync throttle; record identity and dedupe) |
| S1 changes | P1 OTP flow, links sync, callback attribution, consent lifecycle (2), record storage |
| NHA cases named across the PRs | P1 address cases, P2 linking and deep-link cases, P3 consent cases, P4 locker cases |
| API tests with the database at day's end | about 1,100, coverage 94.7% |

Two things in that table are deliberate. The first is the number of promotions. We didn't batch fixes into a daily
release; each went to QA as soon as it was green, so the person re-running the case was testing one change, not five.
The second is that all but one S1 change carried a security changelog entry with a severity tag, in the same commit. When an
auditor later asks "when did the consent lifecycle change, and why?", the answer is a line in a file, with a PR behind
it.

## 8. What I learned on Day 6

- **The certification cases are the specification, and the sandbox is the second specification.** Where the two
  disagree, follow the written one first and handle the observed answer narrowly, with the evidence in the PR. Never
  quietly switch to "whatever the sandbox does".
- **"Ask why it's there" beats "make the warning go away".** Both container fixes ended with a smaller image and a
  build guard, not a suppression. Agents are good at this when the rules forbid the shortcut.
- **Design for the request nobody will answer.** Distributed consent flows have silent failures. Every waiting state
  needs a timeout, a way to ask the system of record, and a rule that a failure to ask never destroys something live.
- **Read the database, not just the screen.** The duplicate records looked fine in the app. It took a count query on
  QA to see 464 rows for 49 visits.
- **Identity is the hardest part of storing someone else's documents.** Deciding when two records are "the same" is a
  product decision with safety consequences, not a hashing detail. Day 7 proved it.

*Next, Day 7 (4 November): we get document identity wrong in a new way and fix it properly, ship a public demo with a
guided tour, show what Personalised Intelligence could be, and sign our first UHI request.*

## The team behind Day 6

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 6 had no Cally work, but it sharpened what Cally will need to understand about consent. A consent request now has
named outcomes: closed as failed after an hour, closed as expired, denied or revoked, or kept because it is still the
person's to decide. Empty discovery says "No new health record to link", and a programme's id is named for that
programme.

The rule that matters most for Giri's area is "never invent an id": the consent detail screen shows what the consent
manager says, or nothing. For the Cally taxonomy, that is a guardrail on what Cally may answer: what the system of
record says, and never a plausible-looking value made up to fill a gap.

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

Day 6 was fourteen pull requests into `dev`, eleven promotions to QA, 31 commits and two migrations, with every QA
build numbered so a finding names the build it was seen on. AI Studio sat on the far side of the sandbox as hospital
and requester, and its QA logs gave the view from the other end.

The first promotion was blocked by the container image scan. Instead of suppressing the finding, the unused fonts and
an unused nginx module were removed, and build guards keep them out. The links sync gained a throttle, locker set-up a
longer wait, and the day ended with about 1,100 API tests and 94.7% coverage. Read the database, not just the screen:
a count query on QA found the duplicates.

### Narrative and personas (Preetha)

The people in Day 6 include a person who follows an SMS link to a facility before they have an account, and now lands
where the link pointed after registering. They include people enrolled in government programmes, who now see "PM-JAY ID"
or a registered mobile where the programme expects it, in NHA's wording.

A tester tapped Grant three times because nothing showed work was happening; Grant, Deny and Revoke now show a busy
state. A button that ran off the edge of a phone now wraps. And behind the screens, a person about to grant a consent
no longer loses it because a check failed: a failure to ask never drops a live request.

### Product and technology direction (Manish)

My part on Day 6 was deciding which findings mattered, approving the S1 changes to the consent lifecycle and to how
records are stored, and reading the explanations. I came to rely on agent pull requests that read like incident notes.

Two design choices were mine to keep. Be eager when the person asks, and polite when the app asks on their behalf: an
automatic sync goes to ABDM at most once every few minutes. And treat document identity as a product decision with
safety consequences, not a hashing detail. Day 6 shipped a first answer to that question; Day 7 corrected it.

## 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/))
