diff --git a/.github/workflows/hr-workspace-qualification-rule-review-state.yml b/.github/workflows/hr-workspace-qualification-rule-review-state.yml new file mode 100644 index 000000000..4906a1b62 --- /dev/null +++ b/.github/workflows/hr-workspace-qualification-rule-review-state.yml @@ -0,0 +1,55 @@ +name: HR Workspace Qualification Rule Review State Quality + +on: + pull_request: + branches: + - develop + - feat/hr-workspace-protected-read-state + paths: + - "apps/hr-workspace/qualification-rule-review-state.js" + - "apps/hr-workspace/qualification-rule-review-state.css" + - "apps/hr-workspace/qualification-rule-review-state.stories.js" + - "tests/hr-workspace-qualification-rule-review-state.test.mjs" + - "docs/traceability/hr-workspace-qualification-rule-review-state.md" + - "docs/doctoring/hr-workspace-qualification-rule-review-accessibility-references.md" + - ".github/workflows/hr-workspace-qualification-rule-review-state.yml" + workflow_dispatch: + +permissions: + contents: read + +concurrency: + group: hr-workspace-qualification-rule-review-state-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +jobs: + qualification-rule-review-state: + name: Qualification-rule review state contract + runs-on: ubuntu-latest + timeout-minutes: 10 + steps: + - name: Checkout exact candidate + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + ref: ${{ github.event.pull_request.head.sha || github.sha }} + persist-credentials: false + - name: Prove exact candidate checkout + env: + ORGMETRA_EXPECTED_HEAD_SHA: ${{ github.event.pull_request.head.sha || github.sha }} + run: test "$(git rev-parse HEAD)" = "$ORGMETRA_EXPECTED_HEAD_SHA" + - name: Set up Node.js LTS + uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 + with: + node-version: "24" + check-latest: false + - name: Run qualification-rule review accessibility contract with exact coverage + run: >- + node --test --experimental-test-coverage + --test-coverage-lines=100 + --test-coverage-branches=100 + --test-coverage-functions=100 + tests/hr-workspace-qualification-rule-review-state.test.mjs + - name: Require clean checkout + run: | + git diff --exit-code + test -z "$(git status --porcelain)" diff --git a/apps/hr-workspace/qualification-rule-review-state.css b/apps/hr-workspace/qualification-rule-review-state.css new file mode 100644 index 000000000..d0e6de1e5 --- /dev/null +++ b/apps/hr-workspace/qualification-rule-review-state.css @@ -0,0 +1,58 @@ +.qualification-rule-review-state { + display: grid; + gap: var(--orgmetra-space-md); + max-width: 40rem; + padding: var(--orgmetra-space-lg); + border: 1px solid var(--orgmetra-border-subtle); + border-radius: var(--orgmetra-radius-md); + background: var(--orgmetra-surface-card); + color: var(--orgmetra-text-primary); +} + +.qualification-rule-review-status, +.qualification-rule-review-next-action { + display: grid; + gap: var(--orgmetra-space-xs); + margin: 0; +} + +.qualification-rule-review-status span, +.qualification-rule-review-next-action span { + color: var(--orgmetra-text-muted); +} + +.qualification-rule-review-state[data-interaction-state="high-risk-confirmation"] { + border-color: var(--orgmetra-action-review); +} + +.qualification-rule-review-state[data-interaction-state="permission-denied"], +.qualification-rule-review-state[data-interaction-state="validation-error"], +.qualification-rule-review-state[data-interaction-state="error"] { + border-color: var(--orgmetra-danger); +} + +.qualification-rule-review-state[aria-busy="true"] { + cursor: progress; +} + +.qualification-rule-review-submit { + justify-self: start; + min-height: 44px; + padding: var(--orgmetra-space-sm) var(--orgmetra-space-md); + border: 0; + border-radius: var(--orgmetra-radius-sm); + background: var(--orgmetra-action-review); + color: #fff; + font: inherit; + cursor: pointer; +} + +.qualification-rule-review-submit:disabled { + cursor: wait; + opacity: 0.62; +} + +.qualification-rule-review-submit:focus-visible { + outline: 3px solid var(--orgmetra-focus-ring); + outline-offset: 3px; +} diff --git a/apps/hr-workspace/qualification-rule-review-state.js b/apps/hr-workspace/qualification-rule-review-state.js new file mode 100644 index 000000000..a2c0d1964 --- /dev/null +++ b/apps/hr-workspace/qualification-rule-review-state.js @@ -0,0 +1,86 @@ +const STATE_MODELS = Object.freeze({ + idle: Object.freeze({ + ariaBusy: 'false', ariaLive: 'polite', role: 'status', submitDisabled: false, + interactionState: 'default', actionLabel: 'Load qualification evidence', + label: 'Review qualification-rule evidence', + message: 'Load fresh Job, Job Analysis, Task, KSAO, and source evidence before making a human qualification-rule review.', + nextAction: 'Load the current governed qualification evidence for one Job.', + }), + loading: Object.freeze({ + ariaBusy: 'true', ariaLive: 'polite', role: 'status', submitDisabled: true, + interactionState: 'loading', actionLabel: 'Loading qualification evidence', + label: 'Loading governed qualification evidence', + message: 'Orgmetra is waiting for fresh Job and Job Analysis evidence. No cached qualification rule is accepted.', + nextAction: 'Wait for the current evidence load to finish.', + }), + review: Object.freeze({ + ariaBusy: 'false', ariaLive: 'polite', role: 'status', submitDisabled: false, + interactionState: 'high-risk-confirmation', actionLabel: 'Confirm human review', + label: 'Qualification rule requires human confirmation', + message: 'This is read-only evidence for human review. It does not evaluate, rank, reject, or advance a candidate and does not authorize an employment decision.', + nextAction: 'Confirm the reviewed Task, KSAO, and source evidence before recording the human review.', + }), + recording: Object.freeze({ + ariaBusy: 'true', ariaLive: 'polite', role: 'status', submitDisabled: true, + interactionState: 'loading', actionLabel: 'Recording human review', + label: 'Recording human qualification-rule review', + message: 'Orgmetra is recording the human review evidence. Duplicate submission is disabled.', + nextAction: 'Wait for immutable qualification-rule review evidence to be recorded.', + }), + recorded: Object.freeze({ + ariaBusy: 'false', ariaLive: 'polite', role: 'status', submitDisabled: true, + interactionState: 'read-only', actionLabel: 'Review recorded', + label: 'Human qualification-rule review recorded', + message: 'The recorded review is evidence only and does not activate the rule, screen a candidate, or authorize an employment decision.', + nextAction: 'Return to Job Analysis or continue only through the separately authorized authoritative qualification-rule boundary.', + }), + denied: Object.freeze({ + ariaBusy: 'false', ariaLive: 'assertive', role: 'alert', submitDisabled: false, + interactionState: 'permission-denied', actionLabel: 'Review access', + label: 'Qualification-rule review access denied', + message: 'The current purpose or reviewer authority does not permit this qualification-rule review.', + nextAction: 'Check the access purpose and reviewer authority before trying again.', + }), + stale: Object.freeze({ + ariaBusy: 'false', ariaLive: 'assertive', role: 'alert', submitDisabled: false, + interactionState: 'validation-error', actionLabel: 'Reload evidence', + label: 'Qualification evidence is stale', + message: 'The Job, Job Analysis, Task, KSAO, or source evidence changed before review recording.', + nextAction: 'Reload authoritative Job and Job Analysis evidence before reviewing again.', + }), + blocked: Object.freeze({ + ariaBusy: 'false', ariaLive: 'assertive', role: 'alert', submitDisabled: false, + interactionState: 'validation-error', actionLabel: 'Review evidence scope', + label: 'Qualification-rule review is blocked by evidence scope', + message: 'The reviewed qualification rule is not fully supported by the governed Task, KSAO, and source evidence required for this Job.', + nextAction: 'Resolve the Task, KSAO, and source evidence scope before reviewing the qualification rule again.', + }), + error: Object.freeze({ + ariaBusy: 'false', ariaLive: 'assertive', role: 'alert', submitDisabled: false, + interactionState: 'error', actionLabel: 'Retry governed load', + label: 'Qualification-rule review unavailable', + message: 'The governed evidence or immutable review service did not return a usable result. No cached review is accepted.', + nextAction: 'Do not rely on cached qualification evidence; verify the service and authorization before retrying.', + }), +}); + +function requireExactState(value) { + if (typeof value !== 'string') { + throw new TypeError('qualification-rule review state must be an exact built-in string'); + } + const model = Object.hasOwn(STATE_MODELS, value) ? STATE_MODELS[value] : undefined; + if (!model) throw new TypeError(`unsupported qualification-rule review state: ${value}`); + return model; +} + +/** Return immutable, value-minimized accessibility semantics for one qualification-rule review state. */ +export function qualificationRuleReviewViewModel(state) { + return requireExactState(state); +} + +/** Render one static Storybook proof without accepting caller-controlled HR or candidate values. */ +export function qualificationRuleReviewStateMarkup(state) { + const model = requireExactState(state); + const disabled = model.submitDisabled ? ' disabled' : ''; + return `
\n

${model.label}${model.message}

\n

Next action${model.nextAction}

\n \n
`; +} diff --git a/apps/hr-workspace/qualification-rule-review-state.stories.js b/apps/hr-workspace/qualification-rule-review-state.stories.js new file mode 100644 index 000000000..00d7e1ee1 --- /dev/null +++ b/apps/hr-workspace/qualification-rule-review-state.stories.js @@ -0,0 +1,26 @@ +import { qualificationRuleReviewStateMarkup } from './qualification-rule-review-state.js'; +import './qualification-rule-review-state.css'; + +export default { + title: 'HR Workspace/Qualification Rule Review States', + parameters: { + design: { + type: 'figma', + url: 'Orgmetra Baseline — Storybook Inventory node 1:64', + }, + }, +}; + +function story(state) { + return () => qualificationRuleReviewStateMarkup(state); +} + +export const Idle = story('idle'); +export const Loading = story('loading'); +export const HighRiskHumanReview = story('review'); +export const Recording = story('recording'); +export const RecordedReadOnly = story('recorded'); +export const PermissionDenied = story('denied'); +export const StaleEvidence = story('stale'); +export const EvidenceScopeBlocked = story('blocked'); +export const Error = story('error'); diff --git a/docs/doctoring/hr-workspace-qualification-rule-review-accessibility-references.md b/docs/doctoring/hr-workspace-qualification-rule-review-accessibility-references.md new file mode 100644 index 000000000..ec5258e92 --- /dev/null +++ b/docs/doctoring/hr-workspace-qualification-rule-review-accessibility-references.md @@ -0,0 +1,21 @@ +# HR Workspace qualification-rule review accessibility references + +Status: **active PR research/doctoring**. These references support the interaction semantics; they are not a claim of product certification or protected-`develop` conformance. + +## Applied decisions + +- Use native button semantics and expose busy/live state explicitly so assistive technology can receive state changes without converting the entire review surface into an application widget. +- Keep the high-impact qualification review as an explicit human-confirmation state. The state itself does not execute screening, ranking, rejection, advancement, or an employment decision. +- Preserve a visible keyboard focus indicator and a minimum 44 CSS-pixel action height in the workflow-specific proof. +- Error, denial, stale-evidence, and blocked-scope states use assertive alert semantics and always give a concrete next action. +- Loading and recording disable duplicate submission while preserving a polite status announcement. + +## Primary final standards + +World Wide Web Consortium. (2023, October 5). *Web Content Accessibility Guidelines (WCAG) 2.2* (W3C Recommendation). https://www.w3.org/TR/WCAG22/ + +World Wide Web Consortium. (2023, June 6). *Accessible Rich Internet Applications (WAI-ARIA) 1.2* (W3C Recommendation). https://www.w3.org/TR/wai-aria-1.2/ + +## Scope note + +WCAG 2.2 is the current completed W3C Recommendation used here for accessibility design guidance. WAI-ARIA 1.2 is the completed Recommendation used for roles, states, and properties; later ARIA work remains draft and is not treated as the normative production baseline for this slice. diff --git a/docs/traceability/hr-workspace-qualification-rule-review-state.md b/docs/traceability/hr-workspace-qualification-rule-review-state.md new file mode 100644 index 000000000..f0de2fecd --- /dev/null +++ b/docs/traceability/hr-workspace-qualification-rule-review-state.md @@ -0,0 +1,45 @@ +# HR Workspace qualification-rule review state traceability + +Status: **active PR only**. This document does not claim protected-`develop` availability. + +## Ownership and dependency boundary + +- Shared protected-read accessibility owner: PR #130, `feat/hr-workspace-protected-read-state`. +- Qualification-rule governance owner: PR #104 (`JobQualificationRuleReviewPacket`). Its review evidence remains `not_authorized_for_candidate_or_employment_decision`. +- Qualification-rule persistence owner: PR #105, dependency-first under #104. Persistence does not grant candidate-screening or employment-decision authority. +- This PR owns only the HR Workspace presentation/interaction state contract. It does not duplicate #104/#105 source, persistence, authorization, or decision logic. +- Figma design authority: `Orgmetra Baseline`, Storybook Inventory node `1:64`; required interaction states include default, focus, disabled, loading, validation-error, read-only, and high-risk-confirmation. + +## Buyer-visible contract + +The UI must make the next safe action explicit while keeping qualification evidence human-reviewed and non-authorizing: + +| State | Buyer-visible meaning | Safe next action | +| --- | --- | --- | +| `idle` | No governed qualification evidence loaded | Load current Job/Job Analysis evidence | +| `loading` | Fresh evidence is being resolved | Wait; duplicate action disabled | +| `review` | High-risk human confirmation is required | Confirm reviewed Task/KSAO/source evidence | +| `recording` | Immutable human-review evidence is being recorded | Wait; duplicate submission disabled | +| `recorded` | Review evidence exists; rule is not activated | Return to Job Analysis or a separately authorized authoritative boundary | +| `denied` | Purpose/reviewer authority is insufficient | Review access purpose and reviewer authority | +| `stale` | Job/Job Analysis evidence changed | Reload authoritative evidence | +| `blocked` | Required Task/KSAO/source scope is incomplete | Resolve governed evidence scope | +| `error` | Governed evidence/review service is unusable | Verify service and authorization; do not rely on cached evidence | + +`review` and `recorded` must never imply that Orgmetra evaluated, ranked, rejected, or advanced a candidate. They do not authorize an employment decision. + +## Privacy and data minimization + +State evidence contains only bounded interaction semantics. It must not contain Person/candidate identifiers, names, contact information, raw qualification-rule text, assessment/cut scores, compensation values, credentials/tokens, prompts, or model output. + +## Verification + +The dedicated `HR Workspace Qualification Rule Review State Quality` workflow: + +1. checks out the exact PR head; +2. runs Node.js 24 tests with 100% line, branch, and function coverage thresholds; +3. validates Figma correlation and Storybook state inventory; +4. verifies fail-closed runtime state handling; and +5. requires a clean checkout. + +Focused child evidence is stack-local. After #130 integrates, this child must be retargeted to fresh `develop` and all applicable browser/accessibility/Foundation/Recovery/SAST/Security/central controls must execute again. Parent checks and reviews do not transfer. diff --git a/tests/hr-workspace-qualification-rule-review-state.test.mjs b/tests/hr-workspace-qualification-rule-review-state.test.mjs new file mode 100644 index 000000000..95ba5e099 --- /dev/null +++ b/tests/hr-workspace-qualification-rule-review-state.test.mjs @@ -0,0 +1,146 @@ +import assert from 'node:assert/strict'; +import { readFileSync } from 'node:fs'; +import test from 'node:test'; +import { + qualificationRuleReviewStateMarkup, + qualificationRuleReviewViewModel, +} from '../apps/hr-workspace/qualification-rule-review-state.js'; + +const story = readFileSync( + new URL('../apps/hr-workspace/qualification-rule-review-state.stories.js', import.meta.url), + 'utf8', +); +const css = readFileSync( + new URL('../apps/hr-workspace/qualification-rule-review-state.css', import.meta.url), + 'utf8', +); +const workflow = readFileSync( + new URL('../.github/workflows/hr-workspace-qualification-rule-review-state.yml', import.meta.url), + 'utf8', +); + +const expectedStates = { + idle: ['false', 'status', false, 'default', 'Review qualification-rule evidence'], + loading: ['true', 'status', true, 'loading', 'Loading governed qualification evidence'], + review: ['false', 'status', false, 'high-risk-confirmation', 'Qualification rule requires human confirmation'], + recording: ['true', 'status', true, 'loading', 'Recording human qualification-rule review'], + recorded: ['false', 'status', true, 'read-only', 'Human qualification-rule review recorded'], + denied: ['false', 'alert', false, 'permission-denied', 'Qualification-rule review access denied'], + stale: ['false', 'alert', false, 'validation-error', 'Qualification evidence is stale'], + blocked: ['false', 'alert', false, 'validation-error', 'Qualification-rule review is blocked by evidence scope'], + error: ['false', 'alert', false, 'error', 'Qualification-rule review unavailable'], +}; + +const allowedViewModelKeys = [ + 'actionLabel', + 'ariaBusy', + 'ariaLive', + 'interactionState', + 'label', + 'message', + 'nextAction', + 'role', + 'submitDisabled', +]; + +test('qualification-rule review states are bounded, actionable, and value-minimized', () => { + for (const [state, [ariaBusy, role, submitDisabled, interactionState, label]] of Object.entries(expectedStates)) { + const model = qualificationRuleReviewViewModel(state); + assert.equal(model.ariaBusy, ariaBusy); + assert.equal(model.role, role); + assert.equal(model.submitDisabled, submitDisabled); + assert.equal(model.interactionState, interactionState); + assert.equal(model.label, label); + assert.equal(model.ariaLive, role === 'alert' ? 'assertive' : 'polite'); + assert.match(model.nextAction, /\.$/); + assert.deepEqual(Object.keys(model).sort(), allowedViewModelKeys); + + for (const forbiddenKey of [ + 'personRecordId', + 'candidateReference', + 'candidateName', + 'email', + 'phone', + 'rawQualificationRule', + 'assessmentScore', + 'cutScore', + 'compensationValue', + 'credential', + 'token', + 'prompt', + 'modelOutput', + ]) { + assert.equal(Object.hasOwn(model, forbiddenKey), false); + } + + const markup = qualificationRuleReviewStateMarkup(state); + assert.match(markup, /data-figma-node-id="1:64"/); + assert.match(markup, new RegExp(`data-interaction-state="${interactionState}"`)); + assert.match(markup, new RegExp(`aria-busy="${ariaBusy}"`)); + assert.match(markup, /Next action/); + if (submitDisabled) assert.match(markup, /]* disabled/); + else assert.doesNotMatch(markup, /]* disabled/); + } +}); + +test('human review never implies candidate screening or employment-decision authority', () => { + const review = qualificationRuleReviewViewModel('review'); + assert.match(review.message, /human review/i); + assert.match(review.message, /does not evaluate, rank, reject, or advance a candidate/i); + assert.match(review.message, /does not authorize an employment decision/i); + + const recorded = qualificationRuleReviewViewModel('recorded'); + assert.equal(recorded.submitDisabled, true); + assert.match(recorded.message, /evidence only/i); + assert.match(recorded.message, /does not activate the rule/i); + assert.match(recorded.nextAction, /authoritative qualification-rule boundary/i); +}); + +test('denial, stale evidence, blocked scope, and failure explain the next safe action', () => { + assert.match(qualificationRuleReviewViewModel('denied').nextAction, /access purpose and reviewer authority/i); + assert.match(qualificationRuleReviewViewModel('stale').nextAction, /Reload authoritative Job and Job Analysis evidence/i); + assert.match(qualificationRuleReviewViewModel('blocked').nextAction, /Task, KSAO, and source evidence/i); + assert.match(qualificationRuleReviewViewModel('error').nextAction, /Do not rely on cached qualification evidence/i); +}); + +test('unsupported runtime input fails closed before rendering', () => { + assert.throws(() => qualificationRuleReviewViewModel('approved'), /unsupported qualification-rule review state/); + for (const inheritedState of ['constructor', 'toString', '__proto__']) { + assert.throws( + () => qualificationRuleReviewViewModel(inheritedState), + /unsupported qualification-rule review state/, + ); + assert.throws( + () => qualificationRuleReviewStateMarkup(inheritedState), + /unsupported qualification-rule review state/, + ); + } + assert.throws(() => qualificationRuleReviewViewModel(new String('review')), /exact built-in string/); + assert.throws(() => qualificationRuleReviewStateMarkup(Symbol('recorded')), /exact built-in string/); +}); + +test('Storybook and CSS cover high-risk qualification review accessibility states', () => { + for (const storyName of [ + 'Idle', + 'Loading', + 'HighRiskHumanReview', + 'Recording', + 'RecordedReadOnly', + 'PermissionDenied', + 'StaleEvidence', + 'EvidenceScopeBlocked', + 'Error', + ]) { + assert.match(story, new RegExp(`export const ${storyName}`)); + } + assert.match(story, /qualificationRuleReviewStateMarkup/); + assert.match(css, /var\(--orgmetra-focus-ring\)/); + assert.match(css, /:focus-visible/); + assert.match(css, /\[aria-busy="true"\]/); + assert.match(css, /high-risk-confirmation/); + assert.match(css, /min-height:\s*44px/); +}); + +test('the dedicated contract reruns on protected develop after parent integration', () => { + assert.match(workflow, /branches:\n\s+- develop\n\s+- feat\/hr-workspace-protected-read-state/); +});