voku / agent-graph
Deterministic SQLite graph indexing and shared SQLite runtime support for coding-agent tooling.
Requires
- php: >=8.2
Requires (Dev)
- phpstan/phpstan: ^2.2
- phpunit/phpunit: ^11.5
Suggests
None
Provides
None
Conflicts
None
Replaces
None
- dev-main
- 0.3.x-dev
- 0.3.3
- 0.3.2
- 0.3.1
- 0.3.0
- 0.2.x-dev
- 0.2.3
- 0.2.2
- 0.2.1
- 0.2.0
- 0.1.0
- dev-ccr-44bf1ea9-qiofzm
- dev-ccr-784c9e99-0jrxgb
- dev-docs/readme-file-guide-20261110
- dev-release/agent-graph-0.3.2
- dev-feature/guarded-provenance-reuse-20261028
- dev-experiment/graph-provenance-overhead-20261028
- dev-claude/decision-link-experiment-qjop8t
- dev-release/0.3.1
- dev-fix/release-connection-on-failed-open-v2
- dev-release/tag-0.3.0
- dev-release/prepare-0.3.0
- dev-perf/read-path-and-schema-v2
- dev-release/tag-0.2.3
- dev-release/0.2.3-marker
- dev-release/0.2.3
- dev-feat/read-only-graph-store-29
- dev-fix/release-0.2.2-idempotent-tag
- dev-fix/release-0.2.2-tag-guards
- dev-release/tag-0.2.2
- dev-release/0.2.2-marker
- dev-release/0.2.2
- dev-fix/sqlite-vec-workflow-finalization
- dev-automation/sqlite-vec-0.1.9
- dev-fix/sqlite-vec-version-test-authority
- dev-fix/sqlite-vec-release-digest
- dev-chore/reusable-sqlite-vec-update
- dev-release/tag-0.2.1
- dev-release/0.2.1-marker
- dev-release/0.2.1
- dev-fix/indexed-incoming-query
- dev-release/tag-0.2.0
- dev-release/0.2.0-marker
- dev-release/0.2.0-graph-store
- dev-feat/sqlite-graph-store
- dev-fix/single-file-relation-store
- dev-release/0.2.0
- dev-feat/relation-store
- dev-release-tag/0.1.0
- dev-release-marker/0.1.0
- dev-release/0.1.0
- dev-feat/sqlite-vec-runtime
This package is auto-updated.
Last update: 2026-11-29 19:55:19 UTC
README
Your coding agent's code graph should give the same answer twice and fail closed on a database it cannot trust. agent-graph is a small, deterministic SQLite graph index for PHP coding-agent tools that does exactly that, without loading the whole graph into memory.
You get:
- Same input, same answers. Relation and target order are preserved; neighbours and bounded, cycle-safe traversal are deterministic, and
scripts/compare-benchmark.shfails when a change alters any query-result checksum. - Fail-closed reads.
GraphStore::openReadOnly()rejects a missing database, missing graph tables or a schema version other than the current one, and never modifies the file; every graph records the owner's source revision and fingerprint so a stale graph can be detected. - Verified vector runtime. A pinned
sqlite-vecv0.1.9 loadable extension for Linux x86_64 and arm64, resolved only after its SHA-256 matches the bundled manifest (nullon other platforms). An explicitAGENT_GRAPH_SQLITE_VECoverride path is used as given, without those checks.
Part of Agent Loop — a deterministic, local-first workflow for coding agents: approved Contracts, explicit next actions, evidence before "done". This package owns domain-neutral graph storage/query mechanics and the shared SQLite runtime assets used by
agent-map(code relations) andagent-learning(learning lineage).
Quickstart
composer require voku/agent-graph
Requires PHP 8.2 or newer (composer.json: php >=8.2) and the pdo and pdo_sqlite extensions, which composer.json declares because the store opens SQLite through PDO.
<?php require __DIR__ . '/vendor/autoload.php'; use voku\AgentGraph\Graph\GraphRelation; use voku\AgentGraph\Graph\TraversalDirection; use voku\AgentGraph\Sqlite\GraphStore; // Write: replace the complete derived graph in one transaction. $store = new GraphStore(__DIR__ . '/graph.sqlite'); $store->replace( [ new GraphRelation('r1', 'App\Controller', 'calls', ['App\Service']), new GraphRelation('r2', 'App\Service', 'calls', ['App\Repository', 'App\Logger']), ], sourceRevision: 'abc123', // opaque owner identity of the canonical data sourceFingerprint: 'sha256:example', ); // Read: open read-only and query. $graph = GraphStore::openReadOnly(__DIR__ . '/graph.sqlite'); $graph->incoming('App\Service'); // [GraphRelation r1] $graph->neighbours('App\Service'); // ['App\Controller', 'App\Logger', 'App\Repository'] $result = $graph->traverse('App\Controller', TraversalDirection::OUTGOING, maximumDepth: 2); $result->nodeIds; // ['App\Service', 'App\Repository', 'App\Logger'] $result->depthOf('App\Logger'); // 2 $result->truncated; // false $graph->sourceRevision(); // 'abc123'
The values in the comments are the real results of running this snippet.
How it works
- Owners write ordered, grouped
GraphRelationvalues once withGraphStore::replace()(one transaction); readers query indexed incoming/outgoing/neighbour lookups without loading the graph into PHP memory. advanceProvenanceIfUnchanged()skips the rewrite when a rebuild produced exactly the same ordered relations.- Schema version 2 (0.3.0) shrank a 200k-relation graph by about 40% (51.7 → 30.9 MB) with unchanged query results, ordering and public API (CHANGELOG).
- The store does not decide what an edge means; domain owners do. Coming from 0.2.x? Read the upgrade note.
Documentation
| I want to… | Read |
|---|---|
| Write and query a graph, see every read method | GraphStore and the SQLite relation store |
| Validate an in-memory projection before storing it | Structural graph contract |
| Upgrade a 0.2.x graph to schema v2 | Upgrading from 0.2.x to 0.3.0 |
Load sqlite-vec or supply my own binary |
sqlite-vec runtime |
| Know what this package will never own | Scope and boundaries |
| Run benchmarks or find where code lives | Development |
| See what changed in each release | CHANGELOG |
| Check third-party licensing | Third-party notices |
All pages: docs/README.md.
Part of the Agent Loop toolchain
Each package owns one concern and can be used on its own. voku/agent-loop composes them into one governed workflow.
| Package | Owns |
|---|---|
| agent-loop | Task Contracts, lifecycle, next actions, validation and review gates |
| agent-kanban | Git-native Markdown board and card semantics |
| agent-session | Per-task working memory, decisions and checkpoints |
| agent-map | Read-only repository symbol maps and typed edit plans |
| agent-edit | Transactional, verified application of edit plans |
| agent-graph | Deterministic SQLite graph index and runtime |
| agent-recall-compiler | Bounded task context (Recall) and prompt recipes |
| agent-learning | Reviewable findings, proposals and durable guidance |
| agent-skills | Portable engineering skills for coding agents |
| agent-ui | Local server-rendered control plane for humans |
| agent-decision | Experimental bounded, advisory-only decision helper |
| agent-dotfiles | Shell dotfiles for non-interactive agent shells |
Development
composer install
composer ci # composer validate --strict, PHPUnit, PHPStan
CI runs this on PHP 8.2 to 8.5 and additionally checks benchmark parity against a released tag. Benchmarks and the source layout: docs/development.md.
License
MIT, see LICENSE. The bundled sqlite-vec binaries (upstream dual Apache-2.0/MIT) are redistributed under MIT terms; see third-party notices.