---
title: 'Day 11: Who May Do What, and Text You Can Read'
series: Building the Caladrius PHR with agents
part: 11
series_total: 15
date: '2026-11-28'
reading_time: 15 min
description: 'The morning after the biggest landing of the project: the rules for
  who may grant what in the new PHR Console, contrast fixed once in the design system,
  and a production-readiness review that set up the next two days.'
canonical_url: https://caladriushealth.ai/solutions/phr-build-diary/day-11-who-may-do-what-and-text-you-can-read/
publisher: Caladrius Health AI Studio
---

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

The morning after the biggest landing of the project: the rules for who may grant what in the new PHR Console, contrast fixed once in the design system, and a production-readiness review that set up the next two days.

*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](https://caladriushealth.ai/platform/brief/#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:

- A **PHR user** is a patient. They sign in through [ABDM](https://caladriushealth.ai/what-is-abdm/), with their ABHA, and see only their own records.
- An **application user** sets up and runs the PHR: they manage staff, write SDC forms, read the audit trail, configure
  the AI providers. They sign in to the console through the company's identity provider, with extra checks before
  sensitive actions, and there is an emergency route in, tightly controlled and alerted on every use.

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:

- **Users**: row actions to change roles and to suspend or reactivate, each behind a confirmation and step-up. The change-
  roles dialog shows every role, but the ones above your own rights are **disabled, not hidden**, so you can see why you
  can't grant them. No actions appear on your own row.
- **Roles**: *Edit permissions* on an editable role, a checkbox per feature and right. Protected roles show as
  read-only, with the contract's reason in a sentence.
- **Refusals in words.** Every refusal becomes a plain sentence. An administrator reading "You can't remove the last Platform Admin" knows what to do; one
  reading an error code opens a support ticket.

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:

- While a source loads, its tile shows a **skeleton**.
- When it can't be read, the tile shows a muted **dash and the reason**: not in your role, forms authoring is off, or
  could not load, with a retry.
- **Plurals** are real ("1 account", not "1 accounts").
- The **audit trail is in words**: action and resource labels ("Changed roles", "Staff user") with the recorded code as a
  tooltip, and the actor as a type badge with its id in the tooltip.
- A page you aren't allowed to see keeps its title and icon band and says so, instead of collapsing to an error.

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

- the light accent must reach 4.5:1 against its white foreground, and against every light surface it is drawn on;
- the dark accent's foreground must pass;
- the sign-in page must keep the darker teal and the darker label.

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](https://caladriushealth.ai/platform/brief/#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](https://caladriushealth.ai/platform/brief/#platform), 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.

- **Cally's default model.** The installation default became Anthropic's Claude Haiku 5.5: fast and inexpensive for a
  read-only assistant, and changeable per installation from the console's new AI providers settings.
- **Cally's chat, themed to the tokens.** Cally's chat window is built on CopilotKit's React UI. It now takes its colours,
  radii and type from the design tokens (styling only), so it looks like part of the app in both themes.
- **Support issues.** Staff can file a support issue from the console straight into our issue tracker. The person must
  confirm the issue holds no patient data, and the API also scans the text for things that look like it (identifier-
  shaped numbers, labelled personal fields, dates of birth). A hit is refused with the *kinds* found, never the text,
  and nothing is sent or stored. A support ticket is exactly where someone pastes a screen's worth of personal
  details.
- **Copy first, then adapt.** Before porting Cally's speech features and the support-issue code, the original AI Studio
  files were copied **verbatim** into `vendor/ai-studio/<commit>/`, with a manifest naming the commit and each file.
  The port happens in later commits, so every difference from the original is a visible diff in git. `vendor/` is never
  built or imported; a lint rule enforces that.
- **Slow runners, flaky tests.** Our CI machines were heavily loaded. Three tests started failing
  intermittently. One matched the status code 429 inside a random UUID. Another compared an expiry time against the
  test machine's clock instead of the database's own `now()`. The fixes were specific (match 429 as a whole token; anchor
  the assertion on the database's clock), plus a general one: a 20-second test timeout and a 30-second hook timeout in
  every vitest config. A flaky test is a bug report about the test, and you read it like one.

## 6. The production-readiness review

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

- **A. Production readiness**, ten items: no secrets in the repo, every route checks who and what, database rules on
  rows, server-side validation, rate limits on login and paid APIs, errors that leak nothing, dependency scanning,
  backups with a tested restore, logs and alerts, and spending caps.
- **B. System design**, twelve items: caching, queues, load balancing, read replicas, sharding, indexes, object storage
  and CDN, retries with backoff, rate limiting, circuit breakers, idempotency keys, and logs, metrics and tracing.

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

- **Static review only.** The agent read the code, migrations, workflows, compose files and runbooks, and cited a file and
  line for each claim. It didn't run a penetration test or a load test, or look at any cloud console.
- **Four statuses, honestly used.** *Done* only with evidence seen. *Partial* names the gap. *Missing* means nothing in
  the repo. *Not needed yet* names the trigger that would make it needed: for example, read replicas wait until a load
  test shows reads dominate.
- **Anything that lives only in a cloud console is "owner-only, unknown"**, never "done".
- Each item gets a class (S1, S2 or S3), a size, and the risk if it is left.

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

- **Write the refusals before the screen.** For anything that administers access, the list of things it must refuse
  is the specification. Each refusal got a code, a sentence and a test, and the UI fell out of that.
- **Fix shared problems in the shared layer.** Contrast fixed in the tokens fixes every product; contrast fixed per app
  drifts. The same goes for the 11 px floor.
- **Make a fix permanent with a test.** The contrast scan found the problem, and the unit test keeps it fixed.
- **A dash with a reason beats a zero.** A dashboard that shows "0" when it doesn't know is wrong in a way people act
  on.
- **Ask for a review before a build, with honest statuses.** "Not needed yet, and here is the trigger" is a better
  answer than building a read replica because the checklist mentioned one.

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

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

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