Repository navigation
Feat/29 entity comments attachments audit - #72
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #29
Implements entity-scoped comments, secure attachments, and immutable audit history for EventFlow's Work Management bounded context.
This PR extends the existing collaboration and evidence infrastructure while preserving workspace isolation, RBAC, approval invariants, and append-only audit guarantees.
The implementation supports comments on Consultations, Proposals, WorkItems, and BoardCards, alongside authorized attachments for Proposals, WorkItems, and BoardCards.
Existing Consultation attachment and evidence infrastructure remains unchanged.
Changes
1. Entity Comments
Implemented persistent comments for:
Capabilities include:
Comment editing is intentionally unsupported.
PostgreSQL triggers prevent unauthorized modification, hard deletion, and truncation of historical comment records.
2. Secure Entity Attachments
Introduced generic attachment support for:
The implementation reuses the existing attachment security model rather than introducing an independent upload pipeline.
Security guarantees include:
Attachment scan outcomes:
Rejected attachments do not retain stored file blobs.
Quarantined and rejected attachments cannot expose content bytes.
Existing Consultation attachment and evidence tables remain untouched.
3. Append-Only Audit History
Implemented read-only entity history projections using the existing Work Management audit infrastructure.
Supported collaboration events include:
comment.createdcomment.deletedattachment.uploadedattachment.rejectedattachment.deletedHistorical records remain append-only.
Database-level protections prevent unauthorized mutation of audit history.
The implementation preserves the existing approval and transition audit infrastructure rather than duplicating it.
4. Authorization and Tenant Isolation
Added the following RBAC actions:
comment:readcomment:createcomment:deleteAuthorization behavior:
Comment authorship is always derived from the authenticated principal.
Client-supplied author identities are never trusted.
5. API and Contract Updates
Implemented 10 API operations under entity-scoped workspace routes.
Operations cover:
Supported route structure:
/v1/workspaces/{workspace_id}/{entity_collection}/{entity_id}/...BoardCard resources use the established flat card path.
The collaboration router is registered after the existing Consultation routes to preserve route precedence and compatibility.
Updated contract definitions include:
EntityCollectionAttachmentEntityCollectionEntityTypeEntityCommentEntityAttachmentIdempotency is supported for comment creation and attachment uploads.
Repeated requests with matching fingerprints return the original resource.
Reusing an idempotency key with a different request fingerprint returns:
409 IDEMPOTENCY_CONFLICT6. Database Migration
Added migration:
0009_entity_collaborationParent revision:
0008_kanban_boards_columnsNew tables:
entity_commentsentity_attachmentsentity_attachment_blobsDatabase protections include:
Existing Consultation attachment tables were preserved.
Migration integration tests validate the schema, triggers, database functions, and migration revision head.
Testing
All reported local validation checks passed.
Additional verification:
The collaboration suite covers:
Validation Checklist
Architectural Decisions
No Direct WorkItem or BoardCard Creation
This PR does not introduce direct WorkItem or BoardCard creation.
The existing architecture requires authorized Proposal approval before executable work is created.
Direct creation remains blocked pending an approved architectural amendment.
Immutable Comments
Comments cannot be edited.
Deletion creates a tombstone rather than removing the historical record.
This preserves accountability and prevents retrospective modification of collaboration history.
Reuse of Existing Audit Infrastructure
Entity history is a read-only projection of existing append-only audit records.
No competing audit subsystem was introduced.
Known Limitations and Risks
Polymorphic Entity References
entity_idis polymorphic and does not have a direct foreign key to every supported entity table.Referential correctness depends on entity resolution and the existing workspace/project constraints.
Review should verify that all write paths enforce these checks consistently.
Workspace and Project Deletion
Database triggers protecting immutable comments may block cascading deletion of workspaces or projects containing historical collaboration records.
A future archival or retention workflow must account for these constraints.
No unrestricted destructive deletion behavior is introduced by this PR.
Row-Level Security
PostgreSQL Row-Level Security remains deferred.
Tenant isolation currently relies on application authorization and query scoping, supported by integration tests.
Idempotency Implementation
Idempotency uses the existing application and database-row mechanism.
Concurrency behavior, crash recovery, and replay guarantees should remain review considerations.
Review Focus
Please pay particular attention to:
Git Information
Branch:
feat/29-entity-comments-attachments-auditBase commit:
557c6e0Commits:
1c2beea— feat(work-management): add entity comments attachments and audit trails ([FEAT] Implementar comentários, anexos e trilha auditável #29)31dc697— test(work-management): cover proposal comments in collaboration suite ([FEAT] Implementar comentários, anexos e trilha auditável #29)Working tree: Clean.
Local verification: 298 passed, 0 failed, 1 skipped.
Final Status
READY FOR PR
Issue #29 has been implemented and verified locally.
The implementation preserves the existing Work Management architecture, extends collaboration capabilities, and provides database-enforced immutable history.
Remote CI execution and Pull Request review remain pending.