Skip to content

feat(gtd): context_entity_id on assign + harden complete() error path (#520 #522)#600

Merged
ohdearquant merged 3 commits into
mainfrom
show/khive-issue-sweep/gtd-fixes
May 31, 2026
Merged

feat(gtd): context_entity_id on assign + harden complete() error path (#520 #522)#600
ohdearquant merged 3 commits into
mainfrom
show/khive-issue-sweep/gtd-fixes

Conversation

@ohdearquant
Copy link
Copy Markdown
Owner

Summary

Two khive-pack-gtd fixes.

Issue Fix
#522 The active→done complete path was already correct in-tree (schema.rs is_terminal={done,cancelled}, handle_complete admits active). The real defect was a stale rows_affected==0 error that always claimed "terminal state" even on a non-terminal concurrent re-read. Fix branches the message on is_terminal(&actual_now). Locks in behavior with the exact assign → transition(active) → complete regression the issue asked for.
#520 Adds optional context_entity_id to gtd.assign: strict Uuid::from_str validation (rejects prefixes — no silent coerce/drop), entity-kind verification via runtime.resolve(), persisted to properties.context_entity_id, an annotates edge via create_note, exposed in render_task + nested in get. No DB migration — V1 already has properties TEXT.

Honest note on #522

The issue body described "active treated as terminal, active→done rejected." In the actual worktree that path already worked — the explorer caught this rather than fabricating a transition-table edit to match stale issue text. The landed fix hardens the adjacent real defect (misleading concurrent-update error) and adds the regression the issue's acceptance criterion calls for. Graded a non-blocking MIN by the play critic, disclosed transparently.

Tests

  • complete_after_transition_to_active_succeeds
  • assign_context_entity_id_round_trips_through_tasks_and_get
  • assign_rejects_malformed_context_entity_id

cargo test --workspace0 failed · cargo clippy --workspace --all-targets -- -D warningsclean (independently re-run). Migrations untouched (latest still V22).

Scope

Part of the khive issue-sweep. Do not merge — awaiting Ocean's review. Each commit references its issue number(s).

🤖 Generated with Claude Code

ohdearquant and others added 2 commits May 31, 2026 00:03
…#522)

When rows_affected==0 in gtd.complete (concurrent race), re-read the
actual task state and distinguish terminal vs. non-terminal: terminal
still reports "in terminal state", non-terminal now reports "changed
from expected state ... retry with fresh state" to avoid a misleading
message about a state that is not actually terminal.

Adds regression test: complete_after_transition_to_active_succeeds —
assign → transition(active) → gtd.complete must succeed end-to-end.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adds `context_entity_id` (optional, full UUID only) to AssignParams.
Strict validation: rejects short prefixes and non-entity targets with
a clear error naming the field, expected shape, and bad value.

Persists the canonical UUID under properties.context_entity_id and
creates an annotates edge to the KG entity via create_note. Exposes
the field at the top-level in render_task (gtd.assign / gtd.tasks /
gtd.next responses) and in the nested properties of get. Updates the
gtd.assign verb schema metadata with the new ParamDef.

No DB migration — properties TEXT column already exists (V1).
Latest migration remains V22.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@ohdearquant ohdearquant enabled auto-merge (squash) May 31, 2026 12:32
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@ohdearquant ohdearquant merged commit 9fe8633 into main May 31, 2026
1 of 3 checks passed
@ohdearquant ohdearquant deleted the show/khive-issue-sweep/gtd-fixes branch May 31, 2026 12:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant