Skip to content

AIV-P2-012: record decisions as the authorised hiring owner; stages update through the outbox - #641

Open
ALFRED-LUCIFER wants to merge 34 commits into
mainfrom
feat/AIV-P2-012-record-decisions
Open

ALFRED-LUCIFER wants to merge 34 commits into
mainfrom
feat/AIV-P2-012-record-decisions

Conversation

@ALFRED-LUCIFER

@ALFRED-LUCIFER ALFRED-LUCIFER commented Nov 26, 2026 •

Copy link
Copy Markdown
Owner

Ticket

Closes #126 · AIV-P2-012. It also delivers the DecisionsRecorded.v1 stage-update consumer, which #123 left to this ticket.

Stack: main ← #640 (AIV-P2-011) ← this PR. The base is #640's branch until it merges.

What changed

The authorised hiring owner records a decision for each pack member: "Advance to Round 2", "Hold" or "Do not advance". Stages update through the outbox. No candidate is contacted (AGENTS.md 1.5).

Decisions module:

  • getPack returns mayDecide.
  • New readDecisionsAsSystem(tx, workspaceId, packId) in the composition, for the worker.
  • The contracts export DECISIONS and NOTE_MAX.
  • recordDecisions already existed: audit last, strict event, only the named hiring owner may record.

Intake module:

  • Stages round2_shortlist and not_advanced.
  • stageAfter: advance moves to Round 2 shortlist, do not advance to Not advanced, hold keeps the current stage.
  • New findForPersonAndJob and applyDecisions.
  • createDecisionStageHandler({ event, decisionsOf, audit }):
    • runs once per message through the new intake.inbox;
    • moves a stage only if it is still the stage it read;
    • skips a hold, a candidate already at that stage, a withdrawn candidate, or no application;
    • audits each move as application.stage_changed, with the hiring owner as actor and their reason, after the moves.
  • Intake takes no package dependency on decisions (that would be a cycle); the worker passes the event in.

Worker: relays DecisionsRecorded.v1 to the assessment queue and registers the handler. A shortcut: records moving both to a decisions queue later, which needs an infra apply (owner).

Migrations (intake):

  • 0006_uneven_jack_flag.sql: intake.inbox with its tenant policy, and the two stages added to application_stage_check.
  • 0007_force_rls_inbox.sql: forces row-level security on intake.inbox.
  • Both forward-only and generated by drizzle-kit.

Web:

  • recordDecisions server action: zod input. ForbiddenError gives 403; a pack the member cannot see gives 404. Logs carry ids only.
  • useRecordDecisionsController hook and RecordDecisions.tsx.
  • Choosing: each member gets a shared segmented control, with nothing chosen at first.
  • Previewing: "Record decisions" first checks every member has a choice ("Choose a decision for …"), then opens the shared preview card. It shows each resulting stage, asks for a required reason, and says "Nothing changes until you confirm."
  • After confirming: a success banner ("Decisions recorded by you on … and added to the audit trail.") with a "Schedule Round 2 interviews" link.
  • Everyone else sees the controls read-only ("Only the hiring owner can record decisions."). A decided pack shows its decisions read-only, with who recorded them and when.
  • loadPack returns each member's decision, mayDecide and decided. New en.json keys and stage labels. Module READMEs and docs/02-architecture/modules.md updated.

Deviations from the artboard and the 22 Nov design update

  • The decision row: each member's choice keeps a visible legend, "Your decision for ", on its own row, not on the "Credalent's recommendation" row. The recommendation belongs to the cited summary (AIV-P2-011: show the decision pack with cited strengths, risks and Credalent's recommendation #640), and the person's decision must never read as Credalent's (AGENTS.md 1.5). Members with no summary have no recommendation row to share. "Record the decision" is inside the shared Card (ported), with the Card's 16 px padding rather than 24 px. Its heading is an h3 (text-section, 12 px gap), not the artboard's h2 (14 px gap), because the pack title is the page's h2.
  • No decision email drafts. The confirmation uses the ticket's copy and "Schedule Round 2 interviews" instead of "3 decision emails are ready / Review and send them". Drafts are AIV-P2-073 ([AIV-P2-073] Send decision emails after the hiring owner records the decision #515), which changes this copy.
  • Shared components: segmented radio groups instead of toggle buttons, and the shared preview step with one required reason, used as every decision's audit note.
  • Hold keeps the stage; the ticket defines none for it.
  • "Back to ranking" stays at the foot of the pack, where AIV-P2-011: show the decision pack with cited strengths, risks and Credalent's recommendation #640 put it.
  • "Schedule Round 2 interviews" links to the job's Interviews tab; scheduling is AIV-P2-007.

