Skip to content

update_schema never enforces field protection levels: Core-protected fields (e.g. task.status) can be removed from or renamed on core schemas via one agent tool call, and the change is irreversible through the API #2213

Closed

Description

@mstomar125

Summary

SchemaField carries SchemaProtectionLevel and SchemaNode::can_delete_field/can_modify_field exist precisely to protect Core fields, but they have zero callers; handle_update_schema's core-schema gate (schema/mod.rs:698-723) checks only that add_fields and rename DESTINATIONS carry a namespace prefix — remove_fields is completely unguarded (schema/mod.rs:814-817) and a rename's SOURCE being a Core-protected field is never checked, while SchemaNodeBehavior validation checks only names/duplicates/templates; both the local-agent tool (packages/agent tools.rs:2964) and the daemon gRPC handler (daemon node_service.rs:1303) pass args straight through with no gating.

Failure scenario

User tells the agent "drop the status field, we don't use it" and it calls update_schema {schema_id:"task", remove_fields:["status"]}: the Core-protected status field (required, default "open", enum values that drive board columns and completion rollups — core_schemas.rs:60-100) is deleted from the core task schema and persisted (task has no title_template, so Phase-2 validation passes). Status defaults, enum validation, and the schema-driven Status UI disappear for every task. Recovery through the same API is impossible: add_fields {name:"status"} on a core schema is rejected by the namespace-prefix rule (only custom:status can be added), and core-schema seeding never re-runs because the schema node still exists. rename_fields {from:"status", to:"custom:st"} is equally accepted (destination is prefixed) and additionally migrates every task node's status value to the new key, breaking the hardcoded typed task path (update_task_node writes properties.task.status) — and renaming back to bare "status" is blocked by the same prefix rule.

Location

packages/core/src/schema/mod.rs:814

Severity

important


Found via a full-repo adversarial bug sweep, independently verified by two separate skeptical reviewers reading the actual current code before filing.

Activity

  1. self-assigned this
    on Aug 21, 2026
  2. mstomar125 commented on Aug 27, 2026

    @mstomar125
    ContributorAuthor

    Fixed in #2304: added a protection-level guard (checked against SchemaProtectionLevel via can_delete_field/can_modify_field) to handle_update_schema's Phase 0 and to the NodeService::rename_schema_field/update_schema_field_friendly_name primitives, so a Core/System-protected field can no longer be removed, renamed, or relabeled through update_schema. Also moved rename-destination grammar validation ahead of the migration/persist step, so a malformed destination name is rejected before anything is written rather than after. Regression tests cover the removal, rename, friendly-name-relabel, and grammar-before-persist scenarios described here. PR is open for review, not yet merged.

  3. mstomar125 commented on Aug 27, 2026

    @mstomar125
    ContributorAuthor

    Fixed in PR #2304 (merged 7528411a), part of the same cluster as #2194. Closing — GitHub's auto-close only picked up the first issue in the PR's comma-separated closing list, closing the rest manually.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions