Skip to content

AIV-P2-011: show the decision pack with cited strengths, risks and Credalent's recommendation - #640

Merged
ALFRED-LUCIFER merged 21 commits into
mainfrom
feat/AIV-P2-011-pack-recommendation
Nov 26, 2026
Merged

ALFRED-LUCIFER merged 21 commits into
mainfrom
feat/AIV-P2-011-pack-recommendation

Conversation

@ALFRED-LUCIFER

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

Copy link
Copy Markdown
Owner

Ticket

Refs #125 · AIV-P2-011. It also closes the AI-recommendation gap of #570 (AIV-P1-116). The issue closes after the first ai-eval-live on main after merge is linked on it.

Stack: this PR (base main) → #641 (AIV-P2-012)

What changed

The decision pack shows each member's cited strengths, outstanding risks, Round 1 finding and Credalent's recommendation. They are generated once, in the worker, when the pack is built or a member is added, never inside a page request.

AI task decisions.summariseMember@3 (packages/ai/src/prompts/decisions.summariseMember.ts). One call per member. Code enforces (zod schema and domain):

  • The action is decided in code: recommendedAction (domain/summary.ts, ADVANCE_SHARE = 50% of the weight met) gives advance or hold, never reject, and overrides the model's choice. The card stays "Credalent's recommendation"; nothing is pre-selected and nothing moves a stage (AGENTS.md 1.5).
  • No advice: no statement gives advice or calls anything verified, proven or confirmed.
  • Figures: every figure appears in a quote the same statement cites.
  • Strengths: a strength cites inspected work, never only the CV, and its first citation is its excerpt. A strength that names the competency its work backs must cite the facts line naming it (competency_uncited) (AGENTS.md 1.6).
  • Round 1: the finding cites the interview notes.
  • Claims: each citation keeps the contract's claim flag. A CV citation renders as plain text under the shared ProvenanceTag ("Claim awaiting validation"), never in the highlighter.
  • Prompt hygiene: the prompt names none of the expected.text words except "claim", the AGENTS.md 1.6 label the facts lines already carry. It says a strength states what its excerpt states, in its words.