How verified

Scenario Tests
Record decisions Playwright record-decisions.spec.ts (keyboard); PackClient.test.tsx; integration record-decisions.test.ts (3 decisions audited with hiring owner and time; stages moved once even when delivered again)
No candidate is contacted integration (notifications tables and every other outbox unchanged, including after the consumer runs); Playwright (notifications.message and outbox counts unchanged)
Every candidate needs a choice PackClient.test.tsx; Playwright
Not advanced candidates stay visible integration (still in the ranking at not_advanced; can be added to a new pack)
Only the authorised hiring owner integration (recruiter and interviewer 403; an ungranted hiring owner and another workspace get not found; nothing stored); recordDecisions.test.ts; PackClient.test.tsx (read-only); Playwright (recruiter read-only, ungranted hiring owner 403)
Already decided PackClient.test.tsx, loadPack.test.ts, Playwright
  • Other coverage:
    • Unit decisions.test.ts, application.test.ts and packs.test.ts for mayDecide.
    • RLS on intake.inbox in the integration test and the tenancy table check.
    • axe light and dark, including with errors shown.
  • Mutation checks (each made its test fail):
    • the mayDecide check removed;
    • the handler writing to intake.outbox;
    • a random inbox consumer name with no already-at-stage skip;
    • a permissive policy on intake.inbox;
    • the preview opened without the choice check;
    • the already-at-stage skip dropped.
  • Local runs:
    • Lint and typecheck: 27/27.
    • Unit (web, worker, intake, decisions, architecture) pass.
    • Integration: record-decisions, decisions, intake, choose-for-interview, worker and migrations-and-rls pass.
    • Playwright record-decisions and pack-from-ranking: 19/19.
    • next build passes.
  • tenancy.test.ts: passes, now that AIV-P2-011: show the decision pack with cited strengths, risks and Credalent's recommendation #640 seeds its decisions tables.

Not done / risk

  • No screenshot comparison with the artboard.
  • No end-to-end stage check through a running worker; the consumer is proven in integration.
  • The intake migration numbers 0006 and 0007 will clash if another PR adds intake migrations first.

