Skip to content

[comp] Production Deploy#3496

Merged
tofikwest merged 4 commits into
releasefrom
main
Jul 24, 2026
Merged

[comp] Production Deploy#3496
tofikwest merged 4 commits into
releasefrom
main

Conversation

@github-actions

@github-actions github-actions Bot commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

This is an automated pull request to release the candidate branch into production, which will trigger a deployment.
It was created by the [Production PR] action.


Summary by cubic

Adds residual-risk acceptance events and two new ISMS documents (6.1.2 Risk Assessment Methodology, 6.1.3 Risk Treatment Plan), and fixes device-agent adoption so integration-imported devices adopted by the agent are counted in People (CS-770). Also hardens acceptance creation and approval to prevent races and immediate drift, improves error handling, and tightens submit gating (CS-727).

  • New Features

    • API: append-only RiskAcceptance events for risks and vendors; list and record endpoints with “stale” computed against live residuals.
    • Server parity: risk-level calculation mirrored to match UI; new ISMS endpoint returns Risk Treatment Plan rows and readiness messages.
    • ISMS: risk_assessment_methodology (templated narrative with fixed scales and a computed 5×5 color matrix) and risk_treatment_plan (rows from Risk Register + vendors + latest acceptance).
    • Drift: risk_treatment_plan uses a fingerprint to flag drift; methodology is never platform-stale.
    • Submit gate: requires an owner on every risk and in-scope vendor before approval; RTP submit blocks while readiness is loading or on error; generate revalidates the RTP preview.
    • UI: acceptance dialog and history on risk/vendor pages (owner preselect only when selectable; errors surfaced); new pages for both documents; matrix preview; plan tables with acceptance badges.
    • Exports: matrix cell fills supported in DOCX/PDF; PDF columns floor to header word width; risk-treatment extras threaded into snapshots.
    • Reliability: acceptance create runs in a transaction with an org-scoped row lock; approval collects the drift baseline inside a REPEATABLE READ transaction and retries on write conflict; API docs include 500 responses and document authType (including service).
  • Migration

    • Run Prisma migrate to add RiskAcceptance and extend IsmsDocumentType with risk_assessment_methodology and risk_treatment_plan.
    • Seeding adds the two new ISMS templates; ensureSetup will backfill drafts.
    • No config changes; endpoints honor existing risk/vendor permissions; the ISMS risk-treatment API requires evidence:read.

Written for commit 7446c89. Summary will update on new commits.

Review in cubic

github-actions Bot and others added 2 commits July 22, 2026 20:22
…3 treatment plan documents (CS-727) (#3493)

* feat(risks): risk acceptance events + ISMS 6.1.2/6.1.3 document types (API)

- RiskAcceptance append-only model (risk XOR vendor subject, frozen
  residual rating + acceptor name, CHECK constraint in migration)
- record/list acceptance endpoints on risks + vendors (stale computed
  against live residual rating; no update/delete - immutable)
- server-side risk-level mirror of apps/app risk-score.ts
- 11th ISMS doc type risk_assessment_methodology (6.1.2): fully
  templated narrative incl. 5-point scales, computed 5x5 color matrix,
  acceptance thresholds, treatment options; seeded via ensure-setup heal
- 12th ISMS doc type risk_treatment_plan (6.1.3): rendered live from
  Risk Register + vendors with per-row acceptance state, drift via
  riskTreatmentFingerprint, owner submit gate, page payload endpoint
- renderers: optional per-cell fills for the 6.1.2 risk matrix

* feat(app): acceptance UI + ISMS pages for 6.1.2/6.1.3 documents

- ResidualAcceptanceCard + RecordAcceptanceDialog on risk and vendor
  treatment-plan tabs (record acceptance, stale badge, history)
- useAcceptances hook (list + record; append-only)
- RiskMethodologyClient/Form: editable templated narrative with fixed
  scale labels + read-only computed 5x5 matrix preview
- RiskTreatmentPlanClient: live preview of org + supplier risk tables
  with acceptance badges, server-computed submit blockers
- isms-types: new union members, meta, slugs, narrative + RTP types

* test(risks): acceptance service/controller + 6.1.2/6.1.3 builders and drift coverage

* fix(isms): floor pdf table columns at header word width

Wide tables (the 9-column Risk Treatment Plan) squeezed columns below
their header's width, breaking words mid-word ("Acceptanc/e").

* fix(risks): pre-existing RiskCategory typo in controller spec (operational -> operations)

* chore: cs-727 plan + review notes

* fix(risks): address review round 1 on CS-727

- level labels now use the score-based bands everywhere in the feature
  (acceptances, both documents, matrix preview) — matches RiskScoreBadge /
  TreatmentHero instead of the raw getRiskLevel bands they disagree with
- RTP tables gain the ticket's per-row Status column using the reference
  document's abbreviated headers (Cat./Inh/Treat./Res, defined in the
  cell key); UI table moves Status after Acceptance
- restricted roles: record-acceptance now enforces the same assignment
  gate as the list/read endpoints (access callback run on the loaded
  risk before any write)
- acceptance endpoints extracted to RiskAcceptancesController /
  VendorAcceptancesController (both host files back under 300 lines)
- acceptance queries org-scoped as defense-in-depth; 403 responses
  documented; isms riskTreatment endpoint gains controller +
  permission-metadata specs
