Build diary Day 4

Day 4: Midnight in India, and the First Formal Test Run

Built with Giridhar, Venkatakrishna and Preetha

Building the Caladrius PHR with agents Part 4 of 15

13 min read

Hand-drawn sketch of a clock at a quarter past midnight beside a calendar, with notes reading India 00:15, UTC 18:45 (previous day), Same moment. Different date, and a ticked P2 test run

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.

Sunday, 1 November, was the smallest day of the week by volume: five pull requests into dev, 20 commits, four promotions to QA. It was also the day the project changed gear. Until Sunday, our evidence came from our own regression suite, which runs against a stub of ABDM. On Sunday we ran the first plugin-driven functional test of a milestone: NHA’s own P2 test cases, on QA, against the live sandbox, with a person entering every identity, OTP and approval.

Before that, the regression suite found a bug in the most ordinary way possible: it ran across midnight.


1. Bringing the plan up to date first

The day began with documentation, which is how the ABDM plugin wants it. The plugin maintains INTEGRATION-PLAN.md at the root of the repository: every step of every milestone with its exit condition, its status, its evidence and the date. After every step, the plan is updated. Saturday had produced a lot of evidence, so Sunday’s first pull request recorded it:

Step Was Now
P2-3, the first real callback in progress done (consent on-init, notify, on-fetch, data on-request)
P2-4, callback authentication done in code done (real gateway tokens verified; unauthenticated calls 401)
P2-8, linking in progress in progress, HIP-initiated linking proven
P2-10, consents in progress in progress, auto-approval proven (a consent granted with no tap)
P4-7, locker set-up in progress done
P4-8, subscription in progress in progress, granted
P4-9, consent with auto-approval blocked in progress, two NHA cases proven
A real hospital round trip blocked blocked, on the hospital side

P2 went from 8 to 10 of 15 steps, P4 from 10 to 11. The evidence column holds sandbox request ids and statuses. It never holds a token, an ABHA value or anything else that identifies a person.

Why bother just after midnight on a Sunday? Because the next agent to pick up P4 starts by reading this file. If the plan says “blocked” for something that was proven yesterday, the agent spends its first hour re-proving it. The plan is the handover between agents, and between days.

2. The bug that only exists between midnight and 05:30

On Saturday night, the API-build regression suite ran on the qa branch and failed a cluster of upload and consent cases. Nothing in those screens had changed. The agent looked at the page snapshots the failing tests had saved and found the same thing in each: a document dated today, an error “The document date cannot be in the future”, and the Upload button disabled. The timestamps were all between 00:00 and 00:30 IST.

The cause was one line, in two screens:

const today = new Date().toISOString().slice(0, 10);   // the UTC date, not the person's

toISOString() gives the date in UTC. India is UTC+5:30. From midnight to 05:30 IST, the UTC date is still yesterday, so “today” in the person’s calendar is “tomorrow” to the code, and a document dated today counts as future-dated. For five and a half hours every night, nobody using the app in India could upload a document dated today.

The fix had two layers, and it took two pull requests to find the second:

  1. The app. A new todayLocal() uses the device’s own calendar, and both screens use it.
  2. The API. The re-run on the fixed branch still failed. The API compared the upload’s date header with midnight UTC too, and refused the upload with a generic “some details are not valid”. It now uses the Indian calendar day, the way the share-token logic already did, and it also refuses impossible dates such as 30 February, which it had been accepting.

The same re-run found an unrelated failure that is worth a paragraph, because it shows how two good features can combine into a bad one. The test server for the API build served the PDF viewer’s worker (a .mjs file) with the wrong content type. The module failed to load, and the browser fired Vite’s preload-error event. Day 3’s “stale build” handler, written so installed apps recover from a deleted chunk after an update, treated that as a stale build and reloaded the page, closing the record viewer before the test reached it. Production’s web server already maps .mjs correctly, so this was a fix to the test server only. But it was a reminder that a self-healing reload hides the error that triggered it, so a test that sees a reload should ask what failed first.

The lesson about time zones is an old one, and agents make the mistake as readily as people do. The project rule that came out of it (and was later extended into a general one: dates follow the person’s regional settings) is simple: never derive a calendar date from toISOString(). Use one helper for “today” in the person’s calendar, one for the Indian calendar day on the server, and nothing else.

3. Two kinds of test run

Before Sunday’s main event, it’s worth being precise about the two kinds of run this project has. The distinction is written into our functional-testing document, and it matters for anyone building against a certification catalogue:

  Regression run Certification run
What Our Playwright specs, each naming its NHA case ids NHA’s cases, run with the ABDM plugin’s /abdm-test
Against The app as it ships → the PHR API → a stub ABDM The app and API on QA → the ABDM sandbox
Who enters identities, OTPs, approvals The suite, with synthetic values A tester, every time
Output HTML and JUnit reports, a coverage table, a screenshot per case NHA’s workbook filled in, a run log, per-case evidence, a report and findings
When Pull requests to qa and main, and on demand Before submission, on one build

A pass on the regression suite says the screens and API do what the case expects against our reading of ABDM’s specification. It is not certification evidence, because the stub isn’t ABDM. The regression suite exists so that the certification run finds the screens already right, and keeps them right afterwards.

The plugin enforces the human part. It never types an identity, an OTP or an approval, and it never mocks a response. The agent prepares each case, tells the tester what to do, reads the screen and the API’s logs, and records the result against the case id in NHA’s own workbook.

