Repository navigation
Feat/4 consultation multisource intake - #66
Merged
Merged
Conversation
Introduce the DRAFT consultation status and dedicated draft endpoints so offline-capable clients can persist intake before submission, while preserving direct OPEN submission.
- Add draft to the consultation status enum, JSON Schema, and OpenAPI; recreate ck_consultations_status_values in migration 0005.
- Add POST .../consultations/drafts, PATCH .../consultations/{id}, and POST .../consultations/{id}/submit with idempotency, If-Match, and ETag.
- Grant consultation:update and consultation:submit; restrict draft mutation to the author or a workspace administrator.
- Cover create/edit/submit, repeated submission, optimistic locking, idempotent replay, RBAC, tenant isolation, and concurrent submission in PostgreSQL integration tests.
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
Implements the complete consultation intake domain for EventFlow's Work Management bounded context, including multi-source intake, consultation lifecycle management, persistent drafts, evidence, secure attachments, and auditable history.
This PR builds upon the existing authentication, workspace authorization, persistence, and API contracts delivered by Issues #9, #10, #11, and #12.
The implementation enables consultations to originate from manual input, web applications, VS Code, and desktop clients while preserving tenant isolation, action-level RBAC, transactional consistency, and the established Work Management workflow.
Changes
Motivation
Consultations are the entry point for EventFlow's Work Management workflow.
Before this implementation, the platform had foundational persistence, authentication, authorization, and API contracts but lacked the complete executable intake lifecycle required to receive, manage, and track consultation requests from multiple sources.
This PR provides that foundation while preserving the separation between raw intake, triage, proposals, approvals, and executable work.
A consultation does not automatically create a Proposal, WorkItem, or BoardCard.
Type of Change
Related Issues
Closes #4
Depends on:
Implementation Details
Architecture
The implementation extends the existing Work Management bounded context without introducing a parallel consultation domain.
It reuses:
AuthenticatedPrincipal.The established workflow remains:
Consultation → Triage → Proposal → Review → Approval → WorkItem → BoardCard
Consultation creation and submission do not bypass triage or approval.
Multi-Source Intake
Consultations support the following origins:
All origins use the same consultation domain and persistence infrastructure.
The intake model supports workspace/project association, author identity, descriptions, optional initial classification, repository context, and timestamps.
Consultation Lifecycle
Introduces persistent draft support while preserving direct consultation submission.
The lifecycle includes:
The draft extension preserves the established consultation workflow after submission.
Invalid lifecycle transitions are rejected rather than silently changing downstream workflow state.
Evidence Management
Adds consultation evidence support with validation and persistence.
Evidence is associated with the corresponding consultation and remains subject to workspace/project authorization.
The implementation supports evidence references and attachment associations without bypassing the consultation domain boundary.
Secure Attachments
Implements consultation-scoped attachment handling with security controls.
The implementation includes:
Attachments that have not satisfied the required security checks remain quarantined.
Quarantined attachments cannot be treated as approved consultation evidence.
The implementation does not assume that unverified content is safe.
Consultation History
Implements consultation history using the existing audit infrastructure.
History retrieval provides an auditable view of consultation activity while preserving authorization and tenant isolation.
History pagination is covered by integration tests.
Authorization and Tenant Isolation
Consultation operations integrate with the workspace authorization infrastructure delivered by Issue #9.
Authorization uses the trusted internal user identity established by Issue #10.
Security boundaries include:
Client-provided identifiers do not establish authorization.
Persistence and Migrations
Extends the existing PostgreSQL persistence model through incremental Alembic migrations.
The implementation preserves previously merged migration history.
During final validation, the attachment/evidence migration revision identifier exceeded the 32-character limit of
alembic_version.version_num.The revision was corrected from:
0006_consultation_attachments_evidenceto:
0006_attachments_evidenceThis resolved the migration failure affecting 68 database-backed tests.
API Contracts
Updates:
contracts/openapi/work-management.yamlcontracts/schemas/work_management.yamlThe implementation preserves:
/v1/API conventions.Security Considerations
Authentication
Consultation operations reuse the existing OAuth/OIDC authentication infrastructure.
No alternative authentication mechanism is introduced.
Authorization
Workspace and project permissions are enforced through the existing RBAC architecture.
Unauthorized operations are rejected without granting access to unrelated workspace resources.
Attachment Security
Attachment handling follows a fail-closed policy.
The implementation validates content, type, size, and authorization before permitting access.
Quarantined or rejected content cannot be used as approved evidence.
Tenant Isolation
Consultations, evidence, attachments, and history remain scoped to their authorized workspace and project.
Cross-workspace references cannot establish access rights.
Auditability
Consultation activity integrates with existing audit and security observability mechanisms.
Security-sensitive operations are documented in the updated security specifications.
Testing
The implementation was validated locally using the existing
jsr-testrunnerinfrastructure.Results
The single skipped test requires a live Keycloak environment and belongs to the authentication integration suite.
Verified Scenarios
The attachment integration suite adds 11 tests covering successful operations, invalid inputs, security restrictions, and persistence behavior.
Validation Commands
Pre-commit hooks passed, including:
Documentation
Updated the following documentation:
docs/architecture/work-management-api.mddocs/architecture/work-management-workflow.mddocs/security/untrusted-content.mddocs/security/security-observability.mddocs/security/open-decisions.mddocs/security/traceability.mddocs/security/risk-register.mdThe documentation covers consultation lifecycle changes, evidence and attachment handling, security requirements, observability, and traceability.
Security decisions OD-04 and OD-05 were updated as part of the attachment implementation.
Backward Compatibility
Known Limitations and Reservations
Live Keycloak Integration
One authentication integration test was skipped locally because the live Keycloak stack was unavailable.
This is an existing Issue #10 integration requirement and does not represent a reported failure in the consultation implementation.
Remote CI
Remote CI has not yet been executed for this branch.
The local validation results must be confirmed by GitHub Actions before merging.
External Attachment Security Services
Attachment handling implements fail-closed quarantine behavior.
Any external malware-scanning provider or operational security integration must follow the approved deployment configuration and documented security decisions.
Unverified attachments must not bypass quarantine.
Review Checklist
Commits
27a587c— feat(work-management): implement consultation intake, reads, and triage ([FEAT] Implementar domínio de consultas e intake multiorigem #4)bc788d4— feat(work-management): add draft consultation lifecycle ([FEAT] Implementar domínio de consultas e intake multiorigem #4)a4c8724— feat(work-management): add consultation attachments, evidence, and history ([FEAT] Implementar domínio de consultas e intake multiorigem #4)Outcome
Issue #4 delivers the consultation intake foundation required by EventFlow's Work Management domain.
The implementation supports multi-source intake, persistent drafts, consultation submission, evidence, secure attachments, and auditable history while preserving the existing authentication, authorization, and workflow boundaries.
Local validation completed with 228 passing tests, no reported failures, and one unrelated Keycloak-live test skipped.
Status: Ready for Pull Request review, pending remote CI verification.