Skip to content

feat: detection, control and process improvement register linked to incidents - #101

Merged
jusso-dev merged 1 commit into
mainfrom
feat/issue-66
Jul 28, 2026
Merged

feat: detection, control and process improvement register linked to incidents#101
jusso-dev merged 1 commit into
mainfrom
feat/issue-66

Conversation

@jusso-dev

Copy link
Copy Markdown
Owner

Summary

Implements issue #66: a durable detection / control / process improvement register linked to incidents, post-incident reviews, and playbooks.

This is separate from #64 review_improvement_proposals (lightweight PIR proposals). Those can be promoted into the register via POST /api/v1/improvement-register/from-proposal with immutable source links.

Schema (migration 0039_improvement_register)

  • Types: detection_gap, logging_gap, integration_defect, playbook_defect, security_control_gap, process_failure, training_need, documentation_gap
  • Status lifecycle: openin_reviewacceptedin_progressvalidatedclosed, plus reopened / rejected / deferred
  • Tables: improvement_register_items, improvement_register_links, improvement_register_events
  • Immutable source_* fields + source links (isSource); multi-case links drive recurrenceCount
  • Close requires validationMethod + validationEvidence + actor/timestamp; reopen keeps prior proof in event history
  • External ticket fields are references only (ticket-sync cannot replace owner, links, status, recurrence, or audit)

API (improvements:read / improvements:write)

Endpoint Purpose
GET|POST /api/v1/improvement-register List / create (optional caseId / reviewId)
GET|PATCH /api/v1/improvement-register/{id} Read / update
POST .../links, DELETE .../links/{linkId} Link cases/reviews/proposals/playbooks
POST .../close, POST .../reopen Validated close; reopen preserves history
POST .../ticket-sync Bounded external ticket ref/sync state
GET .../events Append-only lifecycle history
POST .../suggestions Similarity matches with explained fields (autoMerge: false)
GET .../dashboard Recurring themes, severity, owners, overdue, validation state
POST .../from-proposal Consume #64 proposal (idempotent)

Case-linked mutations use authorizeCase. Sensitive evidence redacted without view_sensitive on source/linked cases. Fail-closed empty scopes.

Test plan

  • npm run test:improvement-register (Postgres via DATABASE_URL)
  • tsc --noEmit
  • CI green on PR
  • Manual: create from case, link second case → recurrence, close with validation, reopen, ticket conflict, promote PIR proposal

Residual risks

  • No full drizzle snapshot for 0039 (hand-written SQL + journal entry, same pattern as some prior migrations).
  • Parallel open PR feat: restricted stakeholder portal for updates, evidence requests and approvals #98 (stakeholder portal) previously targeted 0038; main already has console as 0038 — this PR uses 0039. If another PR lands 0039 first, renumber before merge.
  • No UI surfaces yet (API + core only); dashboard is API-only.
  • External ticket sync is a bounded ref API, not a live connector adapter.
  • Similarity is token Jaccard (explainable, not semantic embeddings).

Closes #66

…ncidents

Add an organisation-wide improvement register (issue #66) distinct from
lightweight post-incident review proposals (#64). Records cover detection,
logging, integration, playbook, control, process, training, and documentation
gaps with ownership, due dates, multi-incident links, recurrence, validation
on close, reopen history, and bounded external ticket refs.

- Migration 0039: improvement_register_items/links/events + enums
- Core: create (case/review/manual), promote from #64 proposal, link/unlink,
  close with validation, reopen preserving prior closure events, ticket sync
  that cannot replace ownership/links/audit, similarity suggestions, dashboard
- API under /api/v1/improvement-register with improvements:read|write scopes
- Case-linked authorizeCase; sensitive evidence redacted without view_sensitive
- Tests: suggestions, linking, recurrence, validation, sync conflicts, auth,
  tenant isolation

Closes #66
@jusso-dev
jusso-dev merged commit c464579 into main Jul 28, 2026
3 checks passed
@coderabbitai

coderabbitai Bot commented Jul 28, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@jusso-dev, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 12 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 2bd23fcc-4960-402d-b92e-ca3694c1b25b

📥 Commits

Reviewing files that changed from the base of the PR and between 536eba7 and d21117a.

📒 Files selected for processing (22)
  • docs/api.md
  • drizzle/0040_improvement_register.sql
  • drizzle/meta/_journal.json
  • package.json
  • scripts/test-improvement-register.ts
  • src/app/api/v1/improvement-register/[id]/close/route.ts
  • src/app/api/v1/improvement-register/[id]/events/route.ts
  • src/app/api/v1/improvement-register/[id]/links/[linkId]/route.ts
  • src/app/api/v1/improvement-register/[id]/links/route.ts
  • src/app/api/v1/improvement-register/[id]/reopen/route.ts
  • src/app/api/v1/improvement-register/[id]/route.ts
  • src/app/api/v1/improvement-register/[id]/ticket-sync/route.ts
  • src/app/api/v1/improvement-register/dashboard/route.ts
  • src/app/api/v1/improvement-register/from-proposal/route.ts
  • src/app/api/v1/improvement-register/route.ts
  • src/app/api/v1/improvement-register/suggestions/route.ts
  • src/db/schema.ts
  • src/lib/improvement-register/core.ts
  • src/lib/improvement-register/index.ts
  • src/lib/improvement-register/similarity.ts
  • src/lib/improvement-register/types.ts
  • src/lib/scopes.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/issue-66

Comment @coderabbitai help to get the list of available commands.

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.

[P2] Add a detection, control and process improvement register linked to incidents

1 participant