Repository navigation
Fix/result types atomic add - #2
Merged
Merged
Conversation
Columns declared as JSON get NUMERIC affinity in SQLite, so scalar results and metadata such as 500500 or 6.92 are stored as INTEGER or REAL. Reading them back as String failed, breaking get_task, list_tasks and handoff context for tasks with numeric results. Add a json_text helper that reads INTEGER, REAL, TEXT and BLOB values as text, and use it for every JSON column read (task result, metadata, sleep state refs, process/wait state refs, artifact, dependency, event and project JSON fields). Add tests covering scalar and object results through completion and handoff, and numeric task metadata. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The upstream handoff display only rendered string results: done printed "(no result)" for numeric, boolean or object results, and go printed "(structured)". Both truncated long results by byte index, which panics when the cut lands inside a multi-byte UTF-8 character. Render non-string results as compact JSON, keep "(no result)" for null, and truncate by characters instead of bytes. Add functional tests for numeric, object and long non-ASCII results handed off through done --next. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
done --result parsed any text that was valid JSON, so scalar results lost their original form: 6.90 was stored as 6.9, and "null" cleared the result entirely. Only parse objects and arrays as JSON; store everything else as the string the caller passed. Add functional tests that a float result keeps its text in done output and in show. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
task add and batch creation inserted the task rows first and added dependencies afterwards in separate statements. An unknown dependency id failed the command after the task was already written, leaving an orphan task with partial edges and tags behind. Add create_task_with_deps and batch_create_tasks_with_edges, which insert tasks, tags and dependency edges in one transaction. Each edge checks that its upstream task exists and fails with a NotFound error naming the id, which rolls back the whole call. create_task and batch_create_tasks delegate to the new functions, and the shared INSERT_TASK binding moves into insert_task_row. Add unit tests that single and batch creation with an unknown dependency create nothing, and a functional test for task add. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Ignore Cargo build output and Rust tooling artifacts (rustfmt backups, MSVC debug info, cargo-mutants output, rustc ICE dumps), plus local taskgraph state: SQLite databases with their WAL, SHM and journal files, the .taskgraph/ directory, and .env files other than .env.example. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes how taskgraph stores and shows task results, and makes task creation all-or-nothing when a dependency is wrong.
show,list,goanddone --nextfailed for every project holding one.goanddoneoutput, and long non-ASCII results could crash both commands.task addand batch create with an unknown dependency failed only after the task was saved, leaving a half-created task behind.Changes
Read numeric JSON columns as text (
c3e020c)Columns declared as
JSONget NUMERIC type affinity in SQLite, so a result such as500500or6.92is stored as INTEGER or REAL. Reading it back asStringfailed with an invalid column type error, which brokeget_task,list_tasksand handoff context.A new
json_texthelper insrc/db/mod.rsreads INTEGER, REAL, TEXT and BLOB values as text. Every JSON column read now uses it: task result, metadata and sleep state ref; process run and task wait state refs; artifact, dependency and project metadata; and event payload.Show non-string handoff results (
0ba5523)In the upstream section of
goanddone --next:doneprinted(no result)andgoprinted(structured).Keep scalar
done --resultvalues as written (6c35c92)done --resultnow parses the text as JSON only when it is an object or an array. Anything else is stored as the string passed, so6.90stays6.90instead of becoming6.9.Create tasks and their dependencies atomically (
5b399fc)task addsaved the task, then added each--depin a separate statement. Batch create committed the tasks, then added edges and tags outside the transaction. An unknown dependency id failed withFOREIGN KEY constraint failedafter the task was already saved.create_task_with_depsandbatch_create_tasks_with_edgesinsert tasks, tags and edges in one transaction.create_taskandbatch_create_tasksdelegate to the new functions, and the task INSERT that was duplicated between them moves intoinsert_task_row.Add
.gitignore(238e87a)GitHub's Rust template, plus local taskgraph state:
*.dbwith its-wal,-shmand-journalfiles,.taskgraph/, and.env*except.env.example.Behaviour changes
taskgraph done --result 500500now stores the string"500500", not the number. The same applies totrue,falseandnull, so--result nullno longer clears the result. Objects and arrays are still stored as JSON. Code that passes aserde_json::Valuestraight tocomplete_taskis unaffected.taskgraph add --dep <unknown id>now fails withnot found: dependency task <id>; nothing was created. Check the id with `taskgraph list`and leaves no task behind.Testing
cargo test: 28 passed, no warnings. New unit tests insrc/db/tests.rs:scalar_and_object_results_read_back_and_hand_offnumeric_metadata_reads_backadd_with_unknown_dependency_creates_nothingbatch_with_unknown_dependency_creates_nothingtests/functional_test.sh: 147 passed, 0 failed. The new RESULT TYPES and ATOMIC ADD sections cover numeric, float, object and long non-ASCII results throughdone --next, andaddwith an unknown dependency.Not in this PR
insert_task_between,pivot_subtree,split_taskand decompose/replan still create tasks and add edges in separate steps.batch_create_tasks_with_edgesnow accepts tags, so it could pass them through in a follow-up.History
These five commits were first pushed straight to
main(37b8429..9042c2e) and then reverted there (594f7f8..5bdfaab). This PR brings them back through review. Revertedmainhas the same code asffc8dfd, so the PR diff contains the full change.🤖 Generated with Claude Code