- RTP drift fingerprint: includes rendered owner display values (rename
  = drift) and ignores acceptances on archived risks (no false drift)
- RTP preview revalidates on Generate (new IsmsDocumentShell onGenerated)
- methodology form trims whitespace-only input and surfaces per-row
  errors on the labelled-list fields
- acceptance card derives stale client-side from frozen vs live rating
  (no stale-blind cached list); table rows keyed by index

* fix(app): announce methodology and acceptance validation errors to assistive tech

---------

Co-authored-by: Tofik Hasanov <annexcies@gmail.com>
@vercel

vercel Bot commented Jul 24, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
app (staging) Ready Ready Preview, Comment Jul 24, 2026 4:45am
comp-framework-editor (staging) Ready Ready Preview, Comment Jul 24, 2026 4:45am
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
portal (staging) Skipped Skipped Jul 24, 2026 4:45am

Request Review

…s intune device (#3495)

## Problem
A device migrated from Intune integration to Comp AI endpoint agent shows as "missing" in the People tab (Overview) but displays correctly in the Device tab. The customer reported the device was initially imported via Intune, Intune was disconnected, the endpoint agent was installed and confirmed working, but the following morning the device appeared as missing in the People tab only.

## Root cause
When a device migrates from Intune to the endpoint agent (same serial + member), the agent adoption flow in `registerWithSerial` (device-registration.helpers.ts) and `checkIn` (device-agent-auth.service.ts) updates the existing Device row but never sets the `source` field. The row retains `source='integration'` while carrying live agent compliance data. The People tab rollup query filters to only `source='device_agent'` devices (compute-device-status-map.ts:41), so the device is excluded and the member renders as "not-installed" → "Missing". The Device tab lists all devices regardless of source, so it remains visible there. This asymmetry matches the customer's report.

## Fix
Set `source: 'device_agent'` in the agent's adopt and check-in update paths. The change is localized to two code paths (registerWithSerial and checkIn) and backward-compatible: agent rows are already sourced correctly; the Intune sync already refuses to overwrite non-integration serials, so no race condition. No schema change required.

## Explicitly NOT touched
- Offboarding date handling (the customer's mention of an incorrect offboardDate is a separate minor issue and does not affect device display logic, which gates on deactivated/isActive flags)
- The "unable to clear offboardDate" UI issue in EmployeeDetails.tsx (separate bug)
- Device deactivation or member lifecycle logic

## Verification
- Added regression test asserting that when a device transitions from integration source to agent source via checkIn, the source field is updated to 'device_agent' and the device appears in the People-tab rollup query result
- Existing device-registration and device-agent-auth unit tests pass locally ✅

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed

Tip: instead of fixing issues one by one fix them all with cubic

Re-trigger cubic

Comment thread packages/db/prisma/schema/risk-acceptance.prisma
Comment thread apps/api/src/isms/documents/risk-methodology.ts Outdated
Comment thread apps/api/src/risks/risk-acceptances.service.ts Outdated
Comment thread apps/app/src/hooks/use-risk-acceptances.ts Outdated
Comment thread apps/app/src/components/risks/acceptance/RecordAcceptanceDialog.tsx Outdated
Comment thread apps/api/src/isms/utils/pdf-renderer.ts
Comment thread apps/api/src/isms/isms.service.ts Outdated
Comment thread apps/api/src/risks/schemas/risk-acceptances.responses.ts
Comment thread apps/api/src/isms/documents/risk-methodology-defaults.ts
…ft baseline, error surfacing) (#3497)

* fix(risks): cs-727 deploy-review fixes

- acceptance create runs in a transaction with a FOR UPDATE row-lock on
  the subject, so a concurrent residual edit can no longer produce an
  acceptance frozen at a superseded rating
- approve() collects the drift baseline INSIDE the approval transaction
  (collectPlatformData gained an optional client), so a just-approved
  document can't immediately read as stale
- useAcceptances surfaces ApiResponse.error (apiClient never throws);
  the acceptance card renders an error + retry state instead of
  misreporting a failed load as "no acceptance recorded"
- acceptance dialog only preselects the owner when they are selectable
- RTP submit stays blocked while readiness is loading or failed
- methodology matrix intro states score bands AND raw-product bands
  (the previous wording misattributed raw ranges to the score)
- readiness queries extracted to risk-treatment-readiness.ts
- acceptance response schemas document authType/authenticatedUser + 500
- comment fixes: 10-column table note, ISO 27001 attribution

* fix(risks): address review round on the deploy-fix PR

- RTP submit gating fails closed: a load/revalidation error blocks
  submission even when stale cached readiness data is present
- approve() runs REPEATABLE READ (single MVCC snapshot), so the drift
  baseline and the frozen rows can never observe different data; one
  retry on a P2034 write conflict re-runs with a fresh snapshot
- acceptance row locks are org-scoped, so a foreign-tenant id can never
  acquire another organization's row lock
- 500 responses wired into all four acceptance endpoint decorators
- authType documents the 'service' value HybridAuthGuard can return

---------

Co-authored-by: Tofik Hasanov <annexcies@gmail.com>
@vercel
vercel Bot temporarily deployed to staging – portal July 24, 2026 04:42 Inactive
@tofikwest
tofikwest merged commit dab08d5 into release Jul 24, 2026
14 checks passed
@claudfuen

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 3.108.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants