Build diary Day 10

Day 10: Sixty-Two Merges and a Platform

Built with Giridhar, Venkatakrishna and Preetha

Building the Caladrius PHR with agents Part 10 of 15

15 min read

Hand-drawn sketch of many ticked pull requests flowing into one document marked 62, which branches out into shared packages labelled Forms, Auth, Cally, Terminology and Server Core, beside a checklist and a console window

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.

Day 9 was three days of plans and no merges. Day 10, 9 November, was the opposite: 62 pull requests marked merged and 314 commits landed on dev in a single day. By the evening, five pieces of the PHR had become shared Caladrius packages (forms, auth, Cally, terminology and the server core), a second app existed in the repository (the PHR Console, for the people who run the PHR), and staff had a way to sign in that a patient can never use.

This post covers what landed, how a day of that size was kept safe, and the review process that made it possible to merge that much without losing track of any of it.


1. How sixty-two merges happen in a day

Not by sixty-two people. Several agent sessions worked in parallel, each on its own stack of branches from the Day 9 plans: one on the forms filling stack (F1–F6), one on moving the security infrastructure (S1–S2), one on the console and staff sign-in (C1–C2, S2b), one on forms authoring and terminology (A, T). One session acted as reviewer and integrator: it reviewed each PR against its plan step, asked for changes, and decided the merge order.

Every PR followed the same template it had all week: its plan step and class, NHA cases affected (for almost all of these, none, because no screen or ABDM call changed), the checks that were run, and a changelog entry in the same commit.

Then the stacks met a practical problem. Merging about 45 stacked PRs bottom-up means about 45 full CI and security runs in sequence, each one waiting for the last. So I approved a landing PR: one branch built from the tops of the reviewed stacks with plain merges (no rebase, so every commit keeps its history), conflicts resolved (they were changelog-only, both sides kept), and the lockfile regenerated. One CI run, one security run, one merge. Because every included PR’s tip is an ancestor of the landing branch, GitHub marked each of them as merged, so each one still has its own description, review and diff to point to.

The rule I held to: a landing PR may only carry PRs that were already reviewed individually. It’s a way of saving CI time, not a way of skipping review.

2. Moving security code without changing it

The riskiest work of the day was also the least visible: moving the API’s security infrastructure into packages. Day 9’s principle 4 says extraction never changes behaviour, and each PR was written to prove it.

@caladrius/server-core (S1). The logger with field redaction, field encryption, the static-SQL guard, the key-value client, the audit sealer, env parsers, the error handler, request ids, no-store and the security headers.

@caladrius/auth (S2a, S2b) and @caladrius/auth-react (S2c). Sessions (RS256 access tokens, single-use refresh tokens stored as hashes, reuse detection), cookies, the CSRF origin check, ajv validation, RBAC, and then the tiered rate limiter. The app passes in its audience, cookie names, feature list and stores. ABDM sign-in stayed in the API: how a patient signs in is product logic. In the browser, the session client (one shared silent refresh on a 401, signed-out notifications, the error envelope) moved into auth-react; the PHR kept its own error class and its onboarding-aware route guard.

How do you show a move changed nothing? The existing tests move unchanged and pass. The API’s 966 tests ran through the API’s own modules, including both rate-limit suites, with the same coverage. The packages got their own tests on top (the rate limiter at 98% statement coverage), and each step went in as S1 with an owner-review request and a security changelog entry.

3. Who a session is for

With the code in a package, step S2d added the one new security concept of the day’s auth work: every session now says who it is for, patient or operator.

That comes from our own records, never from the request, and every route admits only the kind it is meant for. That gives the four layers the Day 9 draft plan proposed.

4. Staff sign-in

Staff sign-in (S2b) landed in four steps, and in the API it’s off unless a setting enables it. Every staff path is a 404 until then, so nothing new was exposed on QA, or to a security audit, before it was ready.

Step 1, the package. Three provider-agnostic entries in @caladrius/auth: single sign-on with the standard protections, a second factor, and re-authentication for sensitive actions.

Step 2, the tables and roles. Identity providers (a secret is referenced by name only; the value stays in the secret store), user identities, invitations (a hashed token, single use, one open per person), MFA and lockout state, and the step-up time on the session. The roles from the plan arrived: Platform Admin (the old Admin, renamed in place so grants stayed), Installation Admin, Forms Author, Forms Publisher and Auditor.

Step 3, the routes. Staff sign in through the company’s identity provider with multi-factor authentication, with invitations and re-authentication for sensitive actions. Their sessions are deliberately short.

Step 4, an emergency route in. For when the identity provider is down: tightly controlled, and alerted on every use.

