Build diary Day 11

Day 11: Who May Do What, and Text You Can Read

Built with Giridhar, Venkatakrishna and Preetha

Building the Caladrius PHR with agents Part 11 of 15

15 min read

Hand-drawn sketch of a permissions grid of ticks and crosses for four people, locked at the API, beside a faint and a clear Aa, with notes reading Permissions are enforced at the API and Contrast checked. Readability improved

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.

The day before was the biggest day of the project so far: the shared platform packages (server core, auth, forms, terminology, Cally) and the first version of the PHR Console, the desktop app the people who run the PHR use, all landed at once. Day 11 was the morning after. Only eight pull requests merged on 10 November, seven of them into dev, but 87 commits went into branches, and most of them were about the two things a big landing leaves behind: who may do what in the new console, and whether everyone can read what the screens say.

It was also the day the production-readiness review was written, which set up the next two days of work. I’ll come to that at the end.


1. Two kinds of user, two kinds of role

The PHR has two audiences, and the database already keeps them apart:

The patient side has had role-based access control since Day 0, applied to its API routes by convention. The console needed the other half: a way for an administrator to give a colleague a role, take it away, suspend an account, and change what a role may do, without opening a database shell.

The API for this had landed the day before. Day 11 added the console screens on top of it, and the interesting part is not the screens. It is the list of things an administrator must not be able to do.

2. The rules of administering administrators

An access-control screen is itself an access-control risk. If the screen that grants rights can be used to grant yourself more rights, you have built a privilege-escalation feature with a nice user interface. So before any UI, the contract listed the refusals, each with its own error code and its own test:

Rule Why
No one grants more than they hold. An administrator can’t create a more powerful administrator.
No one changes their own access. No self-escalation, and no locking yourself out by accident.
The emergency account can’t be changed from the console. It must not be editable from the screen it exists to rescue.
The installation always keeps an administrator. You can’t end up with an installation nobody can administer.
The most powerful roles can’t be edited, and only the top administrators may change what a role can do. The rights that manage access, and the audit role, stay fixed (separation of duties).
Concurrent edits are detected. Two administrators editing one role never silently overwrite each other.

Three implementation choices are worth spelling out.

Every change needs a fresh confirmation of identity. The API decides when that is needed, never the screen; the console only asks for it and repeats the call.

A change of access ends the person’s sessions at once, and rights are re-read on every request, so there is no window where an old session carries old rights.

Races are tested on real connections. What happens if two administrators act on each other at the same moment? A test fires both changes at once against a real database and asserts that exactly one succeeds and an administrator is always left. This is the kind of test an agent writes well once you name the scenario, and almost never writes unprompted.

2.1 The audit trail, in a form an auditor can read

Every change writes one audit row in the same transaction, and a refused attempt is audited too, with its reason. A change to what a role may do writes one row per changed permission, with a compact before and after. Ids, role names and feature names only: never an email or any other personal data, because the audit trail is read by people who must not see personal data either.

2.2 What the screens do

On top of those rules the console got three things:

The principle behind all of this is in AGENTS.md §2.2: RBAC is enforced server-side, never UI-only. The UI only hides what the API would refuse anyway. If someone bypasses the console and calls the API directly, nothing changes.

3. A console that tells the truth about what it doesn’t know

A review of the console the day before had produced a list of small but telling problems, and one group of them was about honesty. The Home page showed a tile per data source: accounts, invitations, forms, recent audit entries. When a source couldn’t be read (because your role doesn’t include it, because forms authoring is switched off, or because the request failed), the tile showed 0, often with a little “↑” delta beside it.

A zero that means “I don’t know” is a lie. An auditor glancing at “0 failed sign-ins” draws a conclusion. So:

None of this is clever. It’s the difference between a console that is technically correct and one that people trust.

4. Contrast: fix it once, in the design system

The second theme of the day was accessibility, and specifically colour contrast.

The Caladrius design system is shared: the PHR app, the console and, later, other products all use the same tokens. An automated scan had found that the light-theme accent colour fell short of WCAG AA, which asks for a contrast ratio of at least 4.5:1 for normal text. The accent is everywhere: links, tabs, the active item in the side rail, primary buttons with white text.

There were two ways to fix it. Each app could override the colour, or the shared token could change. I chose the shared token: fix contrast in the design system, so every product that uses it passes, rather than letting each app drift its own way. The light accent moved one step darker in the same hue family (from sky-600 to sky-700, with hover on sky-800). The dark accent already passed and was left alone. On the shared sign-in page, the Login button and the “or continue with” label moved one step darker too.

The measurements, as the scan read them (computed text colour against its resolved background):

Element (light theme) Before After
White text on accent buttons 4.10 5.93
Accent text on white (links, tabs) 4.10 5.93
Accent text on the near-white surface 3.91 5.67
Accent text on the soft accent (active rail item) 3.84 5.57
Sign-in “Login”: white on teal 3.67 5.47
Sign-in “or continue with” 2.63 4.7

4.1 How we checked

The scan ran the PHR app at a phone size (390×844) in all five languages and both themes: 240 captures. Every hit below 4.5 disappeared. The only remaining flags were white text on the ABHA card’s gradient, which a script can’t measure; those were checked by eye.

The console was scanned at two desktop sizes. Two remaining failures there were console components (a status pill and a “Retire” button), fixed in the console’s own changes.

4.2 Contrast as a unit test

A scan proves today’s screens. It doesn’t stop tomorrow’s change from undoing the fix. So the design-system packages got contrast tests:

If someone, human or agent, changes a token back to a lighter shade, npm test fails in the tokens package. That is the pattern I keep coming back to on this project: a fix isn’t finished until a test makes it permanent.

4.3 An 11-pixel floor

Contrast wasn’t the only readability problem. Some shared composites (work-queue labels, the side rail’s section label, the ⌘K hint, a few small badges) had hard-coded 9 and 10 pixel text. They now use a text-2xs token whose floor is 11 px, whatever the person’s text-size setting.

That floor came from a related change the day before. I had asked for the PHR’s default text to be 10% smaller: “the 90% should become the new 100%”, with the ±10% steps kept. The root size is fluid (a clamp() on the viewport width), so the change is one line. The careful part was the people who had already chosen a size: their stored preference was migrated so almost nobody’s text changed size on upgrade; only the largest saved size became slightly smaller. A stored 90 became the new 100, and so on. When the smallest step pushed some labels to about 10 px, text-2xs got its floor, and the composites were moved onto it.

A drift pass the following day finished the job on the PHR app: a button and a chip that used white text on a status colour (which failed in dark mode) were moved to the right token pairs, and the touch targets under 44 px (links on the sign-in page, “See all” links, copy buttons beside the ABHA number, Cally’s Send button) were enlarged. Where a bigger target would have changed the row height, it was enlarged with a negative margin instead.

4.4 Recorded as an improvement to offer back

The design-system packages started as a copy from AI Studio, and their README keeps a table of every place they differ from upstream. Both contrast fixes and the 11 px floor went into that table, marked “(a) improvement, to offer back to AI Studio”. AI Studio wasn’t touched: the PHR doesn’t push anything there until it is verified, but the improvement is written down so it isn’t lost.

5. The rest of the day

Several other threads moved on Day 11, and most of them landed the following day.

6. The production-readiness review

The last document of the day may matter most. I gave an agent two checklists:

I asked for a review, not a build. The rules for the review were strict:

The result was a long table, and it was humbling in the useful way. Some items were genuinely done: secret scanning over the whole git history, validation on about 170 routes, a single error handler. Others were missing or partial in ways that mattered: there was no backup with a tested restore, the API connected to the database with more privilege than it needed, there was no idempotency key on our own writes, nothing paged anyone when something broke, and route protection was a convention, not a test. Sharding and read replicas were honestly marked “not needed yet”.

The review was a proposal. Each item would be built one at a time, approved before it started, and that’s what Day 12 is about. The first two, backups and least-privilege database roles, were started that same evening.

7. What I learned on Day 11

Next, Day 12 (11 November): the production-readiness review becomes code: encrypted backups and a restore drill, least-privilege database roles, idempotency keys, retries with jitter, circuit breakers, metrics, a load test — and Cally learns to listen and speak.

The team behind Day 11

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

Cally: taxonomy and intent (Giri)

Day 11’s Cally changes were small, but they set the frame Giri’s area works in. The installation default model became Claude Haiku 5.5, chosen as fast and inexpensive for a read-only assistant: the taxonomy starts from requests Cally can answer about the person’s own data, not actions it takes on their behalf. The model is changeable per installation in the console’s AI provider settings, so the intent framework can’t assume one vendor. Cally’s chat took its look from the design tokens, and its Send button grew to a 44 px target. The original voice files were copied verbatim before porting, which is groundwork for the day Cally hears a request instead of reading one.

Development, infrastructure and go-live (Krishna)

Only eight PRs merged, seven of them into dev, and much of the work on the infrastructure side, which Krishna leads, was about trust in the pipeline. Three tests had started failing on busy CI machines; each got a specific fix, and every test config got sensible timeouts. The race tests for role changes run on real PostgreSQL connections. The production-readiness review then named the go-live gaps plainly: no backup with a tested restore, more database privilege than the API needed, nothing that paged anyone, and route protection that was a convention rather than a test. Anything that lives only in a cloud console was marked “owner-only, unknown”, never “done”.

Narrative and personas (Preetha)

Two groups of people were served on Day 11. For administrators in the console, every refusal became a plain sentence, a tile that can’t be read shows a dash and the reason instead of a misleading zero, plurals are real, and the audit trail reads in words. For patients, text became easier to read: the default size moved 10% smaller while keeping almost everyone’s chosen size on upgrade, an 11 px floor was set, contrast was checked across five languages and both themes, and small touch targets grew to 44 px. In Preetha’s area of wording and tone, the support-issue form also asks people to confirm they haven’t pasted patient details.

Product and technology direction (Manish)

I made two choices that shape the platform. First, contrast is fixed in the shared design-system token, not per app, and kept fixed by a unit test, so every product that uses it passes. Second, I asked for a production-readiness review before any build, with honest statuses: “not needed yet” has to name its trigger, and “done” needs evidence. I also asked for the PHR’s text to be 10% smaller, on the condition that nobody’s chosen size changed. The review’s findings became one-at-a-time items, each approved before it starts.

Further reading

See all 16 parts