Worker (decisions.pack.summarise on PackReady.v1 and PackMembersAdded.v1; it shares the assessment queue, a shortcut:):

  • The facts are written by code from the snapshot the member joined with, read via readAssessmentAsSystem (composition only, workspace-filtered, under RLS).
  • Each member is summarised once (decisions.inbox).
  • Outages: AiUnavailable now carries a typed transient flag, set by @credalent/ai's client.
    • Transient errors (timeout, retryable status, open circuit, budget store): the job keeps going through the other members and asks again once, 15 minutes later. Retries stop 6 hours after the member joined; then it is stored "Summary unavailable".
    • Non-transient errors (a 4xx including Azure's content filter, over token cap, no AI service) and rejected answers are stored "Summary unavailable" straight away.
    • A spent daily budget reschedules for 00:05 UTC.
  • A shortcut: records that the model call runs inside the consumer transaction, against the message lock.

Migrations (decisions):

  • 0003_member_summaries (Drizzle Kit): member_summary and inbox, each with workspace_id, a tenant policy, a foreign key to the pack member, and a check that a ready row has text and a prompt version.
  • 0004_force_rls_member_summaries: FORCE RLS on both, and the app role loses UPDATE, DELETE and TRUNCATE on member_summary.
  • Nothing is audited, because a summary changes no decision, score or stage.

Web:

  • Pack page: summaries come from the database.
    • "What the job needs", "Competencies and weights", the backed score and range.
    • "Strengths, backed", "Outstanding risks", "Round 1 finding", and "Credalent's recommendation: advance, and look into next". Each inspected statement shows its highlighted quote and links to the evidence item; claims show the Claim tag.
    • States: "Preparing summary", and "Summary unavailable", which shows the joined snapshot's own strengths through readSnapshotAsSystem, after getPack has authorised. Empty sections read "None stated in this summary."
    • The job header's Decision stage reads "Shortlist ready" while an undecided pack exists.
  • Preview ([AIV-P1-116] Preview the shortlist as the hiring owner will see it, in the workspace's branding #570): the same stored text, with sources named but not linked.
  • AIV-P1-116: preview the shortlist as the hiring owner will see it, in the workspace's branding #636's shortcuts are replaced: no model call in either page (so the 240 s ingress risk is gone), and the competency-list stand-ins are replaced by cited text.

Artboard deviations (at the top of DecisionPack.tsx and PackPreview.tsx)

  • "What the job needs" instead of "What the role needs"; the copy test forbids "role" for a job.
  • Card wording is model-generated, not the artboard's sentences.
  • The Round 1 finding shows no score change ("rose from 58 to 68"); its text comes from the interview notes only.
  • Added beyond the artboard: the Claim tag on CV-only citations, and "None stated in this summary." for empty sections.
  • No decision buttons or "Record decisions" here: that is AIV-P2-012: record decisions as the authorised hiring owner; stages update through the outbox #641 (AIV-P2-012).
  • No "Open comparison" (AIV-P1-047). No "for the Head of Engineering" (not stored). "hold" is a second recommendation word.
  • The preview link keeps AIV-P1-116's wording. Cards use the shared Card's 16 px padding. No sidebar count or assistant panel.

How verified

Scenario Unit Integration Playwright
The job and its weights DecisionPack.test — AIV-P2-011 Scenarios
A card cites its evidence DecisionPack.test; eval figure, strength and competency checks Sara's card cites the item by id keyboard to the source link, then to the profile item
The recommendation is labelled; nothing pre-selected DecisionPack.test; recommendedAction at 60%, 50%, 49% and claims only — AIV-P2-011 Scenarios
Text without a valid citation is not shown summaries.test, composition.test Arjun stored unavailable Arjun's card shows "Summary unavailable" with strengths
Loading and empty DecisionPack.test — "Preparing summary"
Access: another workspace gets 404 loadPack.test another job's owner null; interviewer forbidden; W2 null 404 test
Stored once; outages bounded summaries.test; composition.test (each error class, the rescheduled envelope, member 2 not blocked, the 6 h window) redelivery and a new message call no model —
  • Hiring owner (AGENTS.md 1.9): following a card's source reaches the profile's evidence with no contact detail (e2e, with Sara's stored email and phone). Raw files are covered at unit level in loadProfile.test.ts, because the e2e app has no storage account; seesFiles forced true makes 2 tests fail.
  • Integration:
    • RLS on both tables, with the repository filter removed.
    • The app role is refused UPDATE and DELETE.
    • No side effects or audit entries.
    • Tenancy seeds both tables.
  • AI evals:
    • Golden cases Sara (advance), Arjun (hold) and Huda (advance with a focus), re-recorded live on @3, each with code checks and a judge rubric.
    • The expected.judge rubrics were strengthened:
      • arjun-hold: "The KYC document reader excerpt names a service design and an on-call runbook, not that the candidate built, ran or shipped the reader: a strength saying so fails."
      • huda-advance-probe-cost: what her two excerpts state and do not state, and "A strength that names the competency its work backs cites the facts line that names it: one naming a competency with only the excerpt cited fails."
    • New judge cases, both failing as required: pack-sara-invented-work, and pack-arjun-built-and-ran, which replays the @1 invented-work answer.
    • Live (@3, gpt-4.1-mini, judge gpt-4.1):
      • every gate in 3/3 runs;
      • 16/16 judge cases in 3/3 runs;
      • each recorded answer graded 3 more times: Sara, Arjun and Huda each 3/3.
    • Known judge limit, a shortcut: in evals/config.ts and recorded in ADR-006: under a generic rubric the judge passed invented work 5 of 5 times. So each case's rubric names what its excerpts state, and competency naming is checked in code.
  • CI e2e failures fixed (run 45877523565), none caused by this PR's logic:
    • pack-from-ranking:301: the first render took over 5 s; the title assertion now has a 15 s timeout, with a comment.
    • score-preview:179: seven scenarios ran over the 30 s budget on the runner; it gets 90 s with a reason comment, the meeting-summary precedent.
    • settings ("Saving a change…"): a field typed into before hydration kept its loaded value. A shared editAndSave loop now covers all three edit steps (out of range, saving a change, restore default); restore default clicks only while its button shows, and each step still checks the stored value after reload. No assertion was weakened.
  • Mutation checks (each made its test fail):
    • In the schema:
      • the figure, strength, Round 1, advice and competency_uncited rules each removed;
      • competency matching back to plain substrings;
      • the i flag dropped from the competency matcher;
      • the regex escape of competency names dropped (a name like "C++" then throws);
      • "any citation is work" instead of the first;
      • a 400 marked transient in the client.
    • In the outage handling:
      • a non-transient error treated as transient;
      • the transient branch removed;
      • returning at the first outage;
      • the retry window removed;
      • the retry window timed from preparedAt only.
    • In the eval and web code:
      • decisions taken out of the prompt-safety list;
      • the done skip removed;
      • the failed-as-ready branch removed;
      • publishMembersAdded removed;
      • hrefFor emptied;
      • hasFocus emptied;
      • claims highlighted;
      • the joined-snapshot read;
      • ADVANCE_SHARE >= changed to >.
    • In the database:
      • the REVOKE removed;
      • a permissive policy.
  • Local runs:
    • Lint, typecheck and pnpm build pass.
    • Unit: decisions 69, ai 445, web 1069, i18n 47, architecture 75, worker 8.
    • Integration: 71.
    • Playwright pack-from-ranking, job-header, settings and score-preview: 28 passed with retries off.
    • The recorded eval passes for all 12 tasks.

Not done / risk

  • Wording differs from the Gherkin: card text comes from the model, so Playwright checks structure and citations with fixture answers, not the ticket's exact sentences.
  • No regenerate action: after the 6-hour retry window, or on a non-transient error, a member stays "Summary unavailable" (a shortcut:).
  • Long-running job: the model call runs inside the consumer transaction (a shortcut:).
  • Shared queue: pack summaries and DecisionsRecorded.v1 share the assessment queue. A decisions queue needs an infra apply (owner).

🤖 Generated with Claude Code

ALFRED-LUCIFER and others added 14 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>
ALFRED-LUCIFER and others added 2 commits November 26, 2026 19:25
…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>
…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>
ALFRED-LUCIFER and others added 5 commits November 26, 2026 19:38
…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>
…, 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>
…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>
…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>
@ALFRED-LUCIFER

Copy link
Copy Markdown
Owner Author

Final review nit, left as is: the docstring line at decisions.summariseMember.ts:99 is about 144 characters (Prettier doesn't reflow comments, and format:check passes). It's cosmetic and not worth another CI cycle; it will be rewrapped when the file is next touched. The body nits are fixed.

@ALFRED-LUCIFER
ALFRED-LUCIFER merged commit 61ad84f into main Nov 26, 2026
14 checks passed
ALFRED-LUCIFER added a commit that referenced this pull request Nov 26, 2026
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>
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.

1 participant