Repository navigation
Production polish : lifecycle bar, denser pages, reliability sweep and deployment basics - #185
frousselet wants to merge 25 commits into
Conversation
…t queries A page of fifty rows issued hundreds of queries, because three things were read one row or one option at a time : - the tags printed on every row : SortableListMixin now prefetches `tags` for every list whose model carries them; - the ancestors of each scope in a scope cell : the scope tree is read once per request and shared by every cell (context/templatetags/scope_tags.py); - the relation options of the advanced filter : the registry was built twice per request (queryset filter, then page context) and labelled each option with str(record), which often reads a parent. It is now built once and the mandatory parents of the listed records are joined. The role list also prefetches its assigned users, and the nonconformity register its requirements. Measured on the demo dataset : users 416 -> 14 queries, requirements 79 -> 16, action plans 78 -> 22, risk register 71 -> 17, roles 114 -> 18, nonconformities 103 -> 16, issues 102 -> 18. core/tests/test_list_queries.py compares the cost of a short and a longer list, so it fails on any per-row query rather than on a hand-tuned ceiling. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FaEkJkxoxKbGMSYquC2dwV
…ility sweep A crawl of every page as a superuser and as a plain member, plus an empty and an invalid submission of every form, surfaced these : - The dashboard raised TypeError for every non-superuser whose group allows all scopes : `get_allowed_scope_ids()` returns None for "no restriction" and the ongoing-audits query filtered on it. It now goes through `filter_queryset_by_scopes` like the other scoped queries. - The nonconformity register form crashed on submission with the Audit source : `Finding.clean()` reports the missing audit on a field the form does not carry, which Django turns into a ValueError. The form no longer offers that source without an audit (RG-FND-01), and SteppedFormMixin now reports any model rule about a field outside the form as a form-level error instead of failing. - Every cache call raised when Redis was unreachable (update check, assistant briefing, Trust Center rate limiter). `core.cache.ResilientRedisCache` degrades to a miss, logs the outage once a minute, and gets 2 s socket timeouts so a silent Redis cannot hold each request. - `core.settings_local` (Docker-less development) still pointed the cache at Redis; it now uses the local-memory backend. And one that no crawl could show : the lifecycle definitions edited in the administration are cached per worker process and were only invalidated in the worker that saved them, while the image runs three. The other two kept enforcing the previous lifecycle until a restart. Each worker now revalidates its cache against the table's stamp at most every LIFECYCLE_CACHE_TTL seconds (5 by default, one aggregate query). Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FaEkJkxoxKbGMSYquC2dwV
The interface spent its first screen on air and on a diagram. On a laptop a
detail page showed 130 px of empty space, a title on two lines at 40 px, a
full-width lifecycle graph clipped on its right edge, then a band of tall
key-figure cards : the content started at the bottom of the window. On a
phone the graph alone ran over three screens.
Lifecycle. Every detail page now renders the lifecycle bar : one line with the
steps of the path the record is on (completed, the current one as its status
badge, the steps ahead), a button for each step the user may move to, the
exits apart on the right and a toggle that opens the full directed graph
underneath, drawn on first opening only.
- The path is read from the schema instead of the declaration order : a step
is completed when the current step is reachable from it along forward
transitions, so a branch that was not taken is left off the bar instead of
being ticked.
- A move is a button named after its transition ("Validate", not
"Validated"), highlighted when forward, quiet for a way back or an exit.
- A lifecycle longer than six steps folds its completed steps to their tick;
a line still too long scrolls inside the bar, starting at the current step.
- The legacy line / cycle / snake renderers and their CSS are removed; the
dagre graph stays as the on-demand view and in the lifecycle editor.
Density. One vertical cadence (1.5rem between blocks, 1rem under the header),
the page starting 1.75rem from the top. The page title steps from 2.5rem to
2rem, and a record name (over 32 characters) to 1.5rem; it takes the free
width and wraps inside it, so the actions stay on its right. The detail rail
becomes a slim strip of key figures below 1800 px, two per line on a phone,
and the list key figures tighten the same way. The brand guidelines carry the
new scale and the cadence.
Lists. A table wider than its card spilled under the page edge, where
`overflow-x: clip` hid its last columns with no way to reach them (the
controls and risk registers at 1440 px). It now scrolls inside the card, with
an edge shadow where columns remain.
Sidebar. Group toggles and links share one size, weight, spacing and hover.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FaEkJkxoxKbGMSYquC2dwV
…g basemap What a deployment could not rely on until now. Health. `GET /health/` answers 200 or 503 depending on whether the process can reach the database. It is a middleware placed first in the stack, so a probe calling by IP with no session is not refused by ALLOWED_HOSTS nor redirected to the sign-in or onboarding screen, and it discloses nothing. The image declares it as its HEALTHCHECK. There was no health endpoint before. Error pages. A missing page, a refused permission, an expired form and an unhandled error rendered Django's bare text pages. They now render in the product's design and in the reader's language, from self-contained templates (no query, no static lookup) so the 500 page survives a database outage. Logging. Django only logs to the console under DEBUG : in production an unhandled error left no traceback anywhere, only a 500 line in the access log. Everything now goes to stderr at LOG_LEVEL, request errors included. Secret key. With DEBUG off, the settings refuse to load while SECRET_KEY is one of the two public placeholders (the settings default and the .env.example value), instead of signing sessions with a key anyone can read. Maps. The scope, site and supplier pages drew CARTO basemap tiles, and CARTO now answers every anonymous request with an "API key required" watermark : the maps were broken for everyone. The provider is now a deployment setting (MAP_TILE_URL, MAP_TILE_URL_DARK, MAP_TILE_ATTRIBUTION), defaulting to OpenStreetMap's tile service, with an empty value switching the maps off. The three copies of the tile code become one helper in base.html, the tiles are desaturated to stay a backdrop, and dimmed under the dark theme when the deployment has no dark tiles. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FaEkJkxoxKbGMSYquC2dwV
…ser pages The 35 images are retaken at 2560x1440 with scripts/capture_screenshots.py on the demo dataset. Detail pages now show the lifecycle bar instead of the graph, pages start near the top of the window, and the supplier page shows an actual map where the previous capture had the tile provider's watermark. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FaEkJkxoxKbGMSYquC2dwV
…whole interface Two blind spots of the test suite, both documented as accepted until now. The fast run builds an in-memory SQLite schema from the models, with migrations switched off. Nothing replayed the 150 migrations a deployment runs, nothing met the engine it runs on, and nothing noticed a model changed without its migration. `core.settings_test_postgres` keeps the fast settings but uses PostgreSQL and real migrations; CI runs the whole suite a second time with it, after `makemigrations --check`. The suite passes on PostgreSQL 16 as it stands : this guards what comes next. Unit tests check what their author thought of. `core/tests/test_site_sweep.py` checks the rest on the demo dataset : it follows every link from the dashboard as a superuser, requests the same pages as an administrator who is not a superuser and as a user with no permission, then submits every create and edit form empty and with invalid values. No page may answer a server error, no printed link may be broken. It is the manual sweep that found four server errors last week, made permanent, and it was checked against the dashboard bug reintroduced on purpose. It is also the first test that executes the demo seed, so a schema change that leaves the seed behind now fails. The sweep is marked `sweep` and takes about 40 s on SQLite. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FaEkJkxoxKbGMSYquC2dwV
…rvice majors The container ran as root, the settings defaulted to DEBUG, and the compose file followed `latest` for the database. Account. The image gains a `cairn` account (uid 1000) that owns /app. The entrypoint starts as root for one job, handing /app/media and /app/staticfiles over when they are still root-owned (a media volume written by an earlier image), then restarts itself with setpriv : no web worker holds root. The account is the owner of /app, so the development bind-mount keeps generated files in the host user's name. Started with `--user`, the container runs as given. Verified on a built image : every process runs as uid 1000, a root-owned volume is handed over and writable, the healthcheck turns healthy. DEBUG. Off unless set. An instance started with no configuration served tracebacks, settings and local variables to whoever triggered an error. `.env.example` and `core.settings_local` turn it on for development; the test settings and CI bring a key of their own, since the settings refuse the placeholder key outside DEBUG. Versions. `postgres:18` and `redis:8-alpine` : the majors in use today, minor and patch releases still flowing in. A new PostgreSQL major cannot read the previous data directory; on `latest`, a routine `docker compose pull` would one day stop the database from starting. The CI PostgreSQL job runs on 18. Documentation. The published-image example had no volume for uploaded files, which lived in the container and were lost on every recreation; it now has one. It also carried a placeholder SECRET_KEY and PostgreSQL 16 with the pre-18 data mount. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FaEkJkxoxKbGMSYquC2dwV
…ree suite The suite printed 1 246 warnings. Two families were defects. Pagination. Fourteen API lists were paginated over an unordered queryset : the database is free to return such rows in a different order on each request, so a page could repeat a record and another record never be listed. The same holds for any `?ordering=` with ties. `StandardPagination` now gives every list a total order before cutting it : oldest first when the queryset has no order, and the primary key appended as the final tie-breaker in all cases. Querysets that are not plain model lists are left alone. Dates. The `date_after` / `date_before` filters of the risks API compared a date-time column with a bare date, read as midnight : `date_before` left out everything created on the day given. They now compare calendar days in the active time zone. The rest was noise, now gone : thirteen factories whose hooks only set relations stop asking for a second save (ObjectiveFactory keeps it, explicitly, because its model checks scopes on save), a channel-layer mock becomes an AsyncMock, and pytest-asyncio gets its loop scope. `pytest.ini` turns the two defect families into errors so they cannot come back, and silences the Django 6.1 `EMAIL_*` deprecation with its reason. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FaEkJkxoxKbGMSYquC2dwV
Progress : safety nets (three commits)
Verification : 3 720 tests pass on SQLite and on PostgreSQL 18, Checklist items covered : tests, For the reviewer
|
Since the version pins were removed, every install took the latest release of everything. The documentation said Django 5.2 LTS; the instance ran Django 6.1, on an image that had moved to Python 3.15 while CI tested on 3.12, an interpreter Django 5.2 does not support. No two builds of the same commit were guaranteed to run the same code. - `requirements.txt` holds the direct dependencies and constrains Django to the current LTS line (5.2.x, supported until April 2028). - `requirements.lock` is the exact set resolved from it, hash-checked, valid from Python 3.12 up. The image, CI and the bootstrap script install it. - The image, the workflows and `mise.toml` name one Python : 3.14, the newest the LTS line supports. - Tests fail if a direct dependency is missing from the lock, if the lock leaves the 5.2 line, or if the suite runs on another Django than the locked one. Going back from 6.1 to 5.2.19 was verified before being written : the 3 720 tests pass on SQLite and on PostgreSQL 18 with all 170 migrations replayed (97 of them generated under Django 6.x), under Python 3.12 and 3.14, and inside the built image. The framework's own migrations are identical on both lines, so a database migrated under 6.1 needs nothing. One behaviour is kept explicitly : a URL typed without a scheme still gets https (FORMS_URLFIELD_ASSUME_HTTPS). Found while running the suite inside the image : `.dockerignore` left out every Markdown file, CHANGELOG.md included, which the dashboard's "what's new" dialog reads. It never appeared on a published image. CHANGELOG.md, README.md and LICENSE are back in. The generated model reference counted fields with a test whose answer depends on the Django version; it now counts the table's columns. CI. The PostgreSQL job takes about twelve minutes on a hosted runner. It now runs on every push to `main`, and on a pull request only with the `ci:postgres` label or a manual run of the workflow. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FaEkJkxoxKbGMSYquC2dwV
Progress : dependencies locked on the LTS line (
|
…at empty means
Detail pages were long for reasons that had nothing to do with their record.
Measured on the demo dataset, card by card, then fixed at the framework level
so every page benefits.
- Traceability was a 270 px card closing every detail page. `record_card` now
renders it as one line of small print : same data, same place.
- An empty section took 180 to 220 px to say "nothing yet". An empty state
inside a section card is now always one line under the title.
- `section_card` gains `clamp=True` : with a count, a long table (or a
`data-clamp-items` list) shows its first eight rows behind a "Show all n"
button. Applied to a framework's requirements, a risk assessment's analyses
and risks, and an incident's chronology. A link to a hidden row opens the
card first.
- An audit folds its requirements by section (foldable table groups). Past
fifteen rows the sections start folded except the first with work left; what
the reader opened is kept for the session, so the HTMX refresh after each
evaluation comes back as it was.
- A page with six sections or more gets a "Jump to a section" menu in its
header, built from the cards it renders.
- Card padding goes from 2rem / 1.75rem to 1.5rem / 1.25rem.
Heights at 1440 px : framework 7 939 -> 2 781, audit 6 351 -> 3 223, risk
assessment 5 896 -> 3 529, incident 6 024 -> 4 991, risk 3 307 -> 2 736.
Forms. Every empty select opened on Django's row of dashes : a required one
now reads "Choose…", an optional one "None", through the one field partial all
forms render with (39 form pages, now none, and the sweep checks it). On a
phone the step indicator gives its room to the current step's label instead
of cutting three labels to their first letters.
Found on the way : two developer notes written as multi-line `{# #}` comments,
which Django does not treat as comments, were printed in the page (management
review, incident obligations). Fixed, and a test forbids the form.
Dropdown menus use the near-opaque glass, so their items read without relying
on the backdrop blur.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FaEkJkxoxKbGMSYquC2dwV
…ry, fewer queries Consistency. - The table standard renders a reference as the clickable `.ref` pill. Eight lists added since (incidents, events, notifications, response plans, controls, tests, documents, campaigns) used a plain link, so a reference looked like one thing in the risk register and another in the next list. A test now forbids the plain-link form. - Tags shown above a record's cards (supplier, site, contract, certificate) were centred between the lifecycle bar and the key figures; they align with the content. - A framework listed its requirements in lexicographic order, which the new "first rows" view made obvious (A.5.10 right after A.5.1). It uses the natural order of the numbers, like the requirements list. Dashboard. - Without a written briefing (assistant off, or the model did not answer) the summary is one sentence, and the column it had to itself stood empty beside the links and the audits. It heads the card and the links take the width. - Indicator widgets ordered and sliced their measurements in the database, discarding the prefetch the dashboard had just done : one query per indicator. Risk acceptances were titled with a query per row. Tag list : usage was counted relation by relation for each tag (396 queries for the demo dataset). It is one grouped query per tagged model, whatever the number of tags (71). Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FaEkJkxoxKbGMSYquC2dwV
The criteria snapshot of a risk keeps its capture time as an ISO 8601 string in its JSON, and the risk and ISO 27005 analysis pages printed it raw (`2026-11-04T10:44:38.610034+00:00`). The new `iso_datetime` filter renders such a value like every other date-time, in the active locale and time zone. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FaEkJkxoxKbGMSYquC2dwV
Retaken at 2560x1440 with scripts/capture_screenshots.py : the traceability line, the section menu, the clamped lists and the reference pills of the incident and controls registers. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FaEkJkxoxKbGMSYquC2dwV
Progress : shorter screens (four commits)
Found on the way : two multi-line Verification : 3 740 tests pass locally, Checklist items covered : tests, |
Locking the dependencies stopped updates from arriving on their own, security releases included. Dependabot now proposes them, one pull request a week per ecosystem : the Python lock, the patch releases of the image's Python, and the GitHub Actions. The lock is renamed so that Dependabot, and GitHub's vulnerability alerts, can read it. Both only recognise the pip-compile convention : `requirements.in` holds the direct dependencies, `requirements.txt` the compiled set with its hashes. Under its previous name (`requirements.lock`) the pinned versions were invisible to both, and the alerts enabled on the repository had no version to match an advisory against. The file is compiled with pip-compile rather than uv for the same reason : it is the format Dependabot knows how to recompile. Same 84 pins as before on CPython; the image builds from it and the suite passes. The configuration leaves the project's decisions alone : Django above the 5.2 LTS line is ignored, and so are minor and major releases of the image's Python. Python and image updates carry the `ci:postgres` label, so the suite also runs on PostgreSQL with the migrations replayed. A test keeps those three rules in place. Not verifiable before it reaches the default branch : Dependabot only reads its configuration there. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FaEkJkxoxKbGMSYquC2dwV
Progress : Dependabot (
|
`timezone.now().date()` is the UTC date. In Europe/Paris that is the previous day for the first hour or two of every local day, and seventeen places used it (or `date.today()`, the container's date) as "today". During that window : - an action plan due the day before was not overdue yet, and a plan completed then was dated a day early; - a contract, a certificate or a supplier contract ending that day had not expired, and an end-of-life asset was still in service; - a document reviewed then had its next review computed from the day before; - the overdue filters of the REST API, an MCP tool, the dashboard and the calendar feed counted from the wrong day. They all use `timezone.localdate()` now, and a stored review time is converted to local time before its day is taken. The demo seed and the tests take the same day : seventy-six test expectations were written against the UTC date or the machine's own, which made them agree with the defect, and would have made them fail on a UTC runner for part of every evening once the code was right. It surfaced because a document test ran a few minutes after midnight. The new tests pin the clock to 00:30 Paris time instead of waiting for it, and one scans the application code for the two spellings. The whole suite passes inside that window. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FaEkJkxoxKbGMSYquC2dwV
… apart
The menu had eight sections, sixteen folding groups inside them and about
fifty entries : three levels, two clicks to reach most pages, set-up screens
mixed with the registers people work in, and the same word for two things
("Documents" for the contracts and for the policies). It was also written by
hand twice : as markup in base.html, and as a table for the breadcrumbs.
`core.navigation.MENU` now declares it once. The sidebar (`{% sidebar_menu %}`)
and the breadcrumbs (`NAV_TREE`) are both derived from it.
- Two levels. Seven sections that open on their pages, under the three
everyday links. No group inside a section, and no heading above one.
- Reference data has its own section : asset groups, supplier types, risk
criteria, threats, vulnerabilities, requirement mappings, reporting
authorities and obligation templates. The last two had pages but no menu
entry at all.
- Controls, their tests, policies and acknowledgement campaigns join
Compliance instead of being two sections of two and three entries.
- Indicators and Dependencies are one entry each. Their lists are views of
one subject : each list page gets a row of links to the others under its
header, limited to the views the reader may open.
- An entry is shown to the users its page lets in. The permission is read
from the list view itself, so the menu cannot drift from what the page
enforces. Until now most entries were shown to everyone and bounced back to
the dashboard with an error.
- The current entry is found by the longest matching URL, so it stays marked
on the records of its register (nothing was marked on a detail page), and
its section carries a mark of its own when folded or in the icon rail.
Page addresses do not change. Breadcrumbs lose a level : Governance > Scopes.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FaEkJkxoxKbGMSYquC2dwV
Retaken at 2560x1440 with scripts/capture_screenshots.py : every screen shows the sidebar, so every image changes. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FaEkJkxoxKbGMSYquC2dwV
Progress : navigation, and a date bug found on the way (three commits)
Page addresses do not change.
Verification : 3 760 tests pass, including the interface sweep on the new menu; Checklist items covered : tests, |
Progress : accessibility (two commits)
Found on the way : on a phone, the rows of the dashboard's progress-bar tiles collapsed onto each other; the framework tile read "90 requirement".
Verification : 3 829 tests pass; Not covered, said plainly : the manual sort order of a progress-bar tile and the tasks board are still drag-only (the board's moves can be made from each record's page); modal titles are Checklist items covered : tests, |
…e checks that hold it The guidelines claimed WCAG 2.2 AA; an axe-core audit of the rendered pages said otherwise. In the light theme the muted grey (#A1A1AA, 2.6:1) carried table headers, labels and sub-lines, and every status badge was under 4.5:1. In the dark theme every link was navy on charcoal (2.7:1). Fourteen Edit buttons could not be reached from the keyboard. Contrast - `--text-muted` is the lightest grey that carries text (5.3:1 light, 5.1:1 dark); lighter greys are for borders. - A colour has a fill and an ink. The fill (`--accent`, `--success`...) stays for dots, bars and buttons; text uses the ink (`--accent-text`, `--success-text`...), which clears 4.5:1 on the surfaces and on its own soft background. 175 text uses moved to the ink tokens. - The calendar draws an event as a tint and a rule in its category colour with the title in the text colour : half of its twelve hues could not carry white text. - A colour typed by an administrator stays readable (`core/colors.py`) : the company accent gets an ink per theme and a label that reads on it; the Trust Center banner deepens the accent until its white text reads, and its links were unreadable on the dark theme. - Placeholders lose their transparency; the focus ring is one neutral token at 3:1 or more, replacing pale halos. Keyboard and screen readers - A skip link, named landmarks, card titles as h2 on the dashboard. - Acting links keep an href beside their hx-get; a day with events in the calendar's year view is a button; dashboard tiles get Move earlier / Move later buttons, the keyboard's equivalent of the drag. - Controls are named : filter panel fields, grid formsets (`LabelledRowsFormSet`), the mobile menu button, calendar arrows, progress bars. A dialog filled over HTMX is named after its title, the native select Tom Select replaces leaves the screen reader's tree, and a table that scrolls sideways becomes a focus stop. - A collapsible card renders its actions beside the summary, not inside it. Checks - `core/tests/test_contrast.py` recomputes every text / surface ratio from the tokens, in both themes, and refuses a fill token used as text. - The interface sweep parses every page (`markup_audit`) for an image without alt, a control without a name, a link without href, a field without a label. It found 113 defects in closed panels a browser audit skips. - `scripts/a11y_audit.py` runs axe-core on 92 renderings : the screenshot set in both themes, an open dialog and filter panel, four pages at a phone's width. A new CI job seeds a demo instance and runs it on every push. Found on the way : on a phone the rows of the dashboard's progress-bar tiles collapsed onto each other (the stacked rule lost to a later one of equal specificity), and the framework tile read "90 requirement". The audit instance is a throwaway SQLite file (`SQLITE_PATH`) whose schema is built from the models (`SCHEMA_FROM_MODELS`) : replaying every migration on SQLite took nine of the job's thirteen minutes. The reference rows the data migrations write come from `accounts.reference_data`, which the test suite's fixture now shares. A page that does not render fails the audit. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FaEkJkxoxKbGMSYquC2dwV
Retaken at 2560x1440 from a freshly seeded demo instance : the muted text, the status badges and the calendar change on every screen. The capture script now emulates the light theme (`--theme`, light by default). Headless Chrome follows the machine's theme, so the set came out dark on a machine set to dark mode. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FaEkJkxoxKbGMSYquC2dwV
71c258b to
feabc13
Compare
The action log merges the history table of every audited model (88 of them). It did so by loading every row of every table and sorting them in Python on each visit, then handing the list to the paginator : the cost of opening the page was the size of the audit trail, which only grows. `MergedHistory` is a lazy sequence the paginator slices. A page costs one UNION ALL over the tables for its keys (ordered and limited by the database, which walks each table's history_date index), one query per table present on the page for the rows, and one count. Rows saved at the same instant are ordered by table and id, so a row cannot land on two pages or on none. A row was also classified (creation, update, transition, deletion) with one query for its previous version. The rows now come with the previous lifecycle state attached by a subquery; `entry_kind` gives the same answer as `classify_record`, checked on 1 250 rows of the demo dataset. On the demo dataset the page goes from 170 queries to 48, the remainder being the related records each row names. The site list also prefetches its tags. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FaEkJkxoxKbGMSYquC2dwV
The documented backup was two shell lines (pg_dump, tar) and the sentence "test the restore". Nothing checked that the two halves belonged together, that the archive was readable, or that a restore worked. `manage.py backup` writes the database and MEDIA_ROOT into one tar archive with a manifest : format, Cairn version, engine and server version, applied migrations, size and SHA-256 of every member. It reads the archive back and verifies it before reporting success. `--keep N` rotates. `manage.py restore` puts an instance back in the exact state of an archive : - every member is verified against the manifest first; - an archive made by a newer release is refused (its schema has migrations this code does not know); an older one reports what is left to migrate; - the current state is saved beside the archive before anything is replaced; - the dump is loaded into a new database that then takes the name of the current one, so a dump that fails to load leaves the current database as it was; the application's sessions are closed for the swap; - the media directory is replaced by the archive's files, extracted beside the live ones first. `--check` verifies and changes nothing. The first design reloaded in place, inside one transaction. Tried on a real instance (412 tables), it exhausted the server's lock table : dropping and recreating a few hundred tables in a single transaction needs more locks than max_locks_per_transaction allows by default. It failed cleanly, which is how the load-beside-then-swap design came about. The client tools must be of the server's major (pg_dump refuses a newer server, a newer pg_restore writes statements an older server rejects) : the commands check it, the image now ships postgresql-client-18, and a test keeps the Dockerfile, the compose file and the CI job on the same major. Tested end to end on SQLite in the default suite (a throwaway instance is backed up, damaged, restored and compared), and on PostgreSQL in the CI job : exact restore, repeated restore, a truncated dump, a restore while a session is open, a role without CREATEDB. Verified by hand in the image on the demo dataset : 7 555 records, 412 tables and 6 files identical after the restore. MEDIA_ROOT and BACKUP_DIR are settable from the environment. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FaEkJkxoxKbGMSYquC2dwV
Progress : operations and front-end hardening (three commits)
Verification : 3 889 tests pass; Not applicable to these commits : MCP tools and REST endpoints (backup and restore are operator commands; exposing a restore over an API would be a risk, not a feature). Checklist items covered : tests, |
Progress : the permission matrix
Also : a table that scrolls sideways is named after its section; the user chip follows the accent's contrast colour; the browser audit visits a group's page. Verification : 3 892 tests pass; Checklist items covered : tests, |
…'s own scripts
Pages were served with no Content Security Policy : a script that reached a
page (a field that escaped sanitising, a tampered record) ran with the user's
session. Every response now carries one (`core/csp.py`) :
default-src 'self'; script-src 'self' 'nonce-<random>';
style-src 'self' 'unsafe-inline'; img-src 'self' data: blob: <tiles>;
connect-src 'self' ws(s)://<host> <geocoder>; object-src 'none';
base-uri 'self'; form-action 'self'; frame-ancestors 'none'
A script runs when it is one of the instance's static files or carries the
nonce of its response. No 'unsafe-inline', no 'unsafe-eval'. To get there :
- The 71 inline scripts carry `nonce="{% csp_nonce %}"`. It is a tag, not a
context variable : a form widget and an inclusion tag are rendered with a
context of their own, where a variable would be empty and the script
refused (the scope picker on a full-page form, the help dialog). The tag
reads the request being answered. htmx gives the scripts of a swapped
fragment the page's nonce and evaluates nothing (`allowEval` off); the one
`hx-on` attribute became a listener.
- The 60 inline event handlers are gone. An element names an action
registered in `window.cairnActions` (`data-on-click="..."`, `data-arg`),
dispatched by `static/js/cairn/actions.js`; `data-confirm` replaces
`return confirm(...)`. Only a registered function can be named, so markup
cannot reach an arbitrary global.
- The error pages lose their "Go back" button : the 500 page is rendered with
no context and could carry no nonce.
- The OAuth consent page drops `form-action` (its form is answered by a
redirect to the client), and its refusal now checks the redirect address
before using it, as its approval did.
- The legacy `stepper` component, unused since the lifecycle bar and holding
two of the handlers, is removed.
Styles stay allowed inline : a style runs no code, and Bootstrap, Tom Select,
Leaflet and ECharts position elements with style attributes.
Writing the policy showed that the maps sent the address of a site or a
supplier to photon.komoot.io from the reader's browser, hard-coded in three
templates and in the address type-ahead, while the README said the tiles were
the only outside call. It is now a setting (`MAP_GEOCODER_URL`), listed in
the policy, documented, and switched off by an empty value.
`CSP_MODE` (enforce, report, off) is the escape hatch for an instance behind
a proxy that rewrites pages.
Checked three ways. `core/tests/test_csp.py` reads the header and scans every
template (no handler, no script without its nonce, no `hx-on`, every named
action registered). The markup audit of the sweep refuses a handler on any
rendered page. The browser audit now fails on any policy violation or script
error a browser reports : 96 renderings clean, after confirming by hand that
an injected script and an injected handler are refused, and that boosted
navigation, dialogs, the calendar, the dependency graph and the permission
presets still work.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FaEkJkxoxKbGMSYquC2dwV
A group's page listed its permissions as ten tables one under the other : a few hundred checkboxes, 5 700 px of form, and no way to see what the group can do without reading all of it. Each module is now a folded section (a native <details>, so the keyboard folds it) whose header shows how many of its permissions the group holds, `12 / 40`, kept current as boxes are ticked and green when the module is granted in full. "Expand all" opens every module. The module's "Select all" sits under its header rather than inside it (a control inside a summary is a control inside a control). The page is 2 300 px tall. A folded module's checkboxes are still part of the form : saving applies the whole matrix whatever is open, which a test pins. Also : - a table that scrolls sideways is named after the section it sits in, so the modules' tables do not all announce themselves as "Permissions"; - the user chip takes the accent's contrast colour instead of a hard-coded white, which a pale custom accent could not carry; - the browser audit visits a group's page. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FaEkJkxoxKbGMSYquC2dwV
5ad4098 to
bf3c937
Compare
Progress : a defect the audit could not see, and the audit fixedThe PostgreSQL job failed on the policy commit : on a migrated database, the help dialog's script was rendered with an empty nonce, so a browser would have refused it on every real instance. The browser audit had passed. Cause. The nonce was a template context variable. A form widget and an inclusion tag are rendered with a context of their own, where it is empty. Fix (folded into Why the audit missed it ( Verification : 3 897 tests pass on SQLite; the policy, accessibility and action-log tests pass on PostgreSQL with migrations; browser audit clean on 98 renderings of the migrated instance. |
The browser audit ran on a database built straight from the models, to spare the nine minutes SQLite takes to replay the migrations. The help content, the default lifecycles and the reference data are written by data migrations, so that instance had none of them : it was not the instance a deployment serves. The policy commit went through it with the help dialog's script being refused on every real instance; the PostgreSQL test job is what caught it. The job now migrates a PostgreSQL service (`LOCAL_POSTGRES=1` keeps the main settings' database under the local settings), seeds it and serves it. The model-built SQLite instance stays documented for a quick local look, with its blind spot stated. Replaying the migrations takes seven minutes on a runner, so the migrated, still empty database is cached as a dump keyed on the content of every migration file. `migrate` runs after a restore as after a miss, finds nothing to apply and fires the post-migrate hooks : the instance is still the product of the migrations, not of a shortcut around them. The audit also opens a form as a page of its own, whose scope picker is a form widget rendered outside the page's template context. That page showed the picker's fold button and checkboxes were 14 px targets touching each other : they are 24 px, or keep 24 px clear (WCAG 2.5.8). Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FaEkJkxoxKbGMSYquC2dwV
bf3c937 to
2e50e96
Compare
A review of the MCP sign-in flow, asked for with "security first", found that its tokens were not tied to a person. An access token belonged to its application and acted as the owner of that application. A public client (dynamic registration, authorization code) is owned by whoever authorizes it first, and shared by everyone who authorizes it after : the second user to approve a client received a token acting as the first. With a desktop client, whose redirect address is on the loopback interface, anyone who knew a client id (it is not a secret) and had an account of their own could obtain a token for the account that first connected that client, an administrator's included. - A token carries its user : the person who consented, or the owner of the application for client credentials. The code already recorded who consented; the token endpoint ignored it. - Migration 0004 deletes the tokens issued to public clients, since nothing recorded tells which of them act as someone else, and attaches the others to their application's owner. The users of a public client approve it again. Around it : - Registration is open to anyone and accepted any redirect address, including none, in which case consent then accepted any address at all. It requires one to ten addresses : https, http on the loopback interface, or an installed application's private scheme; no fragment, no credentials, no scheme the browser interprets. A code only goes to an exact registered address, and an application that registered none has no code flow. - The consent screen shows the address that will receive the access, not only the name the application chose for itself, and is offered only to accounts allowed to use MCP. - Tokens never expired. They live OAUTH_ACCESS_TOKEN_LIFETIME_DAYS (90 by default) and say so (`expires_in`); the existing ones are brought back to that lifetime. - The two open endpoints are rate limited, an authorization code is spent by an atomic update, secrets and PKCE challenges are compared in constant time, and a registered client is always public. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FaEkJkxoxKbGMSYquC2dwV
Summary
A pass on what made Cairn read as a beta : pages that spent their first screen on air and on a diagram, and a handful of failures that only show up outside a superuser session on a healthy single-process stack.
It is stacked on #184 (it needs the Controls module), hence the base branch. Each commit is one self-contained unit and can be reviewed alone.
Related issue
None.
Type of change
Changes
Interface (
feat(ui))Reliability (
fix), found by crawling every page as a superuser and as a plain member, and by submitting every form empty and invalid :core.cache.ResilientRedisCachedegrades to a miss.LIFECYCLE_CACHE_TTLseconds.Performance (
perf(lists))Deployment (
feat(ops))GET /health/(database reachable, no session, any Host), declared as the imageHEALTHCHECK.LOG_LEVEL).SECRET_KEYonceDEBUGis off.MAP_TILE_URL), defaulting to OpenStreetMap.Accessibility (
feat(a11y)), measured with axe-core on the rendered pages :--accent-text,--success-text...); a custom accent (company, Trust Center) gets its readable tones computed (core/colors.py).hrefon the fourteen Edit links that had none, buttons to reorder the dashboard tiles without dragging, scrollable tables as focus stops.test_contrast.py), the markup of every crawled page (markup_audit), andscripts/a11y_audit.py(axe-core on 92 renderings) in a new CI job.Operations and hardening (
feat(ops),feat(security),perf)manage.py backup/restore: the database and the uploaded files in one archive with a manifest and a checksum per member; the restore verifies it, refuses one from a newer release, saves the current state, loads the dump into a new database that then takes the place of the current one. Tested end to end (SQLite in the suite, PostgreSQL in CI) and by hand in the image : 7 555 records, 412 tables, 6 files identical after a restore.unsafe-inline, nounsafe-eval. 71 inline scripts carry the nonce, 60 inline handlers became declarative actions. The browser audit fails on any violation.Points that deserve a decision
docs/brand/brand-guidelines.md). The guidelines ask for approval before such a change; it is in this PR to be accepted or sent back.SECRET_KEYguard is a breaking change for a misconfigured deployment : an instance running withDEBUG=Falseand a placeholder key will refuse to start after upgrading.--text-mutedgoes from#A1A1AAto#6B6B74, status badges and dark-theme links take darker / lighter inks, and the calendar no longer fills events with their category colour. The guidelines document the fill / ink rule; same approval as above.accessibilityCI job runs on every pull request (about five minutes, in parallel withtest). It can be made optional like the PostgreSQL job if that is too much.MAP_GEOCODER_URL), still on by default so nothing changes for an existing instance : decide whether the default should be off.--build-arg POSTGRES_MAJOR=.base.htmlstays inline too, with a nonce : the policy does not need it moved.MAP_TILE_URLto a provider of its own.Screenshots
The 35 documentation screenshots under
docs/screenshots/are recaptured at 2560x1440 withscripts/capture_screenshots.py(last commit), so the before / after of every documented screen is the diff of that directory. Light theme, dark theme and a 390 px phone viewport were checked locally on the dashboard, a list, and the risk, incident, control and supplier detail pages.Checklist
pytestpasses (3892 passed)ruff checkpassesmcp/tools.py(not applicable : no domain feature is added, the health probe and the settings are operational)api/(not applicable, same reason)_()/{% trans %}with French translations inlocale/fr/LC_MESSAGES/django.po(no duplicatemsgid;compilemessagespasses)README.mdupdated (features, MCP tools, tech stack, install) when behaviour changedCHANGELOG.mdupdated under## [Unreleased]docs/brand/brand-guidelines.md); no em dash characters (the guidelines themselves are amended, see above)docs/specs/updated in the same PR🤖 Generated with Claude Code
https://claude.ai/code/session_01FaEkJkxoxKbGMSYquC2dwV