Review fixes (8b8290a, c82480a; merges e11b4b5 and 3a2aeb0 of #640)

  • A recorded decision can't be reversed by choosing for interview. A new chosenOrDecided(stage) in the intake domain covers interview, round2_shortlist and not_advanced.
    • chooseForInterview skips all three with a reason ("On the Round 2 shortlist / Not advanced by the hiring owner's decision, so not chosen again"), and the ranking preview counts them.
    • Mutation check: interview only → applications.test.ts and Ranking.test.tsx failed.
  • No candidate is contacted on the record path: exactly one DecisionsRecorded.v1 in decisions.outbox, and nothing in notifications.*. Mutation check: also enqueue EmailQueued.v1 → the test failed.
  • Controls lock at once: recordDecisions returns { decidedAt }; the choices go read-only and "Record decisions" hides immediately. Mutation-checked.
  • Nits: imports, names computed once, and the choice error in the error tone.
  • Local runs:
    • Lint and typecheck: 27/27.
    • Unit: web 1080, decisions 61, intake 21, worker 8, architecture 75.
    • Integration (record-decisions, intake, choose-for-interview, tenancy, decisions): 100/100.
    • Playwright (record-decisions, pack-from-ranking, choose-for-interview): 23/23.
    • next build passes.

🤖 Generated with Claude Code

ALFRED-LUCIFER and others added 26 commits November 26, 2026 18:14
submitScorecard completes the interview, keeps the draft (rebuilt on the
questions the page shows) as the submitted scorecard with its
recommendation, writes InterviewCompleted.v1, records each rated note as
interview_note evidence ("Interviewer's scorecard") and applies the
previewed ratings through the assessment's audited applyScoreChange, whose
audit entries are the last statements, in one transaction. A competency
not assessed in this round has no rating and stays a gap. A second submit
or a double click is "Already submitted"; a failure rolls everything back
and the saved draft stays.

The scorecard page saves, then submits with the preview the person saw,
says the outcome and links to the ranking; a rating needs a note.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Copy without semicolons ("Your ratings are saved. Try again."), and a
  submit help line that says only what is true now.
- A note is at most 1,000 characters (the most the assessment logs as a
  reason), with its count under the field.
- The confirmation is the shared SuccessBanner (ok tone, tick, status)
  with "See the ranking" inline, as the artboard's ok note.
- Partly shown records no evidence: the preview shows it changing nothing.
- The submit reuses the meeting summary's `decisions` wiring plus
  `suggestedQuestions`, and both end in one `recordAndApply` helper.
- Every refusal says why; Submit waits, disabled with a reason, for the
  preview of the ratings, stays disabled once submitted, and a save
  refused as closed reads "Already submitted".
- One reader for the questions the page shows, for the page and submit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…n per pack member

A new AI task, decisions.summariseMember@1, writes each pack member's card text from the snapshot they joined with:
strengths citing inspected work, risks citing the facts or the claim, the Round 1 finding citing the interview notes,
and Credalent's recommendation (advance or hold, never reject). The worker writes it once per member after
PackReady.v1 or the new PackMembersAdded.v1 (decisions.member_summary, RLS forced, append-only for the app role), so
no model is called inside the pack page or the preview's request: this replaces #636's live explainRanking call and
its ingress-timeout shortcut. A rejected answer (a citation outside the snapshot, off the schema) or no model stores
"Summary unavailable", shown with the assessment's own strengths.

The pack page gains "What the role needs", "Competencies and weights", the cited card text with links to each evidence
item, "Preparing summary", the empty pack and the shared-pack footer; the preview shows the same cited text; the job
header's Decision stage reads "Shortlist ready" while an undecided pack exists.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- A first Partly shown is not in the audit log: the comments, test names,
  README and copy now say the note is kept on the scorecard and logged
  only with a change it makes; the "every change is logged" test rates
  Cost and reliability Partly shown with a note (the ticket's Background)
  and finds one entry.
- "Submitted and logged" only where something was logged.
- A reopened submitted scorecard shows only the ranking link; a save
  refused because the interview closed says submitted or cancelled.
- The submit rebuilds on the questions the page shows only when the
  latest assessment is on the interview's rubric version, as the page.
- shortcut: an older dev draft with a note over 1,000 characters.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The worker's summary job, wired as the worker wires it with the fake model: written once per member and per message
(redelivery and a new message call no model), Arjun's answer citing a source outside his snapshot stored unavailable,
Sara's facts read from the snapshot she joined with, a later member summarised alone after PackMembersAdded.v1, no
stage, decision, notification, other outbox or audit entry written, the job's hiring owner reading the summaries and
another job's owner, an interviewer and another workspace not, RLS alone on member_summary and inbox, and the app role
refused any change or delete.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…source

- shownQuestions and the suggestedQuestions port are tested: no question
  unless the latest assessment is on the interview's rubric version.
- saveScorecardDraft throws scorecard_submitted for a completed interview
  and scorecard_closed only for a cancelled one, so the web action maps
  the codes directly instead of reading the interview again.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…R-006 amendment

The pack spec runs the worker's summary job itself with the fake model and checks, by keyboard and with axe in light
and dark: "Preparing summary" with the scores shown, the role and its weights, Sara's cited strengths, risks, Round 1
line and "Credalent's recommendation: advance, and probe cost and reliability", each source linked to its item on her
profile, Arjun's rejected answer shown as "Summary unavailable" with the assessment's own strengths, no decision option
chosen, "Shortlist ready" on the Decision stage, the preview's cited text, and 404 for another workspace's member.

The decisions README, the modules table and ADR-006 (point 6) record the task, its checks in code and its live runs:
3 of 3 for decisions.summariseMember, and all 15 judge golden cases in 3 of 3.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…es their stages from DecisionsRecorded.v1

Decision controls and Record the decision on the pack page with the shared preview,
the recordDecisions server action (403 for anyone but the named hiring owner),
mayDecide on the pack view, readDecisionsAsSystem, intake stages round2_shortlist and
not_advanced, intake.inbox (RLS forced), and the worker's idempotent stage consumer,
audited as the hiring owner's. Nothing contacts a candidate.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… decision stages

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…y test; word the stage rule for this layer

tenancy.test.ts checks every workspace-owned table for a cross-workspace leak and stopped at decisions.member_summary
and decisions.inbox, which nothing seeded (AGENTS.md 3.4): each workspace now gets a member's summary and a handled
summary message, as the worker writes them. The decisions README and the pack page's header now say what is true for
this layer: the pack summary moves no stage; recorded decisions do, AIV-P2-012.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…for decisions, stage wording)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…its excerpt states

Review blocker: @1 asked what an excerpt "says the candidate built, ran or measured", and its live answer for Arjun
Menon called a service design and on-call runbook a reader he built and ran; the judge passed it in 5 of 5 runs under
the generic rubric. @2 asks what the excerpt states, in its words, with no other activity, role, scale or result and no
adjective of the model's own, and no longer names the words the eval checks for. Arjun's rubric now names what the KYC
excerpt does and does not state, and the invented answer is pinned as a judge case that must fail (5 of 5 live). The
three cases are re-recorded live under @2.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…r@2)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
chosenOrDecided: someone on the Round 2 shortlist or not advanced is skipped like
someone already chosen, in intake and in the ranking's preview, which says why.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…aims labelled, the joined snapshot read

