Repository navigation
Description
Overview
task.status is already declared in seed data (packages/core/src/models/core_schemas.rs:52-90) as protection: SchemaProtectionLevel::Core, extensible: Some(true), with an empty user_values: Some(vec![]) placeholder — the schema-side intent to make this field extensible already shipped. But nothing can actually extend it, and nothing enforces it: there is no update_schema operation that appends to an existing field's user_values, and update_task_node's write path performs no enum validation at all today, so status currently accepts any string unconditionally.
Problem Statement
Two gaps, confirmed by direct code read:
- No operation appends to
user_values.UpdateSchemaParams(packages/core/src/schema/mod.rs) supportsadd_fields,remove_fields,rename_fields,add_relationships,remove_relationships, and a handful of top-level metadata fields — nothing appends a value to an already-existing field's enum vocabulary. - No enforcement in
update_task_node's write path. The generic path (validate_node_with_fields,packages/core/src/services/node_service/crud.rs:2107-2165) already validates enum fields correctly for schema-only types.update_task_nodenever calls it: the service-layer method (packages/core/src/services/node_service/schema.rs:215-292) goes straight to the store layer (packages/core/src/db/sqlite_store/nodes.rs:3050-3115), which writes raw SQL with no validation.TaskStatus::from_str(packages/core/src/models/task_node.rs:123-136) is infallible by construction — any unrecognized string silently becomesTaskStatus::User(string).
The extensible: Option<bool> flag itself has zero consumers anywhere in the codebase today — this issue is its first real use.
This matters for methodology bundles (see ADR-075, PlaybookNode): a Linear-style install needs backlog/in_review as real, validated task.status values, not just informally-written strings with no schema backing.
Proposed Solution
Implement ../nodespace-docs/decisions/076-schema-field-value-extension-and-task-status-enforcement.md (ADR-076) in full: a new add_field_values schema operation gated on extensible, plus real enum enforcement in update_task_node's write path.
Architecture Impact
This issue implements ADR-076, a newly-accepted ADR. It does not reverse or supersede any prior decision. It also does not touch SchemaProtectionLevel's existing can_modify_field/can_delete_field gates (protection == User) — add_field_values is a new, independent gate on extensible, deliberately not reusing that machinery (see ADR-076's "Why this can't reuse existing protection machinery").
Implementation Approach
1. add_field_values schema operation
- Add to
UpdateSchemaParams(packages/core/src/schema/mod.rs), alongsideadd_fields/remove_fields/rename_fields. - Gate: target field's
extensible == Some(true). Reject (matchingcan_modify_field/can_delete_field's existing rejection pattern) ifextensibleisNoneorSome(false). - Append-only: only adds to
user_values, never touchescore_values, never removes/renames existinguser_valuesentries. - Collision check required: reject an attempt to add a value string that already exists in the field's combined
core_values+user_values, compared onEnumValue.value(the machine-comparable string, not.label, which is display text and may legitimately repeat). This prevents two independently-authored methodology bundles from silently colliding on a bare value likein_reviewwith different intended semantics — see ADR-076's namespace-prefix note for why this is a collision-detection problem, not a prefixing-convention problem. - No namespace-prefix requirement for values (ADR-063 governs field names, not enum values — see ADR-076).
2. Enum enforcement in update_task_node
- Wire
update_task_nodeto validatestatusagainstcore_values+user_values, mirroringvalidate_node_with_fields's existing check. - Enforce at the service layer (
packages/core/src/services/node_service/schema.rs) — the store layer trusts the service layer and does not independently re-validate, consistent with the rest of the store layer's existing assumptions. - Confirm during implementation that no other caller reaches the store-layer
update_task_nodemethod directly, bypassing the service layer. If one exists, either route it through the service layer or give the store layer its own copy of the check.
3. Drift audit (precondition, not follow-up)
There is real precedent for this failing badly: enabling enum validation for ai-chat.status broke 16 daemon tests because the schema's declared vocabulary and the code actually writing status values had silently drifted apart (packages/core/src/services/node_service/crud.rs:2178-2181, commit 3118001b). Before enforcement ships:
- Enumerate every writer of
task.statusmechanically — every call site ofupdate_task_node, plus every direct construction ofTaskStatus::User(...)in production code and test fixtures. List the resulting call sites explicitly in the PR, not just "audited." - For each, confirm the status strings it can produce are a subset of
core_values+user_values. Resolve any drift found (add tocore_valuesif legitimate, fix the writer if stray) before enforcement lands. - Any pre-existing database rows with a now-invalid
statussurfaced by this audit must be resolved as part of the audit (corrected or added tocore_values) — there is no backfill path (per this repo's no-migration policy), so such a row becomes un-updatable viaupdate_task_nodeuntil resolved.
4. Standing consistency test
Add a unit/integration test asserting TaskStatus's named variants and task.status's seed core_values stay consistent in both directions — no named variant missing from core_values, no core_values entry without a corresponding variant (or reachability via TaskStatus::User). This is what catches the next drift before it repeats the ai-chat.status failure mode; the one-time audit alone only proves correctness at the moment it runs.
5. Cleanup while in this area (minor, unrelated to the above)
packages/core/src/playbook/engine.rs:33-34 has a stale doc comment describing the playbook engine as "a second subscriber on the broadcast channel, alongside DomainEventForwarder" — DomainEventForwarder is desktop-app-only per ../nodespace-docs/architecture/crate-boundaries.md, and no such dependency exists in the actual code (confirmed: core has no DomainEventForwarder reference anywhere). This framing was already identified as a doc error and corrected in playbook-engine.md, but this inline comment was missed. One-line fix, bundled here as incidental cleanup rather than filed separately.
Acceptance Criteria
-
add_field_valuesschema operation implemented, gated onextensible == Some(true) -
add_field_valuesrejects duplicate values (collision check onEnumValue.valueacrosscore_values+user_values) -
update_task_nodeenforcesstatusagainstcore_values+user_valuesat the service layer - Confirmed (and fixed if needed) that no caller bypasses the service layer to reach the store-layer write directly
- Drift audit performed and documented in the PR: every
task.statuswriter enumerated, any drift resolved - Any pre-existing invalid-status rows surfaced by the audit are resolved
- Standing consistency test added (
TaskStatusvariants ↔core_values, bidirectional) - Stale
DomainEventForwarderdoc comment inpackages/core/src/playbook/engine.rs:33-34corrected - Tests pass (
bun run test:all) - Code passes
bun run quality:fix
Technical Specifications
Reference Files
packages/core/src/schema/mod.rs—UpdateSchemaParams, whereadd_field_valuesis addedpackages/nodespace-types/src/schema.rs—SchemaField,core_values/user_values/extensible,EnumValuepackages/core/src/models/schema_node.rs:280-330—get_enum_values/get_enum_value_strings,can_modify_field/can_delete_field(the gate pattern to follow, not reuse)packages/core/src/models/core_schemas.rs:52-90—task.status's existing seed declarationpackages/core/src/services/node_service/schema.rs:215-292—update_task_nodeservice-layer methodpackages/core/src/db/sqlite_store/nodes.rs:3050-3115—update_task_nodestore-layer methodpackages/core/src/services/node_service/crud.rs:2107-2165—validate_node_with_fields, the existing correct enum-validation pattern to mirrorpackages/core/src/services/node_service/crud.rs:2178-2181— theai-chat.statusincident precedentpackages/core/src/models/task_node.rs:109-136—TaskStatusenum,FromStrimplpackages/core/src/playbook/engine.rs:33-34— stale comment to fix (item 5)../nodespace-docs/decisions/076-schema-field-value-extension-and-task-status-enforcement.md— the ADR this issue implements../nodespace-docs/decisions/063-namespace-prefixes-scope.md— why prefixing doesn't apply to enum values (context only)
Dependencies
- None
Related Issues
- Enables future methodology-bundle work (ADR-075, PlaybookNode) that needs real validated status vocabularies (e.g. Linear-style
backlog/in_review)
Non-Goals
- Any specific methodology bundle's concrete schema (Linear-style, Jira-style, spec-driven) — this issue implements the extension mechanism only
- A general-purpose enum-editing operation (rename/remove existing
user_values) —add_field_valuesis append-only by design
Activity
malibio commentedon Sep 13, 2026
Frontend: 4951 passed (240 test files), Duration 81.98s