feat: add document history for regeneration comparison #35

Merged
pook merged 1 commit from feature/document-history into main 2026-04-09 06:14:34 -04:00
Owner

Summary

  • Adds document_history table to persist every generated document with metadata (business_id, document_type, content, input_hash, generated_at)
  • Both privacy policy and ToS generation routes now automatically persist results to history after each generation
  • Input hash (SHA-256 of questionnaire + business context) prevents storing exact consecutive duplicates
  • New endpoints: GET /documents/:businessId/history?type=privacy-policy and GET /documents/:id for retrieval

New Endpoints

Method Path Description
GET /documents/:businessId/history?type=<type> List previous generations (max 10, sorted desc)
GET /documents/:id Retrieve a specific historical document

Test plan

  • E2E: History entry created after privacy policy generation
  • E2E: History entry created after ToS generation
  • E2E: History returns all types when no filter specified
  • E2E: Individual document retrieval by ID
  • E2E: 404 for non-existent entries
  • E2E: Descending date order, max 10 limit
  • E2E: Consecutive duplicate prevention via input hash
  • E2E: Invalid type filter returns 400

🤖 Generated with Claude Code

Closes #32

## Summary - Adds `document_history` table to persist every generated document with metadata (business_id, document_type, content, input_hash, generated_at) - Both privacy policy and ToS generation routes now automatically persist results to history after each generation - Input hash (SHA-256 of questionnaire + business context) prevents storing exact consecutive duplicates - New endpoints: `GET /documents/:businessId/history?type=privacy-policy` and `GET /documents/:id` for retrieval ## New Endpoints | Method | Path | Description | |--------|------|-------------| | GET | `/documents/:businessId/history?type=<type>` | List previous generations (max 10, sorted desc) | | GET | `/documents/:id` | Retrieve a specific historical document | ## Test plan - [ ] E2E: History entry created after privacy policy generation - [ ] E2E: History entry created after ToS generation - [ ] E2E: History returns all types when no filter specified - [ ] E2E: Individual document retrieval by ID - [ ] E2E: 404 for non-existent entries - [ ] E2E: Descending date order, max 10 limit - [ ] E2E: Consecutive duplicate prevention via input hash - [ ] E2E: Invalid type filter returns 400 🤖 Generated with [Claude Code](https://claude.com/claude-code) Closes #32
Add document_history table to persist every generated document with
metadata (business_id, document_type, content, input_hash, generated_at).
Both privacy policy and ToS generation routes now persist results to
history. Input hash (SHA-256 of questionnaire + business context)
prevents storing exact consecutive duplicates.

New endpoints:
- GET /documents/:businessId/history?type=privacy-policy
- GET /documents/:id (retrieve specific history entry)

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

Review notes (agent-bot):

  • Issue link: Added Closes #32 to the PR description. ✓
  • SHA-256 input hashing for dedup is a clean approach.
  • Test plan items are all unchecked — these E2E tests should be run and verified before merge.
  • No pagination on the history endpoint (hardcoded max 10) — fine for now, but worth noting if document volume grows.
  • Both generation routes (generate.ts, generate-tos.ts) persist to history inline — if a third document type is added, consider extracting this into shared middleware or a post-generation hook.
**Review notes (agent-bot):** - Issue link: Added `Closes #32` to the PR description. ✓ - SHA-256 input hashing for dedup is a clean approach. - Test plan items are all unchecked — these E2E tests should be run and verified before merge. - No pagination on the history endpoint (hardcoded max 10) — fine for now, but worth noting if document volume grows. - Both generation routes (`generate.ts`, `generate-tos.ts`) persist to history inline — if a third document type is added, consider extracting this into shared middleware or a post-generation hook.
pook merged commit ef29177cbc into main 2026-04-09 06:14:34 -04:00
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!35
No description provided.