-
Notifications
You must be signed in to change notification settings - Fork 17
fix: align checkpoint schema with tinyagents #94
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -155,7 +155,9 @@ CREATE TABLE IF NOT EXISTS checkpoints ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| source TEXT NOT NULL, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| step INTEGER NOT NULL, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| has_interrupts INTEGER NOT NULL, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| record TEXT NOT NULL | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| record TEXT NOT NULL, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| format_version INTEGER NOT NULL DEFAULT 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| created_at INTEGER NOT NULL DEFAULT 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+159
to
+160
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When opening a Useful? React with 👍 / 👎. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| CREATE INDEX IF NOT EXISTS idx_checkpoints_thread ON checkpoints (thread_id, seq); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| CREATE INDEX IF NOT EXISTS idx_checkpoints_lookup ON checkpoints (thread_id, checkpoint_id); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -176,6 +178,17 @@ CREATE TABLE IF NOT EXISTS checkpoint_writes ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| CREATE INDEX IF NOT EXISTS idx_checkpoint_writes_thread | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ON checkpoint_writes (thread_id, checkpoint_id); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| -- C3/R4: the durable half of the per-thread execution lease. The executor | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| -- holds an in-process lock for the run's lifetime (see | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| -- `compiled::executor::execute`) AND claims this row, so a lease surviving a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| -- crashed owner past its TTL is reclaimable by a different process instead of | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| -- stranding the thread forever. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| CREATE TABLE IF NOT EXISTS thread_leases ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Record schema change decision in local/docs/11-decisions.md The repository's rules require recording design decisions in [RULE] missing-docs · |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| thread_id TEXT PRIMARY KEY, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| owner TEXT NOT NULL, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| expires_at INTEGER NOT NULL | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
155
to
+191
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win 🔎 Supported by static analysis🏁 Script executed: sed -n '1,30p' crates/tinyflows-sqlite/src/checkpoint/mod.rs
sed -n '140,200p' crates/tinyflows-sqlite/src/checkpoint/mod.rs
rg -n 'tinyagents|format_version|thread_leases|created_at' Cargo.toml Cargo.lock crates README.mdRepository: tinyhumansai/tinyflows Length of output: 10024 🏁 Script executed: #!/bin/bash
set -eu
printf '%s\n' '--- manifests and provenance ---'
rg -n -C 3 'tinyagents|PR `#43`|vendored|external|graph::checkpoint|checkpoint' Cargo.toml Cargo.lock crates/tinyflows/Cargo.toml crates/tinyflows-sqlite/Cargo.toml README.md 2>/dev/null || true
printf '%s\n' '--- graph checkpoint schema/runtime references ---'
rg -n -C 4 'format_version|thread_leases|checkpoint_writes|CREATE TABLE.*checkpoints|checkpoints \(' crates/tinyflows crates/tinyflows-sqlite
printf '%s\n' '--- focused history metadata ---'
git log --oneline -8 -- crates/tinyflows-sqlite/src/checkpoint/mod.rs crates/tinyflows/src/graph crates/tinyflows/Cargo.toml Cargo.toml
printf '%s\n' '--- file history summary ---'
git log --format='%h %s' --follow -- crates/tinyflows-sqlite/src/checkpoint/mod.rs | head -20
printf '%s\n' '--- current changed boundary ---'
git diff --stat
git diff -- crates/tinyflows-sqlite/src/checkpoint/mod.rs crates/tinyflows-sqlite/src/checkpoint/reads.rs crates/tinyflows-sqlite/src/checkpoint/writes.rs crates/tinyflows/src/compiled/executor.rs 2>/dev/null | sed -n '1,260p'Repository: tinyhumansai/tinyflows Length of output: 19336 🤖 get_repo_knowledge executed:
Length of output: 9147 🏁 Script executed: pwd; rg -n -C 3 'tinyagents|PR `#43`|vendored|format_version|thread_leases|created_at' Cargo.toml Cargo.lock crates/tinyflows crates/tinyflows-sqlite README.md 2>/dev/null | head -300Repository: tinyhumansai/tinyflows Length of output: 25761 🏁 Script executed: #!/bin/bash
set -eu
printf '%s\n' '--- alignment commit ---'
git show --format=fuller --stat a94e5a2
git show --format= --find-renames a94e5a2 -- crates/tinyflows-sqlite/src/checkpoint/mod.rs crates/tinyflows-sqlite/src/checkpoint/reads.rs crates/tinyflows-sqlite/src/checkpoint/writes.rs | sed -n '1,360p'
printf '%s\n' '--- parent and current schema provenance ---'
git show a94e5a2^:crates/tinyflows-sqlite/src/checkpoint/mod.rs | sed -n '130,205p'
git show a94e5a2:crates/tinyflows-sqlite/src/checkpoint/mod.rs | sed -n '1,215p'
printf '%s\n' '--- lease bindings ---'
rg -n -C 5 'thread_leases|lease|expires_at|owner' crates/tinyflows crates/tinyflows-sqlite
printf '%s\n' '--- exact tinyagents references in repository history metadata ---'
git log --all --format='%H %s' --grep='tinyagents' -i -12
git show --format=fuller --no-patch a94e5a2Repository: tinyhumansai/tinyflows Length of output: 50379 🏁 Script executed: #!/bin/bash
set -eu
git show --format=fuller --stat a94e5a2
git show --format= --find-renames a94e5a2 -- crates/tinyflows-sqlite/src/checkpoint/mod.rs crates/tinyflows-sqlite/src/checkpoint/reads.rs crates/tinyflows-sqlite/src/checkpoint/writes.rs | sed -n '1,360p'
git show a94e5a2^:crates/tinyflows-sqlite/src/checkpoint/mod.rs | sed -n '130,205p'
printf '%s\n' '--- lease bindings ---'
rg -n -C 5 'thread_leases|lease|expires_at|owner' crates/tinyflows crates/tinyflows-sqlite
printf '%s\n' '--- tinyagents history ---'
git log --all --format='%H %s' --grep='tinyagents' -i -12
git show --format=fuller --no-patch a94e5a2Repository: tinyhumansai/tinyflows Length of output: 50379 🏁 Script executed: #!/bin/bash
set -eu
printf '%s\n' '--- tinyagents history ---'
git log --all --oneline --decorate --grep='tinyagents' -i -20
printf '%s\n' '--- dependency-string history ---'
git log --all --oneline -S'tinyagents' -- Cargo.toml Cargo.lock crates/tinyflows crates/tinyflows-sqlite | head -30
printf '%s\n' '--- graph vendoring history ---'
git log --all --oneline -- crates/tinyflows/src/graph/mod.rs crates/tinyflows/src/graph/checkpoint crates/tinyflows/Cargo.toml | head -30
printf '%s\n' '--- historical manifest references ---'
for c in $(git log --all --format='%H' -S'tinyagents' -- Cargo.toml Cargo.lock crates/tinyflows/Cargo.toml | head -8); do
echo "COMMIT $c"
git show "$c":Cargo.toml 2>/dev/null | rg -n -C 2 'tinyagents' || true
git show "$c":Cargo.lock 2>/dev/null | rg -n -C 4 '^name = \"tinyagents\"|tinyagents' || true
done
printf '%s\n' '--- exact local lease references ---'
rg -n 'thread_leases|CREATE TABLE.*lease|INSERT INTO thread_leases|UPDATE thread_leases|DELETE FROM thread_leases|SELECT .*thread_leases' crates/tinyflows-sqlite crates/tinyflowsRepository: tinyhumansai/tinyflows Length of output: 6091 🏁 Script executed: #!/bin/bash
set -eu
git log --all --oneline --decorate --grep='tinyagents' -i -20
git log --all --oneline -S'tinyagents' -- Cargo.toml Cargo.lock crates/tinyflows crates/tinyflows-sqlite | head -30
git log --all --oneline -- crates/tinyflows/src/graph/mod.rs crates/tinyflows/src/graph/checkpoint crates/tinyflows/Cargo.toml | head -30
for c in $(git log --all --format='%H' -S'tinyagents' -- Cargo.toml Cargo.lock crates/tinyflows/Cargo.toml | head -8); do
echo "COMMIT $c"
git show "$c":Cargo.toml 2>/dev/null | rg -n -C 2 'tinyagents' || true
git show "$c":Cargo.lock 2>/dev/null | rg -n -C 4 '^name = "tinyagents"|tinyagents' || true
done
rg -n 'thread_leases|CREATE TABLE.*lease|INSERT INTO thread_leases|UPDATE thread_leases|DELETE FROM thread_leases|SELECT .*thread_leases' crates/tinyflows-sqlite crates/tinyflowsRepository: tinyhumansai/tinyflows Length of output: 5922 🏁 Script executed: #!/bin/bash
set -eu
printf '%s\n' '--- historical vendor tree ---'
git ls-tree -r --name-only 637db7d | rg '(^|/)(vendor/tinyagents|tinyagents).*(checkpoint|sqlite|graph)' | head -80
git ls-tree 637db7d vendor/tinyagents
printf '%s\n' '--- historical TinyAgents schema candidates ---'
for p in \
vendor/tinyagents/src/graph/checkpoint/sqlite.rs \
vendor/tinyagents/src/graph/checkpoint/mod.rs \
vendor/tinyagents/src/graph/checkpoint.rs; do
if git cat-file -e "637db7d:$p" 2>/dev/null; then
echo "FILE $p"
git show "637db7d:$p" | rg -n -C 5 'CREATE TABLE|format_version|created_at|thread_leases|checkpoint_writes|INSERT INTO checkpoints' || true
fi
done
printf '%s\n' '--- historical exact-name search ---'
git grep -n -E 'thread_leases|format_version|created_at' 637db7d -- 'vendor/tinyagents/**' 2>/dev/null | head -160 || trueRepository: tinyhumansai/tinyflows Length of output: 349 🏁 Script executed: #!/bin/bash
set -eu
git ls-tree -r --name-only 637db7d | rg '(^|/)(vendor/tinyagents|tinyagents).*(checkpoint|sqlite|graph)' | head -80
git ls-tree 637db7d vendor/tinyagents
for p in vendor/tinyagents/src/graph/checkpoint/sqlite.rs vendor/tinyagents/src/graph/checkpoint/mod.rs vendor/tinyagents/src/graph/checkpoint.rs; do
if git cat-file -e "637db7d:$p" 2>/dev/null; then
echo "FILE $p"
git show "637db7d:$p" | rg -n -C 5 'CREATE TABLE|format_version|created_at|thread_leases|checkpoint_writes|INSERT INTO checkpoints' || true
fi
done
git grep -n -E 'thread_leases|format_version|created_at' 637db7d -- 'vendor/tinyagents/**' 2>/dev/null | head -160 || trueRepository: tinyhumansai/tinyflows Length of output: 233 🌐 Web query:
💡 Result: <source_evidence> Citations:
🌐 Web query:
💡 Result: TinyAgents 2.1.0 uses this SQLite schema: CREATE TABLE IF NOT EXISTS checkpoints (
seq INTEGER PRIMARY KEY AUTOINCREMENT,
thread_id TEXT NOT NULL,
checkpoint_id TEXT NOT NULL,
parent_checkpoint_id TEXT,
run_id TEXT,
namespace TEXT NOT NULL,
next_nodes TEXT NOT NULL,
source TEXT NOT NULL,
step INTEGER NOT NULL,
has_interrupts INTEGER NOT NULL,
record TEXT NOT NULL
);
CREATE INDEX IF NOT EXISTS idx_checkpoints_thread
ON checkpoints (thread_id, seq);
CREATE INDEX IF NOT EXISTS idx_checkpoints_lookup
ON checkpoints (thread_id, checkpoint_id);
Citations: Restore the TinyAgents 2.1.0 schema. TinyAgents 2.1.0 does not define Suggested fix- record TEXT NOT NULL,
- format_version INTEGER NOT NULL DEFAULT 1,
- created_at INTEGER NOT NULL DEFAULT 0
+ record TEXT NOT NULL
);
@@
-CREATE TABLE IF NOT EXISTS thread_leases (
- thread_id TEXT PRIMARY KEY,
- owner TEXT NOT NULL,
- expires_at INTEGER NOT NULL
-);📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// tinyflows keeps its own copy `pub(crate)`, so the port carries one. Same | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Migrate existing checkpoint tables before relying on new columns
CREATE TABLE IF NOT EXISTSdoes not alter an already-existingcheckpointstable. A database created before this change therefore still lacksformat_versionandcreated_atafterfrom_connectionorschema_sqlruns, so any caller that expects the newly declared schema will fail on upgraded workspaces. Add an idempotent migration (for example,ALTER TABLE ... ADD COLUMNguarded by a column check) when opening the database, or otherwise document that existing databases are unsupported.[RULE] missing-schema-migration ·