Applied AI-Accelerated Government Development

Build for Three Audiences

Updated

Intermediate

What you'll learn

~25 min
  • Design an executive, an operational and a technical tier for one feature from a single data fetch
  • Choose each role's default tier, and keep tier choice separate from what the role may read or do
  • Hide inactive tiers so assistive technology (screen readers and keyboard navigation) cannot reach them
  • Prove with tests that no tier shows a control its role cannot invoke

One page, three readers

The same fleet data serves three readers who ask different questions. A director wants three numbers and a trend. An operations manager wants a sortable table with action buttons. A technical administrator wants raw fields, audit columns and sync state. Role-tiered disclosure (showing each reader a level of detail suited to their role, from one page and one data fetch) serves all three without three routes to maintain.

The reference app’s component for this is DensityGate, and it is the reference implementation in this lesson. The pattern is the lesson; the component is small.

ProblemThe patternWhere your platform lesson lands itYou decide
Different readers need different detailThree tiers in one page, one data fetch; three routes each with its own permission check is the alternativeNothing platform-specific: the role arrives as session.roles, mapped to the closed role set in Lesson 5 from the provider’s raw role namesWhether one URL and one fetch is worth the shared-component complexity
Which tier a user starts inA default by role, switchable; a tier fixed by role is the alternativeNothing platform-specificWhether a tier is a preference or a boundary
What a tier may showOnly controls the role can invoke; disabled controls with an explanation is the alternativeNothing platform-specificWhether a disabled control helps or only tempts
How inactive tiers are hiddenNot rendered, panel marked hidden; CSS-hidden but mounted keeps state at an accessibility costNothing platform-specific; the role-by-tier contract test runs in the pipeline 37 lands on your code hostWhether kept state is worth the accessibility cost

Plan the change with your agent

Open your workspace agent at the project root, switch to Plan mode (Shift+Tab, /plan, or the desktop app’s mode picker), and ask:

Read our vehicle-fleet page and role helpers, and plan a three-tier view switcher (Executive, Operational, Technical) from a single data fetch that hides inactive tiers from assistive technology. Ask me anything unclear.

What to check in the plan before you approve

  • src/components/DensityGate.tsx implements the WAI-ARIA tabs pattern (tablist, tab, tabpanel, aria-selected, aria-controls, aria-labelledby, arrow keys, Home, and End), omits inactive panel children, and sets the hidden attribute on inactive tabpanel elements.
  • All three tiers read from one useVehicleFleet() call: Executive renders KPI cards and a status breakdown (excluding sample and ai_drafted rows) with no table or action buttons; Operational renders the DataGrid and gates action buttons with canInvoke(role, "vehicle-fleet", action); Technical shows data_source, audit columns, and a JSON detail panel.
  • The server page resolves the caller’s role with requireSession() and passes it as a prop, while defaultTierFor(role) starts viewer and manager in Executive, operator in Operational, and admin and superadmin in Technical.

If the first plan hides inactive tabs with CSS display: none while leaving them mounted, push back before approving:

Do not hide inactive tiers with CSS alone; omit their children and set the hidden attribute on inactive tabpanels.

What you get

SESSION Three tiers: plan, build, then check the contract
  1. Typed in the terminal: claude
  2. Mode:Plan mode
  3. You type in the session: Read our vehicle-fleet page and role helpers, and plan a three-tier view switcher (Executive, Operational, Technical) from a single data fetch that hides inactive tiers from assistive technology. Ask me anything unclear.
  4. The tool replies: Proposed plan: 1. src/components/DensityGate.tsx: client tab switcher for Executive, Operational, and Technical views with WAI-ARIA tab roles and keyboard navigation. 2. Server page resolves the role via requireSession() and passes defaultTierFor(role). 3. Single useVehicleFleet() fetch feeding all three tiers, with Operational buttons gated by canInvoke(). Should inactive tab panels stay mounted in the DOM for state preservation, or should we unmount inactive children and mark their panels hidden?
  5. You type in the session: Do not hide inactive tiers with CSS alone; omit their children and set the hidden attribute on inactive tabpanels. Build it.
  6. The tool replies: Created DensityGate.tsx and updated the page. - Tabs follow the WAI-ARIA pattern; arrow keys move, Home and End jump. - Only the active panel is rendered. Inactive panels, if present, have the hidden attribute. - defaultTierFor maps viewer and manager to Executive, operator to Operational, admin and superadmin to Technical. - The server page resolves the role with requireSession() and passes it down. - The Operational tier's Add, Edit and Delete buttons render through canInvoke; a viewer who opens the Operational tab sees the grid with no action buttons. One decision for you: the Technical tier shows data_source and audit columns. I assumed the API already returns those fields to every role that may read the feature. If some roles must not see them, the API has to omit them; I will not hide them in the browser.
  7. You type in the session: Can a viewer reach the Delete button by editing the page in dev tools?
  8. The tool replies: They can make the button appear, but the request it sends is checked by the route handler against the session and role, so it fails with a 403. The button logic exists so that nobody is offered an action that will be refused. It is not the control that stops them. That is why I did not write a role check into the component and call it done: the handler check from Lesson 5 stays the authority.
  9. You type in the session: A keyboard user tabs through the page in the Executive tier. What do they reach?
  10. The tool replies: The tab list, then the Executive panel's content. Nothing from the Operational or Technical tiers, because those panels are not rendered. In my first version I used display none with the panels mounted, which also removes them from the tab order; I switched to not rendering anyway because a later CSS change, a print stylesheet, or a visibility override could expose the content to focus. The test asserts there are zero focusable elements in any hidden panel.
  11. You type in the session: Write the contract tests for the role by tier matrix.
  12. The tool replies: Created DensityGate.test.tsx. For every role and every tier it renders the page with fixture data, collects the buttons and links, and asserts each one maps to an action canInvoke allows for that role. A second test renders each non-active tier and asserts there are no focusable elements inside any hidden panel. I added a deliberately broken Delete button for viewer, saw the first test fail naming role, tier and control, and removed it.

Illustrative session; exact output varies by tool and agency configuration.


What goes in each tier

Executive: the ten-second view. KPI cards, one trend or breakdown, and an alert if a threshold is crossed. No tables, no forms, no buttons. If the reader has to click to get their answer, the tier is not finished. Compute the numbers from the same data the table uses, and exclude sample and ai_drafted rows so a number never counts values nobody observed (Lesson 10).

Operational: the working view. The grid with filters, inline edits, and the add, edit and delete actions from Lesson 9. Minimize clicks to the common action. Every action control is gated by the role.

Technical: the diagnostic view. Every column, including data_source and the audit columns, a raw JSON panel for a selected row, a count by source, and sync status. When someone insists a record was entered by hand and the column says sync, this tier settles it.

💬Density is curation, not omission

The executive tier is harder to design than the technical one. Three numbers that truthfully summarize a system take more thought than showing all the columns.


Tier choice is not authorization

The reference app lets any role switch to any tier, so an operator can open the technical tier to read a timestamp without asking an administrator. That is a legitimate decision because the data is already loaded, and it is safe only if the API returned nothing the role may not read.

If your agency treats the technical tier as restricted, do not remove the tab and call it done. Change the API so a role without that right never receives the fields, and fix the default and the tab list to match. A hidden tab over a response that still contains the data hides nothing from a person with a browser’s network panel.

This reference excerpt from src/components/DensityGate.tsx shows the shape of the gate your agent builds:

// src/components/DensityGate.tsx (excerpt)
const TIERS = ["executive", "operational", "technical"] as const;
export type Tier = (typeof TIERS)[number];
export function defaultTierFor(role: string): Tier {
if (role === "operator") return "operational";
if (role === "admin" || role === "superadmin") return "technical";
return "executive"; // viewer, manager, and any unknown role fails to the least detail
}
// Inside the component:
<div role="tabpanel" id={`panel-${tier}`} aria-labelledby={`tab-${tier}`} hidden={active !== tier}>
{active === tier ? slots[tier] : null}
</div>

An unknown role falls to the executive tier, which holds the least detail, the same fail-closed habit as the default-deny rule in Lesson 5.

The accessibility side of the same component, including the full tab keyboard pattern and a screen-reader pass, is in Lesson 14: Accessibility: Section 508 and Title II.


Prove it

The contract has two halves, and each gets a test you can run.

REFERENCE TEST src/components/DensityGate.test.tsx: role-by-tier control and hidden-tabpanel contract tests open reference hide reference Reference pattern for your workspace agent; open to inspect or compare this file. You do not type or paste this by hand.
// src/components/DensityGate.test.tsx (sketch)
import { describe, it, expect } from "vitest";
import { renderToStaticMarkup } from "react-dom/server";
import { ROLES, TIERS, renderPage, actionOf, canInvoke } from "./test-support";
describe("no tier shows a control the role cannot invoke", () => {
for (const role of ROLES) {
for (const tier of TIERS) {
it(`${role} in ${tier}`, () => {
const html = renderToStaticMarkup(renderPage(role, tier));
for (const control of actionOf(html)) {
expect(canInvoke(role, "vehicle-fleet", control.action)).toBe(true);
}
});
}
}
});
it("hidden tiers contain nothing focusable", () => {
const html = renderToStaticMarkup(renderPage("admin", "executive"));
const hiddenPanels = [...html.matchAll(/<div[^>]*role="tabpanel"[^>]*hidden[^>]*>([\s\S]*?)<\/div>/g)];
for (const [, inner] of hiddenPanels) {
expect(inner).not.toMatch(/<(button|a|input|select|textarea)\b|tabindex=/);
}
});

Treat the helpers (ROLES, renderPage, actionOf) as yours to write; the AI can generate them from the matrix in Lesson 5. The negative cases: render a Delete button for the viewer role and watch the first test name the role, tier and control; remove hidden from one panel and watch the second fail. A browser-level accessibility scan is in Lesson 14.


KNOWLEDGE CHECK

The operational tier hides the Delete button from viewers with CSS display none, but the button is still in the DOM. What is wrong?

KNOWLEDGE CHECK

A hidden tier is kept mounted and hidden with a class that sets visibility to hidden. A keyboard user is on the executive tier. What should you verify?


Key takeaway

Give each audience its own level of detail from one fetch, show a role only controls it can use, make hidden tiers truly hidden, and let the server decide what any role may read. Next, Lane 3 tests all of this, beginning with server logic in Lesson 12.

LEADERSHIP DECISION
Which roles may see which tier of an intake record, and that the server, not the page, enforces it.
PRACTITIONER ACTION
Add a test that a viewer's response body for a hidden tier contains none of that tier's fields.
SUCCESS MEASURE
Audit finding avoided: no hidden field appears in a response a reviewer captures for a role that should not see it.

Legend: LEADERSHIP DECISION = what a leader decides · PRACTITIONER ACTION = what the engineer does next · SUCCESS MEASURE = how you know, in calendar time, assessor-hours or cost, contract or revenue risk, or audit finding avoided

Search lessons