Skip to content

Implement ProjectNodeBehavior #134

Closed

Description

@malibio

Overview

Implement ProjectNode as a core node type: a project schema entry in core_schemas.rs plus a ProjectNodeBehavior (validation + computed display name). Projects are containers for tasks, milestones, and related work.

Rewritten to align with the Universal Graph model and the current NodeBehavior trait. Supersedes the original pre-Universal-Graph body, which referenced a "Projects Table", a metadata blob, default_metadata defaults, and an on_delete/DeletionAction API — none of which exist in the current architecture.

Read first

Data model (Universal Graph)

ProjectNode is a node with node_type = 'project'; its data lives under properties (type-namespaced properties.project.*, per the Issue #397 pattern used by TaskNodeBehavior). There is no projects side table — indexed querying is handled by the schema field indexed: true flag, not a complementary table.

Children (tasks, milestones) are real graph nodes attached via has_child edges, not a team_members/array blob.

Core fields on the project schema

Field Type Protection Notes
status enum Core planning / active / completed / archived / cancelled. Default planning. indexed: true.
start_date date User Optional.
end_date date User Optional. If both present, start_date <= end_date.
priority enum User Optional. low / medium / high (mirror task.priority). indexed: true.

Project name is the node's content (like Collection and Task), not a property. Ownership/membership are modeled as graph edges (e.g. a person member_of or an owns edge), not an owner_id/team_members property blob — do not re-introduce those.

Validation split (IMPORTANT — matches TaskNodeBehavior)

The behavior does type checks; the schema system validates enum membership and values. Do not duplicate enum-value validation in the behavior.

  • Behavior validate → Result<(), NodeValidationError>:
    • content (project name) non-empty → else NodeValidationError::MissingField.
    • status must be a string if present (type check only) → else NodeValidationError::InvalidProperties.
    • start_date / end_date: if present, must be strings; if both present and both parse as YYYY-MM-DD, enforce start <= end → else NodeValidationError::InvalidProperties. (String comparison is acceptable for ISO dates; chrono optional.)
    • priority must be a string if present.
  • Read project properties from the namespace: node.properties.get("project").

Implementation Tasks

  • Add a project SchemaNode to packages/core/src/models/core_schemas.rs with the fields above. Mirror the task schema's SchemaField shape (enum core_values for status/priority, field_type: "date" for the dates, indexed flags). is_core: true.
  • Implement ProjectNodeBehavior implementing the current NodeBehavior trait. Methods to implement: type_name → "project", validate (above), can_have_children → true, supports_markdown → true (rich descriptions), default_metadata → serde_json::json!({ "project": { "status": "planning", "start_date": null, "end_date": null, "priority": null } }).
  • Implement get_embeddable_content (project name + any description content) and get_parent_contribution consistent with the embeddings model — projects carry semantic content worth embedding, so unlike Task, return the name/description rather than None. Confirm against node-behavior-system.md.
  • Register it in NodeBehaviorRegistry::new() (packages/core/src/behaviors/mod.rs ~L2089) alongside the existing registry.register(Arc::new(...)) calls.

Acceptance Criteria

  • project schema entry exists in core_schemas.rs with status (Core, default planning, indexed) and optional start_date/end_date/priority.
  • ProjectNodeBehavior implements all NodeBehavior trait methods and is registered in NodeBehaviorRegistry::new().
  • Empty project name (content) rejected with MissingField.
  • Non-string status/priority/date fields rejected with InvalidProperties.
  • start_date > end_date (both present, both ISO) rejected with InvalidProperties.
  • can_have_children() → true; supports_markdown() → true.
  • Unit tests cover: valid full project, minimal project (name only), empty-name rejection, non-string field rejection, invalid date range, and default_metadata shape.
  • Passes cargo clippy; no lint suppression; no #[allow(dead_code)].

Scope

In scope: ProjectNode the type — project schema + ProjectNodeBehavior + validation + tests.

NOT in scope:

  • Project management UI / viewers.
  • Status-transition workflows or automation (see [FUTURE] Implement Workflow/Automation System #334).
  • A projects side table — does not exist (Universal Graph).
  • on_delete / cascade behavior — the trait has no on_delete method; deletion semantics are handled centrally, not per-behavior.

Architecture corrections vs. the original issue (for reviewers)

The pre-Universal-Graph body was inaccurate. Current reality:

  • Trait method is validate(&self, node: &Node) -> Result<(), NodeValidationError> (not ValidationError); variants are MissingField / InvalidProperties / InvalidId.
  • No on_delete / DeletionAction on the NodeBehavior trait.
  • Data lives under type-namespaced properties.project.*, not a metadata blob.
  • No projects complementary table; no owner_id / team_members / budget property blob.
  • Project name is content, consistent with Task and Collection.

Activity

  1. mstomar125 commented on Jul 27, 2026

    @mstomar125
    Contributor

    Resolved in #1753 (merged to main as 624dd323).

    Implemented project as a core node type (Universal Graph model):

    • Schema (core_schemas.rs): status (enum, Core, default planning, indexed, required), priority (enum, User, indexed, optional), start_date/end_date (date, User, optional). is_core: true.
    • ProjectNodeBehavior (registered in NodeBehaviorRegistry::new()): name is the node content; typed data under properties.project.*; no side table / owner_id / team_members blob. Behavior type-checks fields + enforces start_date <= end_date (ISO dates only); the schema system validates enum membership. can_have_children/supports_markdown → true. Projects are embeddable roots (name/description), unlike Task.

    5 behavior tests + a doctest; enumeration tests updated (registry 18→19, core schemas 17→18); a schema_test example renamed "Project"→"Campaign" since project is now a reserved core id a user schema can't shadow. 973 core lib tests pass, clippy clean, gate green, independent review confirmed.

    Follow-up filed #1754: frontend first-class registration of project (CORE_NODE_TYPES, icon registry, sidenav) + eventual project viewer. Out of this core-only scope; projects humanize gracefully today.

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions