Repository navigation
feat(work-management): add differentiated consultation triage and rec… - #68
Merged
Merged
Conversation
32 of 34 tasks
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 Issue #5 by introducing differentiated manual consultation triage for Bug, Feature, and Chore, while preserving existing Docs and Security classifications.
This PR adds authoritative Pydantic discriminated-union validation, category-specific triage templates, explicit manual reclassification, append-only audit history, and consistent authorization enforcement.
The implementation extends the existing Consultation domain delivered by Issue #4 without introducing a separate triage engine or changing downstream approval workflows.
Changes
impact.scope.expected_technical_effect.Motivation
Consultations may represent fundamentally different types of work.
A Bug requires reproduction information, expected and observed behavior, environment details, impact, and severity.
A Feature requires a problem statement, expected value, scope, functional requirements, and acceptance criteria.
A Chore requires maintenance context, technical debt classification, justification, risk of inaction, and expected technical effect.
Applying a single generic validation model to all categories would allow incomplete or semantically inconsistent triage records.
This implementation introduces category-specific validation while keeping classification and reclassification explicitly manual.
It also ensures that consultation triage remains separate from Proposal approval and WorkItem/BoardCard creation.
Type of Change
Related Issues
Closes #5
Depends on:
Implementation Details
Architecture
The implementation extends the existing Work Management Consultation domain.
It reuses:
The established workflow remains:
Consultation → Triage → Proposal → Review → Approval → WorkItem → BoardCard
Manual triage does not automatically create a Proposal, Approval, WorkItem, or BoardCard.
Discriminated Union Validation
Introduces authoritative category-specific Pydantic validation in:
services/triage_criteria.pyThe implementation supports:
The HTTP request model uses a discriminated union based on the
categoryfield.This ensures that category-specific criteria are validated against the corresponding request model rather than accepting arbitrary unstructured data.
The authoritative validation logic is shared with the application service layer.
Bug Triage
Bug classification requires structured defect information.
The criteria include:
The new
impactfield captures the consequences of the defect separately from severity.Feature Triage
Feature classification requires:
The new
scopefield explicitly describes the functional boundaries of the proposed capability.Chore Triage
Chore classification requires:
The new
expected_technical_effectfield describes the intended technical outcome of the maintenance work.Docs and Security Compatibility
Existing DocsCriteria and SecurityCriteria remain supported.
The implementation preserves the established category vocabulary and integrates these categories into the same discriminated-union validation architecture.
No existing category was removed.
Manual Classification
Consultation triage remains an explicit, authenticated user action.
The backend validates:
No automatic AI classification is introduced.
An initial category provided during intake does not bypass the manual triage workflow.
Manual Reclassification
Adds explicit consultation reclassification.
The operation supports:
The audit event is identified as:
consultation.reclassifiedThe audit payload records the previous and new classification snapshots, preserving traceability.
Reclassification does not bypass downstream Proposal or Approval invariants.
Category-Specific Triage Templates
Adds reusable triage template metadata through:
triage_templatesTemplates provide category-specific field definitions for client applications.
This allows future Web, VS Code, and Desktop interfaces to build differentiated forms using consistent backend definitions.
The PR delivers backend template metadata, not frontend form implementations.
HTTP API
Extends:
services/work-management/src/eventflow_work_management/api/consultation_routes.pyThe implementation includes:
New OpenAPI operations:
reclassifyConsultationlistConsultationTriageTemplatesThe existing
triageConsultationoperation remains supported.All operations use the established
/v1/API conventions.Authorization
The triage, reclassification, and template operations declare the following authorized roles:
Authorization behavior:
404.404.403.The implementation reuses the existing authorization services rather than introducing a parallel permission model.
Persistence
No new Alembic migration was required.
The existing Consultation persistence model already contains the
triage_criteriaJSONB field.The implementation reuses that field for validated category-specific criteria.
This avoids unnecessary schema changes and preserves existing migration history.
Idempotency and Concurrency
Manual triage and reclassification integrate with existing idempotency and concurrency mechanisms.
The implementation protects against:
Classification changes and corresponding audit records are handled within the established persistence boundaries.
API Contracts
Updated:
contracts/openapi/work-management.yamlcontracts/schemas/work_management.yamlChanges include:
oneOfand discriminator mapping.ReclassifyConsultationRequest.TriageTemplate.TriageTemplates.The OpenAPI specification remains compatible with OpenAPI 3.1 validation.
Validation Response Semantics
Malformed or mismatched discriminated-union request payloads are rejected with HTTP
400.Previously, some equivalent validation failures were handled at the application service layer with HTTP
422.The existing tests were updated to reflect request-shape validation at the HTTP boundary.
Both
400and422responses remain documented.This response-status change should be considered during client compatibility review.
Security Considerations
Authentication
All protected operations reuse the existing OAuth/OIDC authentication infrastructure.
No alternative authentication mechanism is introduced.
RBAC
Only authorized workspace roles can perform manual triage and reclassification.
Authorization is enforced through the existing application services.
Tenant Isolation
Consultation operations remain workspace-scoped.
Cross-workspace resource identifiers cannot grant access to consultations belonging to another tenant.
Auditability
Reclassification produces an append-only audit event.
Previous classification information remains available for traceability.
Workflow Integrity
Triage cannot directly create:
The existing approval workflow remains authoritative.
Testing
Local Verification Results
The single skipped test is:
test_authentication_keycloak_integration.pyIt requires a live Keycloak environment and is unrelated to the new triage functionality.
Verified Coverage
oneOfand discriminator mapping.Validation Commands
Additional validation:
openapi-spec-validator: passed.Documentation
Updated:
docs/architecture/work-management-api.mddocs/architecture/work-management-workflow.mddocs/security/traceability.mdThe documentation now covers:
Backward Compatibility
Compatibility note: Discriminated-union request-shape violations now return HTTP
400instead of the previous service-level422in affected cases. Clients relying on the old validation status should be reviewed.Known Limitations and Reservations
Live Keycloak Test
One existing Keycloak integration test was skipped locally because the required live authentication stack was unavailable.
Client-Side Forms
This PR provides reusable backend triage templates and API contracts.
The actual Web, VS Code, and Desktop user interfaces are not implemented in this backend issue.
Remote CI
Remote GitHub Actions verification has not yet been executed for this branch.
The PR must pass the required CI checks before merging.
Review Checklist
Commit
6473ed2— feat(work-management): add differentiated consultation triage and reclassification (#5)Base commit:
5041109— Feat/4 consultation multisource intake (#67)Outcome
This PR completes Issue #5 by introducing differentiated, validated, and auditable manual triage for EventFlow consultations.
The implementation establishes consistent category-specific criteria for Bug, Feature, and Chore while preserving Docs and Security compatibility, enforcing workspace authorization, and protecting the existing approval workflow.
Local verification: 244 passed, 0 failed, 1 skipped.
Status: Ready for PR review, pending remote CI verification.