Skip to content

fix(isms): harden internal-audit validation and edge cases from deploy review#3473

Merged
tofikwest merged 2 commits into
mainfrom
tofik/cs-724-deploy-review-fixes
Jul 22, 2026
Merged

fix(isms): harden internal-audit validation and edge cases from deploy review#3473
tofikwest merged 2 commits into
mainfrom
tofik/cs-724-deploy-review-fixes

Conversation

@github-actions

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

Copy link
Copy Markdown
Contributor

Follow-up to #3468, addressing the cubic findings raised on the production deploy PR (#3463) against the merged CS-724 code. Six of the eight findings were real; both remaining ones are answered on their threads.

Fixes

  • Planned-date order enforced — an audit can no longer end before it starts. Client: zod cross-field rule with an inline error on the end-date field. Server: validated on create, and on update against the effective schedule (dto values merged over the stored row), so partial updates can't sneak an inverted range in — while moving both dates together still works.
  • Linked findings always keep a clause label — a finding created (or re-linked) via the API without clauseOrControl now inherits the control row's reference, and deleting a control row first labels any linked label-less findings with its reference. The SetNull FK can no longer strand a finding with neither link nor label in the generated document.
  • Add-control-row form gains the optional Notes field (the table showed the column but the form couldn't fill it).
  • Row editor shows the control-reference validation error instead of a silently disabled Save.
  • Programme read view preserves paragraph breaks (whitespace-pre-wrap) so it matches what was typed.
  • Sign-off "N of 3 signed" badge trims names, matching the API's normalization of whitespace-only signatories to null.
  • Corrected the F-NN doc comment to state the real guarantee (max + 1 over surviving rows).

Answered on the #3463 threads (not changed)

  • F-NN reuse after deleting the newest finding — findings are draft rows until published; every published version freezes its findings in the version contentSnapshot, so a reused reference in a new draft cannot rewrite history. Persisting a sequence table isn't warranted in v1.
  • isms.service.ts length — the file predates the 300-line cap and holds every ISMS document lifecycle gate (roles, monitoring, internal audit) by design; splitting it is a standalone refactor rather than a deploy-review fix.

The ninth finding on #3463 (update-policy-helpers.ts S3 orphan on policy regenerate) belongs to #3471, not CS-724.

Verification

  • 500 ISMS API jest tests green (+6 new: date-order create/update incl. the merged-schedule case, clause-label inheritance and explicit-label precedence, control-delete backfill)
  • 176 ISMS app vitest tests green (+2 new schema tests)
  • bun run --filter '@trycompai/app' build (the Vercel gate) exits 0

Linear: CS-724

…y review

- reject a planned end date before the start date, client-side (zod
  cross-field rule with inline error) and server-side against the
  effective merged schedule on update
- linked findings inherit the control row's reference as their clause
  label when none is given, and deleting a control row labels its
  label-less findings first — no finding is ever left unlabelled
- add the optional Notes field to the add-control-row form
- render the control-reference validation error in the row editor
- preserve paragraph breaks when displaying the programme
- don't count a whitespace-only signatory as signed
- correct the F-NN reference doc comment (max+1 over surviving rows)
@linear

linear Bot commented Jul 22, 2026

Copy link
Copy Markdown

CS-724

@vercel

vercel Bot commented Jul 22, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
comp-framework-editor Ready Ready Preview, Comment Jul 22, 2026 2:08am
2 Skipped Deployments
Project Deployment Actions Updated (UTC)
app Skipped Skipped Jul 22, 2026 2:08am
portal Skipped Skipped Jul 22, 2026 2:08am

Request Review

@tofikwest tofikwest changed the title [dev] [tofikwest] tofik/cs-724-deploy-review-fixes fix(isms): harden internal-audit validation and edge cases from deploy review Jul 22, 2026

@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.

cubic analysis

All reported issues were addressed across 13 files

Confidence score: 5/5

  • Safe to merge after the addressed issues were fixed.

Linked issue analysis

Linked issue: CS-724: [Feature] Area- Internal Audit

Status Acceptance criteria Notes
Enforce planned-date order on create and update (including merged-schedule validation and allowing moving both dates together) Server now asserts date order in create and update (merged schedule check) and client schema enforces the same constraint; unit tests cover rejecting inverted ranges and allowing fixes that move both dates together.
Linked findings always keep a clause label: findings inherit control reference when clauseOrControl omitted; explicit clause text wins; deleting a control backfills label-less linked findings Finding create/update logic now derives clauseOrControl from the linked control when missing; resolveControl returns controlRef; deletion path updates linked findings before deleting the control. Tests exercise inheritance and backfill behavior.
Add optional Notes field to the Add-Control-Row form so the Notes column can be filled on create The Add control form now includes a notes Controller mapped to a Textarea with the Notes placeholder described in the issue.
Row editor surfaces control-reference validation error instead of silently disabling Save The controlRef input is wrapped in Field + FieldError and renders fieldState.error?.message so validation errors will be visible instead of silently disabling save.
Planned end date input surfaces validation errors (client) Planned end date Controller in the form now includes Field + FieldError to show validation messages; the client schema enforces ordering.
Programme read view preserves paragraph breaks Read-only rendering now wraps the programme text with whitespace-pre-wrap so multi-line paragraphs preserve breaks as requested.
Sign-off 'N of 3 signed' badge trims names so whitespace-only signatories don’t count Signed-count logic now trims name values before counting, matching API normalization of whitespace-only signatories to null.

Reply with feedback, questions, or to request a fix.

Fix all with cubic | Re-trigger cubic

Comment thread apps/api/src/isms/isms-audit.service.ts
Comment thread apps/api/src/isms/isms-audit-finding.service.ts
Comment thread apps/api/src/isms/isms-audit-finding.service.ts
Re-read the stored dates inside the locked transaction so two
concurrent partial updates (one moving the start, one the end) can
never persist an inverted schedule. Adds coverage for update-time
clause-label inheritance.
@vercel
vercel Bot temporarily deployed to Preview – portal July 22, 2026 02:07 Inactive
@vercel
vercel Bot temporarily deployed to Preview – app July 22, 2026 02:07 Inactive
@tofikwest
tofikwest merged commit c6c7379 into main Jul 22, 2026
11 checks passed
@tofikwest
tofikwest deleted the tofik/cs-724-deploy-review-fixes branch July 22, 2026 02:18
claudfuen pushed a commit that referenced this pull request Jul 22, 2026
# [3.106.0](v3.105.0...v3.106.0) (2026-07-22)

### Bug Fixes

* **auth:** attribute API-key mutations to the key's creator, not the org owner ([#3472](#3472)) ([206ed96](206ed96)), closes [hi#risk](https://github.com/hi/issues/risk)
* **deps:** bump adm-zip 0.5.18 -> 0.6.0 in apps/api (Dependabot [#88](https://github.com/trycompai/comp/issues/88)/[#89](https://github.com/trycompai/comp/issues/89)) ([#3462](#3462)) ([300f2a1](300f2a1)), closes [#3451](#3451)
* **deps:** override tar to ^7.5.19 to clear node-tar Dependabot alerts ([#94](https://github.com/trycompai/comp/issues/94)-[#104](https://github.com/trycompai/comp/issues/104)) ([#3466](#3466)) ([8ab5709](8ab5709))
* **deps:** patch engine.io ([#93](#93)) and body-parser ([#92](#92)) Dependabot alerts ([#3464](#3464)) ([94c33b1](94c33b1))
* **isms:** harden internal-audit validation and edge cases from deploy review ([#3473](#3473)) ([c6c7379](c6c7379))
* **policies:** create draft version on policy regenerate instead of overwriting published ([#3471](#3471)) ([ff31dbd](ff31dbd))
* **policies:** delete detached PDF objects when regenerating a draft ([#3474](#3474)) ([ecd1bd0](ecd1bd0))
* **policies:** rename CreateVersionDto to avoid swagger collision with automations ([#3469](#3469)) ([2d5290a](2d5290a))

### Features

* **isms:** internal audit programme, plan and report — clause 9.2 (CS-724) ([#3468](#3468)) ([42e5ebd](42e5ebd)), closes [hi#impact](https://github.com/hi/issues/impact)
@claudfuen

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 3.106.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