5. The PHR Console

The console (apps/console) is a desktop React app on the same stack as the PHR, talking to the same API through its own staff routes, English only.

I asked for the console to look exactly like AI Studio’s desktop app, so staff moving between Caladrius products feel at home. The rule from Day 9 applied: AI Studio’s desktop shell was copied verbatim into vendor/ first (scanned for emails, phone numbers and secret-looking assignments: none), then adapted in the console on our @caladrius/ui shell components. The parts specific to AI Studio, its clinical tools among them, were left out.

The console was built and tested but not deployed that day: it has a container file so it builds, and its own end-to-end specs, but no deploy workflow yet.

6. Forms, end to end

The forms stacks from Sunday evening landed in full, and the console gave them their authoring half.

Filling (F1–F6). @caladrius/forms reads FHIR SDC Questionnaires through one allowlist (a form definition can never carry an answer) and renders them three ways: a question at a time, a section at a time, or the whole form with a section list. Some details I liked:

Authoring (A2–A8). In the console, staff now draft, preview, publish and retire forms:

All authoring routes stay off unless a setting enables them, for the same reason as staff sign-in.

7. Terminology, offline by default

@caladrius/terminology landed as a core, a server router, React pickers and optional adapters, and was mounted in the API. The defaults are the point:

8. Cally becomes a package, and gets a memory

Cally’s server side and browser side moved into @caladrius/cally and @caladrius/cally-react with no behaviour change. The browser package has two entry points, and only the chat entry loads the chat framework; a test walks the import graph and fails if the main entry ever reaches it, so builds without live Cally never download it.

Two features followed:

9. Three reviews, and every finding fixed

Three independent security reviews ran on the new code during the day: one on staff sign-in, one on forms authoring and terminology, one on Cally against both security and DPDPA (India’s data protection law). All three were reviewed and fixed the same day. The standard for each fix is the one I’d recommend to anyone: every fix comes with a regression test that fails on the old code, and the reviewer re-ran those tests against the old code to confirm they fail.

It’s an uncomfortable rule for the person fixing, and that’s the point. A test that passes on the old code proves nothing about the fix.

10. And the rest of the day

11. What I learned on Day 10

Next, Day 11 (10 November): the console gets its roles and permissions screens, and the design system goes through a contrast audit.

The team behind Day 10

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

Cally: taxonomy and intent (Giri)

Day 10 gave Cally its clearest list yet of what it may and may not do, which is the heart of Giri’s area. For forms, Cally may make symptom logs, wellbeing check-ins and questions for a visit. It refuses screening or diagnostic instruments, scoring, triage or advice, consent forms, and any question that asks for an identifier. The model sees the request, never the person’s records, and the request is screened for personal data first. On the authoring side, Cally’s help comes back as a proposal only: the assistant has no write port, so “change this form” is an intent it can answer but never carry out. Cally also moved into its own package unchanged, gained a conversation history that needs its own consent and is erased when consent is withdrawn, and stopped sending its reasoning to the browser.

Development, infrastructure and go-live (Krishna)

Sixty-two merges in a day is an infrastructure story, and that is Krishna’s area. Several agent sessions worked in parallel on their own stacks, and about 45 reviewed PRs went in through one landing PR: one CI run and one security run instead of dozens in sequence, with each PR still marked merged and reviewable. Security CI began running the full suite on every PR into dev, qa and main. Staff sign-in and forms authoring landed off by default, every path a 404, so nothing new was exposed on QA before it was ready. The console was built and tested, with a container file, but not deployed: go-live for it is a later, separate step.

Narrative and personas (Preetha)

Two audiences got attention on Day 10. For staff, the console greets them through one shared sign-in page and looks like AI Studio’s desktop app, so moving between Caladrius products feels familiar. For patients, the forms are built for a thumb: 44 px option cards, Yes and No that still allow “not answered”, and a trend page that states the average plainly and never calls a change “better”. Values read from a lab report stay preliminary until the person has checked them. In Preetha’s area of story and wording, these are choices about tone as much as layout: the app reports, the person decides. The new Me page and two screen audits for long languages carried the same care.

Product and technology direction (Manish)

I approved the landing PR on one condition: it may only carry PRs that were already reviewed individually. Batching saves CI time; it never replaces review. I asked for the console to look exactly like AI Studio’s desktop app, through the copy-first rule. I changed one documented rule, per NHA: a person’s own ABHA number and address are shown to them in full, and stay masked everywhere else. And I held the security reviews to the standard I’d recommend to anyone: every fix comes with a regression test that fails on the old code.

Further reading

See all 16 parts