feat: add post-generation validation for AI compliance documents #45

Closed
pook wants to merge 1 commit from feature/post-generation-validation into main
Owner

Summary

  • Adds a document-validator service that validates AI-generated compliance documents before returning to users
  • Checks for required sections per document type (privacy policy, ToS, cookie policy), placeholder/incomplete generation markers ([COMPANY NAME], {{template_vars}}, TODO), and HTML injection (<script>, <iframe>, event handlers)
  • Automatically retries generation once on validation failure, with structured JSON logging for monitoring
  • Validation results (valid, failures, retried) are surfaced in the API response meta object

Files Changed

  • packages/api/src/services/document-validator.ts — New validation service
  • packages/api/src/services/document-generator.ts — Integrate validation + retry loop
  • packages/api/src/routes/generate.ts — Surface validation metadata in privacy policy response
  • packages/api/src/routes/generate-tos.ts — Surface validation metadata in ToS response
  • packages/api/tests/unit/document-validator.test.ts — 21 unit tests covering all validation rules

Test Plan

  • 21 unit tests pass (bun test packages/api/tests/unit/document-validator.test.ts)
  • TypeScript type check passes (bun x tsc --noEmit)
  • E2E generation tests (require running API + DB)

🤖 Generated with Claude Code

## Summary - Adds a `document-validator` service that validates AI-generated compliance documents before returning to users - Checks for required sections per document type (privacy policy, ToS, cookie policy), placeholder/incomplete generation markers (`[COMPANY NAME]`, `{{template_vars}}`, `TODO`), and HTML injection (`<script>`, `<iframe>`, event handlers) - Automatically retries generation once on validation failure, with structured JSON logging for monitoring - Validation results (`valid`, `failures`, `retried`) are surfaced in the API response `meta` object ## Files Changed - `packages/api/src/services/document-validator.ts` — New validation service - `packages/api/src/services/document-generator.ts` — Integrate validation + retry loop - `packages/api/src/routes/generate.ts` — Surface validation metadata in privacy policy response - `packages/api/src/routes/generate-tos.ts` — Surface validation metadata in ToS response - `packages/api/tests/unit/document-validator.test.ts` — 21 unit tests covering all validation rules ## Test Plan - [x] 21 unit tests pass (`bun test packages/api/tests/unit/document-validator.test.ts`) - [x] TypeScript type check passes (`bun x tsc --noEmit`) - [ ] E2E generation tests (require running API + DB) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Validates generated documents for required sections, placeholder artifacts,
and HTML injection before returning to users. Retries generation once
automatically on validation failure with structured logging for monitoring.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Author
Owner

Closed 2026-04-10 during pipeline triage.

Merge conflicts with current main were blocking the CEO agent's backlog view. The compliancebot repo had ~60 open PRs and 141 open agent-task issues. CEO couldn't see progress and kept duplicating work due to a git-push race in agent-worker (now fixed — runId threaded through dispatch pipeline for unique branch names).

Reopen / resubmit against current main if the work is still relevant. Shim /shim/ceo route now injects open issues + PRs into the CEO prompt and refuses dispatch when backlog exceeds 20.

Closed 2026-04-10 during pipeline triage. Merge conflicts with current main were blocking the CEO agent's backlog view. The compliancebot repo had ~60 open PRs and 141 open agent-task issues. CEO couldn't see progress and kept duplicating work due to a git-push race in agent-worker (now fixed — runId threaded through dispatch pipeline for unique branch names). Reopen / resubmit against current main if the work is still relevant. Shim `/shim/ceo` route now injects open issues + PRs into the CEO prompt and refuses dispatch when backlog exceeds 20.
pook closed this pull request 2026-04-10 15:08:23 -04:00

Pull request closed

Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
pook/compliancebot!45
No description provided.