Repository navigation
Add add_field_values schema op and enum enforcement for task.status - #2586
Conversation
…loses #2585) Implements ADR-076: a new add_field_values update_schema operation that appends EnumValue entries to an existing field's user_values, gated on extensible == Some(true) (independent of protection level, since task.status is protection: Core but extensible: Some(true)) and rejecting any value colliding with the field's combined core_values + user_values. Wires update_task_node to actually validate status against task.status's core_values + user_values at the service layer — previously the store-layer write took any string unconditionally, since TaskStatus::from_str is infallible by construction (unknown values become TaskStatus::User(_)). Drift audit (ADR-076 precondition, given the prior ai-chat.status incident): every update_task_node call site (service layer's sole caller; the daemon gRPC handler, Tauri commands, and integration/e2e tests reaching it) and every direct TaskStatus::User(...) construction in production code and test fixtures were enumerated. All write only the four core status strings already declared in task.status's core_values (open/in_progress/done/ cancelled) — no drift found, so no pre-existing rows needed correction. Added a standing bidirectional test (TaskStatus named variants <-> core_values) to catch the next drift before it repeats that incident. Also corrects a stale doc comment in playbook/engine.rs describing the engine as a "second subscriber... alongside DomainEventForwarder" — that type is desktop-app-only and core has no dependency on it. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01DKZ3pUCsNFMfwaSXV4VrnQ
Code Review SummaryInitial Review. This PR implements ADR-076 in full: a new Requirements Validation (issue #2585 acceptance criteria)
All acceptance criteria are met. FindingsCritical IssuesNone. Suggested Improvements
Nitpicks
Verification Performed
VerdictApprove (net positive, no blockers — the one Suggested Improvement is a real but non-urgent gap worth a follow-up, not a merge blocker). Note: this PR is very likely self-authored from this GitHub account's perspective, so a formal |
malibio
left a comment
There was a problem hiding this comment.
Verdict: APPROVE (net positive, no blockers). GitHub rejects --approve on a self-authored PR, so recording the verdict here explicitly. Full pragmatic code review posted as a PR comment above — all issue #2585 acceptance criteria verified met, drift audit independently re-checked and confirmed accurate, all new tests pass, clippy clean. One non-blocking Suggested Improvement noted (add_field_values's field_type==enum gate is documented but not enforced in code).
The gate only checked extensible, not field_type == "enum", so a hypothetical non-enum field marked extensible: true would silently accept user_values that get_enum_values/get_enum_value_strings (schema_node.rs) would never surface, since those independently gate on field_type == "enum". No seed schema combines the two today, so this was unreachable in practice, but the doc comment already claimed both were enforced. Add the explicit check so behavior matches the doc comment, plus a test proving it. Addresses a Suggested Improvement from the pragmatic-code-review of PR #2586. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01DKZ3pUCsNFMfwaSXV4VrnQ
Address-review summaryAddressed the one Suggested Improvement from the pragmatic-code-review: ✅ Addressed: ⏭️ Skipped: none — the review had only one finding, no Critical/Important items, and two nitpicks explicitly called non-blocking by the reviewer (per-call Verification: Re-Review DecisionDecision: NO RE-REVIEW NEEDED Rationale: The change is a small, additive validation check directly matching the reviewer's own suggested fix, scoped to exactly the gap they identified, with a dedicated regression test and a fully green test suite (unit, clippy, and the pre-push gate). No architectural change, no new functionality beyond the one guard, no interconnected changes elsewhere in the PR. |
Summary
Implements ADR-076 in full:
add_field_valuesschema operation (UpdateSchemaParams/handle_update_schema): appendsEnumValueentries to an existing field'suser_values, gated onextensible == Some(true)(a separate axis fromprotection—task.statusisprotection: Corebutextensible: Some(true), so reusingcan_modify_field'sprotection == Usergate would permanently block the exact field this operation exists to extend). Rejects any value colliding with the field's combinedcore_values+user_values(compared on.value, not.label), including within the same call. Append-only: never touchescore_values, never removes/renames existinguser_values.update_task_node: the service-layer method now validatesstatusagainsttask.status'score_values+user_valuesbefore writing, closing the gap where the store-layer write accepted any string unconditionally (TaskStatus::from_stris infallible by construction — unrecognized values silently becomeTaskStatus::User(_)).ai-chat.statusincident — commit3118001b, 16 daemon tests broken by turning on enforcement blind): enumerated every writer oftask.status.NodeService::update_task_nodeis the sole caller of the store-layerupdate_task_node(grepped.update_task_node(across the repo) — no bypass exists.TaskStatus::User(...)construction and everywith_status(TaskStatus::...)call site in production code and test fixtures (core, daemon, desktop-app, e2e/integration tests). All either exercise theTaskNode/FromStrmodel layer directly (never reachingupdate_task_node's write path) or write one of the four core status strings (open/in_progress/done/cancelled).test_task_status_variants_match_core_values_bidirectionallyincore_schemas.rsassertsTaskStatus's named variants andtask.status's seedcore_valuesstay consistent in both directions, so the next drift is caught before it repeats theai-chat.statusfailure mode.playbook/engine.rsdescribing the engine as a "second subscriber... alongsideDomainEventForwarder" — that type isdesktop-app-only andcorehas no dependency on or awareness of it.Test plan
cargo test -p nodespace-core --lib— 1325 passedcargo test -p nodespace-daemon --lib— 204 passed (the exact suite that broke for theai-chat.statusprecedent; confirms no drift)cargo clippy -p nodespace-core -p nodespace-daemon --lib --tests— cleanbun run test(frontend baseline) — 4951 passed (240 files), matches pre-change baselinebun run test:all— unit + browser + Rust, exit 0bun run quality:fix— 0 errors/warnings (lint, format, typecheck)add_field_valuesextensible-gate, collision (vs core_values, vs existing user_values, within-call duplicate), unknown-field, no-namespace-prefix-required;update_task_noderejects an undeclared status and accepts one added viaadd_field_valuestest:all+cargo build --bin nodespaced+test:e2e) passed🤖 Generated with Claude Code
https://claude.ai/code/session_01DKZ3pUCsNFMfwaSXV4VrnQ