- The recommendation's action is decided from the snapshot (advance at 50% or more of the weight met, otherwise hold),
  whatever the model chose; ADR-006 states the threshold.
- A model that stays unavailable (timeouts, an open circuit) is no answer: nothing is stored and the pack is asked
  again 15 minutes later; only answers a redelivery cannot change are stored "Summary unavailable". The handler's
  classification and its rescheduled PackReady.v1 are unit-tested with a throwing model.
- Each statement keeps the citation contract's claim flag and each CV quote is stored as a claim, shown under the
  shared Claim tag, never highlighted as cited evidence.
- "Summary unavailable" shows the levels of the snapshot the member joined with, read by its id after getPack has
  authorised the job, instead of the latest result when it happens to match.
- "What the job needs" (never "role" for a job), neutral "None stated in this summary." for an empty section, the
  deviations for model wording and the Round 1 score change, the need bars' "names no source" shortcut, the
  transaction-length shortcut, a required shortlistReady, and the unused preview key removed.
- A hiring owner following a card's source reaches the profile's evidence, never a raw file or contact detail
  (Playwright).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nd one DecisionsRecorded.v1 proved

recordDecisions returns when the decisions were recorded, so the confirmation and the
read-only choices show at once, before the page is read again. The section is the shared
Card; the remaining artboard differences are listed with their reasons. The record is
proved to write exactly one DecisionsRecorded.v1 and nothing that could reach a
candidate. Error text in the error tone; names computed once.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

# Conflicts:
#	apps/web/src/features/decision-pack/services/loadPack.ts
#	modules/decisions/src/composition.ts
@ALFRED-LUCIFER

Copy link
Copy Markdown
Owner Author

Re-review nits: (2) the heading level is now listed in the deviations. (1) the README line for recordDecisions doesn't mention its { decidedAt } return; the contract's JSDoc does, which is where callers read it. (3) the unreachable ?? '' in DecisionPack.tsx:112 is cosmetic. Neither (1) nor (3) is worth a CI cycle; fold them in when those files are next touched.

ALFRED-LUCIFER and others added 2 commits November 26, 2026 20:09
…, CI flakes fixed at their cause

- AiUnavailable carries a typed `transient` flag (timeout, retryable status, open circuit, budget store). The pack
  summary job reschedules only those, carries on with the remaining members and asks again once at the end, for up to
  6 hours after a member joined; a 4xx (Azure's content filter), an answer over the token cap, no AI service, or an
  outage past the window stores the member "Summary unavailable".
- @3: a strength naming a competency must cite the facts line naming it, checked in code (`competency_uncited`); the
  judge passed @2's uncited names in 3 of 3 runs even with Huda's rubric naming the rule. The focus is a noun phrase,
  and the number rule names a counting word. All three cases re-recorded live, each with a live verdict; Huda's rubric
  names what her excerpts state. evals/config.ts records the judge's miss as a shortcut.
- CI run 45877523565: settings.spec saved before the form hydrated (a native submit the form never saw), so it now
  saves again until the form answers; score-preview's seven-scenario test passed 30 s on the runner with every
  navigation about 2 s, so it gets a 90 s budget; the ranking's first render after sign-in took over 5 s there, so its
  title gets 15 s.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…AsSystem, ADR-006 for @3 and transient retries

- The card reads "advance, and look into <focus> next", with fixtures holding the noun phrase the model now gives.
- The statement-level claim flag, never rendered, is dropped; each citation keeps its own (a CV quote under the Claim
  tag).
- readSnapshot is readSnapshotAsSystem; the pack page header says "What the job needs", lists the Claim tag and that
  claims are never highlighted, and names the code-decided action and the focus wording as deviations.
- The hiring owner's profile check names where the file-link rule is proven (loadProfile.test.ts: a file-backed item,
  a recruiter's link as the positive control; seesFiles forced true made it fail).
- ADR-006 records @3, the transient-only retry and its 6-hour window, the judge's misses, ADVANCE_SHARE's file and
  this round's live runs (task 3 of 3, judge golden cases 3 of 3).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ALFRED-LUCIFER and others added 5 commits November 26, 2026 20:20
…r@3, transient outages)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

# Conflicts:
#	apps/web/src/features/decision-pack/components/DecisionPack.test.tsx
#	apps/web/src/features/decision-pack/components/DecisionPack.tsx
#	modules/decisions/src/composition.ts
…xcerpt first, the retry window from joining

- competency_uncited matched names as substrings, so a short name ("AI", "Go") inside a word ("maintains",
  "algorithm") rejected every honest strength; names now match as whole phrases, in the text and in the quote.
- A strength's first citation must be the excerpt it is about, checked in code (it was prompt-only).
- The outage window is tested from a member's addedAt (13:00, now 14:00, pack prepared 08:00: rescheduled).
- settings.spec: the form is server-rendered, so a field typed into before hydration loses its value to the loaded
  state; each edit-and-save step after a load now retries until the form answers with the edited value.
- The prompt file's comment reads "look into <focus> next".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ited, work cited first)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…f competency names tested

- settings.spec: "Use default" shows only while the value differs from the default, so the restore step clicks it
  only when it is there; the two save steps wait the default time for "Settings saved" and the value (only the
  out-of-range check, which never reaches the server, keeps the quick retry).
- decisions.summariseMember's competency check is tested for a lower-case name and a name with regex characters
  ("C++"), with their mutation checks; its docstring says a strength's first citation is inspected work.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… eval tests)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ALFRED-LUCIFER
ALFRED-LUCIFER changed the base branch from feat/AIV-P2-011-pack-recommendation to main November 26, 2026 19:51
main's tree equals the #640 head (df40c17) already merged here, so every conflict
resolves to this branch's version: #125's content as on main plus this layer's additions.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[AIV-P2-012] Record decisions as the authorised hiring owner

1 participant