4.8 KiB
4.8 KiB
id, title, status, wave, depends_on, plan, requirements, acceptance_criteria, system_design
| id | title | status | wave | depends_on | plan | requirements | acceptance_criteria | system_design | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 02-first-message-composition | First-message composition | done | 2 |
|
plan.md |
|
|
|
Task 02: First-message composition
Summary
Compose the original brief with the additional instruction before first-message persistence. Dispatch the selected stored content and its matching trusted expansion.
In scope
- Opt eligible ordinary CREATED direct messages into Task 01 admission.
- Capture and validate the task description after task/session authorization.
- Keep exact equality, empty descriptions, passthrough, saved prompts, references, and attachments correct.
- Preserve visible direct content through workflow composition and session redirection.
- Exclude Office, ephemeral Quick Chat, configuration, and already-prompted sessions.
Out of scope
Do not change unrelated launch policy, historical messages, or public API fields.
Acceptance
TestWSAddMessage_InitialTaskBrieffails on the original branch and then proves saved and captured content contain both texts once.TestStartCreatedSession_InitialTaskBriefproves real launch composition preserves both texts with empty, placeholder, and replacing step templates.- Retry, queued promotion, plan comments, and excluded modes pass their regression cases without a second dispatch.
Verification
Start with failing behavior assertions before implementation. Then run this block from the repository root:
(cd apps/backend && go test -tags fts5 ./internal/task/handlers ./internal/task/service ./internal/orchestrator -run 'InitialTaskBrief|WSAddMessage|StartCreatedSession|InitialPromptFallback' -count=1)
git diff --check
Files likely touched
apps/backend/internal/task/handlers/message_handlers.goapps/backend/internal/task/handlers/message_handlers_initial_task_brief.go (new helper)apps/backend/internal/task/handlers/message_handlers_initial_task_brief_test.go (new)apps/backend/internal/task/service/service_messages.goapps/backend/internal/orchestrator/task_operations.goapps/backend/internal/orchestrator/task_operations_initial_task_brief_test.go (new)
Dependencies
Task 01 must be complete.
Risks
Never trust a browser initial-content flag or client-supplied system block. Do not let a second workflow transform replace already composed direct content. Preserve the original request fingerprint across candidate preparation.
Parallelism
sequential
Inputs
Results
- Composed the raw trimmed task description and first direct instruction before saved-prompt expansion, so both inputs share one acceptance-time snapshot.
- Preserved the selected stored content and its matching trusted prompt context through created-session dispatch and workflow prompt composition, including an explicit accepted-empty expansion state.
- Kept equality, empty descriptions, attachments, saved references, plan comments, queued promotion, session redirection, and excluded modes on their existing paths.
- Added task/session pair authorization before mutable task reads and a stale-description retry that rebuilds only the candidate without repeating turn-start or title hooks.
- Added handler regressions for distinct saved references, brief-only references, identical brief and instruction deduplication, definitions changed after admission, queued delivery, mismatched task/session IDs, stale descriptions, and concurrent first sends.
- Restricted created-session launch to the atomically selected candidate; later contenders use an admission-order queue marker and the queue fast path defers until the selected launch completes.
- Added handler and orchestrator regressions for empty, placeholder, and replacing workflow step prompts.
- Focused handler, service, and orchestrator tests passed, including
TestWSAddMessage_InitialTaskBriefExpandsCombinedPromptAtAdmission,TestWSAddMessage_InitialTaskBriefKeepsAcceptedExpansionWhenDefinitionsChange,TestWSAddMessage_QueuedInitialTaskBriefPersistsAcceptedExpansion,TestWSAddMessage_RejectsMismatchedTaskSessionBeforeReadingTask,TestWSAddMessage_ConcurrentInitialBriefStartsOnlyAdmittedCandidate,TestWSAddMessage_RefreshesStaleBriefWithoutRepeatingTurnStart,TestStartCreatedSession_InitialTaskBrief, andTestApplyWorkflowAndPlanMode_PreservesEmptyAcceptedPromptSnapshot.