4. The first plugin-driven run: P2 on QA

On Sunday morning we ran /abdm-test p2 ui against the QA build, with a tester on a phone and an agent running the plugin’s P2 workbook. P2 is the patient’s side of linking, sharing and consent, and the profile that goes with it.

One practical note first. The plugin’s P2 skill couldn’t be downloaded on the cloud machine running the agent: the portal’s package URL was geo-restricted from there. We copied the skill folder from the installed plugin (same version) into the repository’s .claude/skills/, so every agent session gets the same skill regardless of where it runs. It’s pinned to the plugin version recorded in the plan, like everything else that comes from NHA.

The run produced a list of findings, and a single pull request fixed them, each tied to its case:

The key change is S1 (cryptography), so it got a security changelog entry, and a test asserts that the ABHA number appears nowhere in the audit log. The rest is S3 or patient-facing consent UX.

The pull request also listed what it didn’t fix: requesters shown by id when QA’s requests carry no name, a possible O for Other on P1’s mobile enrolment with no live refusal on record yet, and ABDM refusals that still surfaced as 500. Writing down what is left is as useful to the next agent as the fix.

By the evening, the key fix had reached QA and the tester re-ran the link cases. The link itself now worked: OTP requested, resent, verified. Two new bugs appeared right behind it.

A success reported as an error. After ABDM accepts the link, it ends the person’s token: the profile has changed, so the person must sign in again. We re-read the profile with that ended token straight away, got ABDM’s “please try login again as you have updated your profile”, and showed it as an error. The link had worked. Now the API answers 200 with signInAgain: true, clears the account’s ABDM tokens, and the app shows NHA’s success message (“ABHA number is securely linked to ABHA address”) with a Sign in again button that ends the session.

Signing in to the linked address gave a 500. This one was about identity, and it is S1. When the person signed in again, the API found two candidate patient records for them: the address’s own record, which had no ABHA number, and an existing record already holding that ABHA number. It threw a conflict that no route handled.

The rule we wrote is deliberately narrow: it says exactly when two patient records are the same person, every consolidation is audited, and when the rule doesn’t apply the result is a 409 “profile conflict”, never a 500.

This is the kind of change I review line by line. An agent can write the merge logic; it can’t decide when two records are the same person. That rule came from me, it’s narrow on purpose, and it’s in the pull request in plain words.

The functional specs for sign-in and registration ran against the API build after the change: P1’s mandatory cases were 63 of 63.

The fix also listed two open questions. The same stale-token re-read probably happens after updating the mobile number. And on the sign-in-again path the button says “Sign in again” where NHA’s sheet says “Go back to home screen”, which is a certification call, not an engineering one. The first was fixed the next morning.

6. A footnote on runners

The same pull request carried a temporary switch back to GitHub-hosted runners, behind a repository variable. Our self-hosted runners were offline and the fix was urgent. It’s a small thing, but it is the second time this week that CI’s behaviour changed through a variable rather than a workflow edit: the NHA gate on Day 3, the runners on Day 4. A switch that is one click to flip back is a switch you dare to use.

7. What I learned on Day 4

Next, Day 5 (2 November): a full day of P2 and P4 runs on the sandbox, three tries at one URL field, and the data push we kept refusing.

The team behind Day 4

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

Cally: taxonomy and intent (Giri)

Day 4 had no Cally work, but its fixes name distinctions the intent framework will need. “Today” is the person’s calendar day, not the server’s, so any request about dates has to be read in the person’s time. A successful link that ends the session is a success, with a next step, not an error. Gender “Other”, state and district, and the rule for when two patient records are the same person all became explicit.

For the Cally taxonomy that last one matters most. The rule for merging patient records is narrow and written in plain words, and it is an owner’s decision. Questions about who a person is, and which records are theirs, belong in a category Cally treats with the same care.

Development, infrastructure and go-live (Krishna)

Day 4 was small in volume (five pull requests into dev, 20 commits, four promotions to QA) but it changed gear on the road to go-live: the first plugin-driven functional run of a milestone, NHA’s P2 cases on QA against the live sandbox. The day started by bringing the integration plan up to date, because it is the handover between agents and between days.

The P2 skill couldn’t be downloaded on the machine running the agent, so it was copied into the repository, pinned to the plugin version in the plan. A test-server content type was fixed, and a temporary switch back to hosted runners, behind a repository variable, kept an urgent fix moving while the self-hosted runners were offline.

Narrative and personas (Preetha)

Day 4’s people include anyone using the app in India who tried to upload a document dated today between midnight and 05:30 IST, and couldn’t. They include the person who links their ABHA number and now sees NHA’s success message, “ABHA number is securely linked to ABHA address”, with a clear Sign in again, rather than an error after a link that worked.

Smaller wording changes served the same people: gender “Other” handled correctly, a refused profile save shown under the form rather than in a toast nobody saw, and facility search no longer saying “no match” before anything was typed. One wording question stayed open: whether the button should say “Sign in again” or follow NHA’s sheet.

Product and technology direction (Manish)

The rule for when two patient records are the same person came from me, and it is narrow on purpose: every consolidation is audited, and anything the rule doesn’t cover is a 409, never a

  1. I reviewed that change line by line. An agent can write merge logic; it shouldn’t decide who a person is.

I also made the time-zone lesson a rule: never derive a calendar date from UTC. And I kept the two kinds of test run apart, because a pass against our stub is not the same evidence as a run on the sandbox.

Further reading

See all 16 parts