fix(isms): production-deploy review follow-ups (CS-701)

Merged
TO
4mo ago
+42-7

Why

The main→release production-deploy PR (#3364) got an automated review that flagged 4 ISMS issues in the CS-701 versioning work (already merged to main). This PR fixes the real ones. Base is main (stage); it flows to release (production) on the next deploy.

What (each maps to a flagged issue)

  • P2 — hasApprovedVersion could report false for an approved doc. The migration intentionally drops legacy (pre-CS-701, snapshot-less) version rows but preserves the approved status, leaving currentVersionId null. hasApprovedVersion now checks currentVersionId != null || status === 'approved', so those docs stay consistent (they capture a real versioned artifact on their next approval). Locked with a unit test.
  • P3 — Scope form showed stale text after "Generate from platform data" / reload. ScopeForm reads its defaults at mount; its remount key tracked the published currentVersionId, which doesn't change when the draft does. The key now reflects draftNarrative, so the form re-seeds on draft changes. (LeadershipForm already handled this via a reset effect; ScopeForm's narrative is a fresh object each render, so keying is the clean equivalent.)
  • P3 — export DTO description was misleading. It said omitting versionId exports the working draft, but runtime serves the current published version when one exists. Description updated to match.
  • P3 — approval banner rendered v 2 instead of v2 (JSX split the v and the number). Now a single expression.

Not changed (by design)

The migration stays non-destructive (approvals preserved rather than reset to draft). The hasApprovedVersion fix makes that state self-consistent, so no destructive reset or heavy backfill is needed for pre-GA (flag-gated) data.

Testing

  • 319 API + 123 app ISMS tests passing, typecheck clean on both.

Follows up on #3361 (CS-701). Flagged in #3364.

🤖 Generated with Claude Code

https://claude.ai/code/session_012CweXoSSEP89mX93u3Bdcp


Summary by cubic

Fixes ISMS follow-ups from CS-701 versioning to keep approval state accurate and refresh scope text, plus minor UI/DTO copy corrections for a cleaner publish/export experience.

  • Bug Fixes
    • hasApprovedVersion now true when currentVersionId exists or status === 'approved' (covers pre-versioning approvals); adds unit test.
    • Scope form remounts when draftNarrative changes so generated/reloaded text appears immediately.
    • Export DTO description corrected: omitting versionId exports the current published version, or the draft if never published.
    • Approval banner now renders (v2) instead of v 2.