The review page
The review page is the browser page a person uses to review sign-off records and identity matches
without writing an API call. It is part of the Management API service: this
document describes what it shows and how it behaves, what its tests cover and what a person still
checks before a release. The routes it calls, the scopes and the token commands are in
management-api.md.
GET /ui serves one HTML document for the sign-off and identity-match routes in
management-api.md, so a person can review without writing a call. It needs no token, because a browser navigation cannot send one, and
it holds no data: it asks for a token, keeps it in the page's memory, and calls those routes from
the same origin. It is not part of /v1 and not in GET /v1/openapi.json; the routes it calls are.
The routes are the sign-off and identity-match routes (see Sign-off records and
Identity matches) and
POST /v1/tokens/rotate, for Rotate token (see Rotating the token
below).
Styling it
The page's look is decided in one block, the <style> element of
engine/management/review_page.html, headed "Presentation layer". It is ordered tokens (colours,
type, spacing, radii and widths), base elements, layout, components and states, and nothing else in the
file carries a style: no style attribute and no size or colour in the script. The block also lists the
names the markup and the script use (the ids #notice, #entry, #work, #waiting, #decided, #rotation; the
classes .tabs, .filters, .sides, .actions, .card, .badge with a status beside it, .note,
.muted, .primary, .danger), so a restyle keeps those names and changes only what they look like.
The service works out the page's security policy from the file when it starts, so an edited page
needs a restart and nothing else; a page whose style or script the policy cannot name is refused at
start.
Opening it
Browse to the service's address and /ui.
- Loopback bind (the default). The address is
http://127.0.0.1:8470/ui, from the appliance itself. - Private-network bind. The service is served over the Node's own certificate, so a reviewer's browser must trust the site's CA, or it will refuse the page before any token is entered.
Enter a token that carries signoff to review records, alerts to see and acknowledge alerts, or one token that carries both.
Once, at sign-in, the page asks the service which scopes the token carries (GET /v1/tokens/self). It turns off the part a token lacks and says so (see Alerts), without asking for anything the token cannot have.
- A token with neither scope goes back to the entry.
- A mistyped, unknown or revoked token is refused (401), and the page returns to the token entry.
What it shows
Sign-off records of any status, filtered by status and record type (a dropdown of the record types the Node's records hold, refreshed each time the list is).
- Each record shows its content as text, with the Approve, Reject and Edit and resubmit actions on a pending one.
- An approved record is labelled Approved. Approval is a status, and nothing else changes, except that an approved
case_summaryalso offers Submit as document (see below).
Pending identity matches, filtered by entity type and kind.
- Each shows the record and its candidate side by side, its stored
originand its derivedkind, and what confirming and rejecting would mean for that kind. - A match leaves the pending list once it is decided. The ones decided in the page's session are shown below it until the page is reloaded.
- Choosing Rejected in the identity tab's status filter lists the rejected matches, from this session or an earlier one, each with who rejected it and when. One that was not re-opened offers Re-open, and one that was says which match replaced it.
The Alerts tab lists the alerts the Node raised. See Alerts below.
Alerts
An alert is what the Node raises when operations are outside an instruction (see Instruction bindings). It is on record and published the moment it is raised, and this page is one place a person sees it; the page cannot make an alert and cannot send one again.
- The banner. Above the tabs, whichever tab is open, a line says how many alerts wait for an acknowledgement and
when the oldest was raised: "No alerts are waiting for acknowledgement" for 0, and "This Node has no alert source"
for a Node that has none, which is never shown as no alerts. The button beside it opens the Alerts tab. It shows
only for a token that carries
alerts. - The one timer. While the page is open and holds a token it asks
GET /v1/alerts/countevery 30 seconds, and asks for nothing else on a timer: not the list, not the sign-off records, and it sends nothing. The interval is the constantCOUNT_REFRESH_SECONDSat the top of the page's script; it is not a setting of the Node. One request is in flight at a time, the page does not ask while it is hidden and asks once when it is shown again, and the timer stops when the token is forgotten (an answer that arrives later is ignored). The list is not refetched by it: when the number waiting differs from the list the page loaded, a note says so, and Refresh loads it, so a button never moves from under a cursor. What the list was loaded with is the number of alerts on it when it holds every alert waiting, so a count that is answered a moment later never makes a list just loaded look out of date; a list with more pages is compared with the count read when it was loaded. - Stale. A count that could not be refreshed stays on the page, marked as stale, with the time it was last confirmed ("Last confirmed at 14:03:12; it could not be refreshed"), and the banner is drawn differently. A first count that fails is "unavailable" and never a number. The next success clears the mark. A refused token (401) goes back to the token entry.
- The tab. It lists alerts newest first, the ones waiting for acknowledgement by default, or the acknowledged ones or all. Each shows the alert's id, when it was raised, the measured value and the limit it crossed with the unit, how long it held, the product and operation, how often it repeated, and who acknowledged it and how.
- Acknowledging. Three buttons, one for each disposition (Confirmed issue, Dismissed: the instruction is correct and The instruction needs revising). A click asks once ("Record ...?"); Yes, record it sends the disposition and nothing else. There is no free text, because a person's words would sit in the append-only Activity Log for good. Who answered is the token's id, never a name typed here. An alert someone else acknowledged first answers 409 and the list catches up. A request that was not confirmed (a 503, a timeout or no answer) is kept under Requests not confirmed, and Retry sends the same disposition again, which finishes a missing entry once and never applies it twice. A double click sends one request.
- Where the instruction is, and the explanation. A button on each alert reads the alert's detail. It shows the
document, revision and place of the instruction, read from the alert's own entry through the alert route, and never
the instruction's wording. Under it, labelled Drafted explanation (for review; it is not part of the alert), is the
Case Triage summary that names the alert, with who wrote it (Written by the model, or Structured facts, written
by code when inference is off or a draft was withheld because it stated a number the alert does not hold) and its
status as a sign-off record. The explanation is a sign-off record, so only a token that carries
signoffis shown it; a token withalertsalone is told one was drafted and that reading it needssignoff. - A token with one scope. The page learns what a token carries from the service once, at sign-in, and keeps the
three tabs off until the answer arrives. With
alertsalone the page opens on the Alerts tab and the sign-off and identity tabs are disabled, with a note; withsignoffalone the Alerts tab is disabled, with a note, and there is no banner. Neither token makes a request the other family's scope would refuse, so the browser's console shows none: analertstoken makes no sign-off request, not even to read a drafted explanation (it is told one was drafted without asking), and asignofftoken makes no alerts request. The answer is advice: each route still checks the token itself, and a 403 from any call is handled as before, so if the service cannot be asked (it is not reachable or answers an error) the page asks for everything and learns from the first refusal, as it did before the route existed.
The token is in the page's memory and nowhere else
The token is not in the address, local or session storage, or a cookie.
When the token is forgotten.
- Reloading or closing the page forgets it, and the reviewer enters it again. The page's Forget token does the same.
- A token the service refuses (401, for instance one revoked while the page was open) also returns the page to the token entry. An edit that was typed but not yet sent is discarded with the rest.
- Forgetting also clears the page of what that token's holder was shown: the lists, the requests waiting to be retried and the matches decided in the session. The next token entered starts from an empty page and cannot retry the last holder's request.
- An answer that was still on its way when the token was forgotten is ignored. So is the search for an edit's successor behind Send this decision again, which stops without sending anything.
- Forgetting does not cancel a request already sent. The service can still apply it under the old token, and the page no longer shows its outcome.
- What the page's filter controls were set to is not cleared.
Requests not confirmed. A page that is open keeps what it needs to repeat a request that was not confirmed (a 503, a timeout or no answer). It keeps the same request id, so the repeat is the service's no-op or completes a missing Activity Log entry, and never applies a decision twice. These are listed under Requests not confirmed.
Rotating the token
Rotate token, in the page's header while a token is in use,
asks once (Yes, rotate or Cancel) and then calls POST /v1/tokens/rotate
with the token the page holds. The new secret is shown once, in a read-only field, with the
time the new token expires when the service sent one (a token minted with no expiry has none to
show). The page uses the new secret for every call from then on, and holds it in its memory like the
one it replaced: not in the address, storage, a cookie or the console. I have stored it removes the
field; so do Forget token, a reload and a refused token. The field is the only copy: the
service keeps a hash. Store the secret before closing the page.
The token the reviewer entered keeps working for the grace window (see Rotating your own token): the page says so, and what to do if the answer did not arrive:
| The page was told | It says |
|---|---|
200 |
The new token, the expiry if one was sent, and that the old one ends after the grace window |
401 |
The token was not accepted, and that an expired token, or one a rotation replaced whose grace window has passed, needs an admin's management_tokens.sh reset; it returns to the token entry |
409 |
Nothing changed, the token still works; Retry |
503 |
Nothing changed, the token still works; Retry, and an admin if it keeps failing (the Activity Log or the token file is unavailable, and no token rotates until it is back) |
No answer, a timeout (504) or another 5xx |
The rotation may or may not have been applied and the new token did not arrive; the old one still works for the grace window, so Retry, and after the window (or if the site turned it off) an admin's reset |
A 200 the page cannot read |
The rotation was applied and its new token is lost; the same advice, and Retry shows a new one |
A retry rotates again with the old secret, which the service accepts inside its window and which gives a working new token; a rotation the first call did apply is replaced by the second. Forgetting the token while a rotation is on its way does not cancel it, as for a decision: if the service applied it, nobody sees the new token, and the page says so and that the old token still works for the grace window. Forgetting it while the new token is still shown says the new token is gone with it. The action rotates the token on this node only.
Repeating a decision after a reload
The repeat needs only what the record carries. A settled
sign-off record shows its resolution_action_id, so Send this decision again sends that decision
with that id: the service answers 200 and writes the entry if it was missing, answers 200 and writes
nothing if it was there, and answers 409 and changes nothing when the token is not the one that
decided it. For an edit the page finds the successor record (the one whose predecessor_id is the
original) and sends its content with the original's id. It cannot tell whether an entry is missing,
because a signoff token cannot read the Activity Log, so the action is offered on every settled
record and is never automatic.
A limit for identity matches
The repeat of a confirmation or rejection is not possible once a page has been closed or its token forgotten (Forget token clears the matches decided in the session, which is where the repeat is offered): a decided match is no longer in the pending list, so if its decision was recorded but its Activity Log entry was not written (a 503) and the page is closed or its token forgotten before the repeat, nothing here can find the match again and the entry stays unwritten. It is the same class as a decision whose token was revoked before the repeat. The decision itself is on the record, with its reviewer, time and request id. (A rejected match can be found again, in the Rejected view, and re-opened.)
How it is served
The response carries a Content-Security-Policy that allows the page's one
inline script and one inline style by hash and nothing else: no other script, no outside origin
(default-src 'none'), connections only back to the service, no framing. It also carries
Cache-Control: no-store, X-Content-Type-Options: nosniff and Referrer-Policy: no-referrer.
The service sets no cross-origin headers, so another origin's page cannot read its answers. The route answers GET only (a health check should call GET /v1/status with a token), and nothing else is served under it. A
record's content is rendered as text, never as markup. A browser holds a number as a double, so
the page refuses to send an edit (or to repeat one) whose content has a whole number beyond 2^53
rather than send it changed, and says to use the API for that record; a decimal is limited to a
double's precision in the edit box. The page's one timer asks for the count of alerts waiting (see Alerts);
everything else it refetches when the reviewer asks, and after a decision.
What the browser tests cover
The page runs in a real Chromium against the shipped service over a real
sign-off store, identity store and alert tables (tests/test_browser_review_page.py and
tests/test_browser_alerts_page.py, with the rotation lines in tests/test_browser_pages.py), under the content security policy the service computes for it. Each test fails
on a script error, a message the browser logs at error level, or a request to any origin but the service's,
whatever it was about, and a copy of the page without its send guards fails the double-click test. The route's policy and headers, that the document has no
script-injection sink and no use of browser storage, the console or the clipboard, and that every route,
parameter, body key and response field it uses is in the served description are tested too.
| What is checked | The test |
|---|---|
The page opens without a token and a signoff token shows the lists |
test_the_page_asks_for_a_token_and_a_signoff_token_shows_the_lists |
| A mistyped token returns to the entry and says so (401) | test_a_mistyped_token_returns_to_the_entry_and_says_so |
A read token is refused and the page says it has neither scope (told by the service, no request refused) |
test_a_read_token_is_refused_and_the_page_says_it_has_neither_scope |
| The lists, and each of the four filters narrowing them | test_the_lists_show_pending_records_and_matches_and_each_filter_narrows_them |
| Approve asks once and is never labelled Published | test_approve_asks_once_and_the_record_is_approved_by_the_reviewer_not_published |
| Reject, and Cancel leaving a record pending | test_cancel_leaves_a_record_pending_and_reject_records_the_reviewer |
| Edit and resubmit, and other top-level keys refused | test_an_edit_is_sent_the_original_is_superseded_and_a_pending_successor_appears, test_content_with_different_top_level_keys_is_refused_and_nothing_changes |
| An identity match: both sides, confirm merges, reject leaves the candidate | test_both_sides_show_before_the_decision_and_confirm_merges_while_reject_leaves_the_candidate |
| Re-open, once, and the two views kept straight | test_a_rejected_match_is_reopened_once_and_the_page_keeps_both_views_straight |
| A reload forgets the token and nothing is stored | test_a_reload_forgets_the_token_and_nothing_of_it_is_stored |
| A new token starts clean | test_forget_token_empties_the_page_and_a_new_token_starts_clean |
| Rotate token: shown once, the old secret works for its window and then ends | test_the_new_secret_is_shown_once_and_the_old_one_stops_working_after_its_window, test_closing_the_page_asks_first_while_the_new_secret_is_the_only_copy |
| An approved case summary, and only that, offers Submit as document | test_an_approved_case_summary_offers_submit_as_document_and_nothing_else_does |
| The disposition is required, and two quick clicks queue one document | test_the_disposition_is_required_and_one_submission_queues_one_document |
| Check reads the document's status | test_check_reads_the_documents_status_and_a_reload_shows_no_second_submit_offer |
A token without the documents scope is told so and the action turns off (403) |
test_a_token_without_the_documents_scope_is_told_so_and_the_action_turns_off |
| A double click sends one decision | test_a_double_click_on_yes_approve_sends_one_decision |
| The banner: how many alerts wait, the oldest, none, no source | test_the_banner_shows_how_many_alerts_wait_and_when_the_oldest_was_raised, test_no_alert_waiting_reads_as_none_and_a_node_with_no_source_reads_as_unknown |
| The count is asked again on an interval, and only the count | test_the_page_asks_for_the_count_again_on_an_interval_and_only_for_the_count |
| A failed refetch keeps the last count marked stale | test_a_failed_refetch_keeps_the_last_count_and_marks_it_stale_until_one_succeeds, test_a_first_count_that_fails_is_unavailable_and_never_zero |
| A hidden page does not ask; forgetting the token stops it | test_a_hidden_page_does_not_ask_and_asks_once_when_it_is_shown_again, test_forgetting_the_token_stops_the_polling_and_clears_the_banner, test_an_answer_that_arrives_after_the_token_was_forgotten_is_ignored |
| The note that the number waiting has changed, and that a reloaded list never says it | test_the_list_says_when_the_number_waiting_has_changed_and_does_not_move_itself, test_acknowledging_one_of_two_does_not_say_the_number_changed_for_a_list_just_reloaded, test_a_count_that_answers_after_the_list_does_not_make_the_list_look_out_of_date, test_a_list_with_more_pages_still_says_when_the_number_waiting_has_changed |
| The tab lists waiting and acknowledged alerts | test_the_tab_lists_waiting_alerts_and_the_filter_shows_acknowledged_ones |
| Acknowledging: each disposition, asked once, the token recorded, Cancel, no free text | test_a_person_acknowledges_with_one_disposition_after_one_confirmation, test_cancel_sends_nothing_and_leaves_the_alert_waiting, test_there_is_no_free_text_field_on_an_alert |
| Someone else answered first; an answer not confirmed and its retry | test_an_alert_acknowledged_by_someone_else_meanwhile_is_refused_and_the_list_catches_up, test_an_acknowledgement_that_was_not_confirmed_is_kept_and_retry_sends_the_same_one |
| A double click on Yes, record it sends one request | test_a_double_click_on_yes_record_it_sends_one_acknowledgement |
| Where the instruction is, the labelled explanation, a withheld draft, none drafted | test_the_detail_shows_where_the_instruction_is_and_the_explanation_labelled_as_a_draft, test_a_withheld_draft_is_shown_as_the_facts_that_stand_in_for_it, test_an_alert_with_no_explanation_says_none_was_drafted |
| A token with one scope, and no refused request | test_a_token_with_alerts_alone_lands_on_the_alerts_tab_and_the_signoff_tabs_are_off, test_a_signoff_token_alone_has_no_alerts_tab_and_no_banner_and_the_lists_work, test_a_new_token_after_forgetting_starts_with_every_tab_on_again, test_neither_family_is_asked_for_that_the_token_lacks, test_a_token_with_both_scopes_has_every_tab_on_and_no_note |
| The scopes are asked once, before any list, and the tabs wait for the answer | test_the_page_asks_the_token_for_its_scopes_once_and_before_any_list, test_the_tabs_stay_off_until_the_service_has_said_what_the_token_carries, test_a_token_forgotten_while_its_scopes_are_on_the_way_starts_nothing |
| The scopes cannot be had, or the token is not accepted | test_when_the_scopes_cannot_be_had_the_page_learns_from_a_refusal_as_it_did, test_an_alerts_token_whose_scopes_were_not_had_is_still_told_by_the_refusal, test_a_token_the_service_does_not_accept_is_sent_back_to_the_entry_by_the_scopes_call |
| Nothing on the page sends an alert again | test_nothing_on_the_page_sends_an_alert_again, test_the_page_has_one_timer_and_it_is_the_counts |
What a fake cannot show
Three things need a running site, so a person checks them before a release: the rotation through the wrapper and the page against a live Node, the certificate warning without the site's CA and the page with it, and a reading of the page for sense.
Submit as document
An approved case_summary card has a Submit as document action: a required Disposition field, where the person
writes how the case was dispositioned in their own words, and one sentence saying what it does (this summary and the
disposition become a past case the Node can retrieve; withdraw it later with the deactivate route). It calls
POST /v1/signoffs/{record_id}/submit-as-document,
which needs the documents scope as well as signoff. A drafted summary never reaches retrieval without this act:
approving, rejecting and editing a record queue nothing.
- The page draws only its tabs from the scopes it was told at sign-in, so the action is shown on every approved case
summary, and the first 403 turns it off with a note that submitting needs both the
signoffand thedocumentsscope (the service's answer does not say which one the token lacks). - Two quick clicks send one request. A request that was not confirmed (no answer, or a 5xx) is listed under the requests waiting to be retried, and Retry sends the same disposition again; the service answers a repeat with the same queue row, so a retry never queues a second document.
- After a call the card shows the queue row's id and queued. Check reads
GET /v1/documents/{id}, which says whether the Node has ingested it. The page never shows the document's text. The page keeps no record of a submission across a reload: submitting the same disposition again answers the same queue row, and a different one is refused (409) because the record was already submitted. - A refusal (a full queue, a record no longer approved) leaves the disposition the person typed in the field.
Looking at the page on a test appliance
To read the page for sense, or to see it work, use a test appliance: the records are invented and the tokens are test tokens.
Records to check with
seed_review_records, run from the checkout as the service user, adds records to look at: five sign-off
records (three case_summary titled Hand-check approve, reject and edit, one playbook_draft and one
drafted instruction_claim, which shows its quoted sentence beside the fields read from it), two inferred
identity matches that each have a candidate (confirm and reject in their reference) and one first
article. It creates the two tables if no Node has started. It writes invented records into the
databases the service reads, so use it on a test appliance only.
Run it through the project's Poetry environment, as the service user, from the checkout. From a root shell on
the appliance, a login shell as that user does all three (poetry is on the PATH of a login shell only):
runuser -l kindred -c 'cd ~/kindred && poetry run python3 -m engine.management.seed_review_records'
Logged in as the service user, it is cd ~/kindred && poetry run python3 -m engine.management.seed_review_records.
Plain python3 -m engine.management.seed_review_records uses the system Python, which does not have the
database driver, and stops with ModuleNotFoundError: No module named 'psycopg'.
It prints Seeded set <id>: 5 sign-off records, 2 inferred matches, 1 first article. Approving, rejecting
and confirming use the records up, so run it again for a fresh set before repeating a decision. Nothing removes
them afterwards.
Run the seed again for a fresh set when a tab you need is empty: the page lists pending
records and matches, so one that was decided is no longer in the pending list. An empty Identity matches
tab means the set's matches are used up, or the seed wrote to a different database from the one the
service reads. The seed reads its database settings from the .env in the directory it is run from, so
run it from the service's checkout and as the service user, or it seeds whatever those settings default to.
The wrapper command below shows what the service itself holds: if it lists nothing, seed again.
To check what the service shows without the page, give the wrapper the service's address, the site CA if the
service is on a network bind (see Where it listens) and a token file:
with the signoff token the sign-off route lists the records, and with the read token it answers
403 insufficient scope, as it should. The identity-matches route lists three entries for one fresh set, not
two: the first article is stored as a pending identity record and is listed beside the two inferred matches.
export KINDRED_MANAGEMENT_URL=<address> CURL_CA_BUNDLE=<the site CA's certificate file>
KINDRED_MANAGEMENT_TOKEN_FILE=<signoff token file> deployment/kindred_management.sh signoffs
KINDRED_MANAGEMENT_TOKEN_FILE=<read token file> deployment/kindred_management.sh signoffs
KINDRED_MANAGEMENT_TOKEN_FILE=<signoff token file> deployment/kindred_management.sh identity-matches
Tokens
The page takes the token's secret, the one line mint_management_token.sh prints, and not its id. The
secret is shown once and the service keeps only its hash, so mint with --save-to FILE to keep it, one token
for signoff and one for read, and read the file when the page asks:
deployment/mint_management_token.sh --id <id> --scope signoff --expires-in 30d --save-to <file>
deployment/mint_management_token.sh --id <id> --scope read --expires-in 30d --save-to <file>
An id that exists or was ever revoked is refused, so each round takes new ids, and --save-to refuses a file
that is already there. A token that was minted earlier but not kept cannot be recovered:
management_tokens.sh list shows whether its id exists, and the way forward is an admin reset of that id
(see Resetting a token). A 401 with the right secret means the token
was revoked or the appliance was reset.
The signoff token is the one that reviews and the alerts token the one that sees and acknowledges alerts
(--scope alerts; a person scope, so it always has an expiry); one token may carry both with a repeated --scope.
A read token is refused, and the page says it carries neither.
If the page answers "did not accept that token" and the secret is right,
KINDRED_MANAGEMENT_URL=<address> KINDRED_MANAGEMENT_TOKEN_FILE=<file holding the secret> deployment/kindred_management.sh signoffs limit=1
tells a refused token (it fails with 401 and authentication required) from a token without the scope (403 and
insufficient scope) and from a page problem (it prints the list). Run it where that file is. On a network
bind whose CA that machine does not trust, set CURL_CA_BUNDLE to the CA's certificate file first, or curl
refuses the certificate.
Release: v0.11.0