Skip to content

Code graph and memory for your coding agents, in one Rust program. For Claude Code, Codex, Cursor and any MCP client.

Graphicle 0.1.3: code-question retrieval, agent guidance, workspace map

VikramLex8a5df4a0f6b2
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 1038978..5d232eb 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -3,7 +3,31 @@
Notable changes to Graphicle: the graph engine (`graphicle-graph`), the memory
library (`graphicle-memory`) and the `graphicle` program.
-## Unreleased
+## 0.1.3 - 2026-10-21
+
+Every crate is at 0.1.3, and `graphicle --version` prints
+`graphicle 0.1.3 (core)`.
+
+### Code graph
+
+- Markdown front matter that opens a bracketed list or mapping on a key's
+ line (`key: [` or `key: {`) and continues it on lines indented no further
+ than the key, such as a closing `]` at the start of a line, is now read as
+ YAML. Graphify's YAML parser (PyYAML) ignores indentation inside brackets,
+ but Graphicle's rejected such lines, so the page's stored front matter fell
+ back to plain text: its fields became strings and the list's entries were
+ lost. An `apm.yml` manifest written this way, which the same parser reads,
+ gave a manifest parse error and is now read too. This was the cause of the
+ known difference in the graph after `graphicle graph update` on
+ gohugoio/hugo.
+- Linking imports across a workspace's projects is incremental. After a sync,
+ a project's imports are linked again only when the project changed, when a
+ project it can import from changed what it exports, or when the set of
+ linked projects changed. The other projects keep their links, and their
+ graphs are not loaded again: each project's export index is kept with the
+ links. The links recorded are the same as those of a full pass. The
+ `graph_link` result lists the projects linked again (`relinked`) and those
+ whose links were kept (`reused`).
### MCP Registry
@@ -12,6 +36,365 @@ library (`graphicle-memory`) and the `graphicle` program.
(`packaging/mcpb/icon.png`). The workflow builds a release's bundles with
the scripts on main, so the bundles of 0.1.2 have the icon too.
+### Agents
+
+- Agents are told when Graphicle helps and when grep is enough, in the same
+ words wherever they read it: use `recall_project` or `query_graph` for
+ where or how something works, for questions across files or history, and
+ before changing unfamiliar code; for an exact identifier you already know,
+ grep is enough. Answers cite file and lines.
+ - Claude Code's and Codex's session-start hook prints this as one line at
+ the start of every session in a project (Claude Code still skips a
+ resumed conversation), before the reviewed memory, open work and stale
+ memory it printed already. A project with nothing reviewed, open or
+ stale used to get no session-start text.
+ - The server's instructions start with it, in the essentials set and in
+ the whole server.
+ - The descriptions of `recall_project`, `query_graph`, `get_node`,
+ `get_neighbors` and `shortest_path` end with one sentence on when to use
+ the tool instead of grep. Apart from these sentences, the whole server's
+ instructions and tools (`--tools all`, which the other agents get) are
+ 0.1.0's.
+ - The Graphicle section that setup writes in `AGENTS.md` and `CLAUDE.md`
+ says it. Running setup again brings an existing section up to date, and
+ `graphicle disconnect` removes it as before. `setup --tools all` still
+ writes 0.1.0's section.
+ - The opt-in guard hook's reminder before a search says it too.
+- `graphicle setup --prompt-context` (off by default) adds a Claude Code
+ UserPromptSubmit hook: before each prompt that is a code question (the
+ classifier `context` uses), it runs `graphicle context` and gives the
+ packet's Markdown, at most 8,400 characters, as the prompt's additional
+ context. Short prompts, questions in plain words, folders of no project,
+ failures and answers slower than 10 seconds add nothing; the prompt is
+ never refused, and the hook waits up to about 10 seconds. The prompt
+ reaches `graphicle context` on its standard input (`graphicle context -`
+ reads the question there). `graphicle disconnect` removes the hook.
+
+### Context and recall
+
+- `graphicle context` prints at most 8,400 characters by default (new
+ `--max-chars`; it was 4 characters per `--max-tokens` token, 12,000 by
+ default), so a prompt hook that prints the packet under a header stays
+ below the 10,000 characters Claude Code shows in full. With only
+ `--max-tokens`, the packet still holds 4 characters per token.
+- A `notes_first` option, off by default: `notes_first: true` in `context`,
+ `graphicle call context`, the SDKs and answers, `graphicle context
+ --notes-first`, or over MCP beside `recall_project`'s arguments (and
+ `graphicle mcp --set notes_first=true` for a server). Every packet's
+ `notes_first` says what applied. It turns on three changes:
+ - A question that names no code (no backtick span, `snake_case` or
+ `camelCase` name, `Type::member`, `call()` or code file) takes the first
+ 50 files of the fused ranking, one passage each. Code files keep their
+ places; the notes and documents among them are ordered again among the
+ notes' places: a note whose name or folder matches the question's words
+ (Porter stems, so close variants match), whose headings match, or with a
+ newer date (the latest ISO date, up to today, in its path or text) comes
+ first. A question that names code keeps the code ranking.
+ - A packet quotes one window per file, and one of files with identical
+ bytes; the next files take the freed places (`notes_first.one_per_file`
+ counts what was dropped). `include_tests: true`, which `--tools all`,
+ `graph` and `memory` send for `recall_project`, and an explicit
+ `origin_quota` keep the windows as ranked.
+ - Excerpts say how old they are. Each excerpt of a project file cites the
+ date its file last changed (`(changed 2026-10-15 05:10 UTC)`: the last
+ commit when Git tracks the file unchanged, else its modification time).
+ An excerpt that names code (a code-shaped document link) whose file
+ changed later says `may be stale: <file> (defines <name>) changed
+ <date>`. Excerpts are not compared with one another, and dates do not
+ reorder them. Imported notes and documents carry no review state, so the
+ stale flags of reviewed memory never applied to them. `source_age: true`
+ or `false` sets the dates alone.
+- An identifier route for `context`: a question that is an identifier, or
+ names identifiers and only asks where they are defined or used
+ (`` `parse_config` ``, `where is Store::open defined`, `who calls
+ ParseConfig`), gets each name's definitions and references from the code
+ graph as `path:line` lines within the call's budget, and one line with the
+ titles of the reviewed memories linked to them, instead of the full
+ retrieval's excerpts (the packet's `evidence` is empty). `recall_project`
+ in the essentials set and `graphicle context` take it unless told
+ otherwise (`identifier_route: false`, `graphicle context
+ --no-identifier-route`, `graphicle mcp --set identifier_route=false`); the
+ HTTP API, `graphicle call context`, the SDKs, the app and `--tools all`,
+ `graph` and `memory` take it only when a call sets `identifier_route:
+ true`. A name is a backtick span, a `snake_case` word, a camelCase or
+ PascalCase word with a capital inside it, a dotted or `::` path, or a
+ call `name()`. A name alone takes the route; other words may only ask
+ where the names are or what uses them, and one of them must. A question
+ in plain words, one that asks for more (what a name is, its code or
+ members, what it calls, where it is mentioned), a call with `needs`, and
+ a name the code graph does not define keep the retrieval. Every project
+ packet's `route` says which path ran, and why the retrieval did.
+- Code questions rank source files first (`code_first`, `"auto"` by
+ default). A question that names code (an identifier or a code file) or
+ reads like an issue or bug report (a code block, a stack trace or error
+ line, or two report words such as crash, error, fails, expected) counts
+ the passages of documentation, test and vendored or generated files at a
+ quarter of their fused score, in the ranking itself, so the excerpts and
+ the budget go to source files first; the code-graph arm leaves Markdown
+ nodes out for such a question. Tests are recognised by folder and name in
+ Rust, Python, Go, Java, Kotlin, C#, JavaScript, TypeScript, C, C++ and
+ Ruby. A question about documents, notes or decisions that is not a report
+ keeps 0.1.2's order, and test files keep their weight when a question
+ that is not a report names a test or the call sets `include_tests: true`.
+ A test or document that defines a code name the question names (with an
+ underscore or an inner capital, such as a test helper or a fixture) keeps
+ its weight when no source file defines that name.
+ A camelCase name needs two lowercase letters before its capital, digits
+ between allowed (`getChoices`, `utf8Decoder`; not `iPhone` or `eBay`);
+ a PascalCase name counts when it has a capital inside it, as for the
+ identifier route (`IsNull`, `ParseConfig`).
+ `code_first: false` keeps 0.1.2's order for any question, `true` ranks
+ source first for any question. The packet's `code_first` says what
+ applied and how many files of each kind it lowered.
+- A code question's query is its content, not its instructions
+ (`query_focus`, `"auto"` by default): when the question marks its content
+ (tags of its own such as `<issue>` or `<pr_description>`, opening at the
+ start of a line, or `--- BEGIN ISSUE ---` / `--- END ISSUE ---` lines),
+ the marked text with every word, followed by the names of code in the
+ prose outside (placeholders such as `ClassName.method_name` and fenced
+ examples left out); without marks, the question without general words of
+ instructions (find, fix, change, list, file, function, please, ...).
+ Either way a code host's links to files (`.../blob/<ref>/src/x.rs#L10`)
+ become the files' paths, and other web addresses and commit hashes are
+ left out. BM25, the code-graph arm, the choice of files past the passage
+ bound, a local reranker and the excerpts' focus read it; the packet keeps
+ the question, and its `query_focus` says what was marked and left out. A
+ prompt that wraps an issue in instructions used to rank by the
+ instructions' words as much as the issue's. `query_focus: false` reads the
+ whole question.
+- The identifiers and file paths a code question names rank their files
+ (`identifier_arm`, `"auto"` by default). The identifier route kept the
+ retrieval for a question that asks more than where names are, and dropped
+ the names it had found; now a code question's identifiers (from code
+ blocks and spans: every identifier; from prose: `snake_case`, camelCase,
+ calls, qualified names) are matched as whole words, case-sensitively, in
+ the project's passages, and found at their definitions in the code graph.
+ Each file scores the weights of the names it holds (rarer names weigh
+ more, a definition counts twice) plus a bonus when the question names its
+ path, and its two best passages join the fusion as the arm `identifiers`
+ (`arm_weights` key `identifiers`). The packet's `identifier_arm` lists the
+ names and paths used; the route's report says `names_fused`.
+ `identifier_arm: false` leaves the arm out.
+- After its excerpts, a code question's packet lists the paths of the next
+ 10 ranked files that no excerpt quotes, one line each (`more_files`, 0 to
+ 40; left out, 10 for a code question and 0 for any other). The room is
+ kept from the excerpts' share, at most an eighth of the budget, so the
+ packet stays within `max_chars` and `max_tokens`; at `graphicle
+ context`'s 8,400 characters the excerpts quote three or four files, and
+ the files after them used to be cut. The packet's `more_files` lists
+ them, and `graphicle context` prints them under "Next ranked files".
+- `code_first`, `query_focus`, `identifier_arm` and `more_files` are flags
+ of `graphicle context` (`--code-first`, `--query-focus`,
+ `--identifier-arm`: auto, true or false; `--more-files N`) and switches
+ of `recall_project` over MCP that `graphicle mcp --set` can fix; packets
+ echo them in `mechanisms.switches`.
+- A `context` question over 16,000 bytes is shortened instead of refused:
+ to its tagged content when that fits, else to its beginning, cut at a
+ line end, followed by the identifiers and file paths of the part cut
+ (within 3,000 bytes). The packet's `question_shortened` gives the
+ question's size, what was kept and how many names were added. A long
+ issue pasted into a prompt hook used to get no packet.
+- Past the per-question bounds (50,000 documents or 40,000 passages), the
+ files a question reads are chosen by a BM25 score of its words in each
+ file (rarer words weigh more, a word's count is divided by the file's
+ length, a word in the path counts twice more), among at most 64 words,
+ those written as code first. The count of the first 24 words a file
+ holds chose them before, so large files filled the bound.
+
+### Memory, recall and answers
+
+- `get_node` lists, for its symbol, the current reviewed memories anchored to
+ it and the documents the reader may read that name it (`linked` in its
+ structured answer, and a line in its citations text). Stale, draft and
+ retired memories are never listed. A connection to one project lists that
+ project's only, also when `repo` reads another project's code graph.
+- Recall and answers take a `symbol_links` switch for the links between
+ reviewed memory and code symbols. Left out, a packet counts the links of
+ its excerpts and memories (`symbol_links`, status `counted`) and follows
+ none. `symbol_links: true` follows them one step each way: an excerpt of
+ code brings in the current reviewed memories linked to a symbol inside it,
+ and a reviewed memory brings in the current code of the symbols it is
+ linked to. `symbol_links: false` reads none. `graphicle mcp --set
+ symbol_links=true` (or `false`) fixes it for a server.
+- The packet's `mechanisms` now fill `symbol_links_enabled`, and
+ `links_used.memory` counts the memory links an answer used.
+- `memory.template` exports a project's reviewed procedures and decisions as
+ an engagement template. Each memory keeps only its kind, title, body and
+ state: quotes, links, ids, dates and authors are left out, and the
+ project's names, the files and symbols it cites, e-mail addresses, links,
+ credentials and terms you list are replaced by placeholders.
+- `memory.import_pack` imports reviewed memories, from an export or a
+ template, into another project as drafts to review. Symbol links are
+ matched to that project's code by path, qualified name, kind and ordinal,
+ and follow a symbol that moved to another file. Quotes are kept only where
+ that project's own sources hold them. Whatever cannot be matched is
+ dropped and counted.
+
+### MCP
+
+- `workspace_map`, a tool of workspace connections (the `graph.map`
+ operation over HTTP, the SDKs and `graphicle call`), maps the projects an
+ access key can read, 8 at a time: for each project, its files, documents,
+ code symbols, memories and links (imports from and into the other
+ projects, document mentions linked to its code, code symbols its memories
+ are anchored to), and the recorded imports between the projects, by pair.
+ Each project is counted as the key's own reads of it count it, and a
+ project the key may not read is left off the map.
+- `recall_project` takes a `cross_repo` switch for the step of a workspace
+ recall that follows imports between projects: `false` turns that step
+ alone off, and `true` turns it on even with `graph_retrieval: false`. Left
+ out, it follows `graph_retrieval`.
+- Every recall packet echoes the switches in force under
+ `mechanisms.switches`. `graphicle mcp --set` (and `serve --mcp-set`) also
+ fixes `cross_repo` and `scope` (`project` or `workspace`), and refuses a
+ switch it does not know.
+- `graphicle mcp --manifest` prints what the server would serve, as JSON,
+ and exits: the program's version, edition and sha256, the tools and
+ instructions with their sha256, the switches it fixes, and the schema and
+ format versions.
+
+### Sync
+
+- A folder sync reads the files Git tracks even when a `.gitignore`
+ pattern (or `.git/info/exclude`, or the global excludes) matches them
+ (`git ls-files --cached --ignored --exclude-standard`): Git versions them
+ with the rest, so they are the project's sources, as in a repository that
+ ignores its build output `jsonata.js` and tracks `src/jsonata.js`. Files
+ Git does not track are left out by those patterns as before, and
+ `node_modules`, `target`, credentials and the other skipped names stay
+ out, and so does a file an `.ignore` file leaves out. The freshness check
+ reads the same files, and the sync's output counts them
+ (`tracked_ignored`). `graphicle config set sync.tracked_ignored false`
+ leaves tracked files that a pattern matches out, as 0.1.2 did; the
+ environment variable `GRAPHICLE_SYNC_TRACKED_IGNORED` overrides the
+ setting. The refusals of a project or folder too large say that
+ `.gitignore` and `.git/info/exclude` cover untracked files only.
+
+### Data
+
+- `graphicle offboard --project PROJECT` removes one project's data from the
+ data folder: its sources, memory, code graph and history in the store, its
+ graph cache, and its copies in the backups kept in the data folder's
+ `backups/` folder. Other projects stay, in those backups too. It shows the
+ plan first and changes nothing until it runs again with
+ `--apply PLAN_HASH`, which carries out exactly that plan. It writes a
+ hash-chained deletion receipt that lists what it removed, touches nothing
+ outside the data folder, and names what it does not cover, such as backups
+ written elsewhere. A path it refuses (a link, or a backup with another
+ name) is never changed and may still hold the project, so the offboarding
+ is then reported as not fully verified.
+- `graphicle backup` without a path writes the backup to the data folder's
+ `backups/` folder.
+- On Windows, `graphicle offboard` leaves every backup in `backups/` as it is
+ and lists it as refused: Windows does not tell Graphicle whether a backup
+ file has another name outside the data folder.
+
+### Usage report
+
+- The owner's usage report (`GET /v1/workspaces/WORKSPACE_ID/usage`) and the
+ Usage view of the app now show what Graphicle served this month (`served`):
+ - the tokens of every MCP tool result and MCP resource read;
+ - over HTTP and through `graphicle call` and `graphicle context`, of every
+ operation an MCP tool runs and of the other reads of a project's
+ sources, memory, evidence or graph (such as `memory.export` and
+ `document.original`);
+ - of the session-start context that capture hooks give a coding agent.
+
+ Tokens are counted with cl100k_base on the text served, by credential,
+ agent session, channel, tool or operation, project and UTC day. A result
+ that names no project but serves several, such as a recall over every
+ project of a workspace, is counted on those projects: its tokens split by
+ the bytes served from each, and the call once, on the largest share.
+ Operations that return only settings, counts or listings, such as
+ `list_projects`, are not counted. These are the tokens Graphicle returned,
+ not your agents' bill: Graphicle does not see your agents' own model calls.
+- These counts never leave your machine. Graphicle keeps counters only, in a
+ new `am_served_usage` table of the local store: no question, result,
+ source id or client session id.
+ - Counting adds no write to a call; counts are written in batches a few
+ seconds later and when the program ends.
+ - Rows go with their project and are kept 25 months, and an agent
+ session's rows are folded into rows without a session after 90 days. One
+ access key keeps at most 200 agent sessions a UTC day; the calls of
+ further sessions that day are counted under one shared session,
+ `other-sessions`.
+ - `deletion.state` lists the table as history.
+ - The table is created the first time the new version opens an existing
+ store.
+- Beside them, the report lists Graphicle's own recorded model tokens by
+ credential and by model (`model_usage_by_credential`,
+ `model_usage_by_model`). `cost` stays null.
+- The MCP endpoints over HTTP (`/mcp/WORKSPACE_ID` and
+ `/mcp/WORKSPACE_ID/PROJECT_ID`) send an `Mcp-Session-Id` header with their
+ answer to `initialize`.
+ - The server signs the id, and the usage report uses it only to group a
+ client's calls into one agent session. An id the server did not sign is
+ counted under one shared session, `mcp:unverified`.
+ - A client that does not send the id back is served as before.
+ - Each `graphicle mcp` connection over stdio is one agent session. A
+ capture hook labels its start context with a digest of the coding
+ agent's session id, never the id itself.
+
+### Store
+
+- A store can record the oldest Graphicle that may open it, as a store format
+ (a new `store_readers` table, created when the new version first opens an
+ existing store). From this version on, Graphicle checks it before it
+ changes anything in a store, and refuses a store that needs a newer
+ program, naming the version it needs. Versions before 0.1.3 do not check.
+- A store can name credentials that a program must refuse unless it
+ enforces their restrictions itself: a table or view
+ `credential_requirements` (`credential_id`, `capability`). Graphicle
+ refuses each credential it names with a capability that `build.info` does
+ not list, instead of granting the credential its role's full access, also
+ in a restored portable backup. Graphicle Core lists none of these
+ capabilities. Graphicle 0.1.2 and older do not read the view and grant
+ such credentials their role's full access, so do not open a store that
+ names credentials there with them.
+
+### Extension interface
+
+- `Extension::authorize` lets an installed extension refuse or narrow a
+ request of a credential other than the owner capability wherever Graphicle
+ authorizes one (`Access`): a permission, a repository, a route that names
+ a workspace, an operation, an MCP tool. It may narrow an operation's
+ arguments and set the most tokens a read's result may hold: a larger read
+ result is refused with 413, and a write's result is never refused once it
+ is saved. `Extension::role_permits` lets it define roles beside
+ Graphicle's, and `Extension::grant_role` may refuse a new credential on a
+ role it defines. The caller of a request is resolved by authentication
+ alone, so these hooks see every credential, whatever its role grants; an
+ error other than a refusal while resolving it fails the request.
+- `Extension::served_allowed` lets an installed extension refuse a metered
+ MCP tool call, MCP resource read or HTTP operation of a credential other
+ than the owner capability, once `authorize` allowed it, for example for a
+ quota. `Extension::metered_operations` meters an extension's own reads of
+ project text.
+ - A refusal with status 429 carries `Retry-After` until the next UTC month.
+ - Core installs no extension, so it refuses and caps nothing, and the
+ command line and capture hooks are never refused for a quota.
+ - A commercial edition for teams is in private preview.
+- `Extension::sources` adds connector kinds beside Graphicle's (the `Source`
+ trait): their connectors are added, scheduled, synced and enforced on read
+ as Graphicle's own.
+- `Extension::vault_key` lets an extension hold the key that seals the
+ store's vault, for example a key held by an external key service; the
+ vault then never falls back to the device key file.
+- `Extension::cross_site_post` names a POST route that an extension
+ authenticates by itself, such as a sign-in callback that another site's
+ page posts to. Such a request skips the origin and browser-mutation
+ checks; the host check stays.
+- `JobKind::cpu_bound()` marks an extension's job kind as CPU-bound, so a
+ worker leases it only with a CPU permit, as it does Core's projections.
+- Routes under `/v1/workspaces/WORKSPACE_ID/usage/` are outside the monthly
+ request budget, like the usage report.
+
+### Other changes
+
+- rustls-webpki 0.103.16, webpki-roots 1.0.10 and webpki-root-certs 1.0.10:
+ certificate paths through the distrusted emSign intermediates are refused
+ (RUSTSEC-2026-0382 and RUSTSEC-2026-0381).
+
## 0.1.2 - 2026-10-18
Every crate is at 0.1.2, and `graphicle --version` prints
diff --git a/README.md b/README.md
index f89c5d7..e25d843 100644
--- a/README.md
+++ b/README.md
@@ -172,6 +172,17 @@ Every figure is labelled, and [docs/benchmarks.md](docs/benchmarks.md) has the f
- **Answering questions** (the same setup). On Graphify's showcase corpus (30 questions), the 0.1.1 agent defaults (a pre-release build) found 99.2% of the facts, against 94.7% for plain Claude Code (a tie) and 87.8% for Graphify 0.9.91: more facts than Graphify, with fewer tokens. On 60 questions about our own project all three tied, and Graphify used about 48k more tokens per question than Graphicle (pre-release 0.1.1 plus a prototype context hook) ([every agent test](docs/benchmarks.md#coding-agents-with-graphicle-graphify-or-neither)).
- **Agent memory.** In a comparison with seven memory systems, registered before any answer was scored and run with one open model as every system's reader and judge, a pre-release build of Graphicle trails none on three development sets. [Every score, with its method and caveats](docs/benchmarks.md#agent-memory-comparison-with-seven-memory-systems).
+### Finding the files a fix changes
+
+<p align="center">
+ <picture>
+ <source media="(prefers-color-scheme: dark)" srcset="docs/assets/retrieval-dark.svg">
+ <img src="docs/assets/retrieval-light.svg" alt="Finding the files a fix changes: 100 SWE-bench Verified issues, held out from tuning. Top 1: Graphicle 0.1.3 43, Graphicle 0.1.2 13, BM25 (SWE-bench style) 35, grep for the issue's names 20; Top 5: Graphicle 0.1.3 75, Graphicle 0.1.2 30, BM25 (SWE-bench style) 61, grep for the issue's names 54; Top 10: Graphicle 0.1.3 82, Graphicle 0.1.2 30, BM25 (SWE-bench style) 77, grep for the issue's names 71; MRR: Graphicle 0.1.3 0.562, Graphicle 0.1.2 0.191, BM25 (SWE-bench style) 0.478, grep for the issue's names 0.365.">
+ </picture>
+</p>
+
+**Offline ranking, 100 SWE-bench Verified issues never used for tuning.** Graphicle 0.1.3 put a file the fix changed in its first 5 files for 75 issues, against 61 for BM25 (SWE-bench style), a significant difference (McNemar exact p = 0.013); for the first file (43 vs 35) and the first 10 (82 vs 77) the differences are not significant. This measures ranking, not whether a coding agent fixes more issues; the agent test of 0.1.3 is pending ([method, task lists and limits](docs/benchmarks/retrieval.md)).
+
## FAQ
### Privacy and local first
diff --git a/crates/graphicle-graph/Cargo.lock b/crates/graphicle-graph/Cargo.lock
index 9e76f2a..5f5fff3 100644
--- a/crates/graphicle-graph/Cargo.lock
+++ b/crates/graphicle-graph/Cargo.lock
@@ -1403,7 +1403,7 @@ checksum = "e4eba85ea1d0a966a983acd07deee566e67395d2d96b6fb39e62b5a833f1eb0b"
[[package]]
name = "graphicle"
-version = "0.1.2"
+version = "0.1.3"
dependencies = [
"aws-config",
"aws-sdk-bedrockruntime",
@@ -1501,7 +1501,7 @@ dependencies = [
[[package]]
name = "graphicle-graph"
-version = "0.1.2"
+version = "0.1.3"
dependencies = [
"graphicle",
"libmimalloc-sys",
@@ -3683,9 +3683,9 @@ dependencies = [
[[package]]
name = "rustls-webpki"
-version = "0.103.15"
+version = "0.103.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f3c3cf1d8b1e7d4927e2d154c3fcb02979afb9939629c62cd9048d4f07b60ac2"
+checksum = "4443b1b6d39d7c663139942cc4558262562d2c84123bb6282ef177009ca8b281"
dependencies = [
"aws-lc-rs",
"ring",
@@ -5066,9 +5066,9 @@ dependencies = [
[[package]]
name = "webpki-roots"
-version = "1.0.9"
+version = "1.0.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7dcd9d09a39985f5344844e66b0c530a33843579125f23e21e9f0f220850f22a"
+checksum = "1c1c8e20c8a38fc7d65abfe74eb7280e4aa667e8eec8bc84996d2874810748d9"
dependencies = [
"rustls-pki-types",
]
diff --git a/crates/graphicle-graph/Cargo.toml b/crates/graphicle-graph/Cargo.toml
index 55a8bdd..a0da138 100644
--- a/crates/graphicle-graph/Cargo.toml
+++ b/crates/graphicle-graph/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "graphicle"
-version = "0.1.2"
+version = "0.1.3"
edition = "2024"
rust-version = "1.94.1"
publish = false
diff --git a/crates/graphicle-graph/README.md b/crates/graphicle-graph/README.md
index cd7b74a..88b4ec0 100644
--- a/crates/graphicle-graph/README.md
+++ b/crates/graphicle-graph/README.md
@@ -278,10 +278,12 @@ with the pinned upstream reference, with the reviewed upstream fixes of
the reference's own tests against the engine (see above; the repository's
`docs/benchmarks.md` has their results). That page's
[parity section](../../docs/benchmarks.md#parity-with-graphify) also
-records a known difference: on gohugoio/hugo v0.167.0, the graph after
-`graphicle graph update` differs from Graphify 0.9.88's in the stored front
-matter of one Markdown page, because the engine's YAML parser rejects a list
-that the page closes at the start of a line. Folder, environment-variable,
+records a known difference of the checked build: on gohugoio/hugo v0.167.0,
+its graph after `graphicle graph update` differed from Graphify 0.9.88's in
+the stored front matter of one Markdown page, because its YAML parser
+rejected a list that the page closes at the start of a line; from 0.1.3 the
+engine reads that list as YAML, and the comparison has not been run again
+since. Folder, environment-variable,
command and installed-file names follow a documented translation table
(`tools/naming.py`), which the checks apply. The first two items below are on
by default and change no output; the rest are opt-in, and the parity claim
diff --git a/crates/graphicle-graph/cli/Cargo.toml b/crates/graphicle-graph/cli/Cargo.toml
index 4757c10..3d1d56e 100644
--- a/crates/graphicle-graph/cli/Cargo.toml
+++ b/crates/graphicle-graph/cli/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "graphicle-graph"
-version = "0.1.2"
+version = "0.1.3"
edition = "2024"
rust-version = "1.94.1"
publish = false
diff --git a/crates/graphicle-graph/licenses/THIRD_PARTY_LICENSES.html b/crates/graphicle-graph/licenses/THIRD_PARTY_LICENSES.html
index 05f50a4..0c95565 100644
--- a/crates/graphicle-graph/licenses/THIRD_PARTY_LICENSES.html
+++ b/crates/graphicle-graph/licenses/THIRD_PARTY_LICENSES.html
@@ -11193,7 +11193,7 @@ express Statement of Purpose.
</pre>
<h3 id="CDLA-Permissive-2.0">Community Data License Agreement Permissive 2.0</h3>
<p>Used by:</p>
-<ul><li><a href="https://github.com/rustls/webpki-roots">webpki-roots 1.0.9</a></li>
+<ul><li><a href="https://github.com/rustls/webpki-roots">webpki-roots 1.0.10</a></li>
</ul>
<pre># Community Data License Agreement - Permissive - Version 2.0
@@ -11801,7 +11801,7 @@ THIS SOFTWARE.
</pre>
<h3 id="ISC">ISC License</h3>
<p>Used by:</p>
-<ul><li><a href="https://github.com/rustls/webpki">rustls-webpki 0.103.15</a></li>
+<ul><li><a href="https://github.com/rustls/webpki">rustls-webpki 0.103.16</a></li>
</ul>
<pre>Except as otherwise noted, this project is licensed under the following
(ISC-style) terms:
diff --git a/crates/graphicle-graph/src/extractors/yaml_frontmatter.rs b/crates/graphicle-graph/src/extractors/yaml_frontmatter.rs
index 8a7b0a6..61d7f28 100644
--- a/crates/graphicle-graph/src/extractors/yaml_frontmatter.rs
+++ b/crates/graphicle-graph/src/extractors/yaml_frontmatter.rs
@@ -10,7 +10,7 @@ use serde_json::{Map, Value, json};
use std::{collections::HashMap, sync::LazyLock};
use yaml_rust2::{
parser::{Event, EventReceiver, Parser, Tag},
- scanner::{Scanner, TScalarStyle, TokenType},
+ scanner::{Scanner, TScalarStyle, Token, TokenType},
};
static INT: LazyLock<Regex> = LazyLock::new(|| {
@@ -380,15 +380,100 @@ fn expand(nodes: &[Node], id: usize, depth: usize) -> Result<Value> {
}
}
}
-pub fn parse(text: &str) -> Result<Value> {
+/// One scan of `text`: refuses duplicate anchors and, when the scan stops at an
+/// indentation error inside a flow collection, returns `text` with the rejected
+/// line moved right of the outermost open bracket.
+///
+/// PyYAML ignores indentation in flow context (`Scanner.unwind_indent`: "In the
+/// flow context, indentation is ignored. We make the scanner less restrictive
+/// then specification requires."); yaml-rust2 does not. Front matter such as
+/// Hugo's
+///
+/// ```yaml
+/// aliases: [
+/// '/templates/base/',
+/// ]
+/// ```
+///
+/// (the closing bracket at the key's column) is therefore YAML upstream but a
+/// scan error here, and the flat fallback stored `"aliases": "["` and string
+/// scalars. Leading spaces inside a flow collection carry no content, so the
+/// repaired text has the reference's value. The scanner hands over a bracket
+/// only once it knows that the bracket does not start a key, so a flow
+/// collection that opens a line or follows `- ` is not repaired. Any other scan
+/// error is left for the parser to report.
+fn scan_repairing_flow_indentation(text: &str) -> Result<Option<String>> {
let mut anchors = std::collections::HashSet::new();
- for token in Scanner::new(text.chars()) {
- if let TokenType::Anchor(name) = token.1
- && !anchors.insert(name)
- {
- return Err("Duplicate YAML anchor".into());
+ let mut flows = vec![];
+ let mut scanner = Scanner::new(text.chars());
+ for Token(mark, token) in &mut scanner {
+ match token {
+ TokenType::Anchor(name) if anchors.contains(&name) => {
+ return Err("Duplicate YAML anchor".into());
+ }
+ TokenType::Anchor(name) => {
+ anchors.insert(name);
+ }
+ TokenType::FlowSequenceStart | TokenType::FlowMappingStart => flows.push(mark),
+ TokenType::FlowSequenceEnd | TokenType::FlowMappingEnd => {
+ flows.pop();
+ }
+ _ => (),
+ }
+ }
+ let (Some(error), Some(outer)) = (scanner.get_error(), flows.first()) else {
+ return Ok(None);
+ };
+ if !error.info().contains("indentation") {
+ return Ok(None);
+ }
+ let (col, target) = (error.marker().col(), outer.col() + 1);
+ let Some(index) = error.marker().line().checked_sub(1) else {
+ return Ok(None);
+ };
+ let lines = text.split('\n').collect::<Vec<_>>();
+ // Only rightwards, and only a line whose first character after its leading
+ // spaces is where the scan stopped.
+ match lines.get(index) {
+ Some(line) if col < target && line.len() - line.trim_start_matches(' ').len() == col => {}
+ _ => return Ok(None),
+ }
+ let mut out = String::with_capacity(text.len() + target);
+ for (i, line) in lines.iter().enumerate() {
+ if i > 0 {
+ out.push('\n');
+ }
+ if i == index {
+ out.push_str(&" ".repeat(target - col));
+ }
+ out.push_str(line);
+ }
+ Ok(Some(out))
+}
+/// Bytes that the rescans of one `parse` may read in all. Each moved line costs
+/// one more scan of the whole text, so a text with very many of them would take
+/// quadratic time; front matter (`markdown::FRONTMATTER_MAX_LINES` lines at
+/// most) and manifests of ordinary size stay far below this.
+const FLOW_REPAIR_READ_LIMIT: usize = 16 << 20;
+/// `text` scanned again after each line that `scan_repairing_flow_indentation`
+/// moves, until a scan moves none. A repaired line clears every flow indent, so
+/// each line is moved at most once; past `limit` bytes read by the rescans, the
+/// text is refused and the caller keeps its flat fallback.
+fn repair_flow_indentation(text: &str, limit: usize) -> Result<std::borrow::Cow<'_, str>> {
+ let mut text = std::borrow::Cow::Borrowed(text);
+ let mut read = 0;
+ while let Some(repaired) = scan_repairing_flow_indentation(&text)? {
+ read += text.len();
+ if read > limit {
+ return Err("Too many YAML flow collection lines to move".into());
}
+ text = std::borrow::Cow::Owned(repaired);
}
+ Ok(text)
+}
+pub fn parse(text: &str) -> Result<Value> {
+ let text = repair_flow_indentation(text, FLOW_REPAIR_READ_LIMIT)?;
+ let text = text.as_ref();
let mut builder = Builder::default();
Parser::new_from_str(text)
.load(&mut builder, true)
@@ -404,3 +489,92 @@ pub fn parse(text: &str) -> Result<Value> {
None => Ok(Value::Null),
}
}
+
+#[cfg(test)]
+mod tests {
+ use super::{parse, repair_flow_indentation};
+ use serde_json::json;
+
+ // gohugoio/hugo 3fff6fb5, docs/content/en/templates/types.md: the closing
+ // bracket of a flow sequence at the key's column. Expected values are
+ // PyYAML 6.0.3's yaml.safe_load, which Graphify 0.9.91 uses.
+ const HUGO: [&str; 16] = [
+ "title: Template types",
+ "description: Create templates of different types to render your content, resources, and data.",
+ "categories: []",
+ "keywords: []",
+ "weight: 30",
+ "aliases: [",
+ " '/templates/base/',",
+ " '/templates/content-view/',",
+ " '/templates/home/',",
+ " '/templates/lists/',",
+ " '/templates/partial/',",
+ " '/templates/section/',",
+ " '/templates/single/',",
+ " '/templates/taxonomy/',",
+ " '/templates/term/',",
+ "]",
+ ];
+
+ #[test]
+ fn flow_collection_lines_at_the_block_indent_parse_as_pyyaml_does() {
+ assert_eq!(
+ parse(&HUGO.join("\n")).unwrap(),
+ json!({"title": "Template types",
+ "description": "Create templates of different types to render your content, resources, and data.",
+ "categories": [], "keywords": [], "weight": 30,
+ "aliases": ["/templates/base/", "/templates/content-view/", "/templates/home/",
+ "/templates/lists/", "/templates/partial/", "/templates/section/",
+ "/templates/single/", "/templates/taxonomy/", "/templates/term/"]})
+ );
+ for (text, expected) in [
+ ("- [\n a,\n]", json!([["a"]])),
+ ("a:\n b: [\n x,\n ]", json!({"a": {"b": ["x"]}})),
+ ("m: {\n k: 1,\n}", json!({"m": {"k": 1}})),
+ (
+ "tags: [\ngo,\nyaml\n]\nweight: 5",
+ json!({"tags": ["go", "yaml"], "weight": 5}),
+ ),
+ ("a: [[\n1,\n],\n2]", json!({"a": [[1], 2]})),
+ (
+ "a: {\n'k': 'v',\n'l': [\n'w'\n]\n}",
+ json!({"a": {"k": "v", "l": ["w"]}}),
+ ),
+ ("- key: [\n'v',\n]", json!([{"key": ["v"]}])),
+ ("a: &x [\n'1'\n]\nb: *x", json!({"a": ["1"], "b": ["1"]})),
+ ("a: [\r\nb\r\n]", json!({"a": ["b"]})),
+ ] {
+ assert_eq!(parse(text).unwrap(), expected, "{text:?}");
+ }
+ }
+
+ #[test]
+ fn other_scan_errors_still_reach_the_fallback() {
+ // PyYAML rejects both; the caller keeps its flat fallback for them.
+ assert!(parse("a: [\n x").is_err());
+ assert!(parse("a:\n b: 1\n c: 2").is_err());
+ // The text is scanned again after a moved line, so a duplicate anchor
+ // after it is still refused, as PyYAML refuses it.
+ assert!(parse("a: &x [\n'1'\n]\nb: &x 2").is_err());
+ }
+
+ #[test]
+ fn rescans_stop_at_their_read_limit() {
+ // 101 moved lines: each entry and the closing bracket.
+ let text = format!("a: [\n{}]", "'x',\n".repeat(100));
+ assert_eq!(
+ parse(&text).unwrap()["a"].as_array().map(Vec::len),
+ Some(100)
+ );
+ assert!(repair_flow_indentation(&text, 10 * text.len()).is_err());
+ }
+
+ #[test]
+ fn hugo_front_matter_keeps_its_types_on_the_page_node() {
+ let fm = crate::extractors::markdown::parse_frontmatter(&HUGO);
+ assert_eq!(fm["weight"], json!(30));
+ assert_eq!(fm["categories"], json!([]));
+ assert_eq!(fm["aliases"].as_array().map(Vec::len), Some(9));
+ }
+}
diff --git a/crates/graphicle-memory/Cargo.lock b/crates/graphicle-memory/Cargo.lock
index c42fd4c..9dcd53c 100644
--- a/crates/graphicle-memory/Cargo.lock
+++ b/crates/graphicle-memory/Cargo.lock
@@ -1453,7 +1453,7 @@ checksum = "e4eba85ea1d0a966a983acd07deee566e67395d2d96b6fb39e62b5a833f1eb0b"
[[package]]
name = "graphicle"
-version = "0.1.2"
+version = "0.1.3"
dependencies = [
"aws-config",
"aws-sdk-bedrockruntime",
@@ -1551,7 +1551,7 @@ dependencies = [
[[package]]
name = "graphicle-memory"
-version = "0.1.2"
+version = "0.1.3"
dependencies = [
"chrono",
"graphicle",
@@ -3817,9 +3817,9 @@ checksum = "f87165f0995f63a9fbeea62b64d10b4d9d8e78ec6d7d51fb2125fda7bb36788f"
[[package]]
name = "rustls-webpki"
-version = "0.103.15"
+version = "0.103.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f3c3cf1d8b1e7d4927e2d154c3fcb02979afb9939629c62cd9048d4f07b60ac2"
+checksum = "4443b1b6d39d7c663139942cc4558262562d2c84123bb6282ef177009ca8b281"
dependencies = [
"aws-lc-rs",
"ring",
@@ -5290,18 +5290,18 @@ dependencies = [
[[package]]
name = "webpki-root-certs"
-version = "1.0.9"
+version = "1.0.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b96554aa2acc8ccdb7e1c9a58a7a68dd5d13bccc69cd124cb09406db612a1c9b"
+checksum = "58ec80e73fd8baf57bf0d9615554c75348bda990d6d5bbeab964dd068319fecb"
dependencies = [
"rustls-pki-types",
]
[[package]]
name = "webpki-roots"
-version = "1.0.9"
+version = "1.0.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7dcd9d09a39985f5344844e66b0c530a33843579125f23e21e9f0f220850f22a"
+checksum = "1c1c8e20c8a38fc7d65abfe74eb7280e4aa667e8eec8bc84996d2874810748d9"
dependencies = [
"rustls-pki-types",
]
diff --git a/crates/graphicle-memory/Cargo.toml b/crates/graphicle-memory/Cargo.toml
index f04a2ce..54287ee 100644
--- a/crates/graphicle-memory/Cargo.toml
+++ b/crates/graphicle-memory/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "graphicle-memory"
-version = "0.1.2"
+version = "0.1.3"
edition = "2024"
rust-version = "1.94.1"
publish = false
diff --git a/crates/graphicle-memory/src/graph/cross_repo_imports.rs b/crates/graphicle-memory/src/graph/cross_repo_imports.rs
index e3adc52..b056c4c 100644
--- a/crates/graphicle-memory/src/graph/cross_repo_imports.rs
+++ b/crates/graphicle-memory/src/graph/cross_repo_imports.rs
@@ -62,7 +62,8 @@ impl Ecosystem {
Ecosystem::Go => "go",
}
}
- fn of_file(relpath: &str) -> Option<Self> {
+ /// The ecosystem of an importing file, by its extension.
+ pub fn of_file(relpath: &str) -> Option<Self> {
let lower = relpath.to_ascii_lowercase();
if PY_EXTS.iter().any(|e| lower.ends_with(e)) {
Some(Ecosystem::Python)
diff --git a/crates/graphicle-memory/src/packing.rs b/crates/graphicle-memory/src/packing.rs
index 4457316..a66a2d2 100644
--- a/crates/graphicle-memory/src/packing.rs
+++ b/crates/graphicle-memory/src/packing.rs
@@ -336,6 +336,37 @@ fn project_line(item: &Value, compact: bool) -> String {
_ => String::new(),
}
}
+/// An excerpt's citation line: `Source [<kind>]: <path>:<line>`, and the
+/// date its file last changed when the caller dated it (`changed`).
+fn citation(source: &Value, line: u64) -> String {
+ let mut text = format!(
+ "\nSource [{}]: {}:{line}",
+ field(source, "source_kind"),
+ field(source, "path")
+ );
+ if let Some(changed) = source
+ .get("changed")
+ .and_then(Value::as_str)
+ .filter(|c| !c.is_empty())
+ {
+ text.push_str(&format!(" (changed {changed})"));
+ }
+ text.push('\n');
+ text
+}
+/// The caller's age marks of a source (`age_marks`: may be stale), a
+/// `Note:` line each.
+fn age_lines(source: &Value) -> String {
+ source
+ .get("age_marks")
+ .and_then(Value::as_array)
+ .into_iter()
+ .flatten()
+ .filter_map(Value::as_str)
+ .take(6)
+ .map(|mark| format!("Note: {mark}\n"))
+ .collect()
+}
fn reader_of(source: &Value) -> &'static str {
if field(source, "source_kind") == "repository_file" {
"read_repository_file"
@@ -396,6 +427,13 @@ pub fn pack(request: &Value) -> Result<Value> {
let fraction = if memories.is_empty() { 1.0 } else { 0.8 };
let mut source_tokens = ((max_tokens - header_tokens - 100) as f64 * fraction) as usize;
let mut source_chars = ((max_chars - header_chars - 350) as f64 * fraction) as usize;
+ // Opt-in `next_files`: after the excerpts, the paths of the files that
+ // rank next, one per line. Room for them is kept from the excerpts'
+ // share (at most an eighth of the budget).
+ let next = NextFiles::parse(request)?;
+ let (next_tokens, next_chars) = next.reserve(max_tokens, max_chars);
+ source_tokens = source_tokens.saturating_sub(next_tokens);
+ source_chars = source_chars.saturating_sub(next_chars);
let mut sources = Vec::new();
let mut included_memories = Vec::new();
let mut omitted_sources = 0;
@@ -463,12 +501,11 @@ pub fn pack(request: &Value) -> Result<Value> {
.checked_add(body.len() as u64)
.ok_or("Source byte range exceeds u64")?;
let id = crate::string(item, "identity")?;
- let mut intro = format!(
- "\nSource [{}]: {}:{}\n",
- field(source, "source_kind"),
- field(source, "path"),
- source.get("line").and_then(Value::as_u64).unwrap_or(1)
+ let mut intro = citation(
+ source,
+ source.get("line").and_then(Value::as_u64).unwrap_or(1),
);
+ intro.push_str(&age_lines(source));
intro.push_str(&project_line(source, compact));
if !compact || field(source, "id") != format!("file:{}", field(source, "path")) {
intro.push_str(&format!("ID: {}\n", field(source, "id")));
@@ -550,16 +587,8 @@ pub fn pack(request: &Value) -> Result<Value> {
.ok_or("Source line range exceeds u64")?;
// The excerpt's visible citation must agree with its structured
// byte/line reference, including when focus skips earlier text.
- let old_intro = format!(
- "\nSource [{}]: {}:{old_line}\n",
- field(source, "source_kind"),
- field(source, "path")
- );
- let new_intro = format!(
- "\nSource [{}]: {}:{line}\n",
- field(source, "source_kind"),
- field(source, "path")
- );
+ let old_intro = citation(source, old_line);
+ let new_intro = citation(source, line);
intro.replace_range(..old_intro.len(), &new_intro);
reference.insert("window_byte_start".into(), json!(source_start));
reference.insert("byte_start".into(), json!(source_start + offset as u64));
@@ -640,11 +669,7 @@ pub fn pack(request: &Value) -> Result<Value> {
quote_end,
)
{
- let mut payload = format!(
- "\nSource [{}]: {}:{line}\n",
- field(source, "source_kind"),
- field(source, "path")
- );
+ let mut payload = citation(source, line);
payload.push_str(&project_line(source, compact));
if !compact || field(source, "id") != format!("file:{}", field(source, "path")) {
payload.push_str(&format!("ID: {}\n", field(source, "id")));
@@ -884,6 +909,18 @@ pub fn pack(request: &Value) -> Result<Value> {
record.remove("body");
included_memories.push(Value::Object(record));
}
+ // The next files, those no excerpt quotes, while they fit.
+ let quoted: std::collections::BTreeSet<&str> = sources
+ .iter()
+ .chain(&held_references)
+ .filter_map(|source| source.get("path").and_then(Value::as_str))
+ .collect();
+ let listed = next.append(
+ &mut rendered,
+ &quoted,
+ max_tokens.saturating_sub(100),
+ max_chars.saturating_sub(350),
+ );
let coverage = request.get("coverage").cloned().unwrap_or(json!({}));
let stale = coverage
.get("stale_memories")
@@ -923,5 +960,116 @@ pub fn pack(request: &Value) -> Result<Value> {
if guidance {
result["reading_guidance"] = json!(true);
}
+ if next.limit > 0 {
+ result["next_files"] = json!(listed);
+ }
Ok(result)
}
+
+/// Most `next_files` one packet lists.
+pub const MAX_NEXT_FILES: usize = 40;
+/// The line before the next files.
+pub const NEXT_FILES_HEADING: &str =
+ "\nNext ranked files (not quoted here; read them if the excerpts fall short):\n";
+
+/// The request's `next_files`: `{"paths": [...], "limit": n}`, the paths in
+/// rank order (those an excerpt quotes are skipped), at most `limit` (0 to
+/// [`MAX_NEXT_FILES`]) listed.
+struct NextFiles {
+ paths: Vec<String>,
+ limit: usize,
+}
+
+impl NextFiles {
+ fn parse(request: &Value) -> Result<Self> {
+ let Some(value) = request.get("next_files").filter(|v| !v.is_null()) else {
+ return Ok(Self {
+ paths: Vec::new(),
+ limit: 0,
+ });
+ };
+ let refused = || "next_files must be an object of paths (strings) and a limit of 0 to 40";
+ let limit = value
+ .get("limit")
+ .and_then(Value::as_u64)
+ .filter(|n| *n as usize <= MAX_NEXT_FILES)
+ .ok_or_else(refused)? as usize;
+ let paths = value
+ .get("paths")
+ .and_then(Value::as_array)
+ .filter(|paths| paths.len() <= 4 * MAX_NEXT_FILES + 200)
+ .ok_or_else(refused)?
+ .iter()
+ .map(|path| {
+ path.as_str()
+ .filter(|p| !p.is_empty() && p.len() <= 1000 && !p.contains('\n'))
+ .map(str::to_string)
+ .ok_or_else(refused)
+ })
+ .collect::<std::result::Result<Vec<_>, _>>()?;
+ Ok(Self { paths, limit })
+ }
+
+ fn line(path: &str) -> String {
+ format!("- {path}\n")
+ }
+
+ /// The tokens and characters kept for the list: the heading and the
+ /// first `limit` paths, at most an eighth of the budget.
+ fn reserve(&self, max_tokens: usize, max_chars: usize) -> (usize, usize) {
+ if self.limit == 0 || self.paths.is_empty() {
+ return (0, 0);
+ }
+ let mut text = NEXT_FILES_HEADING.to_string();
+ // The quoted files are skipped, so the reserve counts the longest
+ // of twice as many paths.
+ let mut longest: Vec<&String> = self.paths.iter().take(2 * self.limit).collect();
+ longest.sort_by_key(|path| std::cmp::Reverse(path.len()));
+ for path in longest.into_iter().take(self.limit) {
+ text.push_str(&Self::line(path));
+ }
+ (
+ text::count(&text).min(max_tokens / 8),
+ chars(&text).min(max_chars / 8),
+ )
+ }
+
+ /// Append the heading and the paths no excerpt quotes, in order, while
+ /// they fit within `tokens` and `characters`; the paths listed.
+ fn append(
+ &self,
+ rendered: &mut String,
+ quoted: &std::collections::BTreeSet<&str>,
+ tokens: usize,
+ characters: usize,
+ ) -> Vec<String> {
+ let mut listed = Vec::new();
+ if self.limit == 0 {
+ return listed;
+ }
+ let mut seen = std::collections::BTreeSet::new();
+ let mut block = String::new();
+ for path in &self.paths {
+ if listed.len() >= self.limit {
+ break;
+ }
+ if quoted.contains(path.as_str()) || !seen.insert(path.as_str()) {
+ continue;
+ }
+ let heading = if block.is_empty() {
+ NEXT_FILES_HEADING
+ } else {
+ ""
+ };
+ let line = format!("{heading}{}", Self::line(path));
+ let candidate = format!("{rendered}{block}{line}");
+ if !fits(&candidate, tokens, characters) {
+ break;
+ }
+ block.push_str(&line);
+ listed.push(path.clone());
+ }
+ rendered.push_str(&block);
+ listed
+ }
+}
diff --git a/crates/graphicle-memory/src/retrieval.rs b/crates/graphicle-memory/src/retrieval.rs
index de5f557..e69a2ba 100644
--- a/crates/graphicle-memory/src/retrieval.rs
+++ b/crates/graphicle-memory/src/retrieval.rs
@@ -640,8 +640,26 @@ pub fn rank(request: &Value) -> Result<Value> {
.iter()
.map(|n| weight_of(n))
.collect::<Result<Vec<_>>>()?;
+ // Opt-in `origin_prior`: a weight between 0 and 1 per origin (the
+ // runtime's code-first prior gives a code question's documentation and
+ // test files less than their source). Every fused score of the origin's
+ // rows, and every score the relationship lift gives them, is multiplied
+ // by it before the order is taken, so selection and packing see it.
+ let priors = origin_priors(request)?;
+ let prior = |i: usize| -> f64 {
+ rows[i]
+ .get("origin")
+ .and_then(Value::as_str)
+ .and_then(|origin| priors.get(origin))
+ .copied()
+ .unwrap_or(1.0)
+ };
let mut scores: BTreeMap<String, f64> = rrf_weighted(&rankings, &weights, rrf_k, 0.0)?
.into_iter()
+ .map(|(id, score)| {
+ let weight = ids.get(&id).map_or(1.0, |&i| prior(i));
+ (id, score * weight)
+ })
.collect();
let mut reasons: BTreeMap<String, Vec<String>> = BTreeMap::new();
for ((name, ranking), weight) in names.iter().zip(&rankings).zip(&weights) {
@@ -730,7 +748,7 @@ pub fn rank(request: &Value) -> Result<Value> {
.filter(|t| features[i].words.contains_key(t))
.count() as f64
/ q.len().max(1) as f64;
- let score = top * (0.45 + 0.15 * overlap) / (hop as f64);
+ let score = top * (0.45 + 0.15 * overlap) / (hop as f64) * prior(i);
let entry = scores.entry(id.to_owned()).or_default();
*entry = entry.max(score);
reasons
@@ -980,6 +998,9 @@ pub fn rank(request: &Value) -> Result<Value> {
if quota.is_some() {
output["origin_quota"] = json!({"origins":origin_count});
}
+ if !priors.is_empty() {
+ output["origin_prior"] = json!({"origins":priors.len()});
+ }
if stem {
output["stemmer"] = json!("porter");
}
@@ -998,6 +1019,29 @@ pub fn rank(request: &Value) -> Result<Value> {
Ok(output)
}
+/// The request's `origin_prior`: origin → weight, each between 0 and 1;
+/// absent or `null`, none. At most [`MAX_ROWS`] origins.
+fn origin_priors(request: &Value) -> Result<BTreeMap<String, f64>> {
+ let Some(value) = request.get("origin_prior").filter(|v| !v.is_null()) else {
+ return Ok(BTreeMap::new());
+ };
+ let refused = || "origin_prior must map origins to weights between 0 and 1".into();
+ let entries = value
+ .as_object()
+ .filter(|entries| entries.len() <= MAX_ROWS)
+ .ok_or_else(refused)?;
+ entries
+ .iter()
+ .map(|(origin, weight)| {
+ weight
+ .as_f64()
+ .filter(|w| (0.0..=1.0).contains(w))
+ .map(|w| (origin.clone(), w))
+ .ok_or_else(refused)
+ })
+ .collect()
+}
+
/// Most static relationship edges [`rank`] reads.
pub const MAX_STATIC_EDGES: usize = 50_000;
diff --git a/crates/graphicle-memory/tests/native_contracts.rs b/crates/graphicle-memory/tests/native_contracts.rs
index 3787a55..8128cba 100644
--- a/crates/graphicle-memory/tests/native_contracts.rs
+++ b/crates/graphicle-memory/tests/native_contracts.rs
@@ -327,6 +327,37 @@ fn packed_utf8_excerpts_have_exact_byte_offsets_and_never_cut_procedures() {
assert_eq!(source["complete"], false);
}
+#[test]
+fn dated_excerpts_cite_their_change_and_age_marks_and_keep_them_when_focused() {
+ let mut body = "unrelated words\n\n".repeat(400);
+ body.push_str("The build host is ci-runner-07.\n");
+ let request = |focus: bool| {
+ let mut request = json!({"repo":{"id":"r","name":"Repo","snapshot":"one"},"question":"which build host","hits":[
+ {"identity":"a","text":body,"source":{"source_kind":"repository_file","path":"notes/node.md","id":"file:notes/node.md",
+ "sha256":"hash","byte_start":0,"line":1,"changed":"2026-10-15 06:52 UTC",
+ "age_marks":["may be stale: src/sync.rs (defines `sync_all`) changed 2026-10-15 07:00 UTC"]}},
+ {"identity":"b","text":"plain text\n","source":{"source_kind":"repository_file","path":"plain.md","id":"file:plain.md",
+ "sha256":"hash2","byte_start":0,"line":1}}],
+ "memories":[],"max_tokens":3000,"max_chars":6000});
+ if focus {
+ request["pack_focus"] = json!(true);
+ }
+ request
+ };
+ for focus in [false, true] {
+ let result = packing::pack(&request(focus)).unwrap();
+ let markdown = result["markdown"].as_str().unwrap();
+ let line = result["sources"][0]["line"].as_u64().unwrap();
+ assert!(markdown.contains(&format!(
+ "\nSource [repository_file]: notes/node.md:{line} (changed 2026-10-15 06:52 UTC)\nNote: may be stale: src/sync.rs (defines `sync_all`) changed 2026-10-15 07:00 UTC\n"
+ )));
+ // An undated source is cited as before.
+ assert!(markdown.contains("\nSource [repository_file]: plain.md:1\nID: file:plain.md\n"));
+ assert_eq!(result["sources"][0]["changed"], "2026-10-15 06:52 UTC");
+ assert_eq!(focus, line > 1);
+ }
+}
+
#[test]
fn abi_and_in_process_boundaries_reject_malformed_input_without_panics() {
for bytes in [
@@ -1441,6 +1472,89 @@ fn origin_quotas_let_the_best_origin_give_more_and_counting_keeps_the_limit() {
assert_eq!(counted["fused"].as_array().unwrap().len(), 5);
}
+#[test]
+fn an_origin_prior_scales_its_rows_before_the_order_is_taken() {
+ let rows = vec![
+ passage(
+ "doc",
+ "file:docs/parser.md",
+ "The parser reads the header and the parser checks the header length.",
+ ),
+ passage(
+ "code",
+ "file:src/parser.rs",
+ "fn read_header() { let length = 4; }",
+ ),
+ ];
+ let base = json!({"scope":"prior-test","question":"parser header length","rows":rows,
+ "limit":2,"debug_fused":2});
+ let order = |ranked: &Value| ranked["fused"].clone();
+ let plain = retrieval::rank(&base).unwrap();
+ assert_eq!(order(&plain), json!(["doc", "code"]));
+ assert!(plain.get("origin_prior").is_none());
+ let mut prior = base.clone();
+ prior["origin_prior"] = json!({"file:docs/parser.md": 0.1});
+ let ranked = retrieval::rank(&prior).unwrap();
+ assert_eq!(order(&ranked), json!(["code", "doc"]), "{ranked}");
+ assert_eq!(ranked["sources"], json!(["code", "doc"]));
+ assert_eq!(ranked["origin_prior"]["origins"], 1);
+ // A weight of 1 changes nothing; weights outside 0 to 1 are refused.
+ prior["origin_prior"] = json!({"file:docs/parser.md": 1.0});
+ assert_eq!(order(&retrieval::rank(&prior).unwrap()), order(&plain));
+ for bad in [
+ json!({"file:docs/parser.md": 1.5}),
+ json!({"x": "a"}),
+ json!([0.5]),
+ ] {
+ prior["origin_prior"] = bad;
+ assert!(retrieval::rank(&prior).is_err());
+ }
+}
+
+#[test]
+fn a_packet_lists_the_next_files_its_excerpts_do_not_quote() {
+ let body = "fn parse() {}\n".repeat(400);
+ let hit = json!({"identity":"a","text":body,"source":{"id":"file:src/a.rs","path":"src/a.rs",
+ "source_kind":"repository_file","byte_start":0,"byte_end":body.len(),"line":1,"sha256":"x"}});
+ let request = |next: Value| {
+ json!({"repo":{"name":"r","snapshot":"s"},"question":"parse","hits":[hit.clone()],
+ "memories":[],"max_tokens":3000,"max_chars":8400,"next_files":next})
+ };
+ let packed = packing::pack(&request(
+ json!({"paths":["src/a.rs","src/b.rs","src/c.rs","src/d.rs"],"limit":2}),
+ ))
+ .unwrap();
+ let markdown = packed["markdown"].as_str().unwrap();
+ assert_eq!(packed["next_files"], json!(["src/b.rs", "src/c.rs"]));
+ assert!(markdown.contains(packing::NEXT_FILES_HEADING), "{markdown}");
+ assert!(markdown.contains("- src/b.rs\n- src/c.rs\n"), "{markdown}");
+ assert!(!markdown.contains("- src/a.rs") && !markdown.contains("- src/d.rs"));
+ // The list is after the excerpt and before the budget line, within the
+ // budget, which the excerpt otherwise fills.
+ let list = markdown.find("- src/b.rs").unwrap();
+ assert!(markdown.find("fn parse").unwrap() < list);
+ assert!(list < markdown.find("\nBudget: ").unwrap());
+ assert!(packed["characters"].as_u64().unwrap() <= 8400);
+ // Without the option, or with a limit of 0, no list.
+ let plain = packing::pack(&request(Value::Null)).unwrap();
+ assert!(plain.get("next_files").is_none());
+ assert!(
+ !plain["markdown"]
+ .as_str()
+ .unwrap()
+ .contains(packing::NEXT_FILES_HEADING)
+ );
+ let none = packing::pack(&request(json!({"paths":["src/b.rs"],"limit":0}))).unwrap();
+ assert!(none.get("next_files").is_none());
+ for bad in [
+ json!({"paths":["src/b.rs"],"limit":41}),
+ json!({"paths":[1],"limit":2}),
+ json!({"limit":2}),
+ ] {
+ assert!(packing::pack(&request(bad)).is_err());
+ }
+}
+
#[test]
fn an_overflowing_window_keeps_its_best_matching_paragraphs() {
let filler = "assistant: ".to_string()
diff --git a/crates/graphicle/Cargo.lock b/crates/graphicle/Cargo.lock
index f35af50..323eb56 100644
--- a/crates/graphicle/Cargo.lock
+++ b/crates/graphicle/Cargo.lock
@@ -1327,7 +1327,7 @@ dependencies = [
[[package]]
name = "graphicle"
-version = "0.1.2"
+version = "0.1.3"
dependencies = [
"base64 0.22.1",
"calamine",
@@ -1421,7 +1421,7 @@ dependencies = [
[[package]]
name = "graphicle-memory"
-version = "0.1.2"
+version = "0.1.3"
dependencies = [
"chrono",
"graphicle",
@@ -1439,7 +1439,7 @@ dependencies = [
[[package]]
name = "graphicle-runtime"
-version = "0.1.2"
+version = "0.1.3"
dependencies = [
"aes-gcm",
"axum",
@@ -3969,9 +3969,9 @@ checksum = "f87165f0995f63a9fbeea62b64d10b4d9d8e78ec6d7d51fb2125fda7bb36788f"
[[package]]
name = "rustls-webpki"
-version = "0.103.15"
+version = "0.103.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f3c3cf1d8b1e7d4927e2d154c3fcb02979afb9939629c62cd9048d4f07b60ac2"
+checksum = "4443b1b6d39d7c663139942cc4558262562d2c84123bb6282ef177009ca8b281"
dependencies = [
"ring",
"rustls-pki-types",
@@ -4501,7 +4501,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "32497e9a4c7b38532efcdebeef879707aa9f794296a4f0244f6f69e9bc8574bd"
dependencies = [
"fastrand",
- "getrandom 0.4.3",
+ "getrandom 0.3.4",
"once_cell",
"rustix",
"windows-sys 0.61.2",
@@ -5545,18 +5545,18 @@ dependencies = [
[[package]]
name = "webpki-root-certs"
-version = "1.0.9"
+version = "1.0.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b96554aa2acc8ccdb7e1c9a58a7a68dd5d13bccc69cd124cb09406db612a1c9b"
+checksum = "58ec80e73fd8baf57bf0d9615554c75348bda990d6d5bbeab964dd068319fecb"
dependencies = [
"rustls-pki-types",
]
[[package]]
name = "webpki-roots"
-version = "1.0.9"
+version = "1.0.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7dcd9d09a39985f5344844e66b0c530a33843579125f23e21e9f0f220850f22a"
+checksum = "1c1c8e20c8a38fc7d65abfe74eb7280e4aa667e8eec8bc84996d2874810748d9"
dependencies = [
"rustls-pki-types",
]
diff --git a/crates/graphicle/Cargo.toml b/crates/graphicle/Cargo.toml
index 2925eff..c3d36a9 100644
--- a/crates/graphicle/Cargo.toml
+++ b/crates/graphicle/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "graphicle-runtime"
-version = "0.1.2"
+version = "0.1.3"
edition = "2024"
rust-version = "1.94.1"
publish = false
diff --git a/crates/graphicle/README.md b/crates/graphicle/README.md
index 18c2842..f80e288 100644
--- a/crates/graphicle/README.md
+++ b/crates/graphicle/README.md
@@ -55,7 +55,7 @@ operations through the extension registry (`src/extension.rs`).
provider permission mode ("is not part of Graphicle Core"), while it still enforces
the provider permissions an existing store holds.
- `build.info` reports the edition and its capabilities, and
- `graphicle --version` prints it (`graphicle 0.1.2 (core)`).
+ `graphicle --version` prints it (`graphicle 0.1.3 (core)`).
- A store keeps every table when either edition opens it, and Core keeps the
other edition's guarantees on a store it has used (`src/store_compat.rs`).
@@ -63,7 +63,9 @@ Extensions add operations, native operations and subcommands under names they
declare, and each name reaches only the extension that declared it. A job of a
kind the core does not run goes to the first installed extension whose job
hook accepts it, so an extension's hook must decline every kind it does not
-run itself.
+run itself. An extension may also add connector kinds (`extension::Source`):
+the core adds, schedules, stages, shares and enforces their connectors like
+its own, and the source only reads its provider through the connector job.
## The browser app and the API
@@ -465,6 +467,26 @@ symbol picker. `memory.import` re-grounds the links in the target project by
their path, qualified name, kind and ordinal, and marks the ones it cannot
match. Observer notes are not linked to symbols.
+**Reuse across clients.** `memory.template` exports a project's reviewed
+procedures and decisions as an engagement template (`graphicle.template.v1`).
+Each memory is rebuilt from an allow-list of fields (kind, title, body and
+state), so no quote, link, dependency, id, date or author leaves the project.
+In the title and body, the memory's quotes, the sources and symbols it cites,
+the project's and workspace's names, the `terms` the caller lists (client
+names, for example), URLs, e-mail addresses, credentials, words with a path
+separator, and the project's file names and code-shaped symbol names become
+placeholders such as `[quote]` and `[symbol]`; `redactions` counts them. Other
+words stay, so read a template before sharing it. `memory.import_pack` imports
+the reviewed memories of a `memory.export` or a template into another project
+as drafts (other states are skipped and counted). Only kind, title and body
+are copied. Each symbol anchor lands on the live symbol of the same path,
+qualified name, kind and ordinal, or, when the symbol moved, on the only
+symbol of that qualified name and kind elsewhere in the project; each quote
+stays evidence only where one of the project's current sources holds it: the
+same source, or the file its anchored symbol moved to, inside that symbol.
+What cannot be grounded is dropped and counted by reason in the draft's
+`data.pack`. Recall metadata is not carried.
+
Later windows keep the exact original header and continuation coordinates.
Packing merges overlapping intervals, includes bounded adjacent paragraphs and
enforces the serialized evidence-token ceiling across the final answer context.
@@ -664,8 +686,21 @@ has the details. For HTTP MCP use `POST /mcp/WORKSPACE_ID/PROJECT_ID` (or
```sh
graphicle backup /safe/private/path/graphicle.sqlite3
graphicle --data-dir /new/restore/directory restore /safe/private/path/graphicle.sqlite3
+graphicle offboard --project PROJECT # the plan; nothing changes
+graphicle offboard --project PROJECT --apply PLAN_HASH # carry out that plan
```
+`graphicle backup` without a path writes to the data folder's `backups/`
+folder. `graphicle offboard` removes one project from the store (the
+certified `project.delete`, PR scratch copies included), its graph cache and
+its copies in `backups/`, where each backup keeps its other projects and
+records its own receipt; the project's receipt lists the backups and files
+removed. It touches nothing outside the data folder: links are refused, and
+backups written elsewhere, the project's `.graphicle/` folder, what `setup`
+added to its folders (`graphicle disconnect`) and memories `memory.import_pack`
+copied into other projects are named as not covered. The result is
+`verified` only when every deletion checks out and no path was refused.
+
Portable backups omit provider secrets and the device key, and pause
connections and pending external cleanup that need reauthorization. Reconnect
providers and explicitly resume cleanup after restore. Source snapshots,
diff --git a/crates/graphicle/THIRD_PARTY_LICENSES.html b/crates/graphicle/THIRD_PARTY_LICENSES.html
index 1cda728..82d0385 100644
--- a/crates/graphicle/THIRD_PARTY_LICENSES.html
+++ b/crates/graphicle/THIRD_PARTY_LICENSES.html
@@ -11253,8 +11253,8 @@ express Statement of Purpose.
</pre>
<h3 id="CDLA-Permissive-2.0">Community Data License Agreement Permissive 2.0</h3>
<p>Used by:</p>
-<ul><li><a href="https://github.com/rustls/webpki-roots">webpki-root-certs 1.0.9</a></li>
-<li><a href="https://github.com/rustls/webpki-roots">webpki-roots 1.0.9</a></li>
+<ul><li><a href="https://github.com/rustls/webpki-roots">webpki-root-certs 1.0.10</a></li>
+<li><a href="https://github.com/rustls/webpki-roots">webpki-roots 1.0.10</a></li>
</ul>
<pre># Community Data License Agreement - Permissive - Version 2.0
@@ -11862,7 +11862,7 @@ THIS SOFTWARE.
</pre>
<h3 id="ISC">ISC License</h3>
<p>Used by:</p>
-<ul><li><a href="https://github.com/rustls/webpki">rustls-webpki 0.103.15</a></li>
+<ul><li><a href="https://github.com/rustls/webpki">rustls-webpki 0.103.16</a></li>
</ul>
<pre>Except as otherwise noted, this project is licensed under the following
(ISC-style) terms:
diff --git a/crates/graphicle/src/agent_instructions.rs b/crates/graphicle/src/agent_instructions.rs
index a59f448..e5e6c77 100644
--- a/crates/graphicle/src/agent_instructions.rs
+++ b/crates/graphicle/src/agent_instructions.rs
@@ -10,6 +10,26 @@
//! so setup adds none when it is the only agent connected. `setup --tools
//! all` writes 0.1.0's section instead ([`section_0_1_0`]), whichever agents
//! are connected.
+//!
+//! **Routing.** Every place an agent reads when to use Graphicle says the
+//! same thing: the tools for where or how something works, for questions
+//! across files or history and before changing unfamiliar code, and grep
+//! for an exact identifier the agent already knows ([`ROUTING_WHEN`],
+//! [`ROUTING_GREP`]). The places are this section, the session-start
+//! context ([`SESSION_ROUTING`]), the server's instructions
+//! ([`crate::api::ESSENTIAL_INSTRUCTIONS`] and the whole server's) and the
+//! search tools' descriptions ([`crate::api::instead_of_grep`]). Each costs
+//! tokens in every session, so each is a sentence or two.
+
+/// When Graphicle's tools are the ones to call, as every routing text says
+/// it.
+pub const ROUTING_WHEN: &str = "for where or how something works, for questions across files or history, and before changing unfamiliar code";
+/// When a text search is enough, as every routing text says it.
+pub const ROUTING_GREP: &str = "for an exact identifier you already know, grep is enough";
+/// The first line of the session-start context
+/// ([`crate::store::Store::session_start_context`]), which Claude Code's and
+/// Codex's session-start hooks print.
+pub const SESSION_ROUTING: &str = "Graphicle: use its MCP tools (recall_project, query_graph) for where or how something works, for questions across files or history, and before changing unfamiliar code; for an exact identifier you already know, grep is enough. Answers cite file and lines.";
/// The first line of the section.
pub const START: &str =
@@ -18,13 +38,13 @@ pub const START: &str =
pub const END: &str = "<!-- graphicle:end -->";
/// The section, markers included, without a final newline: the heading and
-/// two lines, on when to call the tools that every connection publishes and
-/// what to run without them.
+/// two lines, on when to call the tools that every connection publishes
+/// (and when grep is enough) and what to run without them.
pub fn section() -> String {
[
START,
"## Graphicle",
- "When you do not yet know where the code for a task is, who calls it or why it was written that way, ask the `graphicle` MCP server before searching files by hand: `query_graph` or `recall_project` with the question, then `get_node` and `get_neighbors` for one symbol; answers cite file and lines.",
+ "Use the `graphicle` MCP server for where or how something works, for questions across files or history, and before changing unfamiliar code: `recall_project` or `query_graph` with the question, then `get_node` and `get_neighbors` for one symbol; answers cite file and lines. For an exact identifier you already know, grep is enough.",
"Without the server, run `graphicle context \"<question>\"` in a terminal.",
END,
]
@@ -290,6 +310,26 @@ mod tests {
}
}
+ #[test]
+ fn every_routing_text_says_when_to_call_and_when_grep_is_enough() {
+ for text in [
+ section(),
+ SESSION_ROUTING.to_string(),
+ crate::api::ESSENTIAL_INSTRUCTIONS.to_string(),
+ crate::api::routing(true, true).unwrap(),
+ crate::api::routing(false, true).unwrap(),
+ ] {
+ let text = text.to_lowercase();
+ assert!(text.contains(ROUTING_WHEN), "{text}");
+ assert!(text.contains(ROUTING_GREP), "{text}");
+ assert!(!text.contains('\u{2014}'), "no em dash: {text}");
+ }
+ for name in ["recall_project", "query_graph", "get_node", "get_neighbors"] {
+ let sentence = crate::api::instead_of_grep(name).unwrap();
+ assert!(sentence.starts_with("Use it instead of grep"), "{name}");
+ }
+ }
+
#[test]
fn claude_md_importing_agents_md_is_recognized() {
assert!(imports_agents("# Claude\[email protected]\n"));
diff --git a/crates/graphicle/src/agent_setup.rs b/crates/graphicle/src/agent_setup.rs
index 7857da2..8bd405f 100644
--- a/crates/graphicle/src/agent_setup.rs
+++ b/crates/graphicle/src/agent_setup.rs
@@ -917,8 +917,10 @@ struct HookSpec {
timeout: u64,
matcher: Option<&'static str>,
/// A guard hook of `--guards`, else a capture hook
- /// of `connect --hooks`.
+ /// of `connect --hooks` (or the prompt-context hook, `prompt`).
guard: bool,
+ /// Claude Code's prompt-context hook of `setup --prompt-context`.
+ prompt: bool,
}
const fn capture(event: &'static str, argument: &'static str, timeout: u64) -> HookSpec {
@@ -928,6 +930,7 @@ const fn capture(event: &'static str, argument: &'static str, timeout: u64) -> H
timeout,
matcher: None,
guard: false,
+ prompt: false,
}
}
@@ -966,6 +969,7 @@ const CLAUDE_CODE_GUARDS: [HookSpec; 2] = [
timeout: 10,
matcher: Some("Bash|Grep"),
guard: true,
+ prompt: false,
},
HookSpec {
event: "PreToolUse",
@@ -973,9 +977,24 @@ const CLAUDE_CODE_GUARDS: [HookSpec; 2] = [
timeout: 10,
matcher: Some("Read|Glob"),
guard: true,
+ prompt: false,
},
];
+/// Claude Code's prompt-context hook of `setup --prompt-context` (off by
+/// default): on each prompt, `graphicle hook claude-code prompt-context`
+/// adds `graphicle context`'s packet for a code question
+/// ([`crate::prompt_hook`]). Claude Code's timeout is a backstop: the hook
+/// gives up by itself after [`crate::prompt_hook::SECONDS`].
+const CLAUDE_CODE_PROMPT_CONTEXT: HookSpec = HookSpec {
+ event: "UserPromptSubmit",
+ argument: "prompt-context",
+ timeout: crate::prompt_hook::HOOK_TIMEOUT,
+ matcher: None,
+ guard: false,
+ prompt: true,
+};
+
/// The hooks `connect` installs for `client`: the capture hooks with
/// `capture`, and with `guards` the guard hooks (Claude Code only).
fn hook_specs(client: &str, capture: bool, guards: bool) -> Vec<HookSpec> {
@@ -1151,20 +1170,51 @@ pub fn refresh_hooks(store: &Store, client: &str, cwd: &Path) -> Result<Value> {
Err(_) => (true, false),
};
let capture = capture || !guards;
+ // The prompt-context hook of `setup --prompt-context`, when there.
+ let prompt = client == "claude-code"
+ && read_config(&hook_file(client, cwd)?, "hook")
+ .is_ok_and(|(document, _)| holds_prompt_hooks(&document, client, &directory));
+ let mut specs = hook_specs(client, capture, guards);
+ if prompt {
+ specs.push(CLAUDE_CODE_PROMPT_CONTEXT);
+ }
+ let plan = plan_hooks(client, &stable_program()?, &directory, true, cwd, &specs)?;
+ let mut written = write_hooks(plan, &directory, &cwd.canonical()?, &project.id)?;
+ let mut reply = written["capture"].take();
+ if guards {
+ reply["guard"] = written["guard"].take();
+ }
+ if prompt {
+ reply["prompt_context"] = written["prompt_context"].take();
+ }
+ Ok(reply)
+}
+
+/// Install (or bring up to date) Claude Code's prompt-context hook
+/// (`setup --prompt-context`, [`crate::prompt_hook`]) in the personal
+/// settings of the project folder `cwd`, beside its other hooks, which
+/// stay. Its report: the settings file and whether the hook was installed
+/// or already there.
+pub fn connect_prompt_context(store: &Store, cwd: &Path) -> Result<Value> {
+ let session = local::session(store, false)?;
+ let project = store.resolve_project(
+ &session.workspace,
+ &session.capability,
+ None,
+ Some(cwd),
+ session.project.as_deref(),
+ )?;
+ let directory = store.directory.canonical()?;
let plan = plan_hooks(
- client,
+ "claude-code",
&stable_program()?,
&directory,
true,
cwd,
- &hook_specs(client, capture, guards),
+ &[CLAUDE_CODE_PROMPT_CONTEXT],
)?;
let mut written = write_hooks(plan, &directory, &cwd.canonical()?, &project.id)?;
- let mut reply = written["capture"].take();
- if guards {
- reply["guard"] = written["guard"].take();
- }
- Ok(reply)
+ Ok(written["prompt_context"].take())
}
/// Write a hook plan (backing the file up first) and record it in the data
@@ -1204,10 +1254,17 @@ fn write_hooks(plan: HookPlan, directory: &Path, folder: &Path, project: &str) -
let listed = |guard: bool, installed: bool| -> Vec<&str> {
plan.outcomes
.iter()
- .filter(|(spec, done)| spec.guard == guard && *done == installed)
+ .filter(|(spec, done)| spec.guard == guard && !spec.prompt && *done == installed)
.map(|(spec, _)| if guard { spec.argument } else { spec.event })
.collect()
};
+ let prompt = |installed: bool| -> Vec<&str> {
+ plan.outcomes
+ .iter()
+ .filter(|(spec, done)| spec.prompt && *done == installed)
+ .map(|(spec, _)| spec.event)
+ .collect()
+ };
let next = if plan.client == "codex" {
"Review and trust the new hooks in Codex before they run"
} else {
@@ -1222,6 +1279,9 @@ fn write_hooks(plan: HookPlan, directory: &Path, folder: &Path, project: &str) -
"removed":plan.removed,
"nudge":"before a search or a source read in a folder whose Graphicle project has a code graph, the agent is pointed to query_graph, get_node, get_neighbors and recall_project; elsewhere the graph engine's own guard answers",
"next":next},
+ "prompt_context": {"configuration":plan.destination,"installed":prompt(true),"unchanged":prompt(false),
+ "context":"before each prompt that is a code question, the packet of graphicle context (at most 8,400 characters); nothing for other prompts, short ones, or when it fails or takes over 10 seconds",
+ "next":next},
}))
}
@@ -1232,6 +1292,10 @@ const HOOK_ARGUMENTS: [&str; 4] = ["session-start", "stop", "pre-compact", "sess
/// for Claude Code.
pub const GUARD_ARGUMENTS: [&str; 2] = ["guard-search", "guard-read"];
+/// The argument of Claude Code's prompt-context hook (`setup
+/// --prompt-context`).
+pub const PROMPT_ARGUMENTS: [&str; 1] = ["prompt-context"];
+
/// Whether a hook handler runs `<program> --data-dir <folder> hook <client>
/// <argument>` for one of `arguments`.
fn is_hook(handler: &Value, client: &str, arguments: &[&str]) -> bool {
@@ -1254,6 +1318,11 @@ pub fn is_guard_hook(handler: &Value, client: &str) -> bool {
is_hook(handler, client, &GUARD_ARGUMENTS)
}
+/// Whether a hook handler is Graphicle's prompt-context hook for `client`.
+pub fn is_prompt_hook(handler: &Value, client: &str) -> bool {
+ is_hook(handler, client, &PROMPT_ARGUMENTS)
+}
+
/// Whether a hooks document holds one of the hooks `arguments` name for
/// `client` that opens the data folder `data`.
fn holds_hooks(document: &Value, client: &str, data: &Path, arguments: &[&str]) -> bool {
@@ -1285,13 +1354,21 @@ pub fn holds_guard_hooks(document: &Value, client: &str, data: &Path) -> bool {
holds_hooks(document, client, data, &GUARD_ARGUMENTS)
}
-/// Remove Graphicle's capture and guard hooks for `client` that open the
-/// data folder `data` from a hooks document, with the groups, events and
-/// `hooks` object that held only them; other data folders' hooks stay.
-/// Returns whether any was there.
+/// Whether a hooks document holds the prompt-context hook of `client` that
+/// opens the data folder `data`.
+pub fn holds_prompt_hooks(document: &Value, client: &str, data: &Path) -> bool {
+ holds_hooks(document, client, data, &PROMPT_ARGUMENTS)
+}
+
+/// Remove Graphicle's capture, guard and prompt-context hooks for `client`
+/// that open the data folder `data` from a hooks document, with the groups,
+/// events and `hooks` object that held only them; other data folders' hooks
+/// stay. Returns whether any was there.
pub fn remove_hooks(document: &mut Value, client: &str, data: &Path) -> bool {
remove_matching(document, data, &|handler| {
- is_capture_hook(handler, client) || is_guard_hook(handler, client)
+ is_capture_hook(handler, client)
+ || is_guard_hook(handler, client)
+ || is_prompt_hook(handler, client)
})
}
@@ -1623,7 +1700,7 @@ pub fn guard(directory: &Path, kind: &str, payload: &Value) -> Guard {
let (name, root) = (found.name, found.root);
let context = match kind {
"search" => format!(
- "Graphicle: this folder is the project \"{name}\", whose code graph is built. Before searching raw files, ask the graphicle MCP server: query_graph \"<question>\" walks the code graph around a question, get_node and get_neighbors show a symbol with its callers and callees, and recall_project searches the code, documents and reviewed memory together. Search the files afterwards to modify or debug specific lines."
+ "Graphicle: this folder is the project \"{name}\", whose code graph is built. For where or how something works, for questions across files or history, and before changing unfamiliar code, ask the graphicle MCP server first: query_graph \"<question>\" walks the code graph around a question, get_node and get_neighbors show a symbol with its callers and callees, and recall_project searches the code, documents and reviewed memory together. For an exact identifier you already know, grep is enough; search the files to modify or debug specific lines."
),
"read" => {
// A target is a path, or a Glob pattern, relative to the folder
@@ -1860,6 +1937,39 @@ mod tests {
kept["hooks"]["PreToolUse"] =
json!([{"matcher":"Bash","hooks":[{"type":"command","command":"lint-guard"}]}]);
assert_eq!(guarded, kept);
+ // The prompt-context hook of `--prompt-context` goes too.
+ let mut prompted = original.clone();
+ prompted["hooks"]["UserPromptSubmit"] = json!([{"hooks":[ours("prompt-context")]}]);
+ assert!(holds_prompt_hooks(&prompted, "claude-code", d));
+ assert!(!holds_hooks(&prompted, "claude-code", d, &HOOK_ARGUMENTS));
+ assert!(!holds_guard_hooks(&prompted, "claude-code", d));
+ assert!(remove_hooks(&mut prompted, "claude-code", d));
+ assert_eq!(prompted, original);
+ }
+
+ /// The entry `setup --prompt-context` writes: one UserPromptSubmit
+ /// group, no matcher, the hook with its backstop timeout.
+ #[cfg(not(windows))]
+ #[test]
+ fn the_prompt_hook_entry_runs_the_hook_with_its_timeout() {
+ let folder = tempfile::TempDir::new().unwrap();
+ let plan = plan_hooks(
+ "claude-code",
+ Path::new("/usr/local/bin/graphicle"),
+ Path::new("/d"),
+ false,
+ folder.path(),
+ &[CLAUDE_CODE_PROMPT_CONTEXT],
+ )
+ .unwrap();
+ assert_eq!(
+ plan.document,
+ json!({"hooks":{"UserPromptSubmit":[{"hooks":[{"type":"command",
+ "command":"'/usr/local/bin/graphicle' --data-dir '/d' hook claude-code prompt-context",
+ "timeout":15}]}]}})
+ );
+ assert_eq!(plan.outcomes.len(), 1);
+ assert!(plan.outcomes[0].0.prompt && plan.outcomes[0].1);
}
#[test]
diff --git a/crates/graphicle/src/api.rs b/crates/graphicle/src/api.rs
index eb306d9..4356ea1 100644
--- a/crates/graphicle/src/api.rs
+++ b/crates/graphicle/src/api.rs
@@ -1,15 +1,15 @@
use crate::platform::CanonicalExt;
use crate::{Error, Result, string};
use crate::{
- extension::McpTool,
+ extension::{Access, McpTool},
jobs::Worker,
model,
- store::{Store, repo, s},
+ store::{Store, repo, rows, s},
};
use axum::{
Json, Router,
- body::Body,
- extract::{DefaultBodyLimit, Path, Query, State},
+ body::{Body, to_bytes},
+ extract::{DefaultBodyLimit, FromRequestParts, MatchedPath, Path, Query, RawPathParams, State},
http::{HeaderMap, Request, StatusCode, header},
middleware::{self, Next},
response::{IntoResponse, Response},
@@ -121,7 +121,7 @@ pub enum ToolSet {
Memory,
/// The five tools an agent needs to find code ([`ESSENTIAL_TOOLS`]), with
/// descriptions that start with what an agent searches for and carry the
- /// citation details, and one sentence of instructions: what
+ /// citation details, and short instructions on when to call them: what
/// `graphicle setup` gives Claude Code, which loads only tool names and
/// instructions until a tool is searched for. A workspace connection adds
/// `list_projects`; the server's opt-ins add their tools
@@ -193,27 +193,39 @@ pub fn reads_code_graph(tool: &McpTool) -> bool {
.any(|family| tool.operation.starts_with(family))
}
-/// Parse `--set switch=true|false` values into fixed switches; only the
-/// switches of [`RECALL_SWITCHES`] can be fixed, each at most once.
+/// Parse `--set switch=true|false` values (and `scope=project|workspace`)
+/// into fixed switches; only the switches of [`RECALL_SWITCHES`] and
+/// [`RECALL_SCOPE`] can be fixed, each at most once. An unknown name is
+/// refused, never ignored.
pub fn fixed_switches(values: &[String]) -> Result<serde_json::Map<String, Value>> {
let mut fixed = serde_json::Map::new();
for value in values {
let (name, setting) = value
.split_once('=')
.ok_or_else(|| Error::bad("Use --set <switch>=true or false"))?;
- if !RECALL_SWITCHES.contains(&name) {
- let (last, rest) = RECALL_SWITCHES.split_last().unwrap_or((&"", &[]));
+ let setting = if name == RECALL_SCOPE {
+ match setting {
+ "project" | "workspace" => json!(setting),
+ _ => return Err(Error::bad("scope is project or workspace")),
+ }
+ } else if RECALL_SWITCHES.contains(&name) {
+ let value = match setting {
+ "true" => json!(true),
+ "false" => json!(false),
+ "auto" => json!("auto"),
+ number => number.parse::<u64>().map_or(Value::Null, |n| json!(n)),
+ };
+ if let Some(refused) = switch_refusal(name, &value) {
+ return Err(Error::bad(refused));
+ }
+ value
+ } else {
return Err(Error::bad(format!(
- "{name} cannot be fixed; the server fixes {} and {last}",
- rest.join(", ")
+ "{name} cannot be fixed; the server fixes {} and {RECALL_SCOPE}",
+ RECALL_SWITCHES.join(", ")
)));
- }
- let setting = match setting {
- "true" => true,
- "false" => false,
- _ => return Err(Error::bad(format!("{name} is true or false"))),
};
- if fixed.insert(name.to_string(), json!(setting)).is_some() {
+ if fixed.insert(name.to_string(), setting).is_some() {
return Err(Error::bad(format!("{name} is set twice; give it once")));
}
}
@@ -304,18 +316,104 @@ pub fn router(app: App) -> Router {
app.clone(),
crate::product::meter,
))
+ .layer(middleware::from_fn_with_state(app.clone(), admission))
.layer(middleware::from_fn_with_state(app.clone(), boundary))
.with_state(app)
}
+/// A route that names a workspace, before the request meter: an installed
+/// extension may refuse it for the request's credential or limit the tokens
+/// of its response (`extension::admit`, `Access::Route`). The limit applies
+/// to the response of a GET or HEAD route, unless the operation it serves
+/// checked its result already (`metering::SizeChecked`). Core installs none,
+/// so nothing changes there.
+async fn admission(State(app): State<App>, request: Request<Body>, next: Next) -> Response {
+ if crate::extension::installed().is_empty() {
+ return next.run(request).await;
+ }
+ let Some(pattern) = request
+ .extensions()
+ .get::<MatchedPath>()
+ .map(|path| path.as_str().to_owned())
+ else {
+ return next.run(request).await;
+ };
+ let (mut parts, body) = request.into_parts();
+ let workspace = RawPathParams::from_request_parts(&mut parts, &app)
+ .await
+ .ok()
+ .and_then(|params| {
+ params
+ .iter()
+ .find(|(name, _)| *name == "workspace")
+ .map(|(_, value)| value.to_owned())
+ });
+ let credential = token(&parts.headers).ok().map(str::to_owned);
+ let method = parts.method.as_str().to_owned();
+ // A read's response only: a write's is never refused once it is saved.
+ let reads = matches!(method.as_str(), "GET" | "HEAD");
+ let request = Request::from_parts(parts, body);
+ let (Some(workspace), Some(credential)) = (workspace, credential) else {
+ return next.run(request).await;
+ };
+ let store = app.worker.store.clone();
+ let admitted = crate::product::blocking(move || {
+ crate::extension::admit(
+ &store,
+ &workspace,
+ &credential,
+ Access::Route {
+ method: &method,
+ pattern: &pattern,
+ },
+ None,
+ )
+ })
+ .await;
+ let limit = match admitted {
+ Ok(admitted) => admitted.max_tokens.filter(|_| reads),
+ Err(error) => return error.into_response(),
+ };
+ let response = next.run(request).await;
+ if limit.is_none()
+ || !response.status().is_success()
+ || response
+ .extensions()
+ .get::<crate::metering::SizeChecked>()
+ .is_some()
+ {
+ return response;
+ }
+ let (parts, body) = response.into_parts();
+ let Ok(bytes) = to_bytes(body, usize::MAX).await else {
+ return Error::bad("Response unavailable").into_response();
+ };
+ // Counting a large response is CPU work: off the async executor.
+ let checked = crate::product::blocking(move || {
+ crate::extension::within_limit(limit, &String::from_utf8_lossy(&bytes))?;
+ Ok(bytes)
+ })
+ .await;
+ match checked {
+ Ok(bytes) => Response::from_parts(parts, Body::from(bytes)),
+ Err(error) => error.into_response(),
+ }
+}
async fn boundary(State(app): State<App>, mut request: Request<Body>, next: Next) -> Response {
// This header is internal only; untrusted HTTP clients cannot supply session authority.
request.headers_mut().remove("x-graphicle-browser-session");
+ // A cross-site form post that an installed extension authenticates by
+ // itself (a sign-in callback that another site's page posts to) carries
+ // no browser session and skips the origin and browser-mutation checks;
+ // the host check stays.
+ let cross_site = request.method() == axum::http::Method::POST
+ && crate::extension::installed().cross_site_post(request.uri().path());
let cookie_name = if app.public_origin.is_some() {
"__Host-graphicle_session"
} else {
"graphicle_session"
};
- if let Some(cookie) = cookie(request.headers(), cookie_name).map(str::to_string) {
+ if !cross_site && let Some(cookie) = cookie(request.headers(), cookie_name).map(str::to_string)
+ {
let explicit = request.headers().get(header::AUTHORIZATION).is_some()
|| request
.headers()
@@ -355,10 +453,11 @@ async fn boundary(State(app): State<App>, mut request: Request<Body>, next: Next
)
.into_response();
}
- if let Some(origin) = request
- .headers()
- .get(header::ORIGIN)
- .and_then(|v| v.to_str().ok())
+ if !cross_site
+ && let Some(origin) = request
+ .headers()
+ .get(header::ORIGIN)
+ .and_then(|v| v.to_str().ok())
&& !app.public_origin.as_ref().map_or_else(
|| origin == format!("http://{host}") || origin == format!("https://{host}"),
|public| origin == public && public == &format!("https://{host}"),
@@ -622,12 +721,18 @@ async fn graph_episodes(
State(app): State<App>,
Path((workspace, repository)): Path<(String, String)>,
headers: HeaderMap,
-) -> Result<Json<Value>> {
- Ok(Json(app.worker.store.graph_episodes(
+) -> Response {
+ let store = &app.worker.store;
+ let run = async { store.graph_episodes(&workspace, token(&headers)?, &repository) };
+ crate::metering::serve_route(
+ store,
+ &headers,
&workspace,
- token(&headers)?,
&repository,
- )?))
+ "graph.episodes",
+ run,
+ )
+ .await
}
/// `graph.impact`: base-versus-head impact between two graph episodes.
async fn graph_impact(
@@ -635,7 +740,7 @@ async fn graph_impact(
Path((workspace, repository)): Path<(String, String)>,
headers: HeaderMap,
Json(args): Json<Value>,
-) -> Result<Json<Value>> {
+) -> Response {
overridable(
app,
&headers,
@@ -650,35 +755,42 @@ async fn graph_link(
State(app): State<App>,
Path(workspace): Path<String>,
headers: HeaderMap,
-) -> Result<Json<Value>> {
- let token = token(&headers)?.to_string();
- let store = app.worker.store.clone();
- tokio::task::spawn_blocking(move || store.graph_link(&workspace, &token))
- .await
- .map(|result| result.map(Json))
- .map_err(|_| Error::bad("Cross-repository linking interrupted"))?
+) -> Response {
+ let (store, link) = (&app.worker.store, app.worker.store.clone());
+ let run = async {
+ let (token, workspace) = (token(&headers)?.to_string(), workspace.clone());
+ tokio::task::spawn_blocking(move || link.graph_link(&workspace, &token))
+ .await
+ .map_err(|_| Error::bad("Cross-repository linking interrupted"))?
+ };
+ // Workspace-wide: admitted as a metered operation, and not counted.
+ crate::metering::serve_route(store, &headers, &workspace, "", "graph.link", run).await
}
async fn graph_cross_edges(
State(app): State<App>,
Path((workspace, repository)): Path<(String, String)>,
headers: HeaderMap,
-) -> Result<Json<Value>> {
- Ok(Json(app.worker.store.graph_cross_edges(
+) -> Response {
+ let store = &app.worker.store;
+ let run = async { store.graph_cross_edges(&workspace, token(&headers)?, &repository) };
+ crate::metering::serve_route(
+ store,
+ &headers,
&workspace,
- token(&headers)?,
&repository,
- )?))
+ "graph.cross_edges",
+ run,
+ )
+ .await
}
async fn graph_stats(
State(app): State<App>,
Path((workspace, repository)): Path<(String, String)>,
headers: HeaderMap,
-) -> Result<Json<Value>> {
- Ok(Json(app.worker.store.graph_stats(
- &workspace,
- token(&headers)?,
- &repository,
- )?))
+) -> Response {
+ let store = &app.worker.store;
+ let run = async { store.graph_stats(&workspace, token(&headers)?, &repository) };
+ crate::metering::serve_route(store, &headers, &workspace, &repository, "graph.stats", run).await
}
async fn graph_access(
State(app): State<App>,
@@ -698,13 +810,18 @@ async fn graph_as_of(
Path((workspace, repository)): Path<(String, String)>,
headers: HeaderMap,
Json(args): Json<Value>,
-) -> Result<Json<Value>> {
- let token = token(&headers)?.to_string();
- let store = app.worker.store.clone();
- tokio::task::spawn_blocking(move || store.graph_as_of(&workspace, &token, &repository, &args))
+) -> Response {
+ let (store, reader) = (&app.worker.store, app.worker.store.clone());
+ let run = async {
+ let token = token(&headers)?.to_string();
+ let (workspace, repository) = (workspace.clone(), repository.clone());
+ tokio::task::spawn_blocking(move || {
+ reader.graph_as_of(&workspace, &token, &repository, &args)
+ })
.await
- .map(|result| result.map(Json))
.map_err(|_| Error::bad("Episode reconstruction interrupted"))?
+ };
+ crate::metering::serve_route(store, &headers, &workspace, &repository, "graph.as_of", run).await
}
/// `impact.report`: the PR change-impact report.
async fn impact_report(
@@ -712,7 +829,7 @@ async fn impact_report(
Path((workspace, repository)): Path<(String, String)>,
headers: HeaderMap,
Json(args): Json<Value>,
-) -> Result<Json<Value>> {
+) -> Response {
overridable(
app,
&headers,
@@ -729,7 +846,7 @@ async fn coverage_upload(
Path((workspace, repository)): Path<(String, String)>,
headers: HeaderMap,
Json(args): Json<Value>,
-) -> Result<Json<Value>> {
+) -> Response {
overridable(
app,
&headers,
@@ -745,7 +862,8 @@ async fn coverage_upload(
/// extension serves it, and without one it answers 501 after authorization.
/// The repository comes from the path. The work can be CPU-bound (projecting
/// the head set first, parsing large coverage runs), so it runs off the
-/// executor.
+/// executor. It is admitted, size-checked and counted as through the command
+/// routes (`crate::metering::admit`).
async fn overridable(
app: App,
headers: &HeaderMap,
@@ -753,15 +871,42 @@ async fn overridable(
operation: &'static str,
mut args: Value,
interrupted: &'static str,
-) -> Result<Json<Value>> {
- let token = token(headers)?.to_string();
+) -> Response {
+ let token = match token(headers) {
+ Ok(token) => token.to_string(),
+ Err(error) => return error.into_response(),
+ };
if let Some(map) = args.as_object_mut() {
map.insert("repository_id".into(), json!(repository));
}
- tokio::task::spawn_blocking(move || command(&app, &workspace, &token, operation, &args))
- .await
- .map(|result| result.map(Json))
- .map_err(|_| Error::bad(interrupted))?
+ let store = app.worker.store.clone();
+ let mut admission =
+ match crate::metering::admit_request(&store, &workspace, &token, headers, operation, &args)
+ .await
+ {
+ Ok(admission) => admission,
+ Err(error) => return crate::metering::refusal(error),
+ };
+ let args = admission.take_arguments().unwrap_or(args);
+ let result =
+ tokio::task::spawn_blocking(move || dispatch(&app, &workspace, &token, operation, &args))
+ .await
+ .map_err(|_| Error::bad(interrupted))
+ .and_then(|result| result);
+ let served = match result {
+ Ok(value) => crate::metering::served(&store, admission, value).await,
+ Err(error) => Err(error),
+ };
+ match served {
+ Ok(value) => {
+ let mut response = Json(value).into_response();
+ response
+ .extensions_mut()
+ .insert(crate::metering::SizeChecked);
+ response
+ }
+ Err(error) => error.into_response(),
+ }
}
async fn graph_label(
State(app): State<App>,
@@ -792,18 +937,40 @@ async fn http_command(
Path(workspace): Path<String>,
headers: HeaderMap,
Json(body): Json<Command>,
-) -> Result<Json<Value>> {
- Ok(Json(
- command_async(
- &app,
- &workspace,
- token(&headers)?,
- &body.operation,
- &body.arguments,
- )
- .await?,
- ))
+) -> Result<Response> {
+ let capability = token(&headers)?;
+ // The one admission (`crate::metering::admit`): an installed extension
+ // authorizes the operation, then a metered one's quota; it runs; then a
+ // read's result is size-checked and a metered result counted.
+ let mut admission = match crate::metering::admit_request(
+ &app.worker.store,
+ &workspace,
+ capability,
+ &headers,
+ &body.operation,
+ &body.arguments,
+ )
+ .await
+ {
+ Ok(admission) => admission,
+ Err(error) => return Ok(crate::metering::refusal(error)),
+ };
+ let narrowed = admission.take_arguments();
+ let value = dispatch_async(
+ &app,
+ &workspace,
+ capability,
+ &body.operation,
+ narrowed.as_ref().unwrap_or(&body.arguments),
+ )
+ .await?;
+ Ok(Json(crate::metering::served(&app.worker.store, admission, value).await?).into_response())
}
+/// Run one operation for `capability`, as `graphicle call` and the SDKs do:
+/// an installed extension authorizes it (`Access::Operation`) and may narrow
+/// its arguments, and a read's result must fit the credential's per-call cap
+/// (`crate::metering::admit`). The command routes, MCP and the routes that
+/// serve an operation also ask for its quota and count it.
pub async fn command_async(
app: &App,
workspace: &str,
@@ -811,7 +978,55 @@ pub async fn command_async(
operation: &str,
args: &Value,
) -> Result<Value> {
- // An extension operation without an async form runs through `command`
+ let mut admission = operation_admission(app, workspace, capability, operation, args)?;
+ let narrowed = admission.take_arguments();
+ let result = dispatch_async(
+ app,
+ workspace,
+ capability,
+ operation,
+ narrowed.as_ref().unwrap_or(args),
+ )
+ .await?;
+ crate::metering::served(&app.worker.store, admission, result).await
+}
+/// The admission of `command` and `command_async`: authorized, never asked
+/// for a quota or counted here (the local command line counts what it
+/// prints, `metering::served_locally`), and size-checked when it is a read.
+fn operation_admission(
+ app: &App,
+ workspace: &str,
+ capability: &str,
+ operation: &str,
+ args: &Value,
+) -> Result<crate::metering::Admission> {
+ crate::metering::admit(
+ &app.worker.store,
+ capability,
+ crate::metering::Ask {
+ access: Access::Operation(operation),
+ arguments: Some(args),
+ call: crate::metering::Call {
+ workspace: workspace.into(),
+ repository: String::new(),
+ credential: String::new(),
+ session: String::new(),
+ channel: crate::metering::Channel::Cli,
+ kind: operation.into(),
+ },
+ metered: false,
+ read: crate::metering::meter(operation) == Some(crate::metering::Meter::Read),
+ },
+ )
+}
+pub(crate) async fn dispatch_async(
+ app: &App,
+ workspace: &str,
+ capability: &str,
+ operation: &str,
+ args: &Value,
+) -> Result<Value> {
+ // An extension operation without an async form runs through `dispatch`
// on a blocking thread (the fallback arm below).
if let Some(run) = crate::extension::installed()
.operation(operation)
@@ -879,7 +1094,7 @@ pub async fn command_async(
let operation = operation.to_owned();
let args = args.clone();
tokio::task::spawn_blocking(move || {
- command(&app, &workspace, &capability, &operation, &args)
+ dispatch(&app, &workspace, &capability, &operation, &args)
})
.await
.map_err(|_| Error::bad("Command interrupted"))?
@@ -966,6 +1181,7 @@ pub const CORE_OPERATIONS: &[&str] = &[
"graph.episodes",
"graph.impact",
"graph.link",
+ "graph.map",
"graph.navigate",
"graph.neo4j.configure",
"graph.neo4j.publish",
@@ -986,9 +1202,11 @@ pub const CORE_OPERATIONS: &[&str] = &[
"memory.export",
"memory.history",
"memory.import",
+ "memory.import_pack",
"memory.propose",
"memory.search",
"memory.state",
+ "memory.template",
"model.configure",
"model.status",
"note",
@@ -1034,6 +1252,31 @@ pub fn command(
capability: &str,
operation: &str,
args: &Value,
+) -> Result<Value> {
+ if !args.is_object() {
+ return Err(Error::bad("Command arguments must be an object"));
+ }
+ // As `command_async`: authorized, run, and a read's result size-checked.
+ let mut admission = operation_admission(app, workspace, capability, operation, args)?;
+ let narrowed = admission.take_arguments();
+ let result = dispatch(
+ app,
+ workspace,
+ capability,
+ operation,
+ narrowed.as_ref().unwrap_or(args),
+ )?;
+ admission.serve_value(&app.worker.store, &result)?;
+ Ok(result)
+}
+/// Run one operation, once it was admitted (`command`, `command_async`, the
+/// command routes and MCP `tools/call`, through `crate::metering::admit`).
+pub(crate) fn dispatch(
+ app: &App,
+ workspace: &str,
+ capability: &str,
+ operation: &str,
+ args: &Value,
) -> Result<Value> {
if !args.is_object() {
return Err(Error::bad("Command arguments must be an object"));
@@ -1105,6 +1348,9 @@ pub fn command(
store.graph_as_of(workspace, capability, crate::string(args, "repository_id", 100)?, args)
}
"graph.link" => store.graph_link(workspace, capability),
+ // The projects the caller may read, the imports between them and
+ // what each holds.
+ "graph.map" => store.workspace_map(workspace, capability, args),
// Documents' mention links to code, read
// as the caller may read them now.
"graph.doc_links" => crate::doc_links::read(store, workspace, capability, args),
@@ -1198,13 +1444,15 @@ pub fn command(
"connector.schedule" => store.connector_schedule(workspace, capability, args),
"connector.state" | "connector.delete" | "source.forget" | "project.delete"
| "storage.prune" | "retention.apply" => store.maintain(workspace, capability, operation, args),
- "files" | "memories" | "memory.history" | "memory.export" | "history" => {
+ "files" | "memories" | "memory.history" | "memory.export" | "memory.template"
+ | "history" => {
store.project_read(workspace, capability, operation, args)
}
"sync.abort"
| "memory.state"
| "memory.delete"
| "memory.import"
+ | "memory.import_pack"
| "memory.propose"
| "learning.refresh.propose" => {
store.project_mutate(workspace, capability, operation, args)
@@ -1268,12 +1516,34 @@ fn published_tools(learning: bool, work_state: bool, options: &McpOptions) -> Ve
}
}
}
+ for tool in &mut tools {
+ if let Some(sentence) = instead_of_grep(tool.name()) {
+ let description = format!("{} {sentence}", s(&tool.spec, "description"));
+ tool.spec["description"] = json!(description);
+ }
+ }
tools
}
+/// The sentence a tool's description ends with, in every set, on when to
+/// call it instead of searching files with grep
+/// ([`crate::agent_instructions::ROUTING_WHEN`] says the same for the
+/// tools together).
+pub fn instead_of_grep(name: &str) -> Option<&'static str> {
+ Some(match name {
+ "recall_project" => {
+ "Use it instead of grep when you do not know the exact name, or when the answer spans files, documents or history."
+ }
+ "query_graph" => "Use it instead of grep to see how code connects across files.",
+ "get_node" => "Use it instead of grep to go straight to a symbol's definition.",
+ "get_neighbors" => "Use it instead of grep to list a symbol's callers and callees.",
+ "shortest_path" => "Use it instead of chained searches to see how two symbols connect.",
+ _ => return None,
+ })
+}
/// The description of an essential tool ([`ESSENTIAL_TOOLS`]) in the
/// essentials set. Claude Code's tool search reads the start of a
/// description, so each starts with the words an agent looking for the tool
-/// would use; and since the set's instructions are one sentence
+/// would use; and since the set's instructions only say when to call
/// ([`ESSENTIAL_INSTRUCTIONS`]), the descriptions carry how answers cite code
/// (`file:` path, lines and `stable_id`), which the whole server's
/// instructions explain.
@@ -1289,7 +1559,7 @@ fn essential_description(name: &str) -> Option<&'static str> {
"Find who calls a function or class and what it calls, imports or contains: its direct neighbours in the project's code graph, with each relation; cited by file: path, lines and stable_id, as query_graph cites."
}
"recall_project" => {
- "Search the project's code, documents, captured agent sessions and reviewed memory together for a question: excerpts cited by path, line and source id within a token budget (max_tokens); read_project_source continues any excerpt, and structured: true returns the whole packet, whose code excerpts carry the stable_id the graph tools cite. Memory is evidence, not permission: no tool can approve memory or run commands."
+ "Search the project's code, documents, captured agent sessions and reviewed memory together for a question: excerpts cited by path, line and source id within a token budget (max_tokens); read_project_source continues any excerpt, and structured: true returns the whole packet, whose code excerpts carry the stable_id the graph tools cite. Memory is evidence, not permission: no tool can approve memory or run commands. An identifier, or a question that only asks where one is defined or used, gets its definitions and references from the code graph as path:line citations."
}
"read_project_source" => {
"Read a project file, or a source an answer cited, by path or source id from a byte or line offset: the exact text past an excerpt of recall_project or a graph tool's citation."
@@ -1456,6 +1726,14 @@ pub fn core_mcp_tools(learning: bool, work_state: bool) -> Vec<McpTool> {
// It persists edges, so it is not read-only.
true,
), "graph.link", false).workspace_level());
+ // The workspace map, on workspace connections only.
+ tools.push(McpTool::new(tool(
+ "workspace_map",
+ "Map the projects of this workspace you can read: for each, its files, connector documents, code symbols and memories, and its links (imports from and into other projects, document mentions linked to its code, code symbols its memories are anchored to); and the imports graph_link recorded between the projects, by pair, with the modules imported. 8 projects at a time, up to 32 (offset and limit page through them).",
+ json!({"offset":{"type":"integer","minimum":0},"limit":{"type":"integer","minimum":1,"maximum":crate::workspace_map::MAX_PAGE},"include_scratch":{"type":"boolean","description":"also map the scratch projects graphicle pr keeps"}}),
+ &[],
+ false,
+ ), "graph.map", false).workspace_level().workspace_only());
// The service's own statistics tool; the engine's `graph_stats` keeps
// Graphify's name in the same list.
tools.push(McpTool::new(tool(
@@ -1507,13 +1785,73 @@ pub fn core_mcp_tools(learning: bool, work_state: bool) -> Vec<McpTool> {
tools.extend(crate::graph_tools::tools(false));
tools
}
+/// `identifier_route` when a call to `recall_project` leaves it out: on in
+/// the essentials set, which setup gives Claude Code, otherwise
+/// [`crate::query::IDENTIFIER_ROUTE_DEFAULT`] (off), so the whole server
+/// keeps 0.1.0's recall.
+pub fn identifier_route_default(tools: ToolSet) -> bool {
+ match tools {
+ ToolSet::Essentials => true,
+ _ => crate::query::IDENTIFIER_ROUTE_DEFAULT,
+ }
+}
/// The switches `recall_project` accepts beside its published contract
///: each turns one retrieval
/// mechanism off or on for the call, and the packet's `mechanisms` reports
/// it. `doc_links: true` follows documents'
-/// mention links to code (left out, they are counted, not followed;
-/// `false` reads none). A server can fix each (`--set`).
-pub const RECALL_SWITCHES: [&str; 3] = ["graph_retrieval", "memory_retrieval", "doc_links"];
+/// mention links to code, and `symbol_links: true` reviewed memory's links
+/// to code symbols (left out, each is counted, not followed; `false` reads
+/// none). `cross_repo` turns workspace recall's cross-repository import step
+/// alone off or on (left out, it follows `graph_retrieval`). `notes_first:
+/// true` asks for the notes-first order, one window per file and dated
+/// excerpts (left out: [`crate::query::NOTES_FIRST_DEFAULT`]).
+/// `identifier_route: true` answers a question that is an identifier, or
+/// only asks where named identifiers are defined or used, from the code
+/// graph ([`crate::identifier_route`]); left out, it is
+/// [`identifier_route_default`] (on in the essentials set, off in the
+/// others), and `false` keeps the full retrieval. A server can
+/// fix each (`--set`), and every packet echoes the values in force
+/// (`mechanisms.switches`, [`crate::query::switches`]). The code-question
+/// switches take `true`, `false` or `"auto"` ([`THREE_WAY_SWITCHES`]:
+/// `code_first`, `query_focus`, `identifier_arm`), and `more_files` a number
+/// of files from 0 to 40 ([`crate::code_question`], [`crate::query`]).
+pub const RECALL_SWITCHES: [&str; 11] = [
+ "graph_retrieval",
+ "memory_retrieval",
+ "doc_links",
+ "symbol_links",
+ "cross_repo",
+ "notes_first",
+ "identifier_route",
+ "code_first",
+ "query_focus",
+ "identifier_arm",
+ "more_files",
+];
+
+/// The switches of [`RECALL_SWITCHES`] that take `true`, `false` or
+/// `"auto"`.
+pub const THREE_WAY_SWITCHES: [&str; 3] = ["code_first", "query_focus", "identifier_arm"];
+
+/// Why `value` is no value of the switch `field` of [`RECALL_SWITCHES`], or
+/// `None` when it is one: `more_files` takes a number from 0 to 40, the
+/// [`THREE_WAY_SWITCHES`] `true`, `false` or `"auto"`, the others `true` or
+/// `false`.
+pub fn switch_refusal(field: &str, value: &Value) -> Option<String> {
+ let (fits, takes) = if THREE_WAY_SWITCHES.contains(&field) {
+ (value.is_boolean() || value == "auto", "true, false or auto")
+ } else if field == "more_files" {
+ (
+ value
+ .as_u64()
+ .is_some_and(|n| n <= graphicle_memory::packing::MAX_NEXT_FILES as u64),
+ "a number from 0 to 40",
+ )
+ } else {
+ (value.is_boolean(), "true or false")
+ };
+ (!fits).then(|| format!("{field} must be {takes}"))
+}
/// `recall_project`'s scope switch, accepted beside the
/// published contract like [`RECALL_SWITCHES`]: `project`
/// or `workspace`. A workspace connection recalls over the workspace unless
@@ -1529,9 +1867,22 @@ const REPO_DESCRIPTION: &str = "The project to read, by id or key (list_projects
#[derive(Default)]
pub struct McpSession {
shown: std::collections::VecDeque<Value>,
+ /// The client's name from `initialize`, for the metering label.
+ client: Option<String>,
+ /// The connection's agent-session label (`metering::new_session`).
+ label: Option<String>,
}
impl McpSession {
const LIMIT: usize = 200;
+ /// This connection's agent-session label for metering, made at its
+ /// first tool call.
+ fn label(&mut self) -> String {
+ self.label
+ .get_or_insert_with(|| {
+ crate::metering::new_session(self.client.as_deref().unwrap_or("mcp"))
+ })
+ .clone()
+ }
fn record(&mut self, packet: &Value) {
for source in packet["sources"].as_array().into_iter().flatten() {
// Each span names its project: source ids such as
@@ -1570,7 +1921,15 @@ pub fn mcp(
repository: &str,
request: &Value,
) -> Option<Value> {
- mcp_in(app, workspace, capability, Some(repository), request, None)
+ mcp_in(
+ app,
+ workspace,
+ capability,
+ Some(repository),
+ request,
+ None,
+ None,
+ )
}
/// As [`mcp`], for one connection that keeps what it has been given.
pub fn mcp_session(
@@ -1588,6 +1947,7 @@ pub fn mcp_session(
Some(repository),
request,
Some(session),
+ None,
)
}
/// What `initialize` tells a client about the tools it was given: when to
@@ -1596,8 +1956,8 @@ pub fn mcp_session(
fn instructions(app: &App, tools: &[McpTool], whole_workspace: bool) -> String {
let published = |name: &str| tools.iter().any(|tool| tool.name() == name);
let mut parts: Vec<&str> = Vec::new();
- // The essentials set: one sentence on when to call; the tools'
- // descriptions say how answers cite code.
+ // The essentials set: a few sentences on when to call and when grep is
+ // enough; the tools' descriptions say how answers cite code.
if app.mcp.tools == ToolSet::Essentials {
parts.push(ESSENTIAL_INSTRUCTIONS);
if whole_workspace {
@@ -1649,13 +2009,35 @@ fn instructions(app: &App, tools: &[McpTool], whole_workspace: bool) -> String {
if app.mcp_work_state && published("work_state_write") {
parts.push(crate::work_state::INSTRUCTIONS);
}
- parts.join(" ")
+ // When to call the tools at all, first.
+ match routing(published("recall_project"), published("query_graph")) {
+ Some(routing) if parts.is_empty() => routing,
+ Some(routing) => format!("{routing} {}", parts.join(" ")),
+ None => parts.join(" "),
+ }
}
-/// The instructions of the essentials set ([`ToolSet::Essentials`]): one
-/// sentence on when to call. Claude Code shows them, with the tool names, in
-/// every request; the tools' descriptions, which it loads only with a tool,
-/// say how answers cite code.
-pub const ESSENTIAL_INSTRUCTIONS: &str = "When you do not yet know where the code for a task is, who calls it or why it was written that way, call query_graph (the code graph) or recall_project (code, documents and reviewed memory) with the question before searching files by hand; get_node and get_neighbors show one symbol with its callers and callees, and every answer cites file and lines.";
+/// The whole server's sentence on when to call recall and the code graph,
+/// for the tools it publishes ([`ESSENTIAL_INSTRUCTIONS`] says the same for
+/// the essentials).
+pub(crate) fn routing(recall: bool, graph: bool) -> Option<String> {
+ let tools = match (recall, graph) {
+ (true, true) => "recall_project or query_graph",
+ (true, false) => "recall_project",
+ (false, true) => "query_graph",
+ (false, false) => return None,
+ };
+ Some(format!(
+ "Use {tools} {}; {}. Answers cite file and lines.",
+ crate::agent_instructions::ROUTING_WHEN,
+ crate::agent_instructions::ROUTING_GREP
+ ))
+}
+/// The instructions of the essentials set ([`ToolSet::Essentials`]): when
+/// to call the tools, and when grep is enough
+/// ([`crate::agent_instructions::ROUTING_WHEN`]). Claude Code shows them,
+/// with the tool names, in every request; the tools' descriptions, which it
+/// loads only with a tool, say how answers cite code.
+pub const ESSENTIAL_INSTRUCTIONS: &str = "Use recall_project (code, documents and reviewed memory) or query_graph (the code graph) for where or how something works, for questions across files or history, and before changing unfamiliar code; get_node and get_neighbors show one symbol with its callers and callees. For an exact identifier you already know, grep is enough. Every answer cites file and lines.";
/// The sentence for the pull-request tools when recall is not published.
const PULL_REQUEST_INSTRUCTIONS: &str = "list_prs, get_pr_impact and triage_prs run the GitHub CLI and git, read-only, in the project's folder.";
/// The graph tools' part of the `initialize` instructions.
@@ -1683,7 +2065,7 @@ pub fn mcp_workspace(
capability: &str,
request: &Value,
) -> Option<Value> {
- mcp_in(app, workspace, capability, None, request, None)
+ mcp_in(app, workspace, capability, None, request, None, None)
}
/// As [`mcp_workspace`], for one connection that keeps what it has been
/// given.
@@ -1694,7 +2076,15 @@ pub fn mcp_workspace_session(
request: &Value,
session: &mut McpSession,
) -> Option<Value> {
- mcp_in(app, workspace, capability, None, request, Some(session))
+ mcp_in(
+ app,
+ workspace,
+ capability,
+ None,
+ request,
+ Some(session),
+ None,
+ )
}
/// The refusal of a project connection's call that reaches beyond its
/// project.
@@ -1703,6 +2093,80 @@ fn confined(what: &str) -> Error {
"{what} needs a workspace connection (graphicle mcp --workspace, or POST /mcp/WORKSPACE_ID): this connection reads its own project"
))
}
+/// The format of [`manifest`].
+pub const MANIFEST_FORMAT: &str = "graphicle.manifest.v1";
+
+/// The schema files compiled into this program, in the order a store
+/// applies them.
+const SCHEMA_FILES: [&str; 6] = [
+ include_str!("schema.sql"),
+ include_str!("workflow_schema.sql"),
+ include_str!("expansion_schema.sql"),
+ include_str!("projection_schema.sql"),
+ include_str!("temporal_schema.sql"),
+ include_str!("product_schema.sql"),
+];
+
+/// What one MCP server configuration serves, for a record a later run can
+/// be checked against (`graphicle mcp --manifest`): the program (version,
+/// edition, the sha256 of its executable), the tools a connection of this
+/// kind lists and the instructions it sends, each with its sha256, the
+/// switches (`--tools`, `--allow-learning`, `--work-state` and the values
+/// `--set` fixes, with the switches a request may set), the retrieval
+/// defaults, and the schema and format versions: the schema compiled in,
+/// the store's own tables, and the contracts of deletion receipts, state
+/// digests, exports, templates and the cross-repository link state. Reads
+/// only.
+pub fn manifest(
+ app: &App,
+ workspace: &str,
+ capability: &str,
+ repository: Option<&str>,
+) -> Result<Value> {
+ let tools = connection_tools(app, repository);
+ let specs: Vec<Value> = tools.iter().map(|tool| tool.spec.clone()).collect();
+ let text = instructions(app, &tools, repository.is_none());
+ let sha = |bytes: &[u8]| graphicle_memory::text::sha256(bytes);
+ let executable = std::env::current_exe().ok();
+ let binary_sha256 = executable
+ .as_ref()
+ .and_then(|path| std::fs::read(path).ok())
+ .map(|bytes| sha(&bytes));
+ let store = app.worker.store.authorized_read(workspace, capability, "read", |db, _| {
+ let tables = rows(
+ db,
+ "SELECT name,coalesce(sql,'') AS sql FROM sqlite_master WHERE type='table' AND name NOT LIKE 'sqlite_%' ORDER BY name",
+ [],
+ )?;
+ let user_version: i64 = db.query_row("PRAGMA user_version", [], |row| row.get(0))?;
+ Ok(json!({"tables":tables.len(),"tables_sha256":sha(json!(tables).to_string().as_bytes()),
+ "user_version":user_version}))
+ })?;
+ let mut switches: Vec<&str> = RECALL_SWITCHES.to_vec();
+ switches.push(RECALL_SCOPE);
+ Ok(json!({
+ "format": MANIFEST_FORMAT,
+ "program": {"version": env!("CARGO_PKG_VERSION"),
+ "edition": crate::extension::installed().edition().name(),
+ "executable": executable.map(|path| path.display().to_string()),
+ "sha256": binary_sha256},
+ "connection": if repository.is_some() { "project" } else { "workspace" },
+ "tools": {"names": tools.iter().map(McpTool::name).collect::<Vec<_>>(),
+ "count": specs.len(), "sha256": sha(json!(specs).to_string().as_bytes()),
+ "instructions_sha256": sha(text.as_bytes())},
+ "switches": {"tools": app.mcp.tools.name(), "allow_learning": app.mcp_learning,
+ "work_state": app.mcp_work_state, "pull_requests": app.mcp.pull_requests,
+ "server_fixed": app.mcp.fixed, "request": switches,
+ "notes_first_default": crate::query::NOTES_FIRST_DEFAULT,
+ "identifier_route_default": identifier_route_default(app.mcp.tools)},
+ "retrieval_defaults": crate::query::recipe_defaults(),
+ "schemas": {"compiled_sha256": sha(SCHEMA_FILES.concat().as_bytes()), "store": store,
+ "deletion": crate::deletion::CONTRACT, "state": crate::deletion::STATE_CONTRACT,
+ "export": "graphicle.memories.v1", "template": crate::packs::TEMPLATE_FORMAT,
+ "cross_link_state": crate::graph_projection::LINK_STATE_FORMAT},
+ }))
+}
+
/// The tools a connection publishes, of those the server's options give
/// (`--tools`, `--pull-requests`). A project connection
/// publishes each tool as [`McpTool::confined`] gives it, so it reads its own
@@ -1720,6 +2184,8 @@ fn connection_tools(app: &App, repository: Option<&str>) -> Vec<McpTool> {
.collect(),
}
}
+/// One MCP message. `session` is a stdio connection's state; `http_session`
+/// the `Mcp-Session-Id` an HTTP client sent back (metering labels).
fn mcp_in(
app: &App,
workspace: &str,
@@ -1727,6 +2193,7 @@ fn mcp_in(
repository: Option<&str>,
request: &Value,
mut session: Option<&mut McpSession>,
+ http_session: Option<&str>,
) -> Option<Value> {
if request["jsonrpc"] != "2.0" {
return Some(
@@ -1748,13 +2215,52 @@ fn mcp_in(
app.worker.store.workspace(workspace, capability)?;
}
}
+ // A server that fixes the scope serves only connections of that
+ // scope: one project's, or the workspace's.
+ match (
+ app.mcp.fixed.get(RECALL_SCOPE).and_then(Value::as_str),
+ repository,
+ ) {
+ (Some("project"), None) => {
+ return Err(Error::bad(
+ "This server fixes scope to project: serve one project (graphicle mcp without --workspace, or a project's access key)",
+ ));
+ }
+ (Some("workspace"), Some(_)) => {
+ return Err(Error::bad(
+ "This server fixes scope to workspace: serve the workspace (graphicle mcp --workspace, or a workspace access key)",
+ ));
+ }
+ _ => {}
+ }
let tools = connection_tools(app, repository);
+ // The tools an installed extension allows this credential
+ // (`Access::Tool`; every tool in Core): the connection lists and
+ // describes only these. `tools/call` asks again for the tool it
+ // calls, so calling a refused one says why.
+ let allowed = crate::extension::admit_each(
+ &app.worker.store,
+ workspace,
+ capability,
+ &tools.iter().map(tool_access).collect::<Vec<_>>(),
+ )?;
+ let (tools, refused): (Vec<McpTool>, Vec<McpTool>) = {
+ let mut allowed = allowed.into_iter();
+ tools
+ .into_iter()
+ .partition(|_| allowed.next().unwrap_or(false))
+ };
// The engine's resources come with its tools, on
// a project connection: they describe one project's code graph, and
// a workspace connection has no project of its own.
let resources = repository.filter(|_| tools.iter().any(crate::graph_tools::is_graph_tool));
match s(request, "method") {
"initialize" => {
+ if let Some(session) = session.as_deref_mut() {
+ session.client = request["params"]["clientInfo"]["name"]
+ .as_str()
+ .map(str::to_owned);
+ }
let capabilities = if resources.is_some() {
json!({"tools":{},"resources":{}})
} else {
@@ -1779,6 +2285,33 @@ fn mcp_in(
}
"resources/read" if resources.is_some() => {
let uri = string(&request["params"], "uri", 200)?;
+ // A resource reads the code graph as the navigation tools
+ // do: the one admission authorizes it as their operation and
+ // asks for its quota; its text is then size-checked and
+ // counted (`crate::metering`).
+ let admission = crate::metering::admit(
+ &app.worker.store,
+ capability,
+ crate::metering::Ask {
+ access: Access::Operation(crate::graph_tools::NAVIGATE),
+ arguments: None,
+ call: crate::metering::Call {
+ workspace: workspace.to_string(),
+ repository: resources.unwrap_or_default().to_string(),
+ credential: String::new(),
+ session: agent_session(
+ app,
+ workspace,
+ session.as_deref_mut(),
+ http_session,
+ ),
+ channel: crate::metering::Channel::Mcp,
+ kind: "resources/read".into(),
+ },
+ metered: true,
+ read: true,
+ },
+ )?;
let text = crate::graph_tools::read_resource(
&app.worker.store,
workspace,
@@ -1786,6 +2319,7 @@ fn mcp_in(
resources.unwrap_or_default(),
uri,
)?;
+ admission.serve(&app.worker.store, text.clone(), Vec::new())?;
let kind = if uri.starts_with("graphicle-graph://report") {
"text/markdown"
} else {
@@ -1797,8 +2331,18 @@ fn mcp_in(
let name = string(&request["params"], "name", 100)?;
let tool = tools
.iter()
+ .chain(&refused)
.find(|tool| tool.name() == name)
.ok_or_else(|| Error::bad("Tool unavailable"))?;
+ // An installed extension may refuse the tool for this
+ // credential; its operation is admitted again in `command`.
+ crate::extension::admit(
+ &app.worker.store,
+ workspace,
+ capability,
+ tool_access(tool),
+ None,
+ )?;
let operation = tool.operation;
let graph_tool = crate::graph_tools::is_graph_tool(tool);
let mut args = request["params"]
@@ -1825,9 +2369,9 @@ fn mcp_in(
crate::archived::check(crate::archived::Surface::Context, &args)?;
args = crate::archived::without_inert(crate::archived::Surface::Context, &args);
}
- // `recall_project` honours the `graph_retrieval`,
- // `memory_retrieval` and `doc_links` switches, which its
- // published contract leaves out, to keep the ablation
+ // `recall_project` honours the switches of RECALL_SWITCHES
+ // (`graph_retrieval`, `doc_links`, `notes_first` and the
+ // others), which its published contract leaves out, to keep the ablation
// switches out of the schemas agents read. They are taken out
// before the contract is checked and passed on. A switch the
// server fixes (`--set`) takes its fixed value, and a request
@@ -1836,8 +2380,11 @@ fn mcp_in(
if name == "recall_project" {
for field in RECALL_SWITCHES {
let asked = args.as_object_mut().and_then(|a| a.remove(field));
- if asked.as_ref().is_some_and(|value| !value.is_boolean()) {
- return Err(Error::bad(format!("{field} must be true or false")));
+ if let Some(refused) = asked
+ .as_ref()
+ .and_then(|value| switch_refusal(field, value))
+ {
+ return Err(Error::bad(refused));
}
match (app.mcp.fixed.get(field), asked) {
(Some(fixed), Some(asked)) if *fixed != asked => {
@@ -1853,7 +2400,17 @@ fn mcp_in(
// The scope switch likewise. A project
// connection reads its own project only: the workspace
// takes a workspace connection.
- if let Some(value) = args.as_object_mut().and_then(|a| a.remove(RECALL_SCOPE)) {
+ let asked = args.as_object_mut().and_then(|a| a.remove(RECALL_SCOPE));
+ let fixed = app.mcp.fixed.get(RECALL_SCOPE);
+ if let (Some(fixed), Some(asked)) = (fixed, &asked)
+ && fixed != asked
+ {
+ return Err(Error::bad(format!(
+ "{RECALL_SCOPE} is fixed to {} by this server",
+ fixed.as_str().unwrap_or("")
+ )));
+ }
+ if let Some(value) = asked.or_else(|| fixed.cloned()) {
match value.as_str() {
Some("project") => {}
Some("workspace") if repository.is_none() => {}
@@ -1894,9 +2451,20 @@ fn mcp_in(
if name == "recall_project" && !structured {
crate::query::cap_recall(&mut args);
}
- // 0.1.0's order: test files where the ranking puts them.
+ // 0.1.0's order: test files where the ranking puts them, and
+ // 0.1.0's excerpts: no dates or age marks (`source_age`).
if name == "recall_project" && !lean {
args["include_tests"] = json!(true);
+ args["source_age"] = json!(false);
+ }
+ // The essentials' recall takes the identifier route unless
+ // the call or the server says otherwise; the packet then
+ // reports the switch as defaulted, as the call left it out.
+ let route_defaulted = name == "recall_project"
+ && identifier_route_default(app.mcp.tools)
+ && args.get(crate::identifier_route::FIELD).is_none();
+ if route_defaulted {
+ args[crate::identifier_route::FIELD] = json!(true);
}
if name == "recall_project"
&& args
@@ -1938,7 +2506,23 @@ fn mcp_in(
if graph_tool && operation == crate::graph_tools::NAVIGATE {
args["tool"] = json!(name);
}
- let result = (|| {
+ // Every tool result goes through the one admission
+ // (`crate::metering::admit`): an installed extension
+ // authorizes the operation and may narrow its arguments, then
+ // asks for the credential's quota; the tool runs; a read's
+ // reply must fit the per-call cap, on the text served (a
+ // write's reply is never refused once it is saved); the reply
+ // is counted. The pull-request tools read as their contract
+ // says (`readOnlyHint`).
+ let pull_request = operation == crate::graph_tools::PULL_REQUEST;
+ let read = if pull_request {
+ tool.spec["annotations"]["readOnlyHint"] == true
+ } else {
+ crate::metering::meter(operation) != Some(crate::metering::Meter::Write)
+ };
+ let agent_session =
+ agent_session(app, workspace, session.as_deref_mut(), http_session);
+ let result = (|| -> Result<_> {
// Graph tools may name another project of the workspace by
// its id or key, and over stdio by its folder; it is
// authorized again for the caller.
@@ -1953,7 +2537,34 @@ fn mcp_in(
)?;
args["repository_id"] = json!(named);
}
- if operation == crate::graph_tools::PULL_REQUEST {
+ // A call that names no project (a recall over the
+ // workspace) is counted on the projects its reply serves;
+ // one that serves none (`list_projects`) is not counted.
+ let mut admission = crate::metering::admit(
+ &app.worker.store,
+ capability,
+ crate::metering::Ask {
+ access: Access::Operation(operation),
+ arguments: Some(&args),
+ call: crate::metering::Call {
+ workspace: workspace.to_string(),
+ repository: args["repository_id"]
+ .as_str()
+ .or(repository)
+ .unwrap_or("")
+ .to_string(),
+ credential: String::new(),
+ session: agent_session,
+ channel: crate::metering::Channel::Mcp,
+ kind: name.to_string(),
+ },
+ metered: true,
+ read,
+ },
+ )?;
+ let narrowed = admission.take_arguments();
+ let args = narrowed.as_ref().unwrap_or(&args);
+ let packet = if pull_request {
let repository = repository.ok_or_else(|| {
Error::bad("The pull-request tools serve a project connection")
})?;
@@ -1963,52 +2574,55 @@ fn mcp_in(
capability,
repository,
name,
- &args,
- )
+ args,
+ )?
} else {
- command(app, workspace, capability, operation, &args)
- }
+ dispatch(app, workspace, capability, operation, args)?
+ };
+ Ok((packet, admission))
})();
- let result = result.map(|mut packet| {
- if name == "recall_project"
- && !app.mcp.fixed.is_empty()
- && packet["mechanisms"].is_object()
- {
- packet["mechanisms"]["server_fixed"] = Value::Object(app.mcp.fixed.clone());
- }
- packet
- });
+ let (mut packet, admission) = match result {
+ Ok(admitted) => admitted,
+ Err(error) => return Ok(tool_error(&error.message)),
+ };
+ // A project connection keeps memory and documents on its
+ // project, also in get_node's back-links of a symbol that
+ // `repo` reads in another project's code graph.
+ if graph_tool && let Some(own) = repository {
+ crate::symbol_links::confine(&mut packet, own);
+ }
+ if route_defaulted && packet[crate::identifier_route::REPORT].is_object() {
+ packet[crate::identifier_route::REPORT]["defaulted"] = json!(true);
+ }
if name == "recall_project"
- && let (Ok(packet), Some(session)) = (&result, session.as_deref_mut())
+ && !app.mcp.fixed.is_empty()
+ && packet["mechanisms"].is_object()
{
- session.record(packet);
+ packet["mechanisms"]["server_fixed"] = Value::Object(app.mcp.fixed.clone());
}
- if !structured
- && let Ok(value) = &result
- && let Some(lean) = crate::query::lean_reply(name, graph_tool, value)
+ // A recall packet this connection records once it is served.
+ let shown = (name == "recall_project" && session.is_some()).then(|| packet.clone());
+ let shares = if admission.needs_shares() {
+ crate::metering::shares(&packet)
+ } else {
+ Vec::new()
+ };
+ // The essentials' text, else the full reply.
+ let reply = match (!structured)
+ .then(|| crate::query::lean_reply(name, graph_tool, &packet))
+ .flatten()
+ {
+ Some(lean) => lean,
+ None => tool_reply(graph_tool, packet),
+ };
+ if let Err(error) = admission.serve(&app.worker.store, served_text(&reply), shares)
{
- return Ok(lean);
+ return Ok(tool_error(&error.message));
}
- Ok(match result {
- // The engine's text, as its own server answers, then (for
- // the navigation tools) a short citations block, which
- // clients that show the model `content` only also pass on;
- // `structuredContent` has the episode and the
- // nodes the text names.
- Ok(value) if graph_tool => {
- let mut content = vec![json!({"type":"text","text":value["text"]})];
- if value["nodes"].is_array() {
- content.push(json!({"type":"text","text":crate::graph_tools::citations_text(&value)}));
- }
- json!({"content":content,"structuredContent":value,"isError":false})
- }
- Ok(value) => {
- json!({"content":[{"type":"text","text":value.to_string()}],"structuredContent":if value.is_object(){value}else{json!({"items":value})},"isError":false})
- }
- Err(error) => {
- json!({"content":[{"type":"text","text":error.message}],"isError":true})
- }
- })
+ if let (Some(packet), Some(session)) = (&shown, session.as_deref_mut()) {
+ session.record(packet);
+ }
+ Ok(reply)
}
_ => Err(Error::bad(UNSUPPORTED_METHOD)),
}
@@ -2030,6 +2644,57 @@ fn mcp_in(
}
/// The error message of a method a connection does not serve.
const UNSUPPORTED_METHOD: &str = "Unsupported MCP method";
+/// What calling `tool` asks for: its name, and whether its contract writes.
+fn tool_access(tool: &McpTool) -> Access<'_> {
+ Access::Tool {
+ name: tool.name(),
+ writes: tool.spec["annotations"]["readOnlyHint"] != true,
+ }
+}
+/// A tool's reply as the full answer: for the graph engine's tools, the
+/// engine's text as its own server answers, then (for the navigation tools)
+/// a short citations block, which clients that show the model `content` only
+/// also pass on; `structuredContent` has the episode and the nodes the text
+/// names. For the other tools, the answer as JSON text and structured content.
+fn tool_reply(graph_tool: bool, value: Value) -> Value {
+ if graph_tool {
+ let mut content = vec![json!({"type":"text","text":value["text"]})];
+ if value["nodes"].is_array() {
+ content.push(json!({"type":"text","text":crate::graph_tools::citations_text(&value)}));
+ }
+ json!({"content":content,"structuredContent":value,"isError":false})
+ } else {
+ json!({"content":[{"type":"text","text":value.to_string()}],"structuredContent":if value.is_object(){value}else{json!({"items":value})},"isError":false})
+ }
+}
+/// A tool call's error, as the tool's reply.
+fn tool_error(message: &str) -> Value {
+ json!({"content":[{"type":"text","text":message}],"isError":true})
+}
+/// The text a tool reply serves (`metering`): its text content, joined.
+fn served_text(reply: &Value) -> String {
+ reply["content"]
+ .as_array()
+ .into_iter()
+ .flatten()
+ .filter_map(|item| item["text"].as_str())
+ .collect::<Vec<_>>()
+ .join("\n")
+}
+/// The agent session an MCP call is counted under: a stdio connection's own
+/// label, else the label of the `Mcp-Session-Id` an HTTP client sent back.
+fn agent_session(
+ app: &App,
+ workspace: &str,
+ session: Option<&mut McpSession>,
+ http_session: Option<&str>,
+) -> String {
+ match (session, http_session) {
+ (Some(connection), _) => connection.label(),
+ (None, Some(id)) => crate::metering::http_session(&app.worker.store, workspace, id),
+ (None, None) => String::new(),
+ }
+}
async fn mcp_http(
State(app): State<App>,
Path((workspace, repository)): Path<(String, String)>,
@@ -2037,6 +2702,7 @@ async fn mcp_http(
Json(request): Json<Value>,
) -> Result<Response> {
let token = token(&headers)?.to_owned();
+ let (session, client) = mcp_http_session(&headers, &request);
let reply = tokio::task::spawn_blocking(move || {
// Keep transport-level authentication (including notifications) in
// the blocking job too: it may wait on a SQLite transaction.
@@ -2045,18 +2711,24 @@ async fn mcp_http(
let fresh = (request["method"] == "tools/call")
.then(|| mcp_freshness(&app, &workspace, &token, &repository))
.flatten();
- let mut reply = mcp(&app, &workspace, &token, &repository, &request);
+ let mut reply = mcp_in(
+ &app,
+ &workspace,
+ &token,
+ Some(&repository),
+ &request,
+ None,
+ session.as_deref(),
+ );
if let (Some(fresh), Some(reply)) = (&fresh, reply.as_mut()) {
fresh.attach_mcp(reply);
}
- Ok::<_, Error>(reply)
+ let issued = issued_session(&app, &workspace, &request, reply.as_ref(), &client);
+ Ok::<_, Error>((reply, issued))
})
.await
.map_err(|_| Error::bad("MCP request interrupted"))??;
- Ok(match reply {
- Some(value) => Json(value).into_response(),
- None => StatusCode::ACCEPTED.into_response(),
- })
+ Ok(mcp_http_response(reply))
}
/// `POST /mcp/{workspace}`: a workspace connection ([`mcp_workspace`]).
async fn mcp_http_workspace(
@@ -2066,16 +2738,67 @@ async fn mcp_http_workspace(
Json(request): Json<Value>,
) -> Result<Response> {
let token = token(&headers)?.to_owned();
+ let (session, client) = mcp_http_session(&headers, &request);
let reply = tokio::task::spawn_blocking(move || {
app.worker.store.workspace(&workspace, &token)?;
- Ok::<_, Error>(mcp_workspace(&app, &workspace, &token, &request))
+ let reply = mcp_in(
+ &app,
+ &workspace,
+ &token,
+ None,
+ &request,
+ None,
+ session.as_deref(),
+ );
+ let issued = issued_session(&app, &workspace, &request, reply.as_ref(), &client);
+ Ok::<_, Error>((reply, issued))
})
.await
.map_err(|_| Error::bad("MCP request interrupted"))??;
- Ok(match reply {
- Some(value) => Json(value).into_response(),
+ Ok(mcp_http_response(reply))
+}
+/// An HTTP MCP request's agent session for metering: the `Mcp-Session-Id`
+/// this server issued and signed at `initialize`, which the client sends
+/// back, and the client's name from `initialize`. Nothing else depends on
+/// it, so a client without one is served as before.
+fn mcp_http_session(headers: &HeaderMap, request: &Value) -> (Option<String>, String) {
+ let session = headers
+ .get("mcp-session-id")
+ .and_then(|value| value.to_str().ok())
+ .filter(|value| !value.is_empty() && value.len() <= 200)
+ .map(str::to_owned);
+ let client = request["params"]["clientInfo"]["name"]
+ .as_str()
+ .unwrap_or("mcp")
+ .to_owned();
+ (session, client)
+}
+/// A new signed session id for a successful `initialize`
+/// (`metering::issue_http_session`); `None` for any other message.
+fn issued_session(
+ app: &App,
+ workspace: &str,
+ request: &Value,
+ reply: Option<&Value>,
+ client: &str,
+) -> Option<String> {
+ (request["method"] == "initialize" && reply.is_some_and(|value| value.get("result").is_some()))
+ .then(|| crate::metering::issue_http_session(&app.worker.store, workspace, client))
+ .flatten()
+}
+/// The HTTP response to an MCP message: its reply with the session id issued
+/// at `initialize`, or 202 for a notification.
+fn mcp_http_response((reply, issued): (Option<Value>, Option<String>)) -> Response {
+ match reply {
+ Some(value) => {
+ let mut response = Json(value).into_response();
+ if let Some(id) = issued.and_then(|id| header::HeaderValue::from_str(&id).ok()) {
+ response.headers_mut().insert("mcp-session-id", id);
+ }
+ response
+ }
None => StatusCode::ACCEPTED.into_response(),
- })
+ }
}
/// The freshness of an HTTP MCP tool call: what `graphicle mcp` does before
diff --git a/crates/graphicle/src/capture.rs b/crates/graphicle/src/capture.rs
index d7012a7..4e65fdc 100644
--- a/crates/graphicle/src/capture.rs
+++ b/crates/graphicle/src/capture.rs
@@ -1029,16 +1029,17 @@ impl Store {
})
}
- /// Session-start context: open work-state items when an agent recorded
- /// any (labelled as unreviewed), reviewed, current memories (title and
- /// id), the stale count and the last captured turns, within
- /// [`START_CONTEXT_CHARS`]. Drafts and observer notes never appear.
+ /// Session-start context: a line on when to use Graphicle's tools and
+ /// when grep is enough ([`crate::agent_instructions::SESSION_ROUTING`]),
+ /// then open work-state items when an agent recorded any (labelled as
+ /// unreviewed), reviewed, current memories (title and id), the stale
+ /// count and the last captured turns, within [`START_CONTEXT_CHARS`].
+ /// Drafts and observer notes never appear.
///
- /// Empty when there is nothing to report: no reviewed memory, no open
- /// work and no stale memory. Captured turns alone do not make a note
- /// (recall reads them), so a session starts with no Graphicle text until
- /// the project holds something reviewed or open; the session-start hook
- /// then prints nothing.
+ /// Only the line when there is nothing to report: no reviewed memory, no
+ /// open work and no stale memory. Captured turns alone do not make a
+ /// note (recall reads them), so a session starts with the line alone
+ /// until the project holds something reviewed or open.
pub fn session_start_context(
&self,
workspace: &str,
@@ -1086,10 +1087,11 @@ impl Store {
turns.truncate(5);
Ok((open_work, reviewed, stale, turns))
})?;
+ let mut out = format!("{}\n", crate::agent_instructions::SESSION_ROUTING);
if open_work.is_none() && memories.is_empty() && stale == 0 {
- return Ok(String::new());
+ return Ok(out);
}
- let mut out = String::from(
+ out.push_str(
"Graphicle project memory. Reviewed memories are current; cite sources with read_project_source before relying on them.\n",
);
let push = |out: &mut String, line: String| {
diff --git a/crates/graphicle/src/cli.rs b/crates/graphicle/src/cli.rs
index 04515ba..de57215 100644
--- a/crates/graphicle/src/cli.rs
+++ b/crates/graphicle/src/cli.rs
@@ -81,6 +81,13 @@ enum Command {
/// the guard hooks an earlier setup installed.
#[arg(long)]
guards: bool,
+ /// Also give Claude Code a prompt hook: before each prompt that is a
+ /// code question, it adds `graphicle context`'s packet (at most 8,400
+ /// characters); nothing for other or short prompts, or when it fails
+ /// or takes over 10 seconds. Without it, setup leaves an earlier
+ /// setup's prompt hook as it is (`graphicle disconnect` removes it).
+ #[arg(long)]
+ prompt_context: bool,
/// The tools each client's entry publishes: all (every tool, as in
/// 0.1.0), essentials (query_graph, get_node, get_neighbors,
/// recall_project, read_project_source), graph or memory. Default:
@@ -212,8 +219,9 @@ enum Command {
#[arg(long, default_value = "all", value_parser = ["all", "essentials", "graph", "memory"])]
mcp_tools: String,
/// Fix a switch of recall_project on the HTTP MCP endpoint, for
- /// example graph_retrieval=false: no request can change it. Each
- /// switch at most once.
+ /// example graph_retrieval=false or scope=project: no request can
+ /// change it, and every recall packet echoes it. Each switch at most
+ /// once; an unknown switch is refused.
#[arg(long = "mcp-set", value_name = "SWITCH=VALUE")]
mcp_set: Vec<String>,
/// HTTPS origin of a reverse proxy. Public workspace creation is disabled.
@@ -291,6 +299,7 @@ enum Command {
},
/// Retrieve evidence without calling a model.
Context {
+ /// The question; `-` reads it from standard input (at most 1 MiB).
question: String,
/// The project: an id, a key or a synced folder (default: this
/// folder's project, else the last synced one).
@@ -300,8 +309,43 @@ enum Command {
/// this folder's project (or --project) first, then the others.
#[arg(long)]
workspace: bool,
- #[arg(long, default_value_t = 3000)]
- max_tokens: usize,
+ /// The packet's budget in tokens [default: 3000].
+ #[arg(long)]
+ max_tokens: Option<usize>,
+ /// Most characters of the packet. Without it, 4 per token of
+ /// --max-tokens when that is given, else 8,400, which keeps a prompt
+ /// hook that prints the packet below the 10,000 characters Claude
+ /// Code shows in full.
+ #[arg(long)]
+ max_chars: Option<usize>,
+ /// Order notes and documents first for a question in prose, quote one
+ /// window per file and date each excerpt (the packet's notes_first
+ /// says what applied).
+ #[arg(long)]
+ notes_first: bool,
+ /// Answer a question that is an identifier, or only asks where named
+ /// identifiers are defined or used, with the full retrieval instead
+ /// of their definitions and references from the code graph (the
+ /// packet's route says which path ran).
+ #[arg(long)]
+ no_identifier_route: bool,
+ /// Rank source files ahead of documentation, tests and vendored code:
+ /// auto (for a code question, the default), true or false.
+ #[arg(long, value_name = "WHEN", value_parser = ["auto", "true", "false"])]
+ code_first: Option<String>,
+ /// Search a code question by its content, not its instructions:
+ /// auto (the default), true or false.
+ #[arg(long, value_name = "WHEN", value_parser = ["auto", "true", "false"])]
+ query_focus: Option<String>,
+ /// Rank the files that hold or define the identifiers and paths the
+ /// question names: auto (for a code question, the default), true or
+ /// false.
+ #[arg(long, value_name = "WHEN", value_parser = ["auto", "true", "false"])]
+ identifier_arm: Option<String>,
+ /// After the excerpts, list the paths of this many next-ranked files
+ /// (0 to 40; default 10 for a code question, 0 otherwise).
+ #[arg(long, value_name = "N", value_parser = clap::value_parser!(u64).range(0..=40))]
+ more_files: Option<u64>,
/// Configured local ONNX embedding profile; requires a prepared vector index.
#[arg(long)]
local_embedding_profile: Option<String>,
@@ -411,15 +455,22 @@ enum Command {
/// graph-history tools), memory (the other tools; recall still
/// reads the code graph unless --set graph_retrieval=false) or
/// essentials (query_graph, get_node, get_neighbors, recall_project
- /// and read_project_source, with one sentence of instructions: what
- /// setup gives Claude Code).
+ /// and read_project_source, with short instructions on when to call
+ /// them and when grep is enough: what setup gives Claude Code).
#[arg(long, default_value = "all", value_parser = ["all", "essentials", "graph", "memory"])]
tools: String,
/// Fix a switch of recall_project for the session, for example
- /// graph_retrieval=false: no request can change it. Each switch at
- /// most once.
+ /// graph_retrieval=false or scope=project: no request can change it,
+ /// and every recall packet echoes it. Each switch at most once; an
+ /// unknown switch is refused.
#[arg(long = "set", value_name = "SWITCH=VALUE")]
set: Vec<String>,
+ /// Print this server's manifest as JSON and exit: the program's
+ /// version, edition and sha256, the tools and instructions it would
+ /// serve with their sha256, the switches it fixes, and the schema
+ /// versions, for a record of exactly what a run used.
+ #[arg(long)]
+ manifest: bool,
/// Also publish the graph engine's pull-request tools (list_prs,
/// get_pr_impact, triage_prs), which run gh here: start the server in
/// the project's own folder. Not with --workspace, which has no
@@ -462,7 +513,10 @@ enum Command {
arguments: Option<PathBuf>,
},
/// Create a consistent, private SQLite backup without stopping the app.
- Backup { path: PathBuf },
+ ///
+ /// Without PATH, the backup goes to the data folder's `backups` folder,
+ /// where `graphicle offboard` finds it.
+ Backup { path: Option<PathBuf> },
/// Restore a database into a new data directory; existing data is never overwritten.
Restore { path: PathBuf },
/// Show or change settings, such as the answer model.
@@ -491,6 +545,27 @@ enum Command {
#[arg(long)]
json: bool,
},
+ /// Remove one project's data from the data folder, with a hash-chained
+ /// deletion receipt that lists what was removed.
+ ///
+ /// The project's sources, memory, code graph and history go from the
+ /// store, with its graph cache and its copies in the backups `graphicle
+ /// backup` keeps in the data folder; other projects, in those backups
+ /// too, stay. Without --apply, only the plan is shown and nothing
+ /// changes; it ends with the command that carries it out. Nothing
+ /// outside the data folder is touched: the plan names what it does not
+ /// cover, such as backups written elsewhere.
+ Offboard {
+ /// The project: an id, a key or a synced folder.
+ #[arg(long)]
+ project: String,
+ /// Carry out the plan with this hash, as the plan printed it.
+ #[arg(long, value_name = "PLAN_HASH")]
+ apply: Option<String>,
+ /// Print JSON (the default when the output is not a terminal).
+ #[arg(long)]
+ json: bool,
+ },
/// Disconnect Graphicle everywhere, then say how to remove the program.
Uninstall {
/// Also delete the data folder, after confirmation.
@@ -644,6 +719,10 @@ pub fn main_with(extensions: Extensions) -> i32 {
1
}
};
+ // This process's served-token counts (`crate::metering`), waiting
+ // at most a second for the store: a capture hook must not hold
+ // up its client.
+ crate::metering::flush_all(std::time::Duration::from_secs(1));
crate::local_inference::exit_if_loaded(code);
if code != 0 {
std::process::exit(code);
@@ -867,6 +946,13 @@ where
Command::Sync { quiet: true, .. } if !directory.join("reviews.sqlite3").is_file() => {
return Ok(());
}
+ // Offboarding never creates one.
+ Command::Offboard { .. } if !directory.join("reviews.sqlite3").is_file() => {
+ return Err(Error::bad(format!(
+ "There is no Graphicle data folder at {}: nothing to offboard",
+ directory.display()
+ )));
+ }
// An agent's server never creates one either: it says what to run.
Command::Mcp { .. } if !directory.join("reviews.sqlite3").is_file() => {
return Err(Error::bad(format!(
@@ -891,6 +977,8 @@ where
// file's `limits`, then `GRAPHICLE_MAX_*`.
let limits = crate::limits::Limits::from_environment(&config.limits)?;
crate::limits::install(limits);
+ // Whether a sync reads tracked files an ignore pattern matches.
+ crate::local::install_tracked_ignored(&config);
let store = store.with_limits(limits);
let app = App::new(store.clone(), config.clone(), vec![])?;
match command {
@@ -903,6 +991,7 @@ where
no_instructions,
switch_from_graphify,
guards,
+ prompt_context,
tools,
json,
} => crate::setup::setup(
@@ -919,6 +1008,7 @@ where
json,
config: config_path.clone(),
guards,
+ prompt_context,
tools: tools.as_deref().map(api::ToolSet::parse).transpose()?,
},
),
@@ -1043,7 +1133,25 @@ where
false,
crate::terminal::update_text,
),
- Command::Backup { path } => print(&store.backup(&path)?),
+ Command::Backup { path } => {
+ let path = match path {
+ Some(path) => path,
+ None => crate::offboard::backup_path(&store)?,
+ };
+ print(&store.backup(&path)?)
+ }
+ Command::Offboard {
+ project,
+ apply,
+ json,
+ } => {
+ let session = local::session(&store, false)?;
+ let reply = match apply {
+ Some(hash) => crate::offboard::apply(&store, &session, &project, &hash)?,
+ None => crate::offboard::plan(&store, &session, &project)?,
+ };
+ crate::terminal::emit(&reply, json, crate::offboard::text)
+ }
Command::DocumentWorker { .. } => unreachable!(),
Command::Restore { .. } => unreachable!(),
Command::RedisWorker { .. } => unreachable!(),
@@ -1241,6 +1349,7 @@ where
tools,
set,
pull_requests,
+ manifest,
} => {
let session = local::session(&store, false)?;
// A project connection, or with --workspace a workspace
@@ -1287,6 +1396,34 @@ where
pull_requests,
cwd: Some(cwd),
};
+ // A fixed scope must match the connection.
+ match (
+ app.mcp
+ .fixed
+ .get(api::RECALL_SCOPE)
+ .and_then(|v| v.as_str()),
+ workspace,
+ ) {
+ (Some("project"), true) => {
+ return Err(Error::bad(
+ "--set scope=project serves one project: leave out --workspace",
+ ));
+ }
+ (Some("workspace"), false) => {
+ return Err(Error::bad(
+ "--set scope=workspace serves the workspace: add --workspace",
+ ));
+ }
+ _ => {}
+ }
+ if manifest {
+ return print(&api::manifest(
+ &app,
+ &session.workspace,
+ &session.capability,
+ project.as_deref(),
+ )?);
+ }
// SIGTERM and SIGINT end the session as a closed input does:
// handled, they no longer kill the process in the middle
// of a projection. Installed before the drain starts.
@@ -1434,10 +1571,29 @@ where
project,
workspace,
max_tokens,
+ max_chars,
+ notes_first,
+ no_identifier_route,
+ code_first,
+ query_focus,
+ identifier_arm,
+ more_files,
local_embedding_profile,
local_reranker_profile,
json,
} => {
+ // `-`: the question on standard input (the prompt hook's way, so
+ // a prompt never meets the command line's size limits).
+ let question = if question == "-" {
+ use std::io::Read;
+ let mut read = String::new();
+ std::io::stdin()
+ .take(1024 * 1024)
+ .read_to_string(&mut read)?;
+ read
+ } else {
+ question
+ };
let session = crate::phase::phase("context_session", || local::session(&store, false))?;
// With --workspace the project only comes first,
// and none is needed outside every synced folder.
@@ -1466,10 +1622,41 @@ where
}),
None => crate::fresh::Outcome::default(),
};
- let mut args = json!({"repository_id":project,"question":question,"max_tokens":max_tokens,"max_chars":max_tokens.saturating_mul(4).clamp(2000,64000),"local_embedding_profile":local_embedding_profile,"local_reranker_profile":local_reranker_profile});
+ // A budget in tokens alone keeps 4 characters a token, as before;
+ // neither keeps the packet hook-sized.
+ let max_chars = match (max_chars, max_tokens) {
+ (Some(chars), _) => chars,
+ (None, Some(tokens)) => tokens.saturating_mul(4),
+ (None, None) => crate::query::PUSH_CHARS,
+ };
+ let max_tokens = max_tokens.unwrap_or(3000);
+ let mut args = json!({"repository_id":project,"question":question,"max_tokens":max_tokens,"max_chars":max_chars.clamp(2000,64000),"local_embedding_profile":local_embedding_profile,"local_reranker_profile":local_reranker_profile});
if workspace {
args["scope"] = json!("workspace");
}
+ if notes_first {
+ args["notes_first"] = json!(true);
+ }
+ // The code-question switches, when given (crate::code_question).
+ for (field, value) in [
+ ("code_first", code_first),
+ ("query_focus", query_focus),
+ ("identifier_arm", identifier_arm),
+ ] {
+ if let Some(value) = value {
+ args[field] = match value.as_str() {
+ "true" => json!(true),
+ "false" => json!(false),
+ _ => json!("auto"),
+ };
+ }
+ }
+ if let Some(count) = more_files {
+ args["more_files"] = json!(count);
+ }
+ // The identifier route unless --no-identifier-route (the HTTP
+ // API and the SDKs leave it off unless a call asks).
+ args[crate::identifier_route::FIELD] = json!(!no_identifier_route);
let mut packet = crate::phase::phase("context_packet", || {
api::command(
&app,
@@ -1480,17 +1667,30 @@ where
)
})?;
fresh.attach(&mut packet);
+ if !no_identifier_route && packet[crate::identifier_route::REPORT].is_object() {
+ packet[crate::identifier_route::REPORT]["defaulted"] = json!(true);
+ }
// On a terminal the note is part of the readable packet.
if !crate::terminal::human(json) {
fresh.tell();
}
- crate::terminal::emit(&packet, json, |packet, style| {
+ let printed = crate::terminal::emit_text(&packet, json, |packet, style| {
crate::terminal::with_origin(
origin.as_deref(),
style,
crate::terminal::context_text(packet, style),
)
- })
+ })?;
+ // Served on the command line: metered (`crate::metering`).
+ crate::metering::served_locally(
+ &store,
+ &session.workspace,
+ &session.capability,
+ project.as_deref().unwrap_or(""),
+ "context",
+ &printed,
+ );
+ Ok(())
}
Command::Ask {
question,
@@ -1635,13 +1835,25 @@ where
if let Some(project) = project {
args["repository_id"] = json!(project);
}
- print(&api::command(
+ let value = api::command(
&app,
&session.workspace,
&session.capability,
&operation,
&args,
- )?)
+ )?;
+ let printed = serde_json::to_string_pretty(&value)?;
+ crate::terminal::say(&printed)?;
+ // A metered operation is counted (`crate::metering::meter`).
+ crate::metering::served_locally(
+ &store,
+ &session.workspace,
+ &session.capability,
+ args["repository_id"].as_str().unwrap_or(""),
+ &operation,
+ &printed,
+ );
+ Ok(())
}
Command::ConfigExample
| Command::Help { .. }
@@ -1885,32 +2097,58 @@ fn hook(directory: &std::path::Path, client: &str, event: &str) {
};
let directory = directory.to_path_buf();
let (sender, receiver) = std::sync::mpsc::channel();
+ // The agent's session, for metering: a digest of its id.
+ let agent_session = payload["session_id"]
+ .as_str()
+ .filter(|id| !id.is_empty())
+ .map(|id| crate::metering::session_label(client.as_str(), id))
+ .unwrap_or_default();
// A plain thread: returning from main does not wait for it.
std::thread::spawn(move || {
- let context = (|| -> Result<Option<String>> {
+ let context = (|| -> Result<Option<(String, Store, crate::metering::Call)>> {
let store = Store::open(directory)?;
let session = local::session(&store, false)?;
let Some(project) = crate::capture::project_for_cwd(&store, &session, &cwd)?
else {
return Ok(None);
};
- // An empty context (nothing reviewed, open or stale)
- // prints nothing, so the session gets no Graphicle text.
+ // The context starts with the line on when to use
+ // Graphicle (crate::agent_instructions::SESSION_ROUTING),
+ // so every session in a project gets it; an empty one
+ // would print nothing.
let context = store.session_start_context(
&session.workspace,
&session.capability,
&project,
)?;
- Ok((!context.is_empty()).then_some(context))
+ if context.is_empty() {
+ return Ok(None);
+ }
+ let credential =
+ crate::metering::principal(&store, &session.workspace, &session.capability)
+ .map(|principal| principal.credential)
+ .unwrap_or_default();
+ let call = crate::metering::Call {
+ workspace: session.workspace,
+ repository: project,
+ credential,
+ session: agent_session,
+ channel: crate::metering::Channel::Hook,
+ kind: "session_start".into(),
+ };
+ Ok(Some((context, store, call)))
})();
let _ = sender.send(context);
});
- if let Ok(Ok(Some(context))) =
+ if let Ok(Ok(Some((context, store, call)))) =
receiver.recv_timeout(std::time::Duration::from_millis(2500))
{
use std::io::Write;
let output = json!({"hookSpecificOutput":{"hookEventName":"SessionStart","additionalContext":context}});
- let _ = writeln!(std::io::stdout(), "{output}");
+ if writeln!(std::io::stdout(), "{output}").is_ok() && !call.credential.is_empty() {
+ // Served: written when the program ends (`main_with`).
+ crate::metering::record(&store, &call, crate::metering::tokens(&context));
+ }
}
}
"stop" | "sessionend" | "precompact" => {
@@ -1936,6 +2174,8 @@ fn hook(directory: &std::path::Path, client: &str, event: &str) {
// timeout does not stop the import.
let _ = crate::platform::spawn_detached(&mut command);
}
+ // The prompt hook of `setup --prompt-context` (crate::prompt_hook).
+ "promptcontext" => crate::prompt_hook::run(directory, &payload),
// The guard hooks of `connect --graph`.
"guardsearch" | "guardread" => {
use std::io::Write;
diff --git a/crates/graphicle/src/code_question.rs b/crates/graphicle/src/code_question.rs
new file mode 100644
index 0000000..9faebc2
--- /dev/null
+++ b/crates/graphicle/src/code_question.rs
@@ -0,0 +1,1168 @@
+//! Code questions: a question that names code (an identifier or a code
+//! file, [`crate::notes_first::names_code`]) or reads like an issue or a bug
+//! report ([`reads_like_report`]). For such a question `context` ranks the
+//! project's source files ahead of its documentation, tests and vendored or
+//! generated code (the `code_first` option, [`CodeFirst`]): `rank` multiplies
+//! the fused score of every passage of those files by [`CODE_FIRST_WEIGHT`]
+//! before it takes the order, so the selection and the budget see the prior.
+//! A question about documents, notes or decisions ([`asks_about_documents`])
+//! keeps the order it had, unless it reads like a report; so does a
+//! question in plain words. Test files keep their weight when the call sets
+//! `include_tests: true`, or when a question that is not a report names a
+//! test ([`names_tests`]).
+use crate::{Error, Result};
+use serde_json::{Map, Value, json};
+use std::collections::{HashMap, HashSet};
+use std::sync::LazyLock;
+
+/// What a project file holds, by its path ([`path_class`]).
+#[derive(Clone, Copy, Debug, PartialEq, Eq)]
+pub enum PathClass {
+ /// Everything else: the project's code, its build files and data.
+ Source,
+ /// A test, or a test's data or fixtures.
+ Test,
+ /// Documentation, notes, changelogs and licences.
+ Doc,
+ /// Vendored or generated code, and lock files.
+ Vendored,
+}
+
+impl PathClass {
+ pub fn name(self) -> &'static str {
+ match self {
+ Self::Source => "source",
+ Self::Test => "test",
+ Self::Doc => "doc",
+ Self::Vendored => "vendored",
+ }
+ }
+}
+
+/// Extensions of code files: a documentation file name (`CHANGES`,
+/// `HISTORY`) with one of these is code (`history.py`).
+const CODE_EXTENSIONS: &[&str] = &[
+ "c", "h", "cc", "cpp", "cxx", "c++", "hpp", "hh", "hxx", "h++", "inl", "ipp", "tpp", "cu",
+ "cuh", "rs", "java", "kt", "kts", "scala", "sc", "cs", "fs", "vb", "js", "jsx", "mjs", "cjs",
+ "ts", "tsx", "mts", "cts", "go", "py", "pyi", "pyx", "rb", "php", "swift", "m", "mm", "lua",
+ "ex", "exs", "erl", "hs", "ml", "mli", "dart", "jl", "r", "clj", "cljs", "zig", "vue",
+ "svelte", "groovy", "pl", "pm", "sh", "bash", "zsh", "ps1", "sql", "proto",
+];
+
+/// Extensions of documentation files.
+const DOC_EXTENSIONS: &[&str] = &[
+ "md", "markdown", "mdx", "mdown", "rst", "adoc", "asciidoc", "rdoc", "org", "txt", "text",
+ "textile", "pod",
+];
+
+/// Text files that are build or dependency lists, not documentation.
+const NOT_DOCS: &[&str] = &["cmakelists.txt", "llvmbuild.txt"];
+
+static DOC_NAME: LazyLock<regex::Regex> = LazyLock::new(|| {
+ regex::Regex::new(concat!(
+ r"(?i)^(readme|changelog|changes|news|history|authors|contributors|contributing|",
+ r"release[-_]?notes|licen[cs]e|copying|notice|code[-_]of[-_]conduct|security|support|",
+ r"maintainers|governance|roadmap|upgrading|migration[-_]?guide)([._-].*)?$",
+ ))
+ .expect("the documentation name rule")
+});
+
+static DOC_FOLDER: LazyLock<regex::Regex> = LazyLock::new(|| {
+ regex::Regex::new(
+ r"(?i)^(docs?|documentation|man|manual|changelog\.d|changelogs?|newsfragments|release[-_]?notes|wiki)$",
+ )
+ .expect("the documentation folder rule")
+});
+
+static TEST_FOLDER: LazyLock<regex::Regex> = LazyLock::new(|| {
+ regex::Regex::new(concat!(
+ r"^(?i:tests?|testing|__tests?__|specs?|testdata|test[-_]data|fixtures?|__fixtures__|",
+ r"__mocks__|e2e|testcases?|test[-_]?suites?|",
+ r"(?:unit|integration|functional|acceptance|regression)[-_]?tests?)$",
+ r"|(?i:[._-](?:unit|integration|functional|acceptance|e2e)?[-_]?tests?)$",
+ r"|^[A-Z][A-Za-z0-9]*Tests?$",
+ ))
+ .expect("the test folder rule")
+});
+
+static TEST_NAME: LazyLock<regex::Regex> = LazyLock::new(|| {
+ regex::Regex::new(concat!(
+ // test_x.py, test-utils.ts, conftest.py, tests.rs, test.c
+ r"^(?i:test[_-].+|conftest\.py|tests?\.[a-z0-9+]+)$",
+ // x_test.go, x_tests.rs, x-test.c, x.test.ts, x.spec.js, x_spec.rb, x_unittest.cc
+ r"|(?i:[._-](?:tests?|specs?|unittests?)\.[a-z0-9+]+)$",
+ // FooTest.java, FooTests.cs, FooTestCase.php, FooSpec.groovy, FooIT.java, TestFoo.java
+ r"|^[A-Z][A-Za-z0-9_]*(?:Test|Tests|TestCase|Spec)\.(?:java|kt|kts|scala|groovy|cs|fs|vb|swift|php|m|mm|ts|js)$",
+ r"|^[A-Z][A-Za-z0-9_]*[a-z0-9]IT\.(?:java|kt|groovy|scala)$",
+ r"|^Test[A-Z][A-Za-z0-9_]*\.(?:java|kt|cs|php|swift|scala)$",
+ ))
+ .expect("the test name rule")
+});
+
+static VENDOR_FOLDER: LazyLock<regex::Regex> = LazyLock::new(|| {
+ regex::Regex::new(concat!(
+ r"(?i)^(vendor|vendored|third[-_]?party|3rd[-_]?party|node_modules|bower_components|",
+ r"externals?|generated|__generated__)$",
+ ))
+ .expect("the vendored folder rule")
+});
+
+static GENERATED_NAME: LazyLock<regex::Regex> = LazyLock::new(|| {
+ regex::Regex::new(concat!(
+ r"(?i)(\.min\.(js|css)|\.bundle\.js|\.pb\.(go|cc|h)|_pb2(_grpc)?\.pyi?|\.g\.(cs|dart)|",
+ r"\.designer\.cs|[._-]generated\.[a-z0-9]+)$",
+ r"|^(package-lock\.json|npm-shrinkwrap\.json|yarn\.lock|pnpm-lock\.yaml|cargo\.lock|",
+ r"poetry\.lock|pipfile\.lock|gemfile\.lock|composer\.lock|go\.sum|bun\.lockb|uv\.lock)$",
+ ))
+ .expect("the generated name rule")
+});
+
+/// The class of the project file at `path` (relative, `/` or `\`): tests
+/// by folder (`tests/`, `__tests__/`, `src/test/`, `Foo.Tests/`,
+/// `FooTests/`, `testdata/`, `fixtures/`) or name, in Rust (`tests.rs`,
+/// `x_test.rs`), Python (`test_x.py`, `x_test.py`, `conftest.py`), Go
+/// (`x_test.go`), Java, Kotlin and Scala (`FooTest.java`, `FooTests.kt`,
+/// `FooIT.java`, `TestFoo.java`), C# (`FooTests.cs`), JavaScript and
+/// TypeScript (`x.test.ts`, `x.spec.js`), C and C++ (`test_x.c`,
+/// `x_test.cc`, `x_unittest.cpp`) and Ruby (`x_spec.rb`); documentation by
+/// extension (Markdown, reStructuredText, AsciiDoc, Org, plain text except
+/// `CMakeLists.txt`), name (`README`, `CHANGELOG`, `LICENSE`, ...) or folder
+/// (`doc/`, `man/`, `changelog.d/`; code files only under `docs/` or
+/// `documentation/`); vendored or generated code by folder
+/// (`vendor/`, `third_party/`, `node_modules/`, `generated/`), name
+/// (`x.min.js`, `x.pb.go`, `x_pb2.py`, `x.designer.cs`) or lock file. A test
+/// or document under a vendored folder is vendored.
+pub fn path_class(path: &str) -> PathClass {
+ let path = path.replace('\\', "/");
+ let segments: Vec<&str> = path.split('/').filter(|s| !s.is_empty()).collect();
+ let Some((name, folders)) = segments.split_last() else {
+ return PathClass::Source;
+ };
+ if folders.iter().any(|s| VENDOR_FOLDER.is_match(s)) || GENERATED_NAME.is_match(name) {
+ return PathClass::Vendored;
+ }
+ if folders.iter().any(|s| TEST_FOLDER.is_match(s)) || TEST_NAME.is_match(name) {
+ return PathClass::Test;
+ }
+ let lower = name.to_ascii_lowercase();
+ let extension = lower.rsplit_once('.').map(|(_, e)| e);
+ if extension.is_some_and(|e| CODE_EXTENSIONS.contains(&e)) {
+ // Code is documentation only in a documentation site's folder
+ // (`docs/conf.py`, `docs/examples/demo.rs`).
+ let site = |s: &&str| matches!(s.to_ascii_lowercase().as_str(), "docs" | "documentation");
+ return if folders.iter().any(site) {
+ PathClass::Doc
+ } else {
+ PathClass::Source
+ };
+ }
+ let doc_extension = extension.is_some_and(|e| DOC_EXTENSIONS.contains(&e))
+ && !NOT_DOCS.contains(&lower.as_str());
+ // `README`, `LICENSE-MIT`, `COPYING.LIB`, `CHANGES.rst`; not
+ // `security.yaml` or `history.json`.
+ let capitals = name
+ .split(['.', '-', '_'])
+ .next()
+ .is_some_and(|stem| stem.len() > 1 && stem.chars().all(|c| c.is_ascii_uppercase()));
+ let doc_name = DOC_NAME.is_match(name) && (extension.is_none() || doc_extension || capitals);
+ if doc_extension || doc_name || folders.iter().any(|s| DOC_FOLDER.is_match(s)) {
+ return PathClass::Doc;
+ }
+ PathClass::Source
+}
+
+/// Whether `text` reads like an issue or a bug report: it holds a code
+/// block (three backticks or tildes), a stack trace or error line (a Java
+/// or JavaScript `at x.y(...)` frame, a Python traceback, a Rust panic or
+/// compiler error, an `XError:` or `XException`, a segmentation fault), or
+/// at least two of the words reports use (bug, crash, error, exception,
+/// fails, regression, reproduce, expected, actual, broken, wrong, ...).
+pub fn reads_like_report(text: &str) -> bool {
+ static MARKS: LazyLock<regex::Regex> = LazyLock::new(|| {
+ regex::Regex::new(concat!(
+ r"(?m:^\s*(?:```|~~~))",
+ r"|(?m:^\s+at [\w$.<>/]+ ?\()",
+ r"|Traceback \(most recent call last\)|File .[^\n]{1,300}., line \d+",
+ r"|panicked at|error\[E\d{4}\]|(?i:segmentation fault|core dumped)",
+ r"|\b[A-Z][A-Za-z0-9]*(?:Error|Exception)\b(?::|\s+in\b|\s+at\b)",
+ ))
+ .expect("the report marks")
+ });
+ static WORDS: LazyLock<regex::Regex> = LazyLock::new(|| {
+ regex::Regex::new(concat!(
+ r"(?i)\b(bugs?|crash(es|ed|ing)?|errors?|exceptions?|fail(s|ed|ing|ures?)?|",
+ r"panic(s|ked)?|regressions?|reproduc(e|es|ed|ing|ible|tion)|repro|expected|",
+ r"actual(ly)?|broken|wrong(ly)?|incorrect(ly)?|unexpected(ly)?|segfaults?|",
+ r"hangs?|deadlocks?|leaks?|warnings?|workaround|stack ?traces?|tracebacks?)\b",
+ ))
+ .expect("the report words")
+ });
+ if MARKS.is_match(text) {
+ return true;
+ }
+ let mut seen = std::collections::BTreeSet::new();
+ for word in WORDS.find_iter(text) {
+ // "crashes" and "crash", "fails" and "failure" are one word.
+ let word = word.as_str().to_ascii_lowercase();
+ let root: String = word.chars().take(3).collect();
+ seen.insert(root);
+ if seen.len() >= 2 {
+ return true;
+ }
+ }
+ false
+}
+
+/// Whether `text` asks about documents, notes or decisions: it names a
+/// documentation file or folder (`README.md`, `docs/setup.rst`,
+/// `CHANGELOG`) or uses the words documentation, documented, docs, readme,
+/// changelog, notes, decision, decided, ADR, rationale, wiki, guide or
+/// tutorial.
+pub fn asks_about_documents(text: &str) -> bool {
+ static DOCS: LazyLock<regex::Regex> = LazyLock::new(|| {
+ regex::Regex::new(concat!(
+ r"(?i)\b(documentation|documented|docs|doc|readme|changelog|release notes|notes?|",
+ r"decisions?|decided|decide|adrs?|rationale|wiki|guide|tutorial|design doc)\b",
+ r"|(?i)[\w./-]+\.(md|markdown|mdx|rst|adoc|asciidoc|org)\b",
+ ))
+ .expect("the documents rule")
+ });
+ DOCS.is_match(text)
+}
+
+/// Whether `text` names a test: [`crate::query::question_names_tests`]'s
+/// Python names, a path or file name [`path_class`] reads as a test, in any
+/// of its languages, or a `FooTest`, `FooTests`, `FooSpec` or `x_test` name.
+pub fn names_tests(text: &str) -> bool {
+ static TESTS: LazyLock<regex::Regex> = LazyLock::new(|| {
+ regex::Regex::new(r"\b[A-Z][A-Za-z0-9]*(Test|Tests|Spec)\b|\b[a-z][a-z0-9_]*_tests?\b")
+ .expect("the test names rule")
+ });
+ static PATHS: LazyLock<regex::Regex> = LazyLock::new(|| {
+ regex::Regex::new(r"[A-Za-z0-9_][A-Za-z0-9_./-]*\.[A-Za-z][A-Za-z0-9+]{0,5}\b")
+ .expect("the file names rule")
+ });
+ crate::query::question_names_tests(text)
+ || TESTS.is_match(text)
+ || PATHS
+ .find_iter(text)
+ .any(|m| path_class(m.as_str()) == PathClass::Test)
+}
+
+/// Whether `question` is a code question: it names code or reads like a
+/// report.
+pub fn is_code_question(question: &str) -> bool {
+ crate::notes_first::names_code(question) || reads_like_report(question)
+}
+
+/// A three-way option: `"auto"` (left out or `null`), `true` or `false`.
+fn three_way(args: &Value, field: &str) -> Result<(Option<bool>, bool)> {
+ match args.get(field) {
+ None | Some(Value::Null) => Ok((None, true)),
+ Some(Value::Bool(on)) => Ok((Some(*on), false)),
+ Some(Value::String(mode)) if mode == "auto" => Ok((None, false)),
+ Some(_) => Err(Error::bad(format!("{field} must be true, false or auto"))),
+ }
+}
+
+/// General English words of instructions to an assistant: the task's verbs
+/// (find, fix, change, list, ...), its generic objects (task, issue,
+/// question, file, function, method, class) and please. A code question
+/// without marked content leaves them out of its query ([`focus`]): they say
+/// what to do with the code, not which code. Text a question marks as its
+/// content keeps every word.
+pub const INSTRUCTION_WORDS: &str = "\
+ answer answers ask asked change changes class classes create delete describe edit edits \
+ explain file files find fix fixes function functions help identify implement instruction \
+ instructions issue issues list locate look method methods modify need needs please \
+ problem question questions request resolve search show task tasks tell";
+
+/// Words of placeholders in instructions (`ClassName.method_name`,
+/// `path/to/your/file.py`, `foo.bar()`): a name made only of these is no
+/// name of the project's code.
+const PLACEHOLDER_WORDS: &str = "\
+ a an the my your our some any this that to from of in at by for with path paths file files \
+ filename dir directory folder root repo repository project src module modules package class \
+ classes name names method methods function functions func fn var variable variables param \
+ params parameter parameters arg args argument arguments value values type types field \
+ fields attr attribute key keys item items obj object objects instance foo bar baz qux \
+ example examples sample placeholder thing stuff x y z py js ts rs java go c h cpp cs rb";
+
+/// Whether `name` is a placeholder: all its words are [`PLACEHOLDER_WORDS`].
+fn placeholder(name: &str) -> bool {
+ static WORDS: LazyLock<HashSet<&'static str>> =
+ LazyLock::new(|| PLACEHOLDER_WORDS.split_whitespace().collect());
+ let words = graphicle_memory::text::words(name);
+ !words.is_empty() && words.iter().all(|word| WORDS.contains(word.as_str()))
+}
+
+/// Whether `word` (any case) is one of [`INSTRUCTION_WORDS`].
+fn instruction_word(word: &str) -> bool {
+ let word = word.to_ascii_lowercase();
+ INSTRUCTION_WORDS.split_whitespace().any(|w| w == word)
+}
+
+/// Element names of HTML, which a question quotes rather than uses to mark
+/// its parts (GitHub's `<details>` and `<summary>` included).
+const HTML_ELEMENTS: &[&str] = &[
+ "a",
+ "abbr",
+ "b",
+ "blockquote",
+ "body",
+ "br",
+ "button",
+ "caption",
+ "code",
+ "dd",
+ "details",
+ "div",
+ "dl",
+ "dt",
+ "em",
+ "footer",
+ "form",
+ "h1",
+ "h2",
+ "h3",
+ "h4",
+ "h5",
+ "h6",
+ "head",
+ "header",
+ "hr",
+ "html",
+ "i",
+ "img",
+ "input",
+ "kbd",
+ "label",
+ "li",
+ "link",
+ "main",
+ "meta",
+ "nav",
+ "ol",
+ "option",
+ "p",
+ "pre",
+ "script",
+ "section",
+ "select",
+ "small",
+ "span",
+ "strong",
+ "style",
+ "sub",
+ "summary",
+ "sup",
+ "svg",
+ "table",
+ "tbody",
+ "td",
+ "template",
+ "textarea",
+ "tfoot",
+ "th",
+ "thead",
+ "title",
+ "tr",
+ "u",
+ "ul",
+ "video",
+];
+
+/// The parts a question marks as its content ([`marked`]).
+struct Marked {
+ /// What marked each part: its tag (`issue`) or delimiter (`BEGIN ISSUE`).
+ labels: Vec<String>,
+ /// The parts' text, in order.
+ content: String,
+ /// The question's text outside them.
+ outside: String,
+}
+
+/// The parts of `question` it marks as its content, outermost first: tags
+/// of its own (`<issue>` ... `</issue>`, `<pr_description>` ...), the opening
+/// tag at the start of a line (text may follow it there) and the closing
+/// tag anywhere after it, or delimiter lines (`--- BEGIN ISSUE ---` ...
+/// `--- END ISSUE ---`, drawn with `-`, `=`, `#`, `*` or `~`). HTML elements
+/// are quoted text, not marks. The closing tags and end lines are found in
+/// one pass first, so a question full of tags that never close (`<Foo
+/// object at 0x...>`) is still read once. `None` without such a part, or
+/// when the text outside is longer than 2,000 characters and the parts hold
+/// less than 40% of the question: then the marks are a snippet's.
+fn marked(question: &str) -> Option<Marked> {
+ static OPEN: LazyLock<regex::Regex> = LazyLock::new(|| {
+ regex::Regex::new(concat!(
+ r"(?m)^[ \t]*(?:<([A-Za-z][A-Za-z0-9_.:-]{0,40})(?:[ \t][^<>\n]*)?>",
+ r"|[-=#*~]{2,}[ \t]*(?i:begin)[ \t]+([^\n]{1,80}?)[ \t]*[-=#*~]{2,}[ \t]*\r?$)",
+ ))
+ .expect("the opening mark rule")
+ });
+ static CLOSE: LazyLock<regex::Regex> = LazyLock::new(|| {
+ regex::Regex::new(concat!(
+ r"</([A-Za-z][A-Za-z0-9_.:-]{0,40})>",
+ r"|(?m:^[ \t]*[-=#*~]{2,}[ \t]*(?i:end)[ \t]+([^\n]{1,80}?)[ \t]*[-=#*~]{2,}[ \t]*\r?$)",
+ ))
+ .expect("the closing mark rule")
+ });
+ // Every closing tag and end line, by name, in order.
+ let mut ends: HashMap<String, Vec<(usize, usize)>> = HashMap::new();
+ for close in CLOSE.captures_iter(question) {
+ let whole = close.get(0).expect("a match");
+ let key = match (close.get(1), close.get(2)) {
+ (Some(tag), _) => format!("<{}", tag.as_str()),
+ (_, Some(label)) => format!("-{}", label.as_str().trim().to_lowercase()),
+ _ => continue,
+ };
+ ends.entry(key)
+ .or_default()
+ .push((whole.start(), whole.end()));
+ }
+ let mut labels = Vec::new();
+ let mut content = String::new();
+ let mut outside = String::new();
+ let (mut from, mut copied) = (0usize, 0usize);
+ while let Some(open) = OPEN.captures_at(question, from) {
+ let whole = open.get(0).expect("a match");
+ from = whole.end();
+ let (label, key) = match (open.get(1), open.get(2)) {
+ (Some(tag), _) => {
+ let tag = tag.as_str();
+ if HTML_ELEMENTS.contains(&tag.to_ascii_lowercase().as_str()) {
+ continue;
+ }
+ (tag.to_string(), format!("<{tag}"))
+ }
+ (_, Some(label)) => {
+ let label = label.as_str().trim();
+ (
+ format!("BEGIN {label}"),
+ format!("-{}", label.to_lowercase()),
+ )
+ }
+ _ => continue,
+ };
+ // The first end of this name after the opening.
+ let Some(&(start, end)) = ends
+ .get(&key)
+ .and_then(|spans| spans.get(spans.partition_point(|(start, _)| *start < whole.end())))
+ else {
+ continue;
+ };
+ let text = question[whole.end()..start].trim_matches(['\n', '\r']);
+ if !text.trim().is_empty() {
+ if !content.is_empty() {
+ content.push_str("\n\n");
+ }
+ content.push_str(text);
+ outside.push_str(&question[copied..whole.start()]);
+ outside.push('\n');
+ copied = end;
+ labels.push(label);
+ }
+ from = end;
+ }
+ if labels.is_empty() {
+ return None;
+ }
+ outside.push_str(&question[copied..]);
+ let total = question.chars().count().max(1);
+ (outside.len() <= 2000 || content.chars().count() * 10 >= total * 4).then_some(Marked {
+ labels,
+ content,
+ outside,
+ })
+}
+
+/// The names of code in the prose of `outside` (a question's text outside
+/// its marked parts; fenced blocks there are examples and left out): its
+/// file paths, then its identifiers ([`crate::identifier_arm::named`]),
+/// without placeholders ([`placeholder`]), at most 40.
+fn outside_names(outside: &str) -> Vec<String> {
+ static FENCE: LazyLock<regex::Regex> = LazyLock::new(|| {
+ regex::Regex::new(r"(?s)```.*?(?:```|\z)|~~~.*?(?:~~~|\z)").expect("the fence rule")
+ });
+ let prose = FENCE.replace_all(outside, " ");
+ let named = crate::identifier_arm::named(&prose);
+ named
+ .paths
+ .into_iter()
+ .chain(named.names)
+ .filter(|name| !placeholder(name))
+ .take(40)
+ .collect()
+}
+
+/// A question's marked content ([`marked`]) followed by the names of code
+/// in its prose outside ([`outside_names`]): its labels, the text, and how
+/// many names were added. `None` without marked content.
+fn marked_content(question: &str) -> Option<(Vec<String>, String, usize)> {
+ let marked = marked(question)?;
+ let names = outside_names(&marked.outside);
+ let mut text = marked.content;
+ if !names.is_empty() {
+ text.push_str("\n\n");
+ text.push_str(&names.join(" "));
+ }
+ Some((marked.labels, text, names.len()))
+}
+
+/// `text` with each web address replaced: a code host's link to a file
+/// (`https://github.com/o/r/blob/<ref>/src/x.rs#L10`, GitLab's `/-/blob/`,
+/// `tree`, `raw`, Bitbucket's `src`) by the file's path in its repository
+/// (`src/x.rs`), any other address by nothing; and how many of each.
+fn rewrite_links(text: &str) -> (String, usize, usize) {
+ static URL: LazyLock<regex::Regex> = LazyLock::new(|| {
+ regex::Regex::new(r#"https?://[^\s<>()\[\]{}"'`|]+"#).expect("the address rule")
+ });
+ static FILE: LazyLock<regex::Regex> = LazyLock::new(|| {
+ regex::Regex::new(
+ r"^https?://[^/]+/(?:[^/]+/)+?(?:-/)?(?:blob|tree|raw|src)/[^/]+/([^#?]+)",
+ )
+ .expect("the file link rule")
+ });
+ let (mut files, mut others) = (0, 0);
+ let rewritten = URL.replace_all(text, |found: &regex::Captures| {
+ // Sentence punctuation after an address stays.
+ let link = found[0].trim_end_matches(['.', ',', ';', ':', '!', '?']);
+ let tail = &found[0][link.len()..];
+ match FILE.captures(link) {
+ Some(path) => {
+ files += 1;
+ format!(" {}{tail} ", path[1].trim_end_matches('/'))
+ }
+ None => {
+ others += 1;
+ format!(" {tail}")
+ }
+ }
+ });
+ (rewritten.into_owned(), files, others)
+}
+
+/// The longest question `context` reads, in bytes; a longer one is
+/// shortened ([`shorten`]).
+pub const MAX_QUESTION_BYTES: usize = 16_000;
+
+/// Bytes of identifiers and paths a shortened question keeps from the text
+/// it cuts.
+const SHORTENED_NAMES_BYTES: usize = 3_000;
+
+/// Bytes of a long question's beginning, and of its end, that
+/// [`shorten`] reads: the work stays bounded whatever the question's size.
+pub const SHORTEN_WINDOW: usize = 256 * 1024;
+
+/// `text` when it has at most twice [`SHORTEN_WINDOW`] bytes; else its first
+/// and last [`SHORTEN_WINDOW`] bytes (at character boundaries), one line
+/// apart.
+fn window(text: &str) -> std::borrow::Cow<'_, str> {
+ if text.len() <= 2 * SHORTEN_WINDOW {
+ return std::borrow::Cow::Borrowed(text);
+ }
+ let mut head = SHORTEN_WINDOW;
+ while !text.is_char_boundary(head) {
+ head -= 1;
+ }
+ let mut tail = text.len() - SHORTEN_WINDOW;
+ while !text.is_char_boundary(tail) {
+ tail += 1;
+ }
+ std::borrow::Cow::Owned(format!("{}\n{}", &text[..head], &text[tail..]))
+}
+
+/// A question over [`MAX_QUESTION_BYTES`], shortened to fit, and the
+/// packet's `question_shortened` report; `None` for a question that fits.
+/// The question's marked content ([`marked_content`]) when that fits; else
+/// the content's beginning, cut at a line end, followed by the identifiers
+/// and file paths of the text cut ([`crate::identifier_arm::named`]) that
+/// the beginning does not hold, each once, within 3,000 bytes. Only the
+/// question's first and last 256 KiB are read ([`window`]). A question that
+/// long used to be refused.
+pub fn shorten(question: &str) -> Option<(String, Value)> {
+ if question.len() <= MAX_QUESTION_BYTES {
+ return None;
+ }
+ let read = window(question);
+ let question_bytes = question.len();
+ let question = read.as_ref();
+ let tagged = marked_content(question).map(|(_, content, _)| content);
+ let content = tagged.as_deref().unwrap_or(question);
+ let mut report = json!({"bytes": question_bytes, "tagged_content": tagged.is_some()});
+ if content.len() <= MAX_QUESTION_BYTES {
+ report["kept_bytes"] = json!(content.len());
+ report["names_appended"] = json!(0);
+ return Some((content.to_string(), report));
+ }
+ let boundary = |mut at: usize| {
+ while !content.is_char_boundary(at) {
+ at -= 1;
+ }
+ at
+ };
+ let floor = boundary(MAX_QUESTION_BYTES - SHORTENED_NAMES_BYTES - 2);
+ let named = crate::identifier_arm::named(&content[floor..]);
+ // Names the kept beginning already holds are not repeated.
+ let kept = &content[..floor];
+ let mut names = String::new();
+ let mut appended = 0;
+ for item in named
+ .paths
+ .iter()
+ .chain(&named.names)
+ .filter(|item| !kept.contains(item.as_str()))
+ {
+ if names.len() + item.len() + 1 > SHORTENED_NAMES_BYTES {
+ break;
+ }
+ if !names.is_empty() {
+ names.push(' ');
+ }
+ names.push_str(item);
+ appended += 1;
+ }
+ let mut cut = boundary(MAX_QUESTION_BYTES - names.len() - 2);
+ // At a line end when one is near.
+ if let Some(line) = content[..cut].rfind('\n').filter(|at| cut - at < 2_000) {
+ cut = line;
+ }
+ let shortened = format!("{}\n\n{names}", content[..cut].trim_end());
+ report["kept_bytes"] = json!(shortened.len());
+ report["names_appended"] = json!(appended);
+ Some((shortened, report))
+}
+
+/// What a code question's query reads ([`focus`]).
+#[derive(Clone, Debug)]
+pub struct Focus {
+ /// The text the retrieval's arms read: the question itself when no focus
+ /// applies.
+ pub text: String,
+ pub applied: bool,
+ pub report: Value,
+}
+
+/// The query of `question` under the call's `query_focus` (`"auto"`, left
+/// out: a code question's, [`is_code_question`]; `true`: any question's;
+/// `false`: none). The query is the question's content, not its
+/// instructions: the parts it marks as its content when it has them, every
+/// word kept, with the names of code in its prose outside them
+/// ([`marked_content`]); else the question without [`INSTRUCTION_WORDS`]
+/// (identifiers, paths and other words stay). Either way a code host's file
+/// links become the files' paths, other web addresses go
+/// ([`rewrite_links`]) and so do commit hashes. When nothing of three
+/// letters would remain, the question stays.
+pub fn focus(args: &Value, question: &str) -> Result<Focus> {
+ static HASH: LazyLock<regex::Regex> =
+ LazyLock::new(|| regex::Regex::new(r"\b[0-9a-f]{7,40}\b").expect("the commit hash rule"));
+ static TOKEN: LazyLock<regex::Regex> =
+ LazyLock::new(|| regex::Regex::new(r"[A-Za-z]+").expect("the word rule"));
+ static RUN: LazyLock<regex::Regex> =
+ LazyLock::new(|| regex::Regex::new(r"\S+").expect("the token rule"));
+ let (mode, defaulted) = three_way(args, "query_focus")?;
+ let applied = mode.unwrap_or_else(|| is_code_question(question));
+ let setting = mode.map_or(json!("auto"), |on| json!(on));
+ let mut report = json!({"query_focus": setting, "defaulted": defaulted, "applied": applied});
+ if !applied {
+ return Ok(Focus {
+ text: question.to_string(),
+ applied,
+ report,
+ });
+ }
+ let marked = marked_content(question);
+ let content = marked
+ .as_ref()
+ .map_or(question, |(_, content, _)| content.as_str());
+ let (linked, files, others) = rewrite_links(content);
+ let mut hashes = 0;
+ let unhashed = HASH.replace_all(&linked, |hash: &regex::Captures| {
+ let hash = &hash[0];
+ if hash.bytes().any(|b| b.is_ascii_digit()) && hash.bytes().any(|b| b.is_ascii_alphabetic())
+ {
+ hashes += 1;
+ String::new()
+ } else {
+ hash.to_string()
+ }
+ });
+ // Plain words between spaces and sentence punctuation only: `find()`,
+ // `` `fix` ``, `find_config`, `List::new` and `docs/find.md` stay.
+ let mut dropped = 0;
+ let text = RUN.replace_all(&unhashed, |run: &regex::Captures| {
+ let token = &run[0];
+ let start = token
+ .find(|c: char| !matches!(c, '"' | '\'' | '(' | '['))
+ .unwrap_or(token.len());
+ let end = token
+ .char_indices()
+ .rev()
+ .find(|(_, c)| {
+ !matches!(
+ c,
+ '"' | '\'' | ')' | ']' | ',' | '.' | ';' | ':' | '!' | '?'
+ )
+ })
+ .map_or(start, |(i, c)| i + c.len_utf8())
+ .max(start);
+ let core = &token[start..end];
+ if marked.is_none()
+ && !core.is_empty()
+ && core.chars().all(|c| c.is_ascii_alphabetic())
+ && instruction_word(core)
+ {
+ dropped += 1;
+ format!("{}{}", &token[..start], &token[end..])
+ } else {
+ token.to_string()
+ }
+ });
+ let text = text.into_owned();
+ let kept = TOKEN.find_iter(&text).any(|w| w.as_str().len() >= 3);
+ report["marked"] = json!(
+ marked
+ .as_ref()
+ .map_or(Vec::new(), |(labels, _, _)| labels.clone())
+ );
+ report["names_from_outside"] = json!(marked.as_ref().map_or(0, |(_, _, names)| *names));
+ report["links_to_paths"] = json!(files);
+ report["links_left_out"] = json!(others);
+ report["hashes_left_out"] = json!(hashes);
+ report["instruction_words_left_out"] = json!(dropped);
+ if !kept {
+ report["applied"] = json!(false);
+ report["reason"] = json!("nothing_left");
+ return Ok(Focus {
+ text: question.to_string(),
+ applied: false,
+ report,
+ });
+ }
+ report["characters"] = json!(text.chars().count());
+ report["question_characters"] = json!(question.chars().count());
+ Ok(Focus {
+ text,
+ applied: true,
+ report,
+ })
+}
+
+/// The `code_first` option: `"auto"` (left out), `true` or `false`.
+#[derive(Clone, Copy, Debug, PartialEq, Eq)]
+pub enum CodeFirst {
+ /// A code question that does not ask about documents, or reads like a
+ /// report, ranks source files first.
+ Auto,
+ /// Every question ranks source files first.
+ On,
+ /// No question does (0.1.2's order).
+ Off,
+}
+
+/// `code_first` when a call leaves it out.
+pub const CODE_FIRST_DEFAULT: CodeFirst = CodeFirst::Auto;
+
+/// The key beside `context`'s rankings (never fused) that lists the files
+/// defining a code name the question names when no source file defines it
+/// ([`crate::identifier_arm`]): the code-first prior leaves them their
+/// weight, so a test helper or a fixture the question asks about is not
+/// lowered.
+pub const DEFINING: &str = "code_first_defining";
+
+/// What a documentation, test or vendored file's passages count in the
+/// fusion of a code question, against 1 for a source file's: a test or a
+/// document must rank about four times higher in the arms to come first.
+pub const CODE_FIRST_WEIGHT: f64 = 0.25;
+
+impl CodeFirst {
+ /// The call's `code_first`, and whether the call left it out.
+ pub fn parse(args: &Value) -> Result<(Self, bool)> {
+ match args.get("code_first") {
+ None | Some(Value::Null) => Ok((CODE_FIRST_DEFAULT, true)),
+ Some(Value::Bool(true)) => Ok((Self::On, false)),
+ Some(Value::Bool(false)) => Ok((Self::Off, false)),
+ Some(Value::String(mode)) if mode == "auto" => Ok((Self::Auto, false)),
+ Some(_) => Err(Error::bad("code_first must be true, false or auto")),
+ }
+ }
+ fn value(self) -> Value {
+ match self {
+ Self::Auto => json!("auto"),
+ Self::On => json!(true),
+ Self::Off => json!(false),
+ }
+ }
+}
+
+/// How one call ranks a code question ([`decide`]).
+#[derive(Clone, Debug)]
+pub struct Decision {
+ /// Documentation and vendored files count [`CODE_FIRST_WEIGHT`].
+ pub applied: bool,
+ /// Test files do too.
+ pub tests: bool,
+ report: Value,
+}
+
+/// The code-first decision for `question` under the call's `code_first`
+/// and `include_tests` (`true` keeps test files' weight). `content` is the
+/// question's query when [`focus`] applied (else the question): whether
+/// it reads like a report, asks about documents or names a test is read
+/// there, so instructions around the content ("leave out tests and
+/// documentation") do not count.
+pub fn decide(args: &Value, question: &str, content: &str) -> Result<Decision> {
+ let (mode, defaulted) = CodeFirst::parse(args)?;
+ let names_code =
+ crate::notes_first::names_code(question) || crate::notes_first::names_code(content);
+ let report = reads_like_report(content);
+ let documents = asks_about_documents(content);
+ let tests_named = names_tests(content);
+ let code = names_code || report;
+ let applied = match mode {
+ CodeFirst::On => true,
+ CodeFirst::Off => false,
+ CodeFirst::Auto => code && (report || !documents),
+ };
+ let keep_tests = args["include_tests"] == true || (tests_named && !report);
+ let tests = applied && !keep_tests;
+ let reason = match mode {
+ CodeFirst::On => "requested",
+ CodeFirst::Off => "off",
+ CodeFirst::Auto if !code => "not_code",
+ CodeFirst::Auto if !applied => "asks_about_documents",
+ CodeFirst::Auto if report => "report",
+ CodeFirst::Auto => "names_code",
+ };
+ Ok(Decision {
+ applied,
+ tests,
+ report: json!({"code_first":mode.value(),"defaulted":defaulted,"applied":applied,
+ "reason":reason,"weight":CODE_FIRST_WEIGHT,"tests":tests,
+ "question":{"names_code":names_code,"report":report,
+ "asks_about_documents":documents,"names_tests":tests_named}}),
+ })
+}
+
+impl Decision {
+ /// The weight of each passage origin of `rows` that the decision lowers
+ /// (`rank`'s `origin_prior`), and the packet's report with what it
+ /// lowered by class. Only project files (`file:` origins) are weighed,
+ /// and those in `defining` (files that define a code name the question
+ /// names that no source file defines) keep their weight.
+ pub fn priors(&self, rows: &[Value], defining: &[String]) -> (Map<String, Value>, Value) {
+ let mut priors = Map::new();
+ let mut lowered: std::collections::BTreeMap<&str, usize> = Default::default();
+ let defining: HashSet<&str> = defining.iter().map(String::as_str).collect();
+ let mut kept = 0usize;
+ if self.applied {
+ for row in rows {
+ let Some(origin) = row["origin"].as_str() else {
+ continue;
+ };
+ let Some(path) = origin.strip_prefix("file:") else {
+ continue;
+ };
+ if priors.contains_key(origin) {
+ continue;
+ }
+ let class = path_class(path);
+ let lower = match class {
+ PathClass::Source => false,
+ PathClass::Test => self.tests,
+ PathClass::Doc | PathClass::Vendored => true,
+ };
+ if lower && defining.contains(origin) {
+ // It defines what the question names: its weight stays.
+ priors.insert(origin.to_string(), json!(1.0));
+ kept += 1;
+ } else if lower {
+ priors.insert(origin.to_string(), json!(CODE_FIRST_WEIGHT));
+ *lowered.entry(class.name()).or_default() += 1;
+ }
+ }
+ }
+ let mut report = self.report.clone();
+ if self.applied {
+ report["files_lowered"] = json!(lowered);
+ report["files_kept_as_defining"] = json!(kept);
+ }
+ (priors, report)
+ }
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ #[test]
+ fn paths_are_classed_as_source_test_doc_or_vendored() {
+ for (path, class) in [
+ ("src/parser.rs", PathClass::Source),
+ ("core/lib/globals_api.h", PathClass::Source),
+ ("lib/history.py", PathClass::Source),
+ ("CMakeLists.txt", PathClass::Source),
+ ("src/main/java/org/x/Parser.java", PathClass::Source),
+ ("contest/latest.go", PathClass::Source),
+ ("examples/demo.rs", PathClass::Source),
+ ("tests/parse.rs", PathClass::Test),
+ ("src/parser/tests.rs", PathClass::Test),
+ ("crates/x/src/lexer_test.rs", PathClass::Test),
+ ("pkg/http/header_test.go", PathClass::Test),
+ ("app/test_views.py", PathClass::Test),
+ ("app/conftest.py", PathClass::Test),
+ ("src/test/java/org/x/ParserTest.java", PathClass::Test),
+ ("core/src/main/java/org/x/ParserIT.java", PathClass::Test),
+ ("Foo.Tests/ParserTests.cs", PathClass::Test),
+ ("src/FooTests/Bar.cs", PathClass::Test),
+ ("lib/parser.spec.ts", PathClass::Test),
+ ("src/__tests__/parse.js", PathClass::Test),
+ ("tests/unit/test_parse.c", PathClass::Test),
+ ("base/strings_unittest.cc", PathClass::Test),
+ ("spec/models/user_spec.rb", PathClass::Test),
+ ("testdata/input.json", PathClass::Test),
+ ("README.md", PathClass::Doc),
+ ("docs/guide/setup.rst", PathClass::Doc),
+ ("CHANGELOG", PathClass::Doc),
+ ("LICENSE-APACHE", PathClass::Doc),
+ ("notes/decisions.txt", PathClass::Doc),
+ ("docs/examples/demo.py", PathClass::Doc),
+ ("vendor/lib/x.c", PathClass::Vendored),
+ ("third_party/zlib/inflate.c", PathClass::Vendored),
+ ("web/app.min.js", PathClass::Vendored),
+ ("api/v1/service.pb.go", PathClass::Vendored),
+ ("Cargo.lock", PathClass::Vendored),
+ ("node_modules/x/test/a.js", PathClass::Vendored),
+ ] {
+ assert_eq!(path_class(path), class, "{path}");
+ }
+ }
+
+ #[test]
+ fn reports_and_questions_about_documents_are_told_apart() {
+ assert!(reads_like_report(
+ "Parsing fails.\n```\nthread 'main' panicked at src/x.rs:3\n```"
+ ));
+ assert!(reads_like_report(
+ "Traceback (most recent call last):\n File \"a.py\", line 3, in f"
+ ));
+ assert!(reads_like_report(
+ "The export crashes and the log shows an error."
+ ));
+ assert!(!reads_like_report("How does the parser handle errors?"));
+ assert!(!reads_like_report("What did we decide about caching?"));
+ assert!(asks_about_documents("Where is `parse_config` documented?"));
+ assert!(asks_about_documents("Fix the example in docs/usage.md"));
+ assert!(asks_about_documents(
+ "What did we decide about `Store::open`?"
+ ));
+ assert!(!asks_about_documents(
+ "How does `parse_config` handle a missing file?"
+ ));
+ assert!(names_tests("Why does `ParserTest` fail?"));
+ assert!(names_tests("header_test.go fails on Windows"));
+ assert!(names_tests("see tests/test_parser.py"));
+ assert!(!names_tests("which tests cover parse_header"));
+ }
+
+ #[test]
+ fn a_code_question_reads_its_content_not_its_instructions() {
+ let prompt = "Here is a report from a user about `load_settings`.\n\n<report>\n\
+ `parse_config` crashes on \
+ https://github.com/o/r/blob/0123abc4567def/src/config/parse.rs#L10 (see \
+ https://example.com/issue/7, commit 0123abc4567def).\n\
+ Please find the function and delete the first list.\n</report>\n\n\
+ Find where the code must change. Answer as ClassName.method_name in \
+ path/to/file.py.\n```json\n{\"files\": [\"src/your_module.py\"]}\n```\n";
+ let focus = focus(&json!({}), prompt).unwrap();
+ assert!(focus.applied);
+ let words: Vec<&str> = focus.text.split_whitespace().collect();
+ // The marked text keeps every word; the prose outside gives its
+ // names of code, not its placeholders or its example's.
+ assert_eq!(
+ words,
+ [
+ "`parse_config`",
+ "crashes",
+ "on",
+ "src/config/parse.rs",
+ "(see",
+ ",",
+ "commit",
+ ").",
+ "Please",
+ "find",
+ "the",
+ "function",
+ "and",
+ "delete",
+ "the",
+ "first",
+ "list.",
+ "load_settings"
+ ],
+ "{}",
+ focus.text
+ );
+ assert_eq!(focus.report["marked"], json!(["report"]));
+ assert_eq!(focus.report["names_from_outside"], 1);
+ assert_eq!(focus.report["links_to_paths"], 1);
+ assert_eq!(focus.report["links_left_out"], 1);
+ assert_eq!(focus.report["hashes_left_out"], 1);
+ assert_eq!(focus.report["instruction_words_left_out"], 0);
+ // An opening tag with text after it, a closing tag inside a line,
+ // and delimiter lines mark content too.
+ assert_eq!(
+ focus_text("<issue>`render()` fails\nwhen empty</issue>\nList the files."),
+ "`render()` fails\nwhen empty"
+ );
+ assert_eq!(
+ focus_text("Fix this.\n--- BEGIN ISSUE ---\n`x_y` breaks\n--- END ISSUE ---\nThanks"),
+ "`x_y` breaks"
+ );
+ assert_eq!(
+ focus_text("=== begin bug report ===\n`x_y` breaks\n=== END BUG REPORT ==="),
+ "`x_y` breaks"
+ );
+ // Without marks, instruction words go; identifiers, calls, quoted
+ // words and paths stay.
+ let kept = focus_text("Fix `fix`, find() and find_config in List::new and docs/find.md");
+ assert_eq!(
+ kept.trim(),
+ "`fix`, find() and find_config in List::new and docs/find.md"
+ );
+ // HTML blocks are quoted text, not the question's parts.
+ let html = "`render()` fails here:\n<div>\nsome text\n</div>\nwhy?";
+ assert_eq!(focus_text(html), html);
+ // A question in plain words, and `query_focus: false`, keep the
+ // question.
+ let plain = "Please list the decisions about caching";
+ assert_eq!(super::focus(&json!({}), plain).unwrap().text, plain);
+ assert!(!super::focus(&json!({}), plain).unwrap().applied);
+ let off = super::focus(&json!({"query_focus": false}), prompt).unwrap();
+ assert_eq!(off.text, prompt);
+ assert!(super::focus(&json!({"query_focus": 1}), prompt).is_err());
+ // Nothing of three letters left: the question stays.
+ assert_eq!(focus_text("Fix `x`"), "Fix `x`");
+ assert!(placeholder("ClassName.method_name") && placeholder("path/to/your/file.py"));
+ assert!(!placeholder("load_settings") && !placeholder("ClassLoader"));
+ }
+
+ #[test]
+ fn a_question_over_the_bound_is_shortened_keeping_its_content_and_names() {
+ assert!(shorten("short").is_none());
+ // Tagged content that fits: the instructions go.
+ let issue = "`parse_config` fails.\n".repeat(700);
+ let prompt = format!(
+ "{}\n<issue>\n{issue}</issue>\nList the files.",
+ "Read this. ".repeat(100)
+ );
+ assert!(prompt.len() > MAX_QUESTION_BYTES);
+ let (short, report) = shorten(&prompt).unwrap();
+ assert_eq!(short, issue.trim_end_matches('\n'));
+ assert_eq!(report["tagged_content"], true);
+ // Too long even so: the beginning, then the names of the cut text.
+ let long = format!(
+ "{}\nThe tail names `late_name` and src/late/file.rs.\n",
+ "word ".repeat(4000)
+ );
+ let (short, report) = shorten(&long).unwrap();
+ assert!(short.len() <= MAX_QUESTION_BYTES, "{}", short.len());
+ assert!(short.starts_with("word word"));
+ assert!(
+ short.ends_with("src/late/file.rs late_name"),
+ "{}",
+ &short[short.len() - 80..]
+ );
+ assert_eq!(report["names_appended"], 2);
+ assert_eq!(report["bytes"], long.len());
+ }
+
+ /// A prompt of several MiB full of tags that never close (a log of
+ /// `<Foo object at 0x...>` lines) is shortened, focused and handed to the
+ /// prompt hook in bounded time.
+ #[test]
+ fn a_huge_prompt_of_unclosed_tags_is_read_in_bounded_time() {
+ let mut prompt = String::from("`parse_config` fails with this log:\n");
+ for i in 0..120_000 {
+ prompt.push_str(&format!("<Foo{} object at 0x7f{i:08x}>\n", i % 997));
+ }
+ prompt.push_str("and `late_name` at the end.\n");
+ assert!(prompt.len() > 3 * 1024 * 1024);
+ let started = std::time::Instant::now();
+ let (short, report) = shorten(&prompt).unwrap();
+ assert!(short.len() <= MAX_QUESTION_BYTES);
+ assert!(short.starts_with("`parse_config` fails"));
+ assert!(
+ short.contains("late_name"),
+ "{}",
+ &short[short.len() - 200..]
+ );
+ assert_eq!(report["bytes"], prompt.len());
+ let focused = focus(&json!({}), &short).unwrap();
+ assert!(focused.applied);
+ let asked = crate::prompt_hook::question(&json!({"prompt": prompt})).unwrap();
+ assert!(asked.len() <= MAX_QUESTION_BYTES);
+ let took = started.elapsed();
+ assert!(took < std::time::Duration::from_secs(10), "{took:?}");
+ // Names the kept beginning holds are not appended again.
+ let repeated = format!(
+ "`parse_config` and `load_it` fail.\n{}\n`parse_config` and `late_one`.",
+ "word ".repeat(4000)
+ );
+ let (short, _) = shorten(&repeated).unwrap();
+ assert!(
+ short.ends_with("late_one"),
+ "{}",
+ &short[short.len() - 80..]
+ );
+ assert_eq!(short.matches("parse_config").count(), 1);
+ }
+
+ fn focus_text(question: &str) -> String {
+ focus(&json!({}), question).unwrap().text
+ }
+
+ #[test]
+ fn a_code_question_lowers_documents_and_tests_unless_it_asks_for_them() {
+ let decide = |args: Value, question: &str| decide(&args, question, question).unwrap();
+ let rows = vec![
+ json!({"origin":"file:src/a.rs"}),
+ json!({"origin":"file:README.md"}),
+ json!({"origin":"file:tests/a.rs"}),
+ json!({"origin":"memory:m1"}),
+ ];
+ let lowered = |decision: &Decision| {
+ let (priors, _) = decision.priors(&rows, &[]);
+ priors.keys().cloned().collect::<Vec<_>>()
+ };
+ let code = decide(json!({}), "How does `parse_config` handle a missing file?");
+ assert!(code.applied && code.tests);
+ assert_eq!(lowered(&code), ["file:README.md", "file:tests/a.rs"]);
+ // A test or a document that defines a code name the question names,
+ // which no source file defines, keeps its weight.
+ let (priors, report) = code.priors(&rows, &["file:tests/a.rs".to_string()]);
+ assert_eq!(priors["file:tests/a.rs"], json!(1.0));
+ assert_eq!(priors["file:README.md"], json!(CODE_FIRST_WEIGHT));
+ assert_eq!(report["files_kept_as_defining"], 1);
+ // Plain words and questions about documents keep their order.
+ assert!(!decide(json!({}), "How do we deploy?").applied);
+ assert!(!decide(json!({}), "Where is `parse_config` documented?").applied);
+ // A report is a code question whatever words it uses.
+ let report = decide(
+ json!({}),
+ "`parse_config` crashes; the docs say it returns None.\n```\npanicked at x\n```",
+ );
+ assert!(report.applied && report.tests);
+ // A named test keeps the tests' weight; so does include_tests: true.
+ let named = decide(json!({}), "Why does `ParserTest` fail for parse_config?");
+ assert!(named.applied && !named.tests);
+ assert_eq!(lowered(&named), ["file:README.md"]);
+ let kept = decide(json!({"include_tests": true}), "How does `parse` work?");
+ assert!(kept.applied && !kept.tests);
+ // The switch.
+ assert!(decide(json!({"code_first": true}), "How do we deploy?").applied);
+ assert!(!decide(json!({"code_first": false}), "How does `parse` work?").applied);
+ assert!(super::decide(&json!({"code_first": "yes"}), "x", "x").is_err());
+ }
+}
diff --git a/crates/graphicle/src/connectors.rs b/crates/graphicle/src/connectors.rs
index e481055..fb4c202 100644
--- a/crates/graphicle/src/connectors.rs
+++ b/crates/graphicle/src/connectors.rs
@@ -24,6 +24,64 @@ pub fn provider_permission_sync() -> bool {
crate::core_capabilities::capabilities()["provider_permission_sync"] == true
}
+/// The connector kinds of the core. An installed extension may add others
+/// (`extension::Source`).
+pub const CORE_KINDS: &[&str] = &[
+ "github",
+ "slack",
+ "notion",
+ "gdrive",
+ "jira",
+ "confluence",
+ "jsonl",
+];
+
+/// The core kinds whose provider ACL an extension can sync without naming
+/// them: GitHub, Slack and Drive.
+const PROVIDER_ACL_KINDS: &[&str] = &["github", "slack", "gdrive"];
+
+/// The connector kinds whose provider permissions an installed extension
+/// syncs: its `provider_permission_kinds` capability, or GitHub, Slack and
+/// Drive for one that only sets `provider_permission_sync`. Empty in Core.
+pub fn provider_permission_kinds() -> Vec<String> {
+ let capabilities = crate::core_capabilities::capabilities();
+ if capabilities["provider_permission_sync"] != true {
+ return Vec::new();
+ }
+ match capabilities["provider_permission_kinds"].as_array() {
+ Some(kinds) => kinds
+ .iter()
+ .filter_map(|kind| kind.as_str().map(str::to_string))
+ .collect(),
+ None => PROVIDER_ACL_KINDS
+ .iter()
+ .map(|kind| kind.to_string())
+ .collect(),
+ }
+}
+
+/// The provider of a connector kind's connected accounts and verified
+/// identities: Atlassian for Jira and Confluence, the declared OAuth
+/// provider for a kind an extension adds, else the kind itself.
+pub fn identity_provider(kind: &str) -> &str {
+ match kind {
+ "jira" | "confluence" => "atlassian",
+ _ => crate::extension::installed()
+ .source(kind)
+ .map_or(kind, |source| source.oauth_provider()),
+ }
+}
+
+/// The kinds whose identity provider is not the kind itself, as a JSON object
+/// of kind to provider (for joins in SQL).
+pub fn identity_providers() -> Value {
+ let mut providers = json!({"jira":"atlassian","confluence":"atlassian"});
+ for source in crate::extension::installed().sources() {
+ providers[source.kind()] = json!(source.oauth_provider());
+ }
+ providers
+}
+
fn validate_acl(db: &Connection, workspace: &str, acl: &Value) -> Result<()> {
if !acl.is_object()
|| !acl["workspace_readers"].is_boolean()
@@ -91,7 +149,10 @@ fn validate_config(kind: &str, config: &Value) -> Result<()> {
"max_age_seconds",
],
"jsonl" => vec!["acl", "max_age_seconds"],
- _ => return Err(Error::bad("Unsupported source connector")),
+ _ => match crate::extension::installed().source(kind) {
+ Some(source) => [&["acl", "max_age_seconds"], source.fields()].concat(),
+ None => return Err(Error::bad("Unsupported source connector")),
+ },
};
allowed.push("observe");
if let Some(policy) = config.get("observe") {
@@ -109,12 +170,14 @@ fn validate_config(kind: &str, config: &Value) -> Result<()> {
if !["explicit", "provider"].contains(&permission_mode) {
return Err(Error::bad("Choose explicit or provider permission mode"));
}
- if permission_mode == "provider" && !["github", "slack", "gdrive"].contains(&kind) {
+ let synced = provider_permission_kinds();
+ let synced = synced.iter().any(|synced| synced == kind);
+ if permission_mode == "provider" && !PROVIDER_ACL_KINDS.contains(&kind) && !synced {
return Err(Error::bad(
"This provider does not expose the required source ACL API; use explicit sharing",
));
}
- if permission_mode == "provider" && !provider_permission_sync() {
+ if permission_mode == "provider" && !synced {
return Err(Error::bad(
"Provider permission mode is not part of Graphicle Core; use explicit sharing",
));
@@ -142,6 +205,9 @@ fn validate_config(kind: &str, config: &Value) -> Result<()> {
model::checked_url(site)?;
}
}
+ if let Some(source) = crate::extension::installed().source(kind) {
+ source.validate(config)?;
+ }
if kind == "github" {
let name = string(config, "repository", 200)?;
if name.split('/').count() != 2
@@ -255,7 +321,7 @@ impl Store {
if kind!="jsonl" && credential.is_none(){return Err(Error::bad("Connect an account or choose a saved source credential"));}
if credential.is_some_and(|v|v.is_empty() || v.len()>100 || !v.bytes().all(|b|b.is_ascii_alphanumeric() || b"_:-".contains(&b))) {return Err(Error::bad("Invalid credential reference"));}
if let Some(reference)=credential.filter(|v|v.starts_with("secret:"))&& one(db,"SELECT id FROM am_secrets WHERE workspace_id=? AND id=?",params![workspace,&reference[7..]])?.is_none(){return Err(Error::denied());}
- if let Some(reference)=credential.filter(|v|v.starts_with("oauth:")) {let provider=if ["jira","confluence"].contains(&kind){"atlassian"}else{kind};if one(db,"SELECT id FROM am_oauth_accounts WHERE workspace_id=? AND id=? AND provider=? AND state='active'",params![workspace,&reference[6..],provider])?.is_none(){return Err(Error::denied());}}
+ if let Some(reference)=credential.filter(|v|v.starts_with("oauth:")) {let provider=identity_provider(kind);if one(db,"SELECT id FROM am_oauth_accounts WHERE workspace_id=? AND id=? AND provider=? AND state='active'",params![workspace,&reference[6..],provider])?.is_none(){return Err(Error::denied());}}
let identifier=id();db.execute("INSERT INTO am_connectors(id,repository_id,name,kind,config,credential_env,state,created_at) VALUES(?,?,?,?,?,?,'active',?)",params![identifier,s(&repository,"id"),name,kind,config.to_string(),credential,now()])?;
Ok(json!({"id":identifier,"name":name,"kind":kind,"state":"active","sharing":"explicit_workspace_policy","provider_permissions_synced":false}))
})
@@ -603,7 +669,10 @@ pub struct Remote<'a> {
pub permissions: BTreeMap<String, Value>,
}
impl Remote<'_> {
- pub(crate) async fn request(
+ /// One provider request within the job's budget, with the connector's
+ /// credential; a JSON reply. 401 and 403 withhold the connector's
+ /// documents until its next complete sync; rate limits are reported.
+ pub async fn request(
&mut self,
method: reqwest::Method,
path: &str,
@@ -862,20 +931,24 @@ pub async fn probe(worker: &Worker, job: &Job) -> Result<Value> {
decode(&mut connector, "config")?;
let kind = s(&connector, "kind");
let cfg = &connector["config"];
+ let source = crate::extension::installed().source(kind);
let default = match kind {
- "github" => "https://api.github.com",
- "slack" => "https://slack.com/api",
- "notion" => "https://api.notion.com/v1",
- "gdrive" => "https://www.googleapis.com/drive/v3",
- "jira" | "confluence" => string(cfg, "base_url", 2000)?,
- _ => return Err(Error::bad("This source does not use a remote account")),
+ "github" => "https://api.github.com".to_string(),
+ "slack" => "https://slack.com/api".to_string(),
+ "notion" => "https://api.notion.com/v1".to_string(),
+ "gdrive" => "https://www.googleapis.com/drive/v3".to_string(),
+ "jira" | "confluence" => string(cfg, "base_url", 2000)?.to_string(),
+ _ => match source {
+ Some(source) => source.base_url(cfg)?,
+ None => return Err(Error::bad("This source does not use a remote account")),
+ },
};
let endpoint = worker
.config
.connector_endpoints
.get(kind)
.cloned()
- .unwrap_or_else(|| default.into());
+ .unwrap_or(default);
let url = model::checked_url(&endpoint)?;
let loopback = url
.host_str()
@@ -996,7 +1069,10 @@ pub async fn probe(worker: &Worker, job: &Job) -> Result<Value> {
json!({"id":target["id"],"name":target["name"]}),
)
}
- _ => unreachable!(),
+ _ => match source {
+ Some(source) => source.probe(&mut remote).await?,
+ None => unreachable!(),
+ },
};
jobs::guarded(&worker.store, job, |db, _, _| {
ensure_connector(db, &connector)
@@ -1028,19 +1104,22 @@ pub async fn sync(worker: &Worker, job: &Job) -> Result<Value> {
return Err(Error::bad(PROVIDER_SYNC_UNAVAILABLE));
}
let default = match kind {
- "github" => "https://api.github.com",
- "slack" => "https://slack.com/api",
- "notion" => "https://api.notion.com/v1",
- "gdrive" => "https://www.googleapis.com/drive/v3",
- "jira" | "confluence" => string(&connector["config"], "base_url", 2000)?,
- _ => return Err(Error::bad("Unknown source connector")),
+ "github" => "https://api.github.com".to_string(),
+ "slack" => "https://slack.com/api".to_string(),
+ "notion" => "https://api.notion.com/v1".to_string(),
+ "gdrive" => "https://www.googleapis.com/drive/v3".to_string(),
+ "jira" | "confluence" => string(&connector["config"], "base_url", 2000)?.to_string(),
+ _ => match crate::extension::installed().source(kind) {
+ Some(source) => source.base_url(&connector["config"])?,
+ None => return Err(Error::bad("Unknown source connector")),
+ },
};
let base = worker
.config
.connector_endpoints
.get(kind)
.cloned()
- .unwrap_or(default.into());
+ .unwrap_or(default);
model::checked_url(&base)?;
let mut remote = Remote {
worker,
@@ -1379,7 +1458,10 @@ async fn listing(remote: &mut Remote<'_>, cursor: &Value) -> Result<(Vec<Value>,
};
Ok((files, next))
}
- _ => Err(Error::bad("Unsupported connector listing")),
+ kind => match crate::extension::installed().source(kind) {
+ Some(source) => source.listing(remote, cursor).await,
+ None => Err(Error::bad("Unsupported connector listing")),
+ },
}
}
fn indexable(path: &str) -> bool {
@@ -1432,7 +1514,10 @@ async fn fetch_document(remote: &mut Remote<'_>, item: &Value) -> Result<Option<
"notion" => notion_document(remote, item).await,
"gdrive" => drive_document(remote, item).await,
"jira" | "confluence" => crate::atlassian::document(remote, item).await,
- _ => Err(Error::bad("Unsupported connector document")),
+ kind => match crate::extension::installed().source(kind) {
+ Some(source) => source.document(remote, item).await,
+ None => Err(Error::bad("Unsupported connector document")),
+ },
}
}
async fn github_document(remote: &mut Remote<'_>, item: &Value) -> Result<Option<Value>> {
@@ -1709,6 +1794,43 @@ async fn notion_document(remote: &mut Remote<'_>, item: &Value) -> Result<Option
}
Ok(Some(document))
}
+/// Keep the original bytes of a connector document parsed by
+/// `documents::extract` (`parsing`), for **Download original**, within the
+/// repository's retained-originals limit (`retained_original_bytes`).
+pub fn keep_original(
+ remote: &Remote<'_>,
+ document: &str,
+ name: &str,
+ parsing: &Value,
+ bytes: &[u8],
+) -> Result<()> {
+ jobs::guarded(&remote.worker.store, remote.job, |db, _, _| {
+ let used:i64=db.query_row("SELECT coalesce(sum(length(bytes)),0) FROM am_original_documents WHERE repository_id=?",[&remote.job.repository],|r|r.get(0))?;
+ let cap = crate::limits::current().retained_original_bytes;
+ if usize::try_from(used + bytes.len() as i64).unwrap_or(usize::MAX) > cap {
+ return Err(Error::bad(format!(
+ "Original document storage exceeds {}; prune retained versions, or raise the limit with {}",
+ crate::limits::size(cap),
+ crate::limits::raise("retained_original_bytes")
+ )));
+ }
+ db.execute(
+ "INSERT OR IGNORE INTO am_original_documents VALUES(?,?,?,?,?,?,?,?,?)",
+ params![
+ remote.job.repository,
+ s(remote.connector, "id"),
+ format!("connector:{}:{document}", s(remote.connector, "id")),
+ s(parsing, "original_sha256"),
+ name,
+ s(parsing, "parser"),
+ s(parsing, "text_sha256"),
+ bytes,
+ now()
+ ],
+ )?;
+ Ok(())
+ })
+}
async fn drive_document(remote: &mut Remote<'_>, item: &Value) -> Result<Option<Value>> {
let file_id = string(item, "id", 200)?;
let metadata = remote
@@ -1750,32 +1872,7 @@ async fn drive_document(remote: &mut Remote<'_>, item: &Value) -> Result<Option<
_=>return Err(Error::bad(format!("Drive format {mime} is not supported by an installed document parser")))
};
parsing = crate::documents::extract(&name, &bytes)?;
- jobs::guarded(&remote.worker.store, remote.job, |db, _, _| {
- let used:i64=db.query_row("SELECT coalesce(sum(length(bytes)),0) FROM am_original_documents WHERE repository_id=?",[&remote.job.repository],|r|r.get(0))?;
- let cap = crate::limits::current().retained_original_bytes;
- if usize::try_from(used + bytes.len() as i64).unwrap_or(usize::MAX) > cap {
- return Err(Error::bad(format!(
- "Original document storage exceeds {}; prune retained versions, or raise the limit with {}",
- crate::limits::size(cap),
- crate::limits::raise("retained_original_bytes")
- )));
- }
- db.execute(
- "INSERT OR IGNORE INTO am_original_documents VALUES(?,?,?,?,?,?,?,?,?)",
- params![
- remote.job.repository,
- s(remote.connector, "id"),
- format!("connector:{}:{file_id}", s(remote.connector, "id")),
- s(&parsing, "original_sha256"),
- name,
- s(&parsing, "parser"),
- s(&parsing, "text_sha256"),
- bytes,
- now()
- ],
- )?;
- Ok(())
- })?;
+ keep_original(remote, file_id, &name, &parsing, &bytes)?;
s(&parsing, "text").to_string()
};
Ok(Some(
diff --git a/crates/graphicle/src/deletion.rs b/crates/graphicle/src/deletion.rs
index 9b2310d..95dadf4 100644
--- a/crates/graphicle/src/deletion.rs
+++ b/crates/graphicle/src/deletion.rs
@@ -80,6 +80,8 @@ const HISTORY: &[&str] = &[
"am_projection_cleanup",
TOMBSTONES,
"am_oauth_pending",
+ // What Graphicle served (`metering`): counters per day and credential.
+ "am_served_usage",
];
/// Columns holding digests of capabilities minted per store (the owner's and
/// granted credentials'). Like minted identifiers, they never take part in
@@ -140,6 +142,9 @@ const SINCE_VISIBLE: &[(&str, &str, &str)] = &[
("anchors", "gf_anchor_edges", "created_at"),
("overlay_communities", "gf_communities", "created_at"),
("overlay_aliases", "gf_alias_proposals", "created_at"),
+ // The export index the incremental link pass keeps; the next pass
+ // rebuilds it from the graph.
+ ("cross_link_state", "gf_cross_link_state", "created_at"),
];
/// What one forget request covers: every document of a connector, or named
diff --git a/crates/graphicle/src/disconnect.rs b/crates/graphicle/src/disconnect.rs
index 476f314..f6cf6fa 100644
--- a/crates/graphicle/src/disconnect.rs
+++ b/crates/graphicle/src/disconnect.rs
@@ -450,17 +450,34 @@ fn undo_file(path: &Path, targets: &[Target], all: bool, data: &Path) -> Result<
// (setup, `connect --graph`).
let capture = agent_setup::holds_capture_hooks(&document, client, data);
let guard = agent_setup::holds_guard_hooks(&document, client, data);
+ let prompt = agent_setup::holds_prompt_hooks(&document, client, data);
let gone = agent_setup::remove_hooks(&mut document, client, data);
if gone {
text = None;
}
gone.then(|| {
- match (capture, guard) {
- (true, true) => "removed the capture and graph guard hooks",
- (false, true) => "removed the graph guard hooks",
- _ => "removed the capture hooks",
+ let mut kinds = Vec::new();
+ if capture || !(guard || prompt) {
+ kinds.push("capture");
}
- .to_string()
+ if guard {
+ kinds.push("graph guard");
+ }
+ if prompt {
+ kinds.push("prompt-context");
+ }
+ let last = kinds.pop().unwrap_or("capture");
+ let named = if kinds.is_empty() {
+ last.to_string()
+ } else {
+ format!("{} and {last}", kinds.join(", "))
+ };
+ let noun = if named == "prompt-context" {
+ "hook"
+ } else {
+ "hooks"
+ };
+ format!("removed the {named} {noun}")
})
}
"removed-mcp" => match change.replaced.as_ref().map(|r| r["value"].clone()) {
diff --git a/crates/graphicle/src/doc_links.rs b/crates/graphicle/src/doc_links.rs
index 582885a..da538a9 100644
--- a/crates/graphicle/src/doc_links.rs
+++ b/crates/graphicle/src/doc_links.rs
@@ -2369,6 +2369,9 @@ pub struct Lookup<'a> {
db: &'a Connection,
repository: String,
producers: String,
+ /// The folder the project was last synced from, when the caller names
+ /// it ([`Lookup::with_folder`]): `source_age` dates files there.
+ folder: Option<std::path::PathBuf>,
}
/// One link row as a query reads it.
@@ -2399,7 +2402,38 @@ impl<'a> Lookup<'a> {
db,
repository: repository.to_string(),
producers: json!(producers()).to_string(),
- }
+ folder: None,
+ }
+ }
+ /// This lookup, naming the project's folder.
+ pub fn with_folder(mut self, folder: Option<std::path::PathBuf>) -> Self {
+ self.folder = folder;
+ self
+ }
+ /// The project's folder, when named.
+ pub fn folder(&self) -> Option<&std::path::Path> {
+ self.folder.as_deref()
+ }
+ /// The code an excerpt names: the linked mentions inside `[a, b)` of the
+ /// project's `document` at its bytes `sha256` whose definition is in
+ /// this project, as (mention, path of the definition's file).
+ pub fn code_named_in(
+ &self,
+ document: &str,
+ sha256: &str,
+ a: usize,
+ b: usize,
+ ) -> Result<Vec<(String, String)>> {
+ Ok(self
+ .mentions_in(document, a, b)?
+ .into_iter()
+ .filter(|link| {
+ link.document_sha256 == sha256
+ && link.target_repository == self.repository
+ && !link.relpath.is_empty()
+ })
+ .map(|link| (link.mention, link.relpath))
+ .collect())
}
fn links(&self, sql: &str, arguments: impl rusqlite::Params) -> Result<Vec<Link>> {
let found = rows(self.db, sql, arguments)?;
@@ -2429,6 +2463,14 @@ impl<'a> Lookup<'a> {
})
.collect())
}
+ /// The store this lookup reads (the `symbol_links` step reads it too).
+ pub fn db(&self) -> &'a Connection {
+ self.db
+ }
+ /// The project whose links this lookup reads.
+ pub fn repository(&self) -> &str {
+ &self.repository
+ }
/// Linked mentions inside `[a, b)` of one of the project's documents.
fn mentions_in(&self, document: &str, a: usize, b: usize) -> Result<Vec<Link>> {
self.links(
@@ -2476,6 +2518,18 @@ fn line_of(content: &str, at: usize) -> usize {
/// A window `[a, b)` of `document` as a candidate no passage covers (as the
/// code arm synthesizes its anchors).
fn window(document: &Value, a: usize, b: usize, identity: String, facts: Value) -> Option<Value> {
+ window_with(ARM, document, a, b, identity, facts)
+}
+
+/// [`window`], its facts under `arm` (the `symbol_links` step's windows).
+pub(crate) fn window_with(
+ arm: &str,
+ document: &Value,
+ a: usize,
+ b: usize,
+ identity: String,
+ facts: Value,
+) -> Option<Value> {
let content = s(document, "content");
let text = content.get(a..b)?;
if text.trim().is_empty() {
@@ -2493,7 +2547,7 @@ fn window(document: &Value, a: usize, b: usize, identity: String, facts: Value)
source.insert("total_bytes".into(), json!(content.len()));
source.insert("complete".into(), json!(a == 0 && b == content.len()));
source.insert("truncated".into(), json!(b < content.len()));
- source.insert(ARM.into(), facts);
+ source.insert(arm.into(), facts);
Some(
json!({"identity":identity,"kind":"source","origin":document["id"],"title":document["title"],
"text":text,"source_sha":document["sha256"],"source":source}),
@@ -2771,6 +2825,45 @@ struct Listed {
session: bool,
}
+/// A project's documents as one reader may read them (`memory::documents`
+/// for that reader), by id.
+fn listing(documents: &[Value]) -> HashMap<String, Listed> {
+ documents
+ .iter()
+ .map(|d| {
+ (
+ s(d, "id").to_string(),
+ Listed {
+ sha: s(d, "sha256").to_string(),
+ session: sdk_session(d),
+ },
+ )
+ })
+ .collect()
+}
+
+/// The mentions in `project`'s documents that are linked to code, as the
+/// coverage of `graph.doc_links` counts them for `p` (its `total.linked`):
+/// `documents` are the project's documents as `memory::documents` gives them
+/// to `p`, who may read the project. The workspace map's count.
+pub fn linked_mentions(
+ db: &Connection,
+ p: &Principal,
+ project: &str,
+ documents: &[Value],
+) -> Result<u64> {
+ let mut readable = Readable::new(db, p);
+ readable
+ .documents
+ .insert(project.to_string(), Some(listing(documents)));
+ let producers = json!(producers()).to_string();
+ Ok(
+ coverage(db, project, &mut readable, &producers)?["coverage"]["total"]["linked"]
+ .as_u64()
+ .unwrap_or(0),
+ )
+}
+
/// What a reader may read, per project (the snapshot's filter: access,
/// connector sharing and freshness).
struct Readable<'a> {
@@ -2837,20 +2930,11 @@ impl<'a> Readable<'a> {
if !self.documents.contains_key(project) {
let listed = if self.project(project)? {
let repository = crate::store::repo(self.db, self.p, project)?;
- Some(
- crate::memory::documents(self.db, &repository, self.p)?
- .iter()
- .map(|d| {
- (
- s(d, "id").to_string(),
- Listed {
- sha: s(d, "sha256").to_string(),
- session: sdk_session(d),
- },
- )
- })
- .collect(),
- )
+ Some(listing(&crate::memory::documents(
+ self.db,
+ &repository,
+ self.p,
+ )?))
} else {
None
};
@@ -2909,28 +2993,7 @@ pub fn read(store: &Store, workspace: &str, token: &str, args: &Value) -> Result
.as_str()
.filter(|v| !v.is_empty() && v.len() <= 200)
.ok_or_else(|| Error::bad("stable_id must be 1–200 bytes"))?;
- let mut out = Vec::new();
- for link in rows(
- db,
- "SELECT * FROM gf_doc_links WHERE target_repository_id=? AND stable_id=? AND state='linked' \
- AND producer IN (SELECT value FROM json_each(?)) ORDER BY repository_id,document_id,byte_start,id",
- params![project, stable, producers],
- )? {
- let document = s(&link, "document_id");
- if readable
- .document(s(&link, "repository_id"), document)?
- .is_none_or(|listed| listed.sha != s(&link, "document_sha256"))
- || readable.state(&link)? != "linked"
- {
- continue;
- }
- if out.len() < limit {
- out.push(json!({"repository_id":link["repository_id"],"document_id":document,
- "source_kind":link["source_kind"],"byte_start":link["byte_start"],"byte_end":link["byte_end"],
- "mention":link["mention"],"mark":link["mark"],"rung":link["rung"],"producer":link["producer"],
- "scope":link["scope"],"target_relpath":link["target_relpath"]}));
- }
- }
+ let out = naming(&mut readable, &project, stable, &producers, limit)?;
return Ok(json!({"repository_id":project,"stable_id":stable,"documents":out,"rules":RULES}));
}
if let Some(document) = args.get("document_id").filter(|v| !v.is_null()) {
@@ -2985,6 +3048,83 @@ pub fn read(store: &Store, workspace: &str, token: &str, args: &Value) -> Result
})
}
+/// The documents the reader may read now that mention the definition
+/// `stable` of `project` (from any project of the workspace), at most
+/// `limit`: `graph.doc_links` with `stable_id`, and the back-links of the
+/// graph tools' `get_node`.
+pub fn documents_naming(
+ db: &Connection,
+ p: &Principal,
+ project: &str,
+ stable: &str,
+ limit: usize,
+) -> Result<Vec<Value>> {
+ Naming::new(db, p).documents(project, stable, limit)
+}
+
+/// [`documents_naming`] for many definitions read by one reader (the
+/// back-links of one `get_node` call): each project's documents are listed
+/// once for all of them, not once per definition.
+pub struct Naming<'a> {
+ readable: Readable<'a>,
+ producers: String,
+}
+
+impl<'a> Naming<'a> {
+ pub fn new(db: &'a Connection, p: &'a Principal) -> Self {
+ Self {
+ readable: Readable::new(db, p),
+ producers: json!(producers()).to_string(),
+ }
+ }
+ /// Use `documents`, the project's documents as `memory::documents` gives
+ /// them to this reader (who may read `project`), instead of listing them
+ /// again.
+ pub fn knowing(mut self, project: &str, documents: &[Value]) -> Self {
+ self.readable
+ .documents
+ .insert(project.to_string(), Some(listing(documents)));
+ self
+ }
+ /// The documents that mention `stable` of `project`, as
+ /// [`documents_naming`].
+ pub fn documents(&mut self, project: &str, stable: &str, limit: usize) -> Result<Vec<Value>> {
+ naming(&mut self.readable, project, stable, &self.producers, limit)
+ }
+}
+
+fn naming(
+ readable: &mut Readable<'_>,
+ project: &str,
+ stable: &str,
+ producers: &str,
+ limit: usize,
+) -> Result<Vec<Value>> {
+ let mut out = Vec::new();
+ for link in rows(
+ readable.db,
+ "SELECT * FROM gf_doc_links WHERE target_repository_id=? AND stable_id=? AND state='linked' \
+ AND producer IN (SELECT value FROM json_each(?)) ORDER BY repository_id,document_id,byte_start,id",
+ params![project, stable, producers],
+ )? {
+ let document = s(&link, "document_id");
+ if readable
+ .document(s(&link, "repository_id"), document)?
+ .is_none_or(|listed| listed.sha != s(&link, "document_sha256"))
+ || readable.state(&link)? != "linked"
+ {
+ continue;
+ }
+ if out.len() < limit {
+ out.push(json!({"repository_id":link["repository_id"],"document_id":document,
+ "source_kind":link["source_kind"],"byte_start":link["byte_start"],"byte_end":link["byte_end"],
+ "mention":link["mention"],"mark":link["mark"],"rung":link["rung"],"producer":link["producer"],
+ "scope":link["scope"],"target_relpath":link["target_relpath"]}));
+ }
+ }
+ Ok(out)
+}
+
fn coverage(
db: &Connection,
project: &str,
diff --git a/crates/graphicle/src/extension.rs b/crates/graphicle/src/extension.rs
index 4936d9e..63960f6 100644
--- a/crates/graphicle/src/extension.rs
+++ b/crates/graphicle/src/extension.rs
@@ -19,6 +19,8 @@
//! `api::command_async`, before the core operations;
//! - `routes`: `api::router`, inside the request meter and the host, origin
//! and browser-session boundary;
+//! - `cross_site_post`: that boundary (`api::router`), before its origin and
+//! browser-mutation checks;
//! - `mcp_tools`: `api::mcp_tools_with` and MCP `tools/call`;
//! - `native_operations`, `native`: [`crate::native`], for the declared
//! operations only, before the memory engine;
@@ -26,7 +28,11 @@
//! - `credential_revoked`: `Store::revoke`;
//! - `request_allowance`, `usage_details`: the request meter and the owner's
//! usage report (`product`);
+//! - `served_allowed`, `metered_operations`: before a metered MCP tool call
+//! or HTTP operation runs, and which operations are metered (`metering`);
//! - `scrub_backup`: `Store::backup`, on the copy;
+//! - `vault_key`: the vault (`Store::save_secret` and `Store::secret`),
+//! before the device key file;
//! - `job_kinds`, `job`: queueing, leasing and `workflows::execute`, for the
//! declared job kinds (the core runs its own); `job` is asked in
//! installation order, not routed by declaration (see [`Extensions::job`]);
@@ -36,6 +42,9 @@
//! - `schedule`: `Store::schedule_connectors`, the worker's scheduler;
//! - `source_permissions`: provider permissions captured during a connector
//! sync;
+//! - `sources`: connector kinds beside the core's (`connectors`: adding,
+//! probing and syncing a connector, its endpoint override in the provider
+//! configuration, and the OAuth accounts it uses in `oauth`);
//! - `environment`, `serve`: `graphicle serve` and `graphicle start`, before
//! the server announces readiness; its background tasks run until shutdown;
//! - `cli`, `run_cli`: the `graphicle` command line ([`crate::cli`]), for the
@@ -43,7 +52,13 @@
//! - `ui_script`: the `/extensions.js` script of the web app;
//! - `page`: the public `/product` page (`product`);
//! - `history_tables`, `retained_tables`: verified deletion (`deletion`), for
-//! `deletion.state` and the residue scans of deletion receipts.
+//! `deletion.state` and the residue scans of deletion receipts;
+//! - `role_permits`: `store::authorize_hash` and `Store::grant`, for roles the
+//! core does not define;
+//! - `grant_role`: `Store::grant`, before a credential is made on a role the
+//! core does not define;
+//! - `authorize`: wherever a credential other than the owner capability is
+//! authorized, at each place [`Access`] lists.
use crate::{
Error, Result,
api::App,
@@ -51,10 +66,11 @@ use crate::{
jobs::{Job, Worker},
store::{Principal, Store},
};
-use axum::Router;
+use axum::{Router, http::StatusCode};
use rusqlite::Connection;
use serde_json::{Map, Value};
use std::{
+ borrow::Cow,
collections::{BTreeMap, BTreeSet},
future::Future,
path::PathBuf,
@@ -98,6 +114,10 @@ pub struct JobKind {
/// The permission its requester needs (`read`, `propose`, `run` or
/// `admin`), checked when it is queued and at every lease.
pub permission: &'static str,
+ /// Work dominated by local CPU, like a projection: a worker leases it
+ /// only with a CPU permit in hand (G08 admission,
+ /// `ingestion::cpu_bound`). Set with [`Self::cpu_bound`].
+ pub cpu: bool,
/// Source work, like a connector sync: no model call and no pinned
/// source state.
pub source: bool,
@@ -112,8 +132,13 @@ pub struct JobKind {
}
impl JobKind {
+ /// This kind, as CPU-bound work ([`Self::cpu`]).
+ pub const fn cpu_bound(self) -> Self {
+ Self { cpu: true, ..self }
+ }
pub const fn new(name: &'static str, permission: &'static str, source: bool) -> Self {
Self {
+ cpu: false,
name,
permission,
source,
@@ -197,6 +222,225 @@ impl McpTool {
}
}
+/// What a request of a workspace credential asks for, at each place the
+/// runtime asks [`Extension::authorize`]. The owner capability is never
+/// asked about.
+#[derive(Clone, Copy, Debug, PartialEq, Eq)]
+pub enum Access<'a> {
+ /// A store permission (`read`, `write`, `collect`, `propose`, `approve`,
+ /// `run`, `verify` or `admin`), at every authorization of the credential
+ /// (`store::authorize_hash`), once its role grants it.
+ Permission(&'a str),
+ /// A repository the request opens or lists
+ /// (`graph_projection::repo_readable`); a PR scratch project is asked
+ /// about as its folder project, whose code it holds.
+ Repository(&'a str),
+ /// An HTTP route that names a workspace (`{workspace}`), by its method
+ /// and pattern, before its handler runs (`api::router`).
+ Route { method: &'a str, pattern: &'a str },
+ /// An operation (`api::command`, `api::command_async`): the command
+ /// endpoints, the routes that run one, MCP tools and `graphicle call`;
+ /// also the pull-request tools (`graph.pull_requests`) and MCP resource
+ /// reads, which read the code graph as `graph.navigate` does.
+ Operation(&'a str),
+ /// An MCP tool, at `tools/call` before its operation and at
+ /// `tools/list`; `writes` when its contract is not read-only.
+ Tool { name: &'a str, writes: bool },
+}
+
+/// One request of a workspace credential, as [`Extension::authorize`] sees
+/// it: an extension refuses it with an error, or narrows it.
+#[derive(Debug)]
+pub struct AccessRequest<'a> {
+ pub access: Access<'a>,
+ /// The arguments of an [`Access::Operation`]; `None` for other accesses.
+ /// An extension may narrow them through `Cow::to_mut` (a lower token
+ /// budget, for example); the operation then runs with the copy.
+ pub arguments: Option<Cow<'a, Value>>,
+ /// The most tokens (`graphicle_memory::text::count` of the text served)
+ /// a read's response may carry; an extension may set or lower it, and the
+ /// lowest applies. The runtime answers a larger result with 413 (the
+ /// size check of [`crate::metering`]): an operation's or MCP tool's
+ /// result when it is a read (`metering::meter`; for the pull-request
+ /// tools, when the tool is read-only), an MCP resource, and the response
+ /// of a GET or HEAD route. A write's result is never refused once it is
+ /// saved. Unused for [`Access::Permission`] and [`Access::Repository`].
+ pub max_tokens: Option<usize>,
+}
+
+impl<'a> AccessRequest<'a> {
+ pub fn new(access: Access<'a>) -> Self {
+ Self {
+ access,
+ arguments: None,
+ max_tokens: None,
+ }
+ }
+}
+
+/// What [`admit`] allowed: the narrowed arguments, if an extension narrowed
+/// them, and the response's token limit.
+#[derive(Debug, Default)]
+pub struct Admitted {
+ pub arguments: Option<Value>,
+ pub max_tokens: Option<usize>,
+}
+
+/// Ask the installed extensions ([`Extension::authorize`]) whether the
+/// credential `token` may have `access` where the store does not authorize it
+/// itself: a route, an operation or an MCP tool. Nothing is asked in Core, for
+/// the owner capability, or for a token that is no usable workspace
+/// credential (the request then fails, or authenticates otherwise, where it
+/// always did).
+pub fn admit(
+ store: &Store,
+ workspace: &str,
+ token: &str,
+ access: Access<'_>,
+ arguments: Option<&Value>,
+) -> Result<Admitted> {
+ let extensions = installed();
+ if extensions.is_empty() || token.is_empty() || token.len() > 512 {
+ return Ok(Admitted::default());
+ }
+ let hash = graphicle_memory::text::sha256(token.as_bytes());
+ store.read(|db| {
+ // Authentication only: a credential is checked whichever
+ // permissions its role holds.
+ let principal = match crate::store::authenticate_hash(db, workspace, &hash) {
+ Ok(principal) => principal,
+ // No usable credential: the request fails, or authenticates
+ // otherwise, where it always did.
+ Err(error) if error.status == StatusCode::FORBIDDEN => {
+ return Ok(Admitted::default());
+ }
+ // Anything else fails closed.
+ Err(error) => return Err(error),
+ };
+ if principal.role == "owner" {
+ return Ok(Admitted::default());
+ }
+ let mut request = AccessRequest {
+ access,
+ arguments: arguments.map(Cow::Borrowed),
+ max_tokens: None,
+ };
+ extensions.authorize(db, &principal, &mut request)?;
+ Ok(Admitted {
+ arguments: match request.arguments {
+ Some(Cow::Owned(narrowed)) => Some(narrowed),
+ _ => None,
+ },
+ max_tokens: request.max_tokens,
+ })
+ })
+}
+
+/// [`admit`] for several accesses of one credential in one read, each
+/// answered on its own: whether it is allowed.
+pub fn admit_each(
+ store: &Store,
+ workspace: &str,
+ token: &str,
+ accesses: &[Access<'_>],
+) -> Result<Vec<bool>> {
+ let extensions = installed();
+ if extensions.is_empty() || token.is_empty() || token.len() > 512 {
+ return Ok(vec![true; accesses.len()]);
+ }
+ let hash = graphicle_memory::text::sha256(token.as_bytes());
+ store.read(|db| {
+ let principal = match crate::store::authenticate_hash(db, workspace, &hash) {
+ Ok(principal) => principal,
+ Err(error) if error.status == StatusCode::FORBIDDEN => {
+ return Ok(vec![true; accesses.len()]);
+ }
+ Err(error) => return Err(error),
+ };
+ if principal.role == "owner" {
+ return Ok(vec![true; accesses.len()]);
+ }
+ Ok(accesses
+ .iter()
+ .map(|access| {
+ extensions
+ .authorize(db, &principal, &mut AccessRequest::new(*access))
+ .is_ok()
+ })
+ .collect())
+ })
+}
+
+/// Refuse a response of more than `limit` tokens ([`AccessRequest::max_tokens`]):
+/// the one per-call size check of a read's result, on the text served.
+pub fn within_limit(limit: Option<usize>, text: &str) -> Result<()> {
+ let Some(limit) = limit else {
+ return Ok(());
+ };
+ // Every token holds at least one byte.
+ if text.len() <= limit {
+ return Ok(());
+ }
+ let tokens = graphicle_memory::text::count(text);
+ if tokens > limit {
+ return Err(Error {
+ status: StatusCode::PAYLOAD_TOO_LARGE,
+ message: format!(
+ "The response holds {tokens} tokens; this credential may receive at most {limit} per call. Ask for less (a lower max_tokens, budget_tokens or limit, or a narrower query)."
+ ),
+ provider_failure: None,
+ });
+ }
+ Ok(())
+}
+
+/// A source connector kind an extension adds beside the core's
+/// ([`crate::connectors::CORE_KINDS`]). Connectors of the kind are added,
+/// scheduled, staged, activated, shared and enforced on read by the core
+/// exactly like its own; the source only reads its provider, through the
+/// connector job's [`Remote`] (request budget, credentials and rate limits
+/// as for the core's kinds).
+pub trait Source: Send + Sync + 'static {
+ /// The connector `kind`; never a core kind ([`install`] panics).
+ fn kind(&self) -> &'static str;
+ /// The OAuth provider whose connected accounts (`oauth:` credentials) the
+ /// kind uses. It is also the provider of the verified identities the
+ /// core matches provider permissions against.
+ fn oauth_provider(&self) -> &'static str;
+ /// The stable account ID and display name in the identity response of
+ /// [`Self::oauth_provider`] (its `identity_url`), when the core does not
+ /// know that provider; `None` rejects the connection.
+ fn oauth_identity(&self, _identity: &Value) -> Option<(String, String)> {
+ None
+ }
+ /// The configuration fields of the kind, beside the common ones (`acl`,
+ /// `max_age_seconds`, `sync_every_seconds`, `permission_mode`,
+ /// `permission_max_age_seconds` and `observe`).
+ fn fields(&self) -> &'static [&'static str];
+ /// Check a configuration, after the core's checks of the common fields.
+ fn validate(&self, config: &Value) -> Result<()>;
+ /// The provider API base of a connector; the provider configuration's
+ /// `connector_endpoints.<kind>` overrides it.
+ fn base_url(&self, config: &Value) -> Result<String>;
+ /// One page of the listing from `cursor` (`null` at the start): the
+ /// items, and the next cursor, `null` when the listing is complete.
+ fn listing<'a>(
+ &'a self,
+ remote: &'a mut Remote<'_>,
+ cursor: &'a Value,
+ ) -> BoxFuture<'a, Result<(Vec<Value>, Value)>>;
+ /// The document of one listed item (`id`, `title`, `content`, `url`,
+ /// `source_timestamp`, `metadata`); `None` when it is gone.
+ fn document<'a>(
+ &'a self,
+ remote: &'a mut Remote<'_>,
+ item: &'a Value,
+ ) -> BoxFuture<'a, Result<Option<Value>>>;
+ /// The `connector_probe` diagnostic: the account's identity and the first
+ /// configured target.
+ fn probe<'a>(&'a self, remote: &'a mut Remote<'_>) -> BoxFuture<'a, Result<(Value, Value)>>;
+}
+
/// What `graphicle serve` gives the `serve` hook, before it announces that
/// the server is ready.
pub struct ServeContext<'a> {
@@ -301,6 +545,15 @@ pub trait Extension: Send + Sync + 'static {
fn routes(&self) -> Router<App> {
Router::new()
}
+ /// Whether a POST to `path` is a cross-site form post that this
+ /// extension's route authenticates by itself, such as a sign-in callback
+ /// that another site's page posts to from its own origin. For such a
+ /// request the boundary skips its origin and
+ /// browser-mutation checks and maps no browser session into it; the host
+ /// check still applies. Name exact paths only.
+ fn cross_site_post(&self, _path: &str) -> bool {
+ false
+ }
/// MCP tools, published after the core tools. Names must be unique.
fn mcp_tools(&self, _learning: bool, _work_state: bool) -> Vec<McpTool> {
Vec::new()
@@ -345,6 +598,39 @@ pub trait Extension: Send + Sync + 'static {
) -> Result<()> {
Ok(())
}
+ /// Whether `role`, which the core does not define, grants `permission`
+ /// in `workspace`; `None` when this extension does not define it either.
+ /// The core defines owner, reader, agent, reviewer, collector and runner,
+ /// and denies everything to a role no one defines. `Store::grant` accepts
+ /// a role an extension defines.
+ fn role_permits(
+ &self,
+ _db: &Connection,
+ _workspace: &str,
+ _role: &str,
+ _permission: &str,
+ ) -> Result<Option<bool>> {
+ Ok(None)
+ }
+ /// Before `Store::grant` makes a credential on `role`, a role the core
+ /// does not define: an installed extension may refuse a new credential on
+ /// a role it defines. Every installed extension must allow it.
+ fn grant_role(&self, _db: &Connection, _workspace: &str, _role: &str) -> Result<()> {
+ Ok(())
+ }
+ /// Whether a workspace credential other than the owner capability may
+ /// have `request.access`, once the core's own checks allowed it: refuse
+ /// with an error, or narrow the request (its arguments, its response's
+ /// tokens). Every installed extension must allow it, so an extension can
+ /// only restrict. [`Access`] lists where the runtime asks.
+ fn authorize(
+ &self,
+ _db: &Connection,
+ _principal: &Principal,
+ _request: &mut AccessRequest<'_>,
+ ) -> Result<()> {
+ Ok(())
+ }
/// The workspace's monthly HTTP request allowance from this extension (a
/// plan, for example); `None` sets no limit. The lowest of the owner's own
/// budget and every allowance applies.
@@ -355,11 +641,45 @@ pub trait Extension: Send + Sync + 'static {
fn usage_details(&self, _db: &Connection, _workspace: &str, _usage: &mut Value) -> Result<()> {
Ok(())
}
+ /// Whether a metered result may be served to `principal`, a credential
+ /// other than the owner capability, before its MCP tool call, MCP
+ /// resource read or HTTP operation runs and once [`Self::authorize`]
+ /// allowed it ([`crate::metering`]): refuse with an error, which the
+ /// caller gets instead of the result (a quota, for example), or allow it.
+ /// Every installed extension must allow it. A refusal with status 429 is
+ /// a limit of the current UTC month: an HTTP caller gets `Retry-After`
+ /// until the next one starts. The local command line and capture hooks
+ /// are never asked.
+ fn served_allowed(
+ &self,
+ _db: &Connection,
+ _principal: &Principal,
+ _served: &crate::metering::Served<'_>,
+ ) -> Result<()> {
+ Ok(())
+ }
+ /// The extension's own operations ([`Self::operations`]) that no MCP tool
+ /// of it runs and that return a project's text: metered over HTTP and the
+ /// command line like the core's reads ([`crate::metering::meter`]). The
+ /// operations its tools run are metered anyway.
+ fn metered_operations(&self) -> &'static [&'static str] {
+ &[]
+ }
/// Scrub a portable backup copy (never the live store) after the core
/// scrub: remove sessions, secrets or entitlements the copy must not carry.
fn scrub_backup(&self, _db: &Connection) -> Result<()> {
Ok(())
}
+ /// The key that seals this store's vault (the `am_secrets` rows: provider
+ /// credentials, OAuth tokens and the other encrypted fields) when this
+ /// extension holds it, for example wrapped by a key held by an external
+ /// key service;
+ /// `None` leaves the vault on the device key file (`vault.key`). The
+ /// answer is final: an error fails the vault operation, and the core never
+ /// falls back to the device key for a store whose key an extension holds.
+ fn vault_key(&self, _store: &Store) -> Option<Result<[u8; 32]>> {
+ None
+ }
/// The job kinds this extension runs through [`Self::job`], with the
/// permission each needs. Declared kinds can be queued and are leased; a
/// job of a kind no installed extension declares is never leased, so a
@@ -418,6 +738,11 @@ pub trait Extension: Send + Sync + 'static {
) -> Option<BoxFuture<'a, Result<Value>>> {
None
}
+ /// The source connector kinds this extension adds ([`Source`]).
+ /// [`install`] rejects a core kind or one another extension adds.
+ fn sources(&self) -> &'static [&'static dyn Source] {
+ &[]
+ }
/// Environment variables this extension reads when the server starts.
/// `graphicle serve` refuses to start while a variable that configures an
/// edition feature (hosted billing or the storefront) is set and no
@@ -483,12 +808,13 @@ static INSTALLED: OnceLock<Extensions> = OnceLock::new();
/// through [`crate::cli::main_with`], before anything else runs.
///
/// Panics when extensions are already installed, when an extension claims a
-/// core operation other than the [`OVERRIDABLE_OPERATIONS`], when two
+/// core operation other than the [`OVERRIDABLE_OPERATIONS`] or meters one it
+/// does not serve, when two
/// extensions claim the same operation, when an MCP tool name repeats a core
-/// or another extension's tool, when a declared native operation, job kind or
-/// subcommand clashes with the core's or another extension's, when a declared
-/// job kind is not supported ([`crate::archived`]), or when extensions declare
-/// different editions.
+/// or another extension's tool, when a declared native operation, job kind,
+/// connector kind or subcommand clashes with the core's or another
+/// extension's, when a declared job kind is not supported
+/// ([`crate::archived`]), or when extensions declare different editions.
pub fn install(extensions: Extensions) {
let extensions = extensions.indexed();
if INSTALLED.set(extensions).is_err() {
@@ -553,6 +879,14 @@ impl Extensions {
);
}
}
+ for operation in extension.metered_operations() {
+ if !extension.operations().contains(operation) {
+ panic!(
+ "graphicle: extension {} meters the operation {operation}, which it does not serve",
+ extension.name()
+ );
+ }
+ }
}
for learning in [false, true] {
for work_state in [false, true] {
@@ -615,6 +949,24 @@ impl Extensions {
}
}
}
+ let mut sources = BTreeMap::new();
+ for extension in &self.list {
+ for source in extension.sources() {
+ let kind = source.kind();
+ if crate::connectors::CORE_KINDS.contains(&kind) {
+ panic!(
+ "graphicle: extension {} adds the core connector kind {kind}",
+ extension.name()
+ );
+ }
+ if let Some(other) = sources.insert(kind, extension.name()) {
+ panic!(
+ "graphicle: extensions {other} and {} both add the connector kind {kind}",
+ extension.name()
+ );
+ }
+ }
+ }
let mut natives = BTreeMap::new();
for (index, extension) in self.list.iter().enumerate() {
for &operation in extension.native_operations() {
@@ -693,6 +1045,15 @@ impl Extensions {
.flat_map(|extension| extension.job_kinds().iter().map(|kind| kind.name))
.collect()
}
+ /// Every job kind the extensions declare CPU-bound ([`JobKind::cpu`]).
+ pub fn cpu_bound_kinds(&self) -> Vec<&'static str> {
+ self.list
+ .iter()
+ .flat_map(|extension| extension.job_kinds().iter())
+ .filter(|kind| kind.cpu)
+ .map(|kind| kind.name)
+ .collect()
+ }
/// Every environment variable the extensions read when serving.
pub fn environment(&self) -> Vec<&'static str> {
self.list
@@ -700,6 +1061,10 @@ impl Extensions {
.flat_map(|extension| extension.environment().iter().copied())
.collect()
}
+ /// Every operation the extensions serve, once installed.
+ pub fn operation_names(&self) -> Vec<&'static str> {
+ self.operations.keys().copied().collect()
+ }
/// The extension that serves `operation`, if any.
pub fn operation(&self, operation: &str) -> Option<&dyn Extension> {
self.operations
@@ -721,6 +1086,13 @@ impl Extensions {
router.merge(extension.routes())
})
}
+ /// Whether an installed extension takes a cross-site form post to `path`
+ /// ([`Extension::cross_site_post`]); never in Core.
+ pub fn cross_site_post(&self, path: &str) -> bool {
+ self.list
+ .iter()
+ .any(|extension| extension.cross_site_post(path))
+ }
pub fn mcp_tools(&self, learning: bool, work_state: bool) -> Vec<McpTool> {
self.list
.iter()
@@ -764,6 +1136,39 @@ impl Extensions {
.iter()
.try_for_each(|extension| extension.credential_revoked(db, workspace, credential))
}
+ /// The first extension that defines `role` decides.
+ pub fn role_permits(
+ &self,
+ db: &Connection,
+ workspace: &str,
+ role: &str,
+ permission: &str,
+ ) -> Result<Option<bool>> {
+ for extension in &self.list {
+ if let Some(granted) = extension.role_permits(db, workspace, role, permission)? {
+ return Ok(Some(granted));
+ }
+ }
+ Ok(None)
+ }
+ /// Every extension must allow a new credential on `role`.
+ pub fn grant_role(&self, db: &Connection, workspace: &str, role: &str) -> Result<()> {
+ self.list
+ .iter()
+ .try_for_each(|extension| extension.grant_role(db, workspace, role))
+ }
+ /// Every extension must allow the request; each sees what the earlier
+ /// ones narrowed.
+ pub fn authorize(
+ &self,
+ db: &Connection,
+ principal: &Principal,
+ request: &mut AccessRequest<'_>,
+ ) -> Result<()> {
+ self.list
+ .iter()
+ .try_for_each(|extension| extension.authorize(db, principal, request))
+ }
/// The lowest allowance any extension sets.
pub fn request_allowance(&self, db: &Connection, workspace: &str) -> Result<Option<u64>> {
let mut lowest: Option<u64> = None;
@@ -779,11 +1184,36 @@ impl Extensions {
.iter()
.try_for_each(|extension| extension.usage_details(db, workspace, usage))
}
+ /// Every extension's [`Extension::metered_operations`].
+ pub fn metered_operations(&self) -> Vec<&'static str> {
+ self.list
+ .iter()
+ .flat_map(|extension| extension.metered_operations().iter().copied())
+ .collect()
+ }
+ /// Every extension must allow the metered call.
+ pub fn served_allowed(
+ &self,
+ db: &Connection,
+ principal: &Principal,
+ served: &crate::metering::Served<'_>,
+ ) -> Result<()> {
+ self.list
+ .iter()
+ .try_for_each(|extension| extension.served_allowed(db, principal, served))
+ }
pub fn scrub_backup(&self, db: &Connection) -> Result<()> {
self.list
.iter()
.try_for_each(|extension| extension.scrub_backup(db))
}
+ /// The vault key of the first extension that holds this store's; `None`
+ /// when none does.
+ pub fn vault_key(&self, store: &Store) -> Option<Result<[u8; 32]>> {
+ self.list
+ .iter()
+ .find_map(|extension| extension.vault_key(store))
+ }
/// Run a leased job through the first installed extension whose
/// [`Extension::job`] accepts it; `None` when none does. Operations,
/// native operations and subcommands reach the extension that declared
@@ -871,6 +1301,28 @@ impl Extensions {
}
None
}
+ /// Every source the extensions add, in installation order.
+ pub fn sources(&self) -> Vec<&'static dyn Source> {
+ self.list
+ .iter()
+ .flat_map(|extension| extension.sources().iter().copied())
+ .collect()
+ }
+ /// The source an extension adds for the connector kind `kind`.
+ pub fn source(&self, kind: &str) -> Option<&'static dyn Source> {
+ self.list
+ .iter()
+ .flat_map(|extension| extension.sources().iter().copied())
+ .find(|source| source.kind() == kind)
+ }
+ /// The first added source whose connected accounts come from the OAuth
+ /// provider `provider`.
+ pub fn oauth_source(&self, provider: &str) -> Option<&'static dyn Source> {
+ self.list
+ .iter()
+ .flat_map(|extension| extension.sources().iter().copied())
+ .find(|source| source.oauth_provider() == provider)
+ }
pub fn serve(&self, context: &mut ServeContext<'_>) -> Result<()> {
self.list
.iter()
@@ -952,6 +1404,7 @@ mod tests {
assert!(none.operation("status").is_none());
assert!(none.mcp_tools(true, true).is_empty());
assert_eq!(none.ui_script(), "");
+ assert!(!none.cross_site_post("/hooks/example"));
assert!(installed().operation("impact.report").is_none());
}
@@ -1069,7 +1522,10 @@ mod tests {
#[test]
fn declared_job_kinds_and_native_operations_are_indexed() {
- const KINDS: &[JobKind] = &[JobKind::new("probe_kind", "read", true)];
+ const KINDS: &[JobKind] = &[
+ JobKind::new("probe_kind", "read", true),
+ JobKind::new("probe_cpu", "admin", true).cpu_bound(),
+ ];
let extensions = Extensions::none()
.with(Declares {
kinds: KINDS,
@@ -1083,7 +1539,11 @@ mod tests {
Some("read")
);
assert!(extensions.job_kind("project").is_none());
- assert_eq!(extensions.job_kinds(), ["probe_kind"]);
+ assert_eq!(extensions.job_kinds(), ["probe_kind", "probe_cpu"]);
+ assert!(!extensions.job_kind("probe_kind").unwrap().cpu);
+ assert!(extensions.job_kind("probe_cpu").unwrap().cpu);
+ assert_eq!(extensions.cpu_bound_kinds(), ["probe_cpu"]);
+ assert!(Extensions::none().cpu_bound_kinds().is_empty());
assert_eq!(extensions.natives.get("graph.probe_native"), Some(&0));
assert_eq!(extensions.subcommands.get("probe-command"), Some(&0));
assert!(!extensions.subcommands.contains_key("serve"));
@@ -1174,6 +1634,87 @@ mod tests {
.indexed();
}
+ struct ProbeSource(&'static str);
+ impl Source for ProbeSource {
+ fn kind(&self) -> &'static str {
+ self.0
+ }
+ fn oauth_provider(&self) -> &'static str {
+ "probe_accounts"
+ }
+ fn fields(&self) -> &'static [&'static str] {
+ &[]
+ }
+ fn validate(&self, _config: &Value) -> Result<()> {
+ Ok(())
+ }
+ fn base_url(&self, _config: &Value) -> Result<String> {
+ Ok("https://probe.invalid".into())
+ }
+ fn listing<'a>(
+ &'a self,
+ _remote: &'a mut Remote<'_>,
+ _cursor: &'a Value,
+ ) -> BoxFuture<'a, Result<(Vec<Value>, Value)>> {
+ Box::pin(async { Ok((Vec::new(), Value::Null)) })
+ }
+ fn document<'a>(
+ &'a self,
+ _remote: &'a mut Remote<'_>,
+ _item: &'a Value,
+ ) -> BoxFuture<'a, Result<Option<Value>>> {
+ Box::pin(async { Ok(None) })
+ }
+ fn probe<'a>(
+ &'a self,
+ _remote: &'a mut Remote<'_>,
+ ) -> BoxFuture<'a, Result<(Value, Value)>> {
+ Box::pin(async { Ok((Value::Null, Value::Null)) })
+ }
+ }
+ struct Sources(&'static [&'static dyn Source]);
+ impl Extension for Sources {
+ fn name(&self) -> &'static str {
+ "sources"
+ }
+ fn sources(&self) -> &'static [&'static dyn Source] {
+ self.0
+ }
+ }
+
+ #[test]
+ fn added_connector_kinds_are_found_by_kind_and_by_oauth_provider() {
+ static PROBE: &[&dyn Source] = &[&ProbeSource("probe_kind")];
+ let extensions = Extensions::none().with(Sources(PROBE)).indexed();
+ assert_eq!(
+ extensions.source("probe_kind").map(|s| s.oauth_provider()),
+ Some("probe_accounts")
+ );
+ assert_eq!(
+ extensions.oauth_source("probe_accounts").map(|s| s.kind()),
+ Some("probe_kind")
+ );
+ assert!(extensions.source("github").is_none());
+ assert!(Extensions::none().source("probe_kind").is_none());
+ }
+
+ #[test]
+ #[should_panic(expected = "adds the core connector kind gdrive")]
+ fn a_core_connector_kind_cannot_be_added() {
+ static DRIVE: &[&dyn Source] = &[&ProbeSource("gdrive")];
+ let _ = Extensions::none().with(Sources(DRIVE)).indexed();
+ }
+
+ #[test]
+ #[should_panic(expected = "both add the connector kind probe_same")]
+ fn two_extensions_cannot_add_one_connector_kind() {
+ static SAME: &[&dyn Source] = &[&ProbeSource("probe_same")];
+ let _ = Extensions::none()
+ .with(Sources(SAME))
+ .with(Sources(SAME))
+ .indexed();
+ }
+
#[test]
fn extension_mcp_tools_follow_in_order() {
let extensions = Extensions::none()
diff --git a/crates/graphicle/src/fresh.rs b/crates/graphicle/src/fresh.rs
index ac98d2d..9f6f058 100644
--- a/crates/graphicle/src/fresh.rs
+++ b/crates/graphicle/src/fresh.rs
@@ -453,7 +453,7 @@ fn check_at(
Ok(check)
}
-/// The files under `folder` (the sync's walk) whose inode changed after
+/// The files under `folder` (the sync's walk, [`local::folder_entries`]) whose inode changed after
/// `since_ns`, and the synced files (`heads`, path to SHA-256) that are gone;
/// `None` when the folder holds more than [`MAX_SCAN`] entries or the scan
/// takes longer than [`SCAN_TIME`]. A file whose inode changed within
@@ -476,7 +476,7 @@ fn scan(
let threshold = since_ns.saturating_sub(MARGIN_NS);
let mut seen = BTreeSet::new();
let mut changed = BTreeSet::new();
- for (count, entry) in local::folder_walk(folder).build().enumerate() {
+ for (count, entry) in local::folder_entries(folder).enumerate() {
if count > MAX_SCAN || started.elapsed() > SCAN_TIME {
return None;
}
@@ -485,7 +485,9 @@ fn scan(
let Some(kind) = entry.file_type() else {
continue;
};
- if entry.depth() == 0 || kind.is_dir() {
+ // The folder itself or a directory; a tracked file the walk left
+ // out comes at depth 0 too, and is scanned.
+ if entry.path() == folder || kind.is_dir() {
continue;
}
let Ok(relative) = entry.path().strip_prefix(folder) else {
@@ -700,7 +702,7 @@ fn porcelain(output: &[u8], prefix: &str) -> (String, Vec<(String, Vec<u8>)>, bo
/// variables a git hook sets are removed, so git finds the folder's own
/// repository, and optional locks are off, so the check never writes the
/// index another git process may be using.
-fn git(folder: &Path, args: &[&str]) -> Option<Vec<u8>> {
+pub(crate) fn git(folder: &Path, args: &[&str]) -> Option<Vec<u8>> {
let mut command = std::process::Command::new("git");
// Git refuses Windows' verbatim `\\?\` paths.
command
diff --git a/crates/graphicle/src/graph_projection.rs b/crates/graphicle/src/graph_projection.rs
index 7a31b27..7421257 100644
--- a/crates/graphicle/src/graph_projection.rs
+++ b/crates/graphicle/src/graph_projection.rs
@@ -1513,7 +1513,8 @@ const MANIFEST_SKIP_DIRS: &[&str] = &["node_modules/", "vendor/", ".venv/", "dis
/// repository unless an explicit `revoked` row in `gf_repo_access` names the
/// principal's credential; the workspace owner always reads everything. A
/// PR scratch project linked to a folder project is readable only while the
-/// folder project is.
+/// folder project is. An installed extension may narrow the repositories of
+/// a credential (`extension::Access::Repository`).
pub fn repo_readable(db: &Connection, p: &Principal, repository: &str) -> Result<bool> {
if p.role == "owner" {
return Ok(true);
@@ -1526,7 +1527,26 @@ pub fn repo_readable(db: &Connection, p: &Principal, repository: &str) -> Result
AND (repository_id=?2 OR repository_id IN (SELECT project_id FROM repo_pr_scratch WHERE repository_id=?2))",
params![p.credential, repository],
)?;
- Ok(revoked.is_none())
+ if revoked.is_some() {
+ return Ok(false);
+ }
+ // An installed extension may narrow the credential's repositories. A PR
+ // scratch project is asked about as its folder project, whose code it
+ // holds.
+ let extensions = crate::extension::installed();
+ if extensions.is_empty() {
+ return Ok(true);
+ }
+ let scope = crate::folders::scratch_of(db, repository)?;
+ Ok(extensions
+ .authorize(
+ db,
+ p,
+ &mut crate::extension::AccessRequest::new(crate::extension::Access::Repository(
+ scope.as_deref().unwrap_or(repository),
+ )),
+ )
+ .is_ok())
}
/// Record `granted` / `revoked` repository access for a credential.
@@ -1605,10 +1625,122 @@ struct Linkable {
episode: String,
/// Whether `episode` is the current head set (sources then match the graph).
current: bool,
- graph: GraphHandle,
+ /// The resident graph, once this pass needed it: to build the export
+ /// index, or to link the project's own imports.
+ graph: Option<GraphHandle>,
heads: BTreeMap<String, String>,
manifests: Vec<PackageManifest>,
index: ExportIndex,
+ /// The export index as built from the graph, before the nested-project
+ /// filter, when this pass built it (it is then stored for later passes).
+ built: Option<String>,
+}
+
+/// Version of the stored link state (`gf_cross_link_state`). Another value,
+/// as after an upgrade, rebuilds every export index and relinks every
+/// project once.
+pub const LINK_STATE_FORMAT: &str = concat!("xrepo-link-1/", env!("CARGO_PKG_VERSION"));
+
+/// The export index stored for `repository` at `episode`, if any.
+fn stored_export_index(
+ db: &Connection,
+ repository: &str,
+ episode: &str,
+) -> Result<Option<ExportIndex>> {
+ let Some(row) = one(
+ db,
+ "SELECT export_index FROM gf_cross_link_state WHERE repository_id=? AND episode=? AND format=?",
+ params![repository, episode, LINK_STATE_FORMAT],
+ )?
+ else {
+ return Ok(None);
+ };
+ Ok(serde_json::from_str(s(&row, "export_index")).ok())
+}
+
+/// What other projects can import from `index`: its digest without the
+/// episode, so a new episode that exports the same modules and symbols
+/// (same node ids) has the same surface.
+fn export_surface(index: &ExportIndex) -> String {
+ let mut value = json!(index);
+ if let Some(map) = value.as_object_mut() {
+ map.remove("episode");
+ }
+ digest(&value)
+}
+
+/// The live link rows of `repository` as its import report: what its last
+/// link wrote. Only the persisted fields are filled; the persistence of
+/// [`link_workspace`] reads nothing else.
+fn previous_report(db: &Connection, repository: &str, episode: &str) -> Result<xrepo::LinkReport> {
+ let text = |row: &Value, field: &str| row[field].as_str().map(str::to_string);
+ let line = |row: &Value| row["line"].as_u64().map(|line| line as usize);
+ let edges = rows(
+ db,
+ "SELECT * FROM gf_cross_edges WHERE source_repository_id=? AND valid_to_episode IS NULL ORDER BY id",
+ [repository],
+ )?
+ .iter()
+ .map(|row| xrepo::CrossEdge {
+ source: xrepo::EdgeEnd {
+ repo: repository.to_string(),
+ node_id: s(row, "source_node_id").to_string(),
+ stable_id: text(row, "source_stable_id"),
+ ..Default::default()
+ },
+ target: xrepo::EdgeEnd {
+ repo: s(row, "target_repository_id").to_string(),
+ node_id: s(row, "target_node_id").to_string(),
+ stable_id: text(row, "target_stable_id"),
+ ..Default::default()
+ },
+ relation: s(row, "relation").to_string(),
+ confidence: s(row, "confidence").to_string(),
+ derivation: s(row, "derivation").to_string(),
+ module_path: s(row, "module_path").to_string(),
+ symbol: text(row, "symbol"),
+ version_constraint: text(row, "version_constraint"),
+ exporter_version: text(row, "exporter_version"),
+ version_status: s(row, "version_status").to_string(),
+ line: line(row),
+ })
+ .collect();
+ let unresolved = rows(
+ db,
+ "SELECT * FROM gf_cross_unresolved WHERE source_repository_id=? AND valid_to_episode IS NULL ORDER BY id",
+ [repository],
+ )?
+ .iter()
+ .map(|row| {
+ let relpath = text(row, "relpath");
+ xrepo::UnresolvedImport {
+ repo: repository.to_string(),
+ node_id: s(row, "source_node_id").to_string(),
+ stable_id: text(row, "source_stable_id"),
+ // Not stored; the persistence does not read it.
+ ecosystem: relpath
+ .as_deref()
+ .and_then(xrepo::Ecosystem::of_file)
+ .unwrap_or(xrepo::Ecosystem::Python),
+ relpath,
+ module_path: s(row, "module_path").to_string(),
+ symbol: text(row, "symbol"),
+ package: s(row, "package").to_string(),
+ reason: s(row, "reason").to_string(),
+ candidates: serde_json::from_str(s(row, "candidates")).unwrap_or_default(),
+ version_constraint: text(row, "version_constraint"),
+ exporter_version: text(row, "exporter_version"),
+ line: line(row),
+ }
+ })
+ .collect();
+ Ok(xrepo::LinkReport {
+ repo: repository.to_string(),
+ episode: Some(episode.to_string()),
+ edges,
+ unresolved,
+ ..Default::default()
+ })
}
fn live_pair_episodes(
@@ -1744,7 +1876,29 @@ fn export_index(
/// side moved to a new episode the stale rows are closed with
/// `valid_to_episode` (the new episode of the side that changed) and the pair
/// is re-linked.
+///
+/// The pass is incremental. A project's own imports are linked again only
+/// when its episode, the export surface of another taking part (what it
+/// exports, without the episode) or the set of projects taking part changed
+/// since its last link, or when it no longer has as many live rows as that
+/// link left (rows are only ever closed or deleted, never edited in place);
+/// otherwise its live rows stand for the link and go through
+/// the same persistence, so the rows are those of a full pass
+/// ([`link_workspace_full`]). Export indexes are stored per project
+/// (`gf_cross_link_state`), so an unchanged project's graph is not loaded.
+/// The summary lists the projects linked again (`relinked`) and those whose
+/// links were reused (`reused`).
pub fn link_workspace(db: &Connection, p: &Principal) -> Result<Value> {
+ link_workspace_with(db, p, true)
+}
+
+/// [`link_workspace`] that rebuilds every export index from the graphs and
+/// links every project's imports again, whatever changed.
+pub fn link_workspace_full(db: &Connection, p: &Principal) -> Result<Value> {
+ link_workspace_with(db, p, false)
+}
+
+fn link_workspace_with(db: &Connection, p: &Principal, incremental: bool) -> Result<Value> {
let workspace = p.workspace.as_str();
let mut hidden = 0usize;
let mut unprojected = Vec::new();
@@ -1784,10 +1938,22 @@ pub fn link_workspace(db: &Connection, p: &Principal) -> Result<Value> {
}
let mut repos: Vec<Linkable> = Vec::new();
for (id, name, episode, current) in candidates {
- let graph = resident(db, &id, &episode)?;
let heads = episode_heads(db, &id, &episode)?.unwrap_or_default();
let manifests = manifests(db, &id, &heads)?;
- let index = export_index(&graph, &id, &episode, &manifests);
+ let stored = if incremental {
+ stored_export_index(db, &id, &episode)?
+ } else {
+ None
+ };
+ let (graph, index, built) = match stored {
+ Some(index) => (None, index, None),
+ None => {
+ let graph = resident(db, &id, &episode)?;
+ let index = export_index(&graph, &id, &episode, &manifests);
+ let built = json!(index).to_string();
+ (Some(graph), index, Some(built))
+ }
+ };
repos.push(Linkable {
id,
name,
@@ -1797,6 +1963,7 @@ pub fn link_workspace(db: &Connection, p: &Principal) -> Result<Value> {
heads,
manifests,
index,
+ built,
});
}
// Nested projects: a project synced from a folder inside
@@ -1869,6 +2036,11 @@ pub fn link_workspace(db: &Connection, p: &Principal) -> Result<Value> {
WHERE source_repository_id=?2 AND valid_to_episode IS NULL",
params![copy.episode, copy.id],
)?;
+ // Its rows no longer describe its last link.
+ db.execute(
+ "UPDATE gf_cross_link_state SET inputs=NULL WHERE repository_id=?",
+ [&copy.id],
+ )?;
}
}
let skipped_scratch: Vec<&str> = shadowed.iter().map(|copy| copy.id.as_str()).collect();
@@ -1894,29 +2066,80 @@ pub fn link_workspace(db: &Connection, p: &Principal) -> Result<Value> {
record_packages(db, workspace, repo)?;
}
}
+ // Link state is stored only from a complete view of a workspace with
+ // something to link: a workspace whose projects export nothing (one of
+ // conversations only, for example) gains no rows.
+ let keep_state = hidden == 0
+ && repos
+ .iter()
+ .any(|repo| !repo.index.packages.is_empty() || !repo.index.modules.is_empty());
+ if keep_state {
+ for repo in &repos {
+ if let Some(built) = &repo.built {
+ db.execute(
+ "INSERT INTO gf_cross_link_state(repository_id,workspace_id,episode,format,export_index,created_at) \
+ VALUES(?,?,?,?,?,?) ON CONFLICT(repository_id) DO UPDATE SET workspace_id=excluded.workspace_id,\
+ episode=excluded.episode,format=excluded.format,export_index=excluded.export_index,\
+ created_at=excluded.created_at",
+ params![repo.id, workspace, repo.episode, LINK_STATE_FORMAT, built, now()],
+ )?;
+ }
+ }
+ }
+ let surfaces: Vec<String> = repos
+ .iter()
+ .map(|repo| export_surface(&repo.index))
+ .collect();
let stamp = now();
let mut pairs = Vec::new();
let mut edges_total = 0usize;
let mut unresolved_total = 0usize;
+ let mut relinked = Vec::new();
+ let mut reused = Vec::new();
for (i, importer) in repos.iter().enumerate() {
- let others: Vec<ExportIndex> = repos
- .iter()
- .enumerate()
- .filter(|(j, _)| *j != i)
- .map(|(_, r)| r.index.clone())
- .collect();
- let loader = |relpath: &str| -> Option<String> {
- let sha = importer.heads.get(relpath)?;
- blob(db, &importer.id, sha).ok().flatten()
+ // Everything the importer's link reads besides its own episode: the
+ // other projects taking part, in order, with their export surfaces.
+ let inputs = digest(&json!([
+ LINK_STATE_FORMAT,
+ importer.id,
+ importer.episode,
+ repos
+ .iter()
+ .zip(&surfaces)
+ .enumerate()
+ .filter(|(j, _)| *j != i)
+ .map(|(_, (repo, surface))| json!([repo.id, surface]))
+ .collect::<Vec<_>>(),
+ ]));
+ let reuse = incremental && keep_state && unchanged_link(db, &importer.id, &inputs)?;
+ let report = if reuse {
+ reused.push(importer.id.as_str());
+ previous_report(db, &importer.id, &importer.episode)?
+ } else {
+ relinked.push(importer.id.as_str());
+ let others: Vec<ExportIndex> = repos
+ .iter()
+ .enumerate()
+ .filter(|(j, _)| *j != i)
+ .map(|(_, r)| r.index.clone())
+ .collect();
+ let graph = match &importer.graph {
+ Some(graph) => graph.clone(),
+ None => resident(db, &importer.id, &importer.episode)?,
+ };
+ let loader = |relpath: &str| -> Option<String> {
+ let sha = importer.heads.get(relpath)?;
+ blob(db, &importer.id, sha).ok().flatten()
+ };
+ xrepo::link(
+ &graph,
+ &importer.id,
+ Some(&importer.episode),
+ &importer.manifests,
+ &others,
+ &loader,
+ )
};
- let report = xrepo::link(
- &importer.graph,
- &importer.id,
- Some(&importer.episode),
- &importer.manifests,
- &others,
- &loader,
- );
if hidden > 0 {
// A restricted view cannot establish workspace-wide uniqueness of
// an exporter. It must not overwrite shared links or unresolved
@@ -1926,9 +2149,11 @@ pub fn link_workspace(db: &Connection, p: &Principal) -> Result<Value> {
continue;
}
let exporter_episodes = json!(
- others
+ repos
.iter()
- .map(|other| (other.repo.clone(), other.episode.clone()))
+ .enumerate()
+ .filter(|(j, _)| *j != i)
+ .map(|(_, other)| (other.index.repo.clone(), other.index.episode.clone()))
.collect::<BTreeMap<_, _>>()
)
.to_string();
@@ -2051,6 +2276,15 @@ pub fn link_workspace(db: &Connection, p: &Principal) -> Result<Value> {
)?;
}
}
+ // What this link read and wrote, for the next pass to compare. It
+ // updates a stored row only, so a workspace without one gains none.
+ db.execute(
+ "UPDATE gf_cross_link_state SET inputs=?1,\
+ edges=(SELECT count(*) FROM gf_cross_edges WHERE source_repository_id=?2 AND valid_to_episode IS NULL),\
+ unresolved=(SELECT count(*) FROM gf_cross_unresolved WHERE source_repository_id=?2 AND valid_to_episode IS NULL) \
+ WHERE repository_id=?2",
+ params![inputs, importer.id],
+ )?;
unresolved_total += report.unresolved.len();
}
let mut summary = json!({
@@ -2067,6 +2301,9 @@ pub fn link_workspace(db: &Connection, p: &Principal) -> Result<Value> {
"hidden_repositories": hidden,
"persisted": hidden == 0,
"unprojected_repositories": unprojected,
+ "incremental": incremental,
+ "relinked": relinked,
+ "reused": reused,
});
if !skipped_scratch.is_empty() {
summary["pr_scratch_skipped"] = json!(skipped_scratch);
@@ -2074,6 +2311,19 @@ pub fn link_workspace(db: &Connection, p: &Principal) -> Result<Value> {
Ok(summary)
}
+/// Whether `repository`'s last link read `inputs` and its live rows are
+/// still the ones that link wrote (as many edges and unresolved imports).
+fn unchanged_link(db: &Connection, repository: &str, inputs: &str) -> Result<bool> {
+ Ok(one(
+ db,
+ "SELECT 1 AS same FROM gf_cross_link_state WHERE repository_id=?1 AND inputs=?2 \
+ AND edges=(SELECT count(*) FROM gf_cross_edges WHERE source_repository_id=?1 AND valid_to_episode IS NULL) \
+ AND unresolved=(SELECT count(*) FROM gf_cross_unresolved WHERE source_repository_id=?1 AND valid_to_episode IS NULL)",
+ params![repository, inputs],
+ )?
+ .is_some())
+}
+
/// Whether the repository-relative `path` is `prefix` or lies under it.
fn below(path: &str, prefix: &str) -> bool {
path == prefix
@@ -2294,8 +2544,21 @@ impl Store {
/// ([`crate::doc_links::relink`]): its summary, or its error, is the
/// result's `documents`.
pub fn graph_link(&self, workspace: &str, token: &str) -> Result<Value> {
+ self.graph_link_with(workspace, token, link_workspace)
+ }
+ /// [`Store::graph_link`] with a full pass ([`link_workspace_full`]):
+ /// every project's imports are linked again, whatever changed.
+ pub fn graph_link_full(&self, workspace: &str, token: &str) -> Result<Value> {
+ self.graph_link_with(workspace, token, link_workspace_full)
+ }
+ fn graph_link_with(
+ &self,
+ workspace: &str,
+ token: &str,
+ pass: fn(&Connection, &Principal) -> Result<Value>,
+ ) -> Result<Value> {
let (mut result, principal) = self.authorized(workspace, token, "read", |db, p| {
- Ok((link_workspace(db, p)?, p.hash.clone()))
+ Ok((pass(db, p)?, p.hash.clone()))
})?;
result["documents"] =
match crate::doc_links::relink(self, workspace, &principal, |_| Ok(())) {
diff --git a/crates/graphicle/src/graph_tools.rs b/crates/graphicle/src/graph_tools.rs
index 1cef151..aad7230 100644
--- a/crates/graphicle/src/graph_tools.rs
+++ b/crates/graphicle/src/graph_tools.rs
@@ -26,6 +26,10 @@
//! through a relation says whether a relation read from an unchanged file
//! reaches it (`relation_checked`), the rule the code-graph arm follows
//! when it withholds such neighbours.
+//! - **Back-links.** `get_node`'s node also lists, under `linked`, the
+//! current reviewed memories linked to that symbol and the documents the
+//! reader may read that mention it ([`crate::symbol_links::attach`]); the
+//! citations block names them too.
//! - **Communities**. The episode is clustered when the
//! server first reads it (the engine's Leiden clustering, as `cluster-only`
//! runs it), so `get_community`, the nodes' community numbers and the six
@@ -414,7 +418,7 @@ pub fn call(store: &Store, workspace: &str, token: &str, args: &Value) -> Result
})
});
let mut contents = HashMap::new();
- let nodes = named
+ let mut nodes = named
.nodes
.iter()
.take(CITED_LIMIT)
@@ -426,6 +430,10 @@ pub fn call(store: &Store, workspace: &str, token: &str, args: &Value) -> Result
Ok(fact)
})
.collect::<Result<Vec<_>>>()?;
+ // The symbol `get_node` describes, with what links to it.
+ if tool == "get_node" {
+ crate::symbol_links::attach(db, p, &repository, &mut nodes)?;
+ }
let mut reply = json!({"tool":tool,"text":text,"repo":identifier,
"episode":reading.episode,"current_episode":reading.current,"episode_lag":reading.lag(),
"nodes":nodes});
@@ -515,6 +523,7 @@ pub fn citations_text(reply: &Value) -> String {
if node["relation_checked"] == false {
out.push_str(" (reached only through relations read from changed files)");
}
+ out.push_str(&linked_text(&node["linked"]));
}
let more = nodes.len().saturating_sub(CITED_IN_TEXT) as u64;
if more > 0 {
@@ -539,6 +548,57 @@ pub fn citations_text(reply: &Value) -> String {
out
}
+/// Back-links named per node in the citations block.
+const LINKED_IN_TEXT: usize = 3;
+
+/// A node's back-links in the citations block: the reviewed memories (by
+/// title and id) and documents linked to it, at most [`LINKED_IN_TEXT`] of
+/// each named; empty when nothing links to it.
+fn linked_text(linked: &Value) -> String {
+ let list = |key: &str| linked[key].as_array().map(Vec::as_slice).unwrap_or(&[]);
+ let (memories, documents) = (list("memories"), list("documents"));
+ let mut out = String::new();
+ let more = |n: usize| {
+ let extra = n.saturating_sub(LINKED_IN_TEXT);
+ if extra > 0 {
+ format!(" and {extra} more")
+ } else {
+ String::new()
+ }
+ };
+ if !memories.is_empty() {
+ let named: Vec<String> = memories
+ .iter()
+ .take(LINKED_IN_TEXT)
+ .map(|m| {
+ format!(
+ "{} ({})",
+ m["title"].as_str().unwrap_or(""),
+ m["id"].as_str().unwrap_or("")
+ )
+ })
+ .collect();
+ out.push_str(&format!(
+ "\n reviewed memory linked: {}{}",
+ named.join("; "),
+ more(memories.len())
+ ));
+ }
+ if !documents.is_empty() {
+ let named: Vec<&str> = documents
+ .iter()
+ .take(LINKED_IN_TEXT)
+ .map(|d| d["document_id"].as_str().unwrap_or(""))
+ .collect();
+ out.push_str(&format!(
+ "\n documents mentioning it: {}{}",
+ named.join(", "),
+ more(documents.len())
+ ));
+ }
+ out
+}
+
/// The first `n` characters of `text`, and `…` when there are more.
fn abbreviated(text: &str, n: usize) -> String {
let shown: String = text.chars().take(n).collect();
diff --git a/crates/graphicle/src/identifier_arm.rs b/crates/graphicle/src/identifier_arm.rs
new file mode 100644
index 0000000..6d834a2
--- /dev/null
+++ b/crates/graphicle/src/identifier_arm.rs
@@ -0,0 +1,763 @@
+//! The identifier arm of `context`: the identifiers and file paths a code
+//! question names ([`named`]), found in the project's passages by a
+//! case-sensitive whole-word match and, for identifiers, at their
+//! definitions in the code graph, ranked by file and fused into `rank` as
+//! the arm `identifiers` ([`ARM`]). The identifier route answers a question
+//! that only asks where names are defined or used; any other code question
+//! that names identifiers keeps them here, so the files that define or use
+//! them rank with the rest of the retrieval (the route's `asks_more` exit
+//! used to drop them).
+//!
+//! A file's score sums, over the names it holds, each name's weight
+//! `ln(1 + files / files holding it)`, doubled where the file defines the
+//! name; a file whose path the question names adds twice the weight of a
+//! name only it holds. Files come in score order, each with its two best
+//! passages. The switch is `identifier_arm`: `"auto"` (left out) for a code
+//! question ([`crate::code_question::is_code_question`]), `true` for any
+//! question that names identifiers or paths, `false` for none.
+use crate::code_graph_arm::{self, Reading};
+use crate::query::Passages;
+use crate::store::s;
+use crate::{Result, graph_projection};
+use graphicle::graph::Graph;
+use graphicle::session::GraphHandle;
+use rusqlite::Connection;
+use serde_json::{Value, json};
+use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet};
+use std::sync::LazyLock;
+
+/// The arm's name in `rank`'s fusion, `arm_weights` and the packet's
+/// `arms`.
+pub const ARM: &str = "identifiers";
+/// Names one question may look for; the most specific are kept.
+pub const MAX_NAMES: usize = 40;
+/// Names and paths read from one question, in order of mention.
+pub const MAX_CANDIDATES: usize = 160;
+/// A name with more definitions than this is too common to weigh its
+/// definitions.
+pub const MAX_DEFINITIONS: usize = 20;
+/// Passages the arm ranks.
+pub const RANKED: usize = 200;
+/// Passages one file gives the arm.
+pub const PER_FILE: usize = 2;
+
+/// The identifiers and file paths a text names ([`named`]).
+#[derive(Clone, Debug, Default, PartialEq, Eq)]
+pub struct Named {
+ pub names: Vec<String>,
+ pub paths: Vec<String>,
+}
+
+/// Extensions a named file path may have.
+const PATH_EXTENSIONS: &str = "c h cc cpp cxx hpp hh hxx inl ipp tpp cu cuh rs java kt kts \
+ scala cs fs vb js jsx mjs cjs ts tsx mts cts go py pyi pyx rb php swift m mm lua ex exs \
+ erl hs ml mli dart jl r clj cljs zig vue svelte groovy pl pm sh bash ps1 sql proto toml \
+ json yaml yml xml gradle cmake csproj props ini cfg conf md rst txt html css scss less";
+
+/// Common English words and keywords of programming languages: a word of a
+/// code block or span that is one of these is not a name.
+const COMMON: &str = "the and for with that this from into are was were has have had not \
+ can about there their they them then than its our your you all any did should would will \
+ what which where when does how why who use used using also just like get set new old one \
+ two may might must need needs make makes made see more most some such other only same each \
+ true false null none nil void self super let var const mut pub impl struct enum trait mod \
+ crate return returns else match while loop break continue static final public private \
+ protected class interface extends implements import package include define ifdef ifndef \
+ endif typedef unsigned signed int long short char float double bool boolean string str \
+ async await function export default delete try catch throw throws yield def elif lambda \
+ pass raise except finally assert global nonlocal print error errors warning info debug \
+ line lines file files value values type types name names test tests example output input";
+
+fn common(word: &str) -> bool {
+ static WORDS: LazyLock<BTreeSet<&'static str>> =
+ LazyLock::new(|| COMMON.split_whitespace().collect());
+ WORDS.contains(word.to_ascii_lowercase().as_str())
+}
+
+fn path_extension(extension: &str) -> bool {
+ static EXTENSIONS: LazyLock<BTreeSet<&'static str>> =
+ LazyLock::new(|| PATH_EXTENSIONS.split_whitespace().collect());
+ EXTENSIONS.contains(extension.to_ascii_lowercase().as_str())
+}
+
+/// A word written as code: with an underscore inside (`parse_config`,
+/// `MAX_NAMES`); camelCase with two lowercase letters before its first
+/// capital, digits between allowed (`parseConfig`, `utf8Decoder`; not
+/// `iPhone` or `eBay`); PascalCase with a capital inside after a lowercase
+/// letter or a digit (`ParseConfig`, `IsNull`); or a run of capitals before
+/// a lowercase letter (`HTTPServer`).
+fn code_like(word: &str) -> bool {
+ static CAPITAL: LazyLock<regex::Regex> = LazyLock::new(|| {
+ regex::Regex::new(r"^[a-z]{2}[a-z0-9]*[A-Z]|^[A-Z][A-Za-z0-9]*[a-z0-9][A-Z]|[A-Z]{2}[a-z]")
+ .expect("the inner capital rule")
+ });
+ word.trim_matches('_').contains('_') || CAPITAL.is_match(word)
+}
+
+/// The identifiers and file paths `text` names, each once, in order of
+/// mention, at most [`MAX_CANDIDATES`]:
+/// - paths: a file name or path with a known extension (`parse.rs`,
+/// `src/config/parse.rs`, `globals_api.h#L172` gives `globals_api.h`);
+/// - in code (a fenced block or a backtick span): every identifier of three
+/// or more characters that is not a common English word or keyword, and
+/// a qualified name whole (`Store::open`) with its parts;
+/// - in prose: `snake_case`, `SCREAMING_CASE`, camelCase and PascalCase
+/// words with a capital inside, calls (`name(`), and qualified names
+/// (`a.b`, `a::b`, `a->b`, `a#b`) with a part written as code or
+/// capitalized, whole and by those parts.
+pub fn named(text: &str) -> Named {
+ static FENCE: LazyLock<regex::Regex> = LazyLock::new(|| {
+ regex::Regex::new(r"(?s)```.*?(?:```|\z)|~~~.*?(?:~~~|\z)").expect("the fence rule")
+ });
+ static SPAN: LazyLock<regex::Regex> =
+ LazyLock::new(|| regex::Regex::new(r"`[^`\n]+`").expect("the span rule"));
+ static PATH: LazyLock<regex::Regex> = LazyLock::new(|| {
+ regex::Regex::new(
+ r"(?:[A-Za-z0-9_.+-]+/)*[A-Za-z0-9_+-][A-Za-z0-9_.+-]*\.([A-Za-z][A-Za-z0-9+]{0,6})\b",
+ )
+ .expect("the path rule")
+ });
+ static QUALIFIED: LazyLock<regex::Regex> = LazyLock::new(|| {
+ regex::Regex::new(r"[A-Za-z_][A-Za-z0-9_]*(?:(?:::|\.|->|#)[A-Za-z_][A-Za-z0-9_]*)*")
+ .expect("the qualified name rule")
+ });
+ static CALL: LazyLock<regex::Regex> =
+ LazyLock::new(|| regex::Regex::new(r"([A-Za-z_][A-Za-z0-9_]*)\(").expect("the call rule"));
+ let mut named = Named::default();
+ // Each once (a set, not a scan of the list), at most MAX_CANDIDATES.
+ let mut seen_paths: HashSet<&str> = HashSet::new();
+ for path in PATH.captures_iter(text) {
+ if named.paths.len() >= MAX_CANDIDATES {
+ break;
+ }
+ let whole = path.get(0).expect("a match").as_str();
+ if path_extension(&path[1]) && whole.chars().any(|c| c.is_ascii_alphabetic()) {
+ let whole = whole.trim_start_matches("./").trim_start_matches('/');
+ if !whole.is_empty() && seen_paths.insert(whole) {
+ named.paths.push(whole.to_string());
+ }
+ }
+ }
+ // Code keeps its offsets; prose is the text with code blanked out, in
+ // place (code spans become spaces of the same length), in one pass.
+ let mut blanked = text.as_bytes().to_vec();
+ let mut code: Vec<(usize, String)> = Vec::new();
+ for rule in [&*FENCE, &*SPAN] {
+ let current = String::from_utf8_lossy(&blanked).into_owned();
+ for found in rule.find_iter(&current) {
+ let (a, b) = (found.start(), found.end());
+ // A fenced block's first line names its language.
+ let block = found.as_str();
+ let skip = if block.starts_with("```") || block.starts_with("~~~") {
+ block.find('\n').unwrap_or(block.len())
+ } else {
+ 0
+ };
+ code.push((a + skip, block[skip..].to_string()));
+ blanked[a..b].fill(b' ');
+ }
+ }
+ let prose = String::from_utf8_lossy(&blanked).into_owned();
+ code.sort();
+ let mut mentions: Vec<(usize, String)> = Vec::new();
+ // A qualified name: whole unless it is a file name, and its parts that
+ // read as code (in code: any part of three or more characters).
+ let qualified = |at: usize, token: &str, in_code: bool, out: &mut Vec<(usize, String)>| {
+ let parts: Vec<&str> = token
+ .split(['.', ':', '#', '-', '>'])
+ .filter(|p| !p.is_empty())
+ .collect();
+ // `globals_api.h#L172` names a file, not a symbol.
+ let file = parts.iter().skip(1).any(|part| path_extension(part));
+ let anchor = |part: &str| {
+ part.strip_prefix('L')
+ .is_some_and(|line| !line.is_empty() && line.chars().all(|c| c.is_ascii_digit()))
+ };
+ let worded = |part: &str| {
+ // A file name's extension is no name.
+ let extension = file && path_extension(part);
+ part.len() >= 3
+ && !common(part)
+ && !anchor(part)
+ && !extension
+ && (in_code
+ || code_like(part)
+ || part.starts_with(|c: char| c.is_ascii_uppercase()))
+ };
+ if parts.len() > 1 {
+ let shows_code = parts
+ .iter()
+ .any(|p| code_like(p) || p.starts_with(|c: char| c.is_ascii_uppercase()))
+ && !parts
+ .iter()
+ .all(|p| p.chars().all(|c| c.is_ascii_lowercase()));
+ if !(in_code || shows_code) {
+ return;
+ }
+ if !file {
+ out.push((at, token.to_string()));
+ }
+ }
+ for part in &parts {
+ if worded(part) && (parts.len() > 1 || in_code || code_like(part)) {
+ out.push((at, (*part).to_string()));
+ }
+ }
+ };
+ for (at, block) in &code {
+ for token in QUALIFIED.find_iter(block) {
+ qualified(at + token.start(), token.as_str(), true, &mut mentions);
+ }
+ }
+ for token in QUALIFIED.find_iter(&prose) {
+ qualified(token.start(), token.as_str(), false, &mut mentions);
+ }
+ for call in CALL.captures_iter(&prose) {
+ let name = &call[1];
+ if name.len() >= 3 && !common(name) {
+ mentions.push((call.get(1).expect("a name").start(), name.to_string()));
+ }
+ }
+ mentions.sort_by_key(|(at, _)| *at);
+ let mut seen_names: HashSet<String> = HashSet::new();
+ for (_, name) in mentions {
+ if named.names.len() + named.paths.len() >= MAX_CANDIDATES {
+ break;
+ }
+ if !name.is_empty() && seen_names.insert(name.clone()) {
+ named.names.push(name);
+ }
+ }
+ named
+}
+
+/// What [`arm`] gives one project's `context` call.
+pub struct Identifiers {
+ /// The arm's ranking of passage identities, when it ran.
+ pub ranking: Option<Vec<String>>,
+ /// The files (`file:` origins) that define a code name the question
+ /// names when no source file defines it (a test helper, a fixture, an
+ /// example in a document): the code-first prior leaves their weight
+ /// ([`crate::code_question::DEFINING`]).
+ pub defining: Vec<String>,
+ /// The packet's `identifier_arm` report.
+ pub report: Value,
+}
+
+/// The arm for one project's `context` call ([`Identifiers`]).
+pub fn arm(
+ db: &Connection,
+ repository: &str,
+ passages: &Passages,
+ args: &Value,
+ question: &str,
+ query: &str,
+) -> Result<Identifiers> {
+ let (mode, defaulted) = match args.get("identifier_arm") {
+ None | Some(Value::Null) => (None, true),
+ Some(Value::Bool(on)) => (Some(*on), false),
+ Some(Value::String(mode)) if mode == "auto" => (None, false),
+ Some(_) => {
+ return Err(crate::Error::bad(
+ "identifier_arm must be true, false or auto",
+ ));
+ }
+ };
+ let setting = mode.map_or(json!("auto"), |on| json!(on));
+ let mut report = json!({"identifier_arm": setting, "defaulted": defaulted});
+ let on = mode.unwrap_or_else(|| crate::code_question::is_code_question(question));
+ let skipped = |report: Value| Identifiers {
+ ranking: None,
+ defining: Vec::new(),
+ report,
+ };
+ if !on {
+ report["status"] = json!("off");
+ return Ok(skipped(report));
+ }
+ let named = named(query);
+ if named.names.is_empty() && named.paths.is_empty() {
+ report["status"] = json!("no_names");
+ return Ok(skipped(report));
+ }
+ let graph = if args["graph_retrieval"] == false {
+ None
+ } else {
+ code_graph(db, repository)
+ };
+ let ranked = rank(&passages.rows, &named, graph.as_ref());
+ report["status"] = json!(if ranked.ranking.is_empty() {
+ "no_match"
+ } else {
+ "fused"
+ });
+ report["names"] = json!(ranked.names);
+ report["paths"] = json!(ranked.paths);
+ report["defined"] = json!(ranked.defined);
+ report["files"] = json!(ranked.files);
+ report["candidates"] = json!(ranked.ranking.len());
+ report["code_graph"] = json!(graph.is_some());
+ report["defining_files_outside_source"] = json!(ranked.defining.len());
+ Ok(Identifiers {
+ ranking: (!ranked.ranking.is_empty()).then_some(ranked.ranking),
+ defining: ranked.defining,
+ report,
+ })
+}
+
+/// The code graph the code-graph arm reads, with its symbols; `None` when
+/// the project has no recorded episode or it cannot be opened (the arm then
+/// matches text alone).
+struct CodeGraph {
+ handle: GraphHandle,
+ /// Code symbols: (node index, dotted name, file).
+ symbols: Vec<(usize, String, String)>,
+ /// Symbols by the last segment of their dotted name.
+ by_last: HashMap<String, Vec<usize>>,
+ /// Files the lag fallback may cite (`None`: all).
+ unchanged: Option<BTreeSet<String>>,
+}
+
+fn code_graph(db: &Connection, repository: &str) -> Option<CodeGraph> {
+ let heads = crate::store::heads(db, repository).ok()?;
+ let current = graph_projection::episode_of(&heads);
+ let Reading { episode, lag } = code_graph_arm::reading(db, repository, &heads, &current)
+ .ok()
+ .flatten()?;
+ let handle = graph_projection::resident(db, repository, &episode).ok()?;
+ let graph: &Graph = &handle;
+ let symbols: Vec<(usize, String, String)> = graph
+ .nodes()
+ .iter()
+ .enumerate()
+ .filter(|(_, node)| code_graph_arm::code_symbol(&node.attributes))
+ .filter_map(|(index, node)| {
+ Some((
+ index,
+ crate::identifier_route::symbol_name(&node.attributes)?,
+ code_graph_arm::relpath(&node.attributes)?,
+ ))
+ })
+ .collect();
+ let mut by_last: HashMap<String, Vec<usize>> = HashMap::new();
+ for (i, (_, name, _)) in symbols.iter().enumerate() {
+ let last = name.rsplit('.').next().unwrap_or(name);
+ by_last.entry(last.to_string()).or_default().push(i);
+ }
+ Some(CodeGraph {
+ handle,
+ symbols,
+ by_last,
+ unchanged: lag.map(|lag| lag.unchanged),
+ })
+}
+
+impl CodeGraph {
+ /// The symbols `name` defines, as the identifier route finds them
+ /// (`crate::identifier_route`'s longest matching suffix), by index into
+ /// `symbols`.
+ fn definitions(&self, name: &str) -> Vec<usize> {
+ let dotted = name
+ .replace("::", ".")
+ .replace(['#'], ".")
+ .replace("->", ".");
+ let mut segments: Vec<&str> = dotted.split('.').filter(|s| !s.is_empty()).collect();
+ while segments.len() > 1 && ["self", "this", "crate", "super"].contains(&segments[0]) {
+ segments.remove(0);
+ }
+ let Some(last) = segments.last() else {
+ return Vec::new();
+ };
+ let Some(bucket) = self.by_last.get(*last) else {
+ return Vec::new();
+ };
+ let ends_with = |qualified: &str, path: &str| {
+ qualified == path
+ || qualified
+ .strip_suffix(path)
+ .is_some_and(|head| head.ends_with('.'))
+ };
+ for k in 0..segments.len() {
+ let suffix = segments[k..].join(".");
+ let last_only = k + 1 == segments.len() && segments.len() > 1;
+ let found: Vec<usize> = bucket
+ .iter()
+ .copied()
+ .filter(|&i| {
+ let (_, qualified, relpath) = &self.symbols[i];
+ ends_with(qualified, &suffix)
+ && (!last_only
+ || relpath
+ .split(['/', '.'])
+ .any(|part| segments[..k].contains(&part)))
+ })
+ .collect();
+ if !found.is_empty() {
+ return found;
+ }
+ }
+ Vec::new()
+ }
+}
+
+/// What [`rank`] found.
+struct Ranked {
+ ranking: Vec<String>,
+ names: Vec<String>,
+ paths: Vec<String>,
+ defined: usize,
+ files: usize,
+ /// The files (`file:` origins) that define one of the code names no
+ /// source file defines ([`defining_outside_source`]).
+ defining: Vec<String>,
+}
+
+/// The arm's passage order over `rows` (the query's passages) for `named`.
+fn rank(rows: &[Value], named: &Named, graph: Option<&CodeGraph>) -> Ranked {
+ // Passages of project files, by file in first-seen order.
+ let mut files: Vec<&str> = Vec::new();
+ let mut by_file: HashMap<&str, Vec<usize>> = HashMap::new();
+ for (i, row) in rows.iter().enumerate() {
+ let Some(origin) = row["origin"].as_str().filter(|o| o.starts_with("file:")) else {
+ continue;
+ };
+ if row["kind"] != "source" {
+ continue;
+ }
+ by_file
+ .entry(origin)
+ .or_insert_with(|| {
+ files.push(origin);
+ Vec::new()
+ })
+ .push(i);
+ }
+ let total = files.len().max(1) as f64;
+ // Whole-word, case-sensitive matches of every candidate name, longest
+ // first so `Store::open` is found before `Store`.
+ let mut candidates: Vec<&String> = named.names.iter().collect();
+ candidates.sort_by_key(|name| std::cmp::Reverse(name.len()));
+ let mut counts: Vec<Vec<(usize, u32)>> = vec![Vec::new(); rows.len()];
+ if !candidates.is_empty() {
+ let pattern = candidates
+ .iter()
+ .map(|name| regex::escape(name))
+ .collect::<Vec<_>>()
+ .join("|");
+ if let Ok(matcher) = regex::Regex::new(&format!(r"(?-u:\b)(?:{pattern})(?-u:\b)")) {
+ let index: HashMap<&str, usize> = named
+ .names
+ .iter()
+ .enumerate()
+ .map(|(i, name)| (name.as_str(), i))
+ .collect();
+ for list in by_file.values() {
+ for &i in list {
+ let mut found: BTreeMap<usize, u32> = BTreeMap::new();
+ for hit in matcher.find_iter(s(&rows[i], "text")) {
+ if let Some(&name) = index.get(hit.as_str()) {
+ *found.entry(name).or_default() += 1;
+ }
+ }
+ counts[i] = found.into_iter().collect();
+ }
+ }
+ }
+ }
+ // Files holding each name, by text and by definition.
+ let mut holders: Vec<BTreeSet<&str>> = vec![BTreeSet::new(); named.names.len()];
+ for (&file, list) in &by_file {
+ for &i in list {
+ for &(name, _) in &counts[i] {
+ holders[name].insert(file);
+ }
+ }
+ }
+ // Definitions, for names specific enough: per name, the files and
+ // start lines that define it.
+ let mut defined: Vec<Vec<(String, usize)>> = vec![Vec::new(); named.names.len()];
+ if let Some(graph) = graph {
+ for (n, name) in named.names.iter().enumerate() {
+ let found = graph.definitions(name);
+ if found.is_empty() || found.len() > MAX_DEFINITIONS {
+ continue;
+ }
+ for i in found {
+ let (index, _, relpath) = &graph.symbols[i];
+ if graph
+ .unchanged
+ .as_ref()
+ .is_some_and(|unchanged| !unchanged.contains(relpath))
+ {
+ continue;
+ }
+ let origin = format!("file:{relpath}");
+ let Some((&file, _)) = by_file.get_key_value(origin.as_str()) else {
+ continue;
+ };
+ let line = graphicle_memory::graph::span::start_line(
+ &graph.handle.nodes()[*index].attributes,
+ );
+ defined[n].push((file.to_string(), line.unwrap_or(0)));
+ holders[n].insert(file);
+ }
+ }
+ }
+ // The most specific names: fewest holding files first.
+ let mut kept: Vec<usize> = (0..named.names.len())
+ .filter(|&n| !holders[n].is_empty())
+ .collect();
+ kept.sort_by_key(|&n| (holders[n].len(), n));
+ kept.truncate(MAX_NAMES);
+ // In `kept` order, so every sum adds in the same order.
+ let weights: Vec<(usize, f64)> = kept
+ .iter()
+ .map(|&n| (n, (1.0 + total / holders[n].len() as f64).ln()))
+ .collect();
+ // Named paths: the files whose path ends with one, or that one ends with.
+ let path_weight = 2.0 * (1.0 + total).ln();
+ let mut path_bonus: HashMap<&str, f64> = HashMap::new();
+ let mut paths_found = Vec::new();
+ for path in &named.paths {
+ let path = path.replace('\\', "/");
+ let matching: Vec<&str> = files
+ .iter()
+ .copied()
+ .filter(|origin| {
+ let file = &origin[5..];
+ file == path
+ || file.ends_with(&format!("/{path}"))
+ || path.ends_with(&format!("/{file}"))
+ })
+ .collect();
+ if matching.is_empty() {
+ continue;
+ }
+ paths_found.push(path.clone());
+ for &file in &matching {
+ *path_bonus.entry(file).or_default() += path_weight / matching.len() as f64;
+ }
+ }
+ // A file or passage holding a name's definition counts the name twice.
+ let defines = |n: usize, file: &str| defined[n].iter().any(|(f, _)| f == file);
+ let passage_defines = |n: usize, row: &Value| {
+ let file = s(row, "origin");
+ let (start, end) = (
+ row["source"]["line"].as_u64().unwrap_or(0) as usize,
+ row["source"]["end_line"].as_u64().unwrap_or(0) as usize,
+ );
+ defined[n]
+ .iter()
+ .any(|(f, line)| f == file && *line >= start.max(1) && (end == 0 || *line <= end))
+ };
+ let mut scored: Vec<(f64, u32, &str)> = Vec::new();
+ for &file in &files {
+ let list = &by_file[file];
+ let mut score = path_bonus.get(file).copied().unwrap_or(0.0);
+ let mut hits = 0u32;
+ for &(n, w) in &weights {
+ let in_text: u32 = list
+ .iter()
+ .flat_map(|&i| counts[i].iter())
+ .filter(|(name, _)| *name == n)
+ .map(|(_, c)| *c)
+ .sum();
+ let here = defines(n, file);
+ if in_text > 0 || here {
+ score += if here { 2.0 * w } else { w };
+ hits += in_text;
+ }
+ }
+ if score > 0.0 {
+ scored.push((score, hits, file));
+ }
+ }
+ scored.sort_by(|a, b| b.0.total_cmp(&a.0).then(b.1.cmp(&a.1)).then(a.2.cmp(b.2)));
+ let mut ranking = Vec::new();
+ for (_, _, file) in &scored {
+ let list = &by_file[file];
+ let mut passages: Vec<(f64, usize)> = list
+ .iter()
+ .map(|&i| {
+ let mut score = 0.0;
+ for &(n, w) in &weights {
+ let in_text = counts[i].iter().any(|(name, _)| *name == n);
+ let here = passage_defines(n, &rows[i]);
+ if in_text || here {
+ score += if here { 2.0 * w } else { w };
+ }
+ }
+ (score, i)
+ })
+ .collect();
+ passages.sort_by(|a, b| b.0.total_cmp(&a.0).then(a.1.cmp(&b.1)));
+ let best = passages.first().map_or(0.0, |p| p.0);
+ for (score, i) in passages.into_iter().take(PER_FILE) {
+ // A file the question names by path gives its first passage
+ // even when no name is in it.
+ if score <= 0.0 && best > 0.0 {
+ break;
+ }
+ ranking.push(s(&rows[i], "identity").to_string());
+ if best <= 0.0 {
+ break;
+ }
+ }
+ if ranking.len() >= RANKED {
+ break;
+ }
+ }
+ ranking.truncate(RANKED);
+ let mut names: Vec<String> = kept.iter().map(|&n| named.names[n].clone()).collect();
+ names.sort();
+ let defining = defining_outside_source(&named.names, &kept, &defined);
+ Ranked {
+ ranking,
+ names,
+ paths: paths_found,
+ defined: kept.iter().filter(|&&n| !defined[n].is_empty()).count(),
+ files: scored.len(),
+ defining,
+ }
+}
+
+/// The files that define one of the `kept` names written as code
+/// ([`code_like`]) when no source file defines that name. A name a source
+/// file defines points at that source, so a test or a document that defines
+/// it too (a mock, a copy in an example) stays lowered; a plain word a test
+/// defines (`repos`, `Book`) says little about that test. A test helper or a
+/// fixture only tests define (`make_client`) keeps its test's weight.
+fn defining_outside_source(
+ names: &[String],
+ kept: &[usize],
+ defined: &[Vec<(String, usize)>],
+) -> Vec<String> {
+ let source = |origin: &str| {
+ crate::code_question::path_class(origin.strip_prefix("file:").unwrap_or(origin))
+ == crate::code_question::PathClass::Source
+ };
+ let files: BTreeSet<&String> = kept
+ .iter()
+ .filter(|&&n| code_like(&names[n]))
+ .filter(|&&n| !defined[n].iter().any(|(file, _)| source(file)))
+ .flat_map(|&n| defined[n].iter().map(|(file, _)| file))
+ .collect();
+ files.into_iter().cloned().collect()
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ #[test]
+ fn identifiers_and_paths_are_read_from_code_and_prose() {
+ let text = "`noinline` breaks in core/lib/globals_api.h#L172 and Store::open \
+ calls parse_config() with HTTPServer.\n```\nlet header = read_header(buf);\n```\n\
+ See the e.g. docs and version 1.2.";
+ let named = named(text);
+ assert_eq!(named.paths, ["core/lib/globals_api.h"]);
+ for name in [
+ "noinline",
+ "globals_api",
+ "Store::open",
+ "Store",
+ "parse_config",
+ "HTTPServer",
+ "header",
+ "read_header",
+ "buf",
+ ] {
+ assert!(named.names.contains(&name.to_string()), "{name}: {named:?}");
+ }
+ for word in ["breaks", "calls", "docs", "let", "open", "version"] {
+ assert!(
+ !named.names.contains(&word.to_string()),
+ "{word}: {named:?}"
+ );
+ }
+ for word in [
+ "parseConfig",
+ "ParseConfig",
+ "utf8Decoder",
+ "int64Value",
+ "HTTPServer",
+ "IsNull",
+ "MyModel",
+ ] {
+ assert!(code_like(word), "{word}");
+ }
+ for word in ["iPhone", "eBay", "iPad", "iOS", "x86", "Parse"] {
+ assert!(!code_like(word), "{word}");
+ }
+ }
+
+ fn row(identity: &str, path: &str, text: &str) -> Value {
+ json!({"identity":identity,"kind":"source","origin":format!("file:{path}"),"text":text,
+ "source":{"id":format!("file:{path}"),"path":path,"line":1,"end_line":text.lines().count()}})
+ }
+
+ #[test]
+ fn files_rank_by_the_specific_names_they_hold_and_named_paths_first() {
+ let rows = vec![
+ row("a0", "src/a.rs", "fn other() {}\nlet x = common_name;"),
+ row("b0", "src/b.rs", "fn parse_config() { common_name }"),
+ row("b1", "src/b.rs", "fn unrelated() {}"),
+ row(
+ "c0",
+ "src/c.rs",
+ "parse_config(); common_name; parse_config();",
+ ),
+ row("d0", "docs/guide.md", "nothing here"),
+ row("e0", "src/e.rs", "common_name"),
+ ];
+ let named = Named {
+ names: vec!["parse_config".into(), "common_name".into()],
+ paths: vec!["docs/guide.md".into()],
+ };
+ let ranked = rank(&rows, &named, None);
+ // The named path first; then the files with the rarer name, the one
+ // with more matches first; then the common name alone.
+ assert_eq!(ranked.ranking, ["d0", "c0", "b0", "a0", "e0"]);
+ assert_eq!(ranked.files, 5);
+ assert_eq!(ranked.paths, ["docs/guide.md"]);
+ // No name or path in the project: nothing ranked.
+ let none = Named {
+ names: vec!["absent_name".into()],
+ paths: vec![],
+ };
+ assert!(rank(&rows, &none, None).ranking.is_empty());
+ }
+
+ #[test]
+ fn only_code_names_no_source_file_defines_keep_their_definers_weight() {
+ let at = |file: &str| (format!("file:{file}"), 1);
+ let names: Vec<String> = [
+ "run_agent",
+ "make_client",
+ "exampleConfig",
+ "repos",
+ "absent_name",
+ ]
+ .iter()
+ .map(|name| name.to_string())
+ .collect();
+ let defined = vec![
+ // A source file and a test define it: the source is what the
+ // question names, and the test stays lowered.
+ vec![at("src/agent.rs"), at("tests/agent.rs")],
+ // Only a test defines it (a fixture): that test keeps its weight.
+ vec![at("tests/conftest.py")],
+ // Only a document defines it: so does the document.
+ vec![at("docs/example.md")],
+ // A plain word only a test defines: the test stays lowered.
+ vec![at("tests/workspace.test.ts")],
+ // Nothing defines it.
+ vec![],
+ ];
+ assert_eq!(
+ defining_outside_source(&names, &[0, 1, 2, 3, 4], &defined),
+ ["file:docs/example.md", "file:tests/conftest.py"]
+ );
+ assert!(defining_outside_source(&names, &[0, 3, 4], &defined).is_empty());
+ }
+}
diff --git a/crates/graphicle/src/identifier_route.rs b/crates/graphicle/src/identifier_route.rs
new file mode 100644
index 0000000..daed832
--- /dev/null
+++ b/crates/graphicle/src/identifier_route.rs
@@ -0,0 +1,782 @@
+//! The identifier route of `context`, which `recall_project` in the
+//! essentials set and `graphicle context` take unless told otherwise, and
+//! the HTTP API and the SDKs when a call asks: a question that is an
+//! identifier, or names identifiers and asks only where they are defined or
+//! used, gets each name's definitions and references from the project's
+//! code graph as `path:line` citations, within the call's budget, instead of
+//! the full retrieval ([`answer`]). One line names the reviewed memories
+//! linked to those definitions ([`crate::symbol_links`]).
+//!
+//! A name is a backtick span that reads as an identifier, a `snake_case` or
+//! `SCREAMING_CASE` word, a camelCase or PascalCase word with an inner
+//! capital, a dotted or `::` path, or a call `name()` ([`classify`]). The
+//! other words of the question may only ask where the names are or who uses
+//! them ([`LOOKUP`]), and at least one must ask that ([`WHERE_OR_USED`]):
+//! "where is `parse` defined", "who calls ParseConfig".
+//! Every other question keeps the retrieval: one in plain words (a lone
+//! plain word too, which reads as prose as often as code), and one that asks
+//! more about the names it gives ("how does `parse` handle errors"), whose
+//! excerpts the retrieval ranks with the named code. So does a call that
+//! names `needs` or turns `graph_retrieval` off, a project without a
+//! recorded code graph, and a question none of whose names the code graph
+//! defines in the caller's view of the project.
+//!
+//! The switch is `identifier_route` (left out:
+//! [`crate::query::IDENTIFIER_ROUTE_DEFAULT`], off, for `context`;
+//! [`crate::api::identifier_route_default`] for `recall_project`); a
+//! project packet's `route` says which path ran and why ([`REPORT`]). The
+//! route's packet has no excerpts: its `evidence` and `sources` are empty.
+use crate::code_graph_arm::{self, Located, Reading};
+use crate::store::{Principal, s};
+use crate::{Error, Result, graph_projection, integer, string};
+use graphicle::graph::Graph;
+use graphicle::record::Properties;
+use graphicle_memory::graph::span;
+use rusqlite::Connection;
+use serde_json::{Value, json};
+use std::collections::{BTreeSet, HashMap};
+use std::sync::LazyLock;
+
+/// The switch, which `recall_project` takes beside its published contract
+/// like the other recall switches ([`crate::api::RECALL_SWITCHES`]).
+pub const FIELD: &str = "identifier_route";
+/// The packet field that says which path ran: `{"path": "identifier"}`, or
+/// `{"path": "retrieval", "reason": ...}`.
+pub const REPORT: &str = "route";
+/// Names one question may look up; a question naming more keeps the
+/// retrieval.
+pub const MAX_NAMES: usize = 8;
+/// Definitions listed per name.
+pub const MAX_DEFINITIONS: usize = 20;
+/// Titles of linked reviewed memories the text names.
+pub const MAX_LINKED_TITLES: usize = 8;
+/// The answer's last line before the budget line: how an agent reads on
+/// (a terminal leaves it out, [`crate::terminal::context_text`]).
+pub const READ_ON: &str =
+ "read_project_source reads any of these lines; a question in plain words gets excerpts.";
+
+/// The call's switch, and whether the call left it out (then it is
+/// [`crate::query::IDENTIFIER_ROUTE_DEFAULT`]).
+pub fn switch(args: &Value) -> Result<(bool, bool)> {
+ match args.get(FIELD) {
+ None | Some(Value::Null) => Ok((crate::query::IDENTIFIER_ROUTE_DEFAULT, true)),
+ Some(Value::Bool(on)) => Ok((*on, false)),
+ Some(_) => Err(Error::bad("identifier_route must be true or false")),
+ }
+}
+
+/// What a question asks, for the route.
+#[derive(Debug, PartialEq, Eq)]
+pub enum Shape {
+ /// Names, and words that only ask where they are defined or used.
+ Lookup(Vec<String>),
+ /// Names, and words that ask more about them.
+ AsksMore(Vec<String>),
+ /// No name: a question in plain words.
+ PlainWords,
+}
+
+/// The words a lookup may use beside its names, separated by spaces
+/// (compared in lower case).
+pub const LOOKUP: &str = "\
+ a all an and any are at attribute attributes call called caller callers calling calls \
+ can class classes code const constant constants could declaration declarations declare \
+ declared declares def define defined defines definition definitions do each enum enums \
+ every field fields file files find fn from func function functions get give i identifier \
+ identifiers impl implement implementation implementations implemented implements import \
+ imported importer importers imports in instance instances interface interfaces \
+ invocations invoke invoked invokes is it its line lines list live lives locate located \
+ location locations look lookup macro macros me member members method methods module \
+ modules name names of on or please properties property ref reference referenced \
+ references referencing refs search show site sites source struct structs symbol symbols \
+ that the their them these this those to trait traits type types up usage usages use used \
+ uses using var variable variables was we were what where which who whom whose";
+
+/// Whether `word` (in lower case) is one of [`LOOKUP`].
+fn lookup_word(word: &str) -> bool {
+ LOOKUP.split_whitespace().any(|lookup| lookup == word)
+}
+
+/// The words of [`LOOKUP`] that ask where a name is or what uses it: a
+/// question with words besides its names takes the route only with one of
+/// these ("what is `X`", "show me the code of `X`" and "list the fields of
+/// `X`" ask for content or members, which the retrieval's excerpts hold).
+pub const WHERE_OR_USED: &str = "\
+ where who whom whose find locate located location locations lookup define defines \
+ defined definition definitions declare declares declared declaration declarations use \
+ uses used using usage usages call calls called calling caller callers invoke invokes \
+ invoked invocations ref refs reference references referenced referencing import imports \
+ imported importer importers implement implements implemented implementations lives site \
+ sites";
+
+/// Whether `word` (in lower case) is one of [`WHERE_OR_USED`].
+fn where_or_used(word: &str) -> bool {
+ WHERE_OR_USED.split_whitespace().any(|usage| usage == word)
+}
+
+/// The last segments that make a dotted word a file name, not a symbol.
+const FILE_EXTENSIONS: &[&str] = &[
+ "c", "cc", "cfg", "cjs", "cpp", "cs", "css", "env", "go", "h", "hpp", "html", "ini", "java",
+ "js", "json", "jsx", "kt", "kts", "lock", "md", "mjs", "php", "proto", "py", "pyi", "rb", "rs",
+ "scala", "scss", "sh", "sql", "svelte", "swift", "toml", "ts", "tsx", "txt", "vue", "xml",
+ "yaml",
+];
+
+static BACKTICKS: LazyLock<regex::Regex> =
+ LazyLock::new(|| regex::Regex::new(r"`[^`\n]+`").expect("the backtick rule"));
+static WORD: LazyLock<regex::Regex> = LazyLock::new(|| {
+ regex::Regex::new(r"[A-Za-z_][A-Za-z0-9_]*(?:(?:::|\.|#)[A-Za-z_][A-Za-z0-9_]*)*(?:\(\))?")
+ .expect("the word rule")
+});
+static IDENTIFIER: LazyLock<regex::Regex> = LazyLock::new(|| {
+ regex::Regex::new(r"^[A-Za-z_][A-Za-z0-9_]*(?:(?:::|\.|#)[A-Za-z_][A-Za-z0-9_]*)*(?:\(\))?$")
+ .expect("the identifier rule")
+});
+static CAPITAL: LazyLock<regex::Regex> = LazyLock::new(|| {
+ regex::Regex::new(r"[a-z0-9][A-Z]|[A-Z]{2}[a-z]").expect("the inner capital rule")
+});
+
+/// Whether a word outside backticks is a name: a call `name()`, a `::` or
+/// `#` path, a dotted path that is not a file name (`parser.py`) or an
+/// abbreviation (`e.g`), a word with an underscore, or one with an inner
+/// capital (`parseConfig`, `ParseConfig`, `HTTPServer`). A plain word
+/// (`parser`, `Config`, `API`) is not.
+fn is_name(word: &str) -> bool {
+ let bare = word.strip_suffix("()").unwrap_or(word);
+ if bare.len() < word.len() || bare.contains("::") || bare.contains('#') {
+ return true;
+ }
+ if bare.contains('.') {
+ let segments: Vec<&str> = bare.split('.').collect();
+ let last = segments.last().map(|s| s.to_ascii_lowercase());
+ return !segments.iter().all(|segment| segment.len() <= 1)
+ && !last.is_some_and(|last| FILE_EXTENSIONS.contains(&last.as_str()));
+ }
+ (bare.contains('_') && bare.chars().any(|c| c.is_ascii_alphanumeric()))
+ || CAPITAL.is_match(bare)
+}
+
+/// Add `name` once, in the order the question gives.
+fn push(names: &mut Vec<String>, name: &str) {
+ let name = name.strip_suffix("()").unwrap_or(name).to_string();
+ if !names.contains(&name) {
+ names.push(name);
+ }
+}
+
+/// The names `question` gives and what it asks about them ([`Shape`]).
+pub fn classify(question: &str) -> Shape {
+ let mut names = Vec::new();
+ // Backtick spans first: one that reads as an identifier is a name, plain
+ // word or not; the words of any other span count as words.
+ let mut rest = String::new();
+ let mut last = 0;
+ for span in BACKTICKS.find_iter(question) {
+ rest.push_str(&question[last..span.start()]);
+ rest.push(' ');
+ last = span.end();
+ let inner = span.as_str().trim_matches('`').trim();
+ if IDENTIFIER.is_match(inner) {
+ push(&mut names, inner);
+ } else {
+ rest.push_str(inner);
+ rest.push(' ');
+ }
+ }
+ rest.push_str(&question[last..]);
+ let mut words = String::new();
+ let mut last = 0;
+ for word in WORD.find_iter(&rest) {
+ if is_name(word.as_str()) {
+ push(&mut names, word.as_str());
+ words.push_str(&rest[last..word.start()]);
+ words.push(' ');
+ last = word.end();
+ }
+ }
+ words.push_str(&rest[last..]);
+ if names.is_empty() {
+ return Shape::PlainWords;
+ }
+ let words: Vec<String> = words
+ .split(|c: char| !c.is_alphanumeric())
+ .filter(|word| !word.is_empty())
+ .map(str::to_lowercase)
+ .collect();
+ // A bare name, or names with words that only ask where they are or what
+ // uses them, and at least one word that asks that.
+ let lookup = words.iter().all(|word| lookup_word(word))
+ && (words.is_empty() || words.iter().any(|word| where_or_used(word)));
+ if lookup {
+ Shape::Lookup(names)
+ } else {
+ Shape::AsksMore(names)
+ }
+}
+
+/// What [`answer`] did: the identifier route's packet, or the `route`
+/// report of a call that keeps the retrieval.
+#[derive(Debug)]
+pub enum Routed {
+ Answered(Value),
+ Retrieval(Value),
+}
+
+/// One reference to a definition: where a relation to it was read.
+#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord)]
+struct Reference {
+ relpath: String,
+ line: Option<usize>,
+ relation: String,
+ from: Option<String>,
+}
+
+/// A string attribute of a node or edge.
+fn text(attributes: &impl Properties, key: &str) -> Option<String> {
+ attributes
+ .get(key)
+ .and_then(Value::as_str)
+ .filter(|value| !value.is_empty())
+ .map(str::to_string)
+}
+
+/// A symbol's dotted name: its `qualified_name`, else its label without a
+/// call's `()` and a method's leading `.`.
+pub(crate) fn symbol_name(attributes: &impl Properties) -> Option<String> {
+ text(attributes, "qualified_name").or_else(|| {
+ text(attributes, "label").map(|label| {
+ label
+ .trim()
+ .trim_end_matches("()")
+ .trim_start_matches('.')
+ .to_string()
+ })
+ })
+}
+
+/// Relations that are not references: containment, and the relations
+/// between a rationale or a concept and code.
+const NOT_REFERENCES: [&str; 3] = [
+ "rationale_for",
+ "semantically_similar_to",
+ "conceptually_related_to",
+];
+
+/// The code symbols of `graph` that `name` defines: those whose dotted name
+/// ends with the longest suffix of the name's segments (`Store::open` and
+/// `store.Store.open` find `Store.open`); a path's last segment alone counts
+/// only in a file whose path names one of the path's other segments, so
+/// `os.path.join` does not find every `join`.
+fn definitions(symbols: &[(usize, String, String)], name: &str) -> Vec<usize> {
+ let dotted = name.replace("::", ".").replace('#', ".");
+ let mut segments: Vec<&str> = dotted.split('.').filter(|s| !s.is_empty()).collect();
+ while segments.len() > 1 && ["self", "this", "crate", "super"].contains(&segments[0]) {
+ segments.remove(0);
+ }
+ let ends_with = |qualified: &str, path: &str| {
+ qualified == path
+ || qualified
+ .strip_suffix(path)
+ .is_some_and(|head| head.ends_with('.'))
+ };
+ for k in 0..segments.len() {
+ let suffix = segments[k..].join(".");
+ let last_only = k + 1 == segments.len() && segments.len() > 1;
+ let found: Vec<usize> = symbols
+ .iter()
+ .filter(|(_, qualified, relpath)| {
+ ends_with(qualified, &suffix)
+ && (!last_only
+ || relpath
+ .split(['/', '.'])
+ .any(|part| segments[..k].contains(&part)))
+ })
+ .map(|(index, _, _)| *index)
+ .collect();
+ if !found.is_empty() {
+ return found;
+ }
+ }
+ Vec::new()
+}
+
+/// The references to node `index`: the other end of every relation that
+/// points to it, cited where the relation was read (the edge's file and
+/// line, else the referring node's), when `citable` allows that file and,
+/// under the lag fallback (`unchanged`), the relation was read from an
+/// unchanged file.
+fn references(
+ graph: &Graph,
+ index: usize,
+ citable: &dyn Fn(&str) -> bool,
+ unchanged: Option<&BTreeSet<String>>,
+) -> Vec<Reference> {
+ let mut incident = graph.out_edges(index);
+ if graph.is_directed() {
+ incident.extend(graph.in_edges(index));
+ }
+ let mut found = BTreeSet::new();
+ for (_, _, edge) in incident {
+ // The extractor's direction (`_src`, `_tgt`) when the stored edge
+ // lost it.
+ let node = |key: &str| edge.attributes.get(key).and_then(|id| graph.node_index(id));
+ let (source, target) = match (node("_src"), node("_tgt")) {
+ (Some(a), Some(b))
+ if BTreeSet::from([a, b]) == BTreeSet::from([edge.source, edge.target]) =>
+ {
+ (a, b)
+ }
+ _ => (edge.source, edge.target),
+ };
+ if target != index || source == index {
+ continue;
+ }
+ let relation = text(&edge.attributes, "relation").unwrap_or_default();
+ if graphicle::markdown_resolution::CONTAINMENT_RELATIONS.contains(&relation.as_str())
+ || NOT_REFERENCES.contains(&relation.as_str())
+ {
+ continue;
+ }
+ if let Some(unchanged) = unchanged
+ && !code_graph_arm::edge_files(&edge.attributes)
+ .iter()
+ .any(|file| unchanged.contains(file))
+ {
+ continue;
+ }
+ let referrer = &graph.nodes()[source].attributes;
+ let (relpath, line) = match (
+ text(&edge.attributes, "source_file").map(|path| path.replace('\\', "/")),
+ span::start_line(&edge.attributes),
+ ) {
+ (Some(path), Some(line)) => (path, Some(line)),
+ _ => match code_graph_arm::relpath(referrer) {
+ Some(path) => (path, span::start_line(referrer)),
+ None => continue,
+ },
+ };
+ if !citable(&relpath) {
+ continue;
+ }
+ let from = code_graph_arm::code_symbol(referrer)
+ .then(|| symbol_name(referrer))
+ .flatten();
+ found.insert(Reference {
+ relpath,
+ line,
+ relation,
+ from,
+ });
+ }
+ found.into_iter().collect()
+}
+
+/// `path:line`, or `path:start-end`, or the path alone.
+fn cite(relpath: &str, line: Option<usize>, end: Option<usize>) -> String {
+ match (line, end) {
+ (Some(line), Some(end)) if end > line => format!("{relpath}:{line}-{end}"),
+ (Some(line), _) => format!("{relpath}:{line}"),
+ (None, _) => relpath.to_string(),
+ }
+}
+
+/// The identifier route for one project's `context` call: the packet of
+/// definitions and references when the question takes it (see the module
+/// documentation), else the `route` report the retrieval's packet carries.
+/// `repository` is authorized for `p`; the caller's view of it (with
+/// `include` and `metadata`) decides what may be cited.
+pub fn answer(db: &Connection, p: &Principal, repository: &Value, args: &Value) -> Result<Routed> {
+ let (on, defaulted) = switch(args)?;
+ let question = string(args, "question", 16000)?;
+ let retrieval = |reason: &str, names: &[String]| -> Result<Routed> {
+ Ok(Routed::Retrieval(
+ json!({"path":"retrieval","reason":reason,
+ FIELD:on,"defaulted":defaulted,"names":names}),
+ ))
+ };
+ if !on {
+ return retrieval("off", &[]);
+ }
+ let names = match classify(question) {
+ Shape::PlainWords => return retrieval("plain_words", &[]),
+ Shape::AsksMore(names) => return retrieval("asks_more", &names),
+ Shape::Lookup(names) => names,
+ };
+ if names.len() > MAX_NAMES {
+ return retrieval("too_many_names", &names);
+ }
+ if args["needs"]
+ .as_array()
+ .is_some_and(|needs| !needs.is_empty())
+ {
+ return retrieval("needs", &names);
+ }
+ if args["graph_retrieval"] == false {
+ return retrieval("graph_retrieval_off", &names);
+ }
+ let max_tokens = integer(args, "max_tokens", 3000, 16000)?.max(256);
+ let max_chars = integer(args, "max_chars", 12000, 64000)?.max(2000);
+ let filter = crate::query::Filter::parse(args)?;
+ // The code graph the code-graph arm reads; one that cannot be read
+ // leaves the question to the retrieval, as a degraded arm never fails
+ // a query.
+ let id = s(repository, "id");
+ let heads = crate::store::heads(db, id)?;
+ let current = graph_projection::episode_of(&heads);
+ let Some(Reading { episode, lag }) = code_graph_arm::reading(db, id, &heads, &current)
+ .ok()
+ .flatten()
+ else {
+ return retrieval("no_code_graph", &names);
+ };
+ let Ok(handle) = graph_projection::resident(db, id, &episode) else {
+ return retrieval("no_code_graph", &names);
+ };
+ let graph: &Graph = &handle;
+ // The names' definitions in the code graph first: when it defines none
+ // of them, the retrieval answers before any source is read here.
+ let symbols: Vec<(usize, String, String)> = graph
+ .nodes()
+ .iter()
+ .enumerate()
+ .filter(|(_, node)| code_graph_arm::code_symbol(&node.attributes))
+ .filter_map(|(index, node)| {
+ Some((
+ index,
+ symbol_name(&node.attributes)?,
+ code_graph_arm::relpath(&node.attributes)?,
+ ))
+ })
+ .collect();
+ let candidates: Vec<(&String, Vec<usize>)> = names
+ .iter()
+ .map(|name| (name, definitions(&symbols, name)))
+ .collect();
+ if candidates.iter().all(|(_, found)| found.is_empty()) {
+ return retrieval("not_in_code_graph", &names);
+ }
+ let mut documents = crate::memory::documents(db, repository, p)?;
+ if let Some(filter) = &filter {
+ documents.retain(|document| filter.keeps(document));
+ }
+ let view: HashMap<&str, &Value> = documents
+ .iter()
+ .map(|document| (s(document, "id"), document))
+ .collect();
+ let unchanged = lag.as_ref().map(|lag| &lag.unchanged);
+ let citable = |path: &str| {
+ view.contains_key(format!("file:{path}").as_str())
+ && unchanged.is_none_or(|unchanged| unchanged.contains(path))
+ };
+ let starts = code_graph_arm::symbol_starts(graph);
+ let mut found: Vec<(String, Vec<Located>, Vec<Reference>)> = Vec::new();
+ let mut missing = Vec::new();
+ for (name, indices) in candidates {
+ let mut defined: Vec<(usize, Located)> = indices
+ .into_iter()
+ .filter_map(|index| {
+ let node_id = match &graph.nodes()[index].id {
+ Value::String(id) => id.clone(),
+ other => other.to_string(),
+ };
+ code_graph_arm::locate(graph, &starts, &node_id, &view)
+ .map(|located| (index, located))
+ })
+ .filter(|(_, located)| citable(&located.relpath))
+ .collect();
+ if defined.is_empty() {
+ missing.push(name.clone());
+ continue;
+ }
+ defined.sort_by(|(_, a), (_, b)| (&a.relpath, a.line).cmp(&(&b.relpath, b.line)));
+ let mut used = BTreeSet::new();
+ for (index, _) in &defined {
+ used.extend(references(graph, *index, &citable, unchanged));
+ }
+ let defined = defined.into_iter().map(|(_, located)| located).collect();
+ found.push((name.clone(), defined, used.into_iter().collect()));
+ }
+ if found.is_empty() {
+ return retrieval("not_in_code_graph", &names);
+ }
+ // The text, within the budget: the header, then per name its
+ // definitions and references while they fit, then the footer.
+ let mut markdown = format!(
+ "Graphicle code graph of {}: where the names in the question are defined and used, as path:line.\n",
+ s(repository, "name")
+ );
+ let footer = |omitted: usize| {
+ format!(
+ "{READ_ON}\nBudget: {max_tokens} cl100k_base reference tokens / {max_chars} characters. Omitted: {omitted} definitions and references.\n"
+ )
+ };
+ let reserve = footer(usize::MAX);
+ let reserve_tokens = graphicle_memory::text::count(&reserve);
+ let reserve_chars = reserve.chars().count();
+ let mut tokens = graphicle_memory::text::count(&markdown);
+ let mut chars = markdown.chars().count();
+ let mut omitted = 0usize;
+ let mut fits = |markdown: &mut String, line: String| {
+ let (more_tokens, more_chars) =
+ (graphicle_memory::text::count(&line), line.chars().count());
+ if tokens + more_tokens + reserve_tokens <= max_tokens
+ && chars + more_chars + reserve_chars <= max_chars
+ {
+ tokens += more_tokens;
+ chars += more_chars;
+ markdown.push_str(&line);
+ true
+ } else {
+ false
+ }
+ };
+ let mut symbols_out = Vec::new();
+ for (name, defined, used) in &found {
+ let head = format!(
+ "`{name}`: {} definition{}, {} reference{}\n",
+ defined.len(),
+ if defined.len() == 1 { "" } else { "s" },
+ used.len(),
+ if used.len() == 1 { "" } else { "s" }
+ );
+ let mut listed_definitions = Vec::new();
+ let mut listed_references = Vec::new();
+ if fits(&mut markdown, head) {
+ for located in defined.iter().take(MAX_DEFINITIONS) {
+ let qualified = located.facts["qualified_name"]
+ .as_str()
+ .or_else(|| located.facts["label"].as_str())
+ .unwrap_or(name);
+ let line = format!(
+ "- definition {} {qualified}\n",
+ cite(&located.relpath, Some(located.line), Some(located.end_line))
+ );
+ if !fits(&mut markdown, line) {
+ break;
+ }
+ listed_definitions.push(json!({"relpath":located.relpath,"line":located.line,
+ "end_line":located.end_line,"qualified_name":located.facts["qualified_name"],
+ "label":located.facts["label"],"stable_id":located.facts["stable_id"]}));
+ }
+ if listed_definitions.len() == defined.len().min(MAX_DEFINITIONS) {
+ for reference in used {
+ let from = reference
+ .from
+ .as_deref()
+ .map(|from| format!(", in {from}"))
+ .unwrap_or_default();
+ let line = format!(
+ "- reference {} {}{from}\n",
+ cite(&reference.relpath, reference.line, None),
+ reference.relation
+ );
+ if !fits(&mut markdown, line) {
+ break;
+ }
+ listed_references.push(json!({"relpath":reference.relpath,
+ "line":reference.line,"relation":reference.relation,"from":reference.from}));
+ }
+ }
+ }
+ omitted += defined.len() - listed_definitions.len() + used.len() - listed_references.len();
+ symbols_out.push(json!({"name":name,"definitions":listed_definitions,
+ "references":listed_references,"definition_count":defined.len(),
+ "reference_count":used.len()}));
+ }
+ // The reviewed memories linked to the definitions (crate::symbol_links),
+ // in one line, unless the call leaves memory out.
+ let mut linked: Vec<Value> = Vec::new();
+ if args["memory_retrieval"] != false {
+ let mut nodes: Vec<Value> = found
+ .iter()
+ .flat_map(|(_, defined, _)| defined.iter())
+ .map(|located| json!({"stable_id": located.facts["stable_id"]}))
+ .collect();
+ crate::symbol_links::attach(db, p, repository, &mut nodes)?;
+ let mut seen = BTreeSet::new();
+ for memory in nodes
+ .iter()
+ .flat_map(|node| node["linked"]["memories"].as_array().into_iter().flatten())
+ {
+ if seen.insert(s(memory, "id").to_string()) {
+ linked
+ .push(json!({"id":memory["id"],"kind":memory["kind"],"title":memory["title"]}));
+ }
+ }
+ if !linked.is_empty() {
+ let titles: Vec<String> = linked
+ .iter()
+ .take(MAX_LINKED_TITLES)
+ .map(|memory| format!("{} (memory {})", s(memory, "title"), s(memory, "id")))
+ .collect();
+ let more = linked.len().saturating_sub(MAX_LINKED_TITLES);
+ let more = if more > 0 {
+ format!("; {more} more")
+ } else {
+ String::new()
+ };
+ let line = format!(
+ "Reviewed memory linked to these symbols: {}{more}\n",
+ titles.join("; ")
+ );
+ fits(&mut markdown, line);
+ }
+ }
+ if !missing.is_empty() {
+ let names: Vec<String> = missing.iter().map(|name| format!("`{name}`")).collect();
+ let line = format!("Not defined in the code graph: {}\n", names.join(", "));
+ fits(&mut markdown, line);
+ }
+ markdown.push_str(&footer(omitted));
+ let mut route = json!({"path":"identifier",FIELD:true,"defaulted":defaulted,
+ "names":names,"not_found":missing,"episode":episode});
+ if let Some(lag) = &lag {
+ route["episode_lag"] = json!(lag.changed);
+ route["current_episode"] = json!(lag.current);
+ }
+ let packet = json!({
+ "repository_id": id,
+ "question": question,
+ "markdown": markdown,
+ "characters": markdown.chars().count(),
+ "max_chars": max_chars,
+ "tokens": graphicle_memory::text::count(&markdown),
+ "max_tokens": max_tokens,
+ "tokenizer": "cl100k_base (reference; agent tokenization may differ)",
+ "symbols": symbols_out,
+ "linked_memories": linked,
+ "evidence": [],
+ "sources": [],
+ "memories": [],
+ "omitted": {"definitions_and_references": omitted},
+ "unresolved_needs": [],
+ "complete_evidence_guaranteed": false,
+ "model_calls": 0,
+ "remote_model_calls": 0,
+ "mechanisms": {"switches": crate::query::switches(args, "project")?,
+ "graph_episode": episode},
+ "code_graph": {"status": "identifier_route", "episode": episode,
+ "episode_lag": lag.as_ref().map_or(0, |lag| lag.changed)},
+ "freshness": crate::invalidation::repository_freshness(db, &p.workspace, id)?,
+ REPORT: route,
+ });
+ Ok(Routed::Answered(packet))
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ fn lookup(names: &[&str]) -> Shape {
+ Shape::Lookup(names.iter().map(|name| name.to_string()).collect())
+ }
+
+ #[test]
+ fn an_identifier_or_a_lookup_of_names_takes_the_route() {
+ for (question, names) in [
+ ("`parse_config`", vec!["parse_config"]),
+ ("parse_config", vec!["parse_config"]),
+ ("ParseConfig", vec!["ParseConfig"]),
+ ("parseConfig()", vec!["parseConfig"]),
+ ("Store::open", vec!["Store::open"]),
+ ("os.path.join", vec!["os.path.join"]),
+ ("`parser`", vec!["parser"]),
+ ("Where is `Store` defined?", vec!["Store"]),
+ (
+ "who calls parse_config and ParseConfig",
+ vec!["parse_config", "ParseConfig"],
+ ),
+ ("find all references to HTTPServer", vec!["HTTPServer"]),
+ ("usages of MAX_NAMES", vec!["MAX_NAMES"]),
+ ] {
+ assert_eq!(classify(question), lookup(&names), "{question}");
+ }
+ }
+
+ #[test]
+ fn plain_words_and_questions_that_ask_more_keep_the_retrieval() {
+ for question in [
+ "how does the parser handle errors",
+ "parser",
+ "Config",
+ "where is config.rs",
+ "API keys e.g. tokens",
+ "`graphicle setup`",
+ ] {
+ assert_eq!(classify(question), Shape::PlainWords, "{question}");
+ }
+ for (question, names) in [
+ (
+ "how does `parse_config` handle a missing file?",
+ vec!["parse_config"],
+ ),
+ ("why is ParseConfig slow", vec!["ParseConfig"]),
+ ("where is `Store` defined in `src/store.rs`", vec!["Store"]),
+ // Content, members, outgoing calls and mentions, not where a
+ // name is or what uses it.
+ ("What is MAX_NAMES?", vec!["MAX_NAMES"]),
+ ("what is `parse_config` used for", vec!["parse_config"]),
+ (
+ "what do parse_config and load_config do",
+ vec!["parse_config", "load_config"],
+ ),
+ ("what type is user_id", vec!["user_id"]),
+ ("show me the code of parse_config", vec!["parse_config"]),
+ (
+ "give me the implementation of Store::open",
+ vec!["Store::open"],
+ ),
+ ("list the fields of `RecallArgs`", vec!["RecallArgs"]),
+ ("callees of parse_config", vec!["parse_config"]),
+ (
+ "what functions are called by parse_config",
+ vec!["parse_config"],
+ ),
+ ("where is `RetryPolicy` mentioned", vec!["RetryPolicy"]),
+ ] {
+ assert_eq!(
+ classify(question),
+ Shape::AsksMore(names.iter().map(|n| n.to_string()).collect()),
+ "{question}"
+ );
+ }
+ }
+
+ #[test]
+ fn every_where_or_used_word_is_a_lookup_word() {
+ for word in WHERE_OR_USED.split_whitespace() {
+ assert!(lookup_word(word), "{word}");
+ }
+ }
+
+ #[test]
+ fn a_path_finds_its_longest_matching_suffix() {
+ let symbols = vec![
+ (0, "Store.open".to_string(), "src/store.rs".to_string()),
+ (1, "open".to_string(), "src/files.rs".to_string()),
+ (2, "join".to_string(), "lib/path/util.py".to_string()),
+ (3, "join".to_string(), "lib/strings.py".to_string()),
+ ];
+ assert_eq!(definitions(&symbols, "Store::open"), vec![0]);
+ assert_eq!(definitions(&symbols, "crate::store::Store::open"), vec![0]);
+ assert_eq!(definitions(&symbols, "self.open"), vec![0, 1]);
+ assert_eq!(definitions(&symbols, "open"), vec![0, 1]);
+ // A path's last segment alone: only in a file its path names.
+ assert_eq!(definitions(&symbols, "os.path.join"), vec![2]);
+ assert!(definitions(&symbols, "Reader.join").is_empty());
+ assert!(definitions(&symbols, "pen").is_empty());
+ }
+
+ #[test]
+ fn the_switch_is_a_boolean_left_out_as_the_default() {
+ assert_eq!(
+ switch(&json!({})).unwrap(),
+ (crate::query::IDENTIFIER_ROUTE_DEFAULT, true)
+ );
+ assert_eq!(
+ switch(&json!({"identifier_route":false})).unwrap(),
+ (false, false)
+ );
+ assert!(switch(&json!({"identifier_route":"no"})).is_err());
+ }
+}
diff --git a/crates/graphicle/src/ingestion.rs b/crates/graphicle/src/ingestion.rs
index 72c25c4..ea59a94 100644
--- a/crates/graphicle/src/ingestion.rs
+++ b/crates/graphicle/src/ingestion.rs
@@ -39,7 +39,8 @@ pub const MAX_BACKOFF_SECONDS: i64 = 30 * 60;
pub const INTERACTIVE: &[&str] = &["context", "search", "impact", "status", "read", "source"];
/// Kinds whose cost is dominated by local CPU (extraction, local inference)
-/// rather than remote provider latency.
+/// rather than remote provider latency. Installed extensions add the kinds
+/// they declare CPU-bound (`extension::JobKind::cpu`).
pub const CPU_BOUND: &[&str] = &["project", "link", "embed", "semantic_overlay"];
pub fn interactive(kind: &str) -> bool {
@@ -47,6 +48,9 @@ pub fn interactive(kind: &str) -> bool {
}
pub fn cpu_bound(kind: &str) -> bool {
CPU_BOUND.contains(&kind)
+ || crate::extension::installed()
+ .job_kind(kind)
+ .is_some_and(|declared| declared.cpu)
}
/// Every non-source, non-projection job may call a model.
pub fn model_bound(kind: &str) -> bool {
@@ -192,6 +196,7 @@ impl Limiter {
let mut excluded = Vec::new();
if admission.cpu.is_none() {
excluded.extend(CPU_BOUND.iter().copied());
+ excluded.extend(crate::extension::installed().cpu_bound_kinds());
}
if admission.model.is_none() {
excluded.extend(
diff --git a/crates/graphicle/src/jobs.rs b/crates/graphicle/src/jobs.rs
index e421b38..25bbd13 100644
--- a/crates/graphicle/src/jobs.rs
+++ b/crates/graphicle/src/jobs.rs
@@ -650,6 +650,8 @@ fn import_link_job(store: &Store, job: &Job) -> Result<Value> {
"repositories": summary["repositories"].as_array().map_or(0, Vec::len),
"hidden_repositories": summary["hidden_repositories"],
"unprojected_repositories": summary["unprojected_repositories"],
+ "relinked": summary["relinked"],
+ "reused": summary["reused"],
"trigger": job.payload["trigger"],
"episode": job.payload["episode"],
});
@@ -946,6 +948,8 @@ pub fn check(args: &Value, config: &model::Config) -> Result<&'static str> {
"memory_retrieval",
"graph_retrieval",
"doc_links",
+ "symbol_links",
+ "notes_first",
"observer_notes",
"verify_answer",
] {
@@ -1216,7 +1220,7 @@ impl Store {
if p.role != "owner" && s(&old, "principal_hash") != p.hash {
return Err(Error::denied());
}
- if !p.permits(permission(s(&old, "kind"))?) {
+ if !crate::store::permitted(db, p, permission(s(&old, "kind"))?)? {
return Err(Error::denied());
}
if !["failed", "cancelled"].contains(&s(&old, "state")) {
diff --git a/crates/graphicle/src/lib.rs b/crates/graphicle/src/lib.rs
index 79892b6..5fc744d 100644
--- a/crates/graphicle/src/lib.rs
+++ b/crates/graphicle/src/lib.rs
@@ -11,6 +11,7 @@ pub mod capture;
pub mod claims;
pub mod cli;
pub mod code_graph_arm;
+pub mod code_question;
pub mod codex_config;
pub mod connectors;
pub mod core_capabilities;
@@ -31,6 +32,8 @@ mod graph_delta;
mod graph_materialize;
pub mod graph_projection;
pub mod graph_tools;
+pub mod identifier_arm;
+pub mod identifier_route;
pub mod ingestion;
pub mod invalidation;
pub mod jobs;
@@ -41,25 +44,32 @@ pub mod local_inference;
pub mod maintenance;
pub mod memory;
pub mod memory_evidence;
+pub mod metering;
pub mod model;
+pub mod notes_first;
pub mod oauth;
pub mod observer;
+pub mod offboard;
pub mod operations;
+pub mod packs;
pub mod permissions;
pub mod phase;
pub mod platform;
pub mod product;
pub mod projection;
pub mod prompt_context;
+pub mod prompt_hook;
pub mod query;
pub mod releases;
pub mod retention;
pub mod search;
pub mod settings;
pub mod setup;
+pub mod source_age;
pub mod store;
pub mod store_compat;
pub mod structured_memory;
+pub mod symbol_links;
pub mod symbols;
pub mod temporal_graph;
pub mod terminal;
@@ -70,6 +80,7 @@ pub mod work_state;
mod workflow_retrieval;
pub mod workflows;
pub mod workspace;
+pub mod workspace_map;
use axum::{
Json,
diff --git a/crates/graphicle/src/limits.rs b/crates/graphicle/src/limits.rs
index f30866a..d1f2f78 100644
--- a/crates/graphicle/src/limits.rs
+++ b/crates/graphicle/src/limits.rs
@@ -420,7 +420,7 @@ pub fn project_refusal(files: usize, bytes: usize, about: bool, limits: &Limits)
("limit", "environment variable")
};
Error::bad(format!(
- "This project is too large to sync: it has {}. Raise the {limit} with {} in the configuration file (models.json) or the {} {variable_noun}, or leave paths out with .gitignore or .git/info/exclude, or set up a subfolder: graphicle setup path/to/subfolder",
+ "This project is too large to sync: it has {}. Raise the {limit} with {} in the configuration file (models.json) or the {} {variable_noun}, or leave untracked paths out with .gitignore or .git/info/exclude (they cover only files Git does not track; graphicle config set sync.tracked_ignored false, or GRAPHICLE_SYNC_TRACKED_IGNORED=0, leaves out the tracked files they match too), or set up a subfolder: graphicle setup path/to/subfolder",
found.join(" and "),
keys.join(" and "),
variables.join(" and ")
@@ -552,7 +552,7 @@ mod tests {
let refused = project_refusal(12_345, 2048, true, &limits).message;
assert_eq!(
refused,
- "This project is too large to sync: it has about 12,345 text files (the limit is 10). Raise the limit with limits.project_files in the configuration file (models.json) or the GRAPHICLE_MAX_PROJECT_FILES environment variable, or leave paths out with .gitignore or .git/info/exclude, or set up a subfolder: graphicle setup path/to/subfolder"
+ "This project is too large to sync: it has about 12,345 text files (the limit is 10). Raise the limit with limits.project_files in the configuration file (models.json) or the GRAPHICLE_MAX_PROJECT_FILES environment variable, or leave untracked paths out with .gitignore or .git/info/exclude (they cover only files Git does not track; graphicle config set sync.tracked_ignored false, or GRAPHICLE_SYNC_TRACKED_IGNORED=0, leaves out the tracked files they match too), or set up a subfolder: graphicle setup path/to/subfolder"
);
let both = project_refusal(11, 3 << 30, false, &limits).message;
assert!(both.contains(
diff --git a/crates/graphicle/src/local.rs b/crates/graphicle/src/local.rs
index 5fb9eef..15f5a97 100644
--- a/crates/graphicle/src/local.rs
+++ b/crates/graphicle/src/local.rs
@@ -212,6 +212,151 @@ pub(crate) fn folder_walk(root: &Path) -> ignore::WalkBuilder {
walk
}
+/// The environment variable that turns reading the tracked files an
+/// ignore pattern matches ([`tracked_ignored`]) off (`0`, `false`, `off` or
+/// `no`) or on (any other value); it wins over the configuration file's
+/// `sync.tracked_ignored` ([`tracked_ignored_setting`]).
+pub const TRACKED_IGNORED_VARIABLE: &str = "GRAPHICLE_SYNC_TRACKED_IGNORED";
+
+/// The configuration file's `sync.tracked_ignored`, installed by the command
+/// line after it loads the file ([`install_tracked_ignored`]).
+static TRACKED_IGNORED_SETTING: std::sync::OnceLock<bool> = std::sync::OnceLock::new();
+
+/// Make the configuration's `sync.tracked_ignored` this process's setting.
+pub fn install_tracked_ignored(config: &crate::model::Config) {
+ if let Some(on) = config.sync.as_ref().and_then(|sync| sync.tracked_ignored) {
+ let _ = TRACKED_IGNORED_SETTING.set(on);
+ }
+}
+
+/// Whether a folder sync reads the tracked files an ignore pattern matches:
+/// [`TRACKED_IGNORED_VARIABLE`] when it is set, else the configuration
+/// file's `sync.tracked_ignored` (`config`, or the installed one), else yes.
+pub fn tracked_ignored_setting(config: Option<&crate::model::Config>) -> bool {
+ if let Ok(value) = std::env::var(TRACKED_IGNORED_VARIABLE) {
+ return !matches!(
+ value.trim().to_ascii_lowercase().as_str(),
+ "0" | "false" | "off" | "no"
+ );
+ }
+ config
+ .and_then(|config| config.sync.as_ref())
+ .and_then(|sync| sync.tracked_ignored)
+ .or_else(|| TRACKED_IGNORED_SETTING.get().copied())
+ .unwrap_or(true)
+}
+
+/// The files under `root` that its Git repository tracks although a
+/// `.gitignore` (or `.git/info/exclude`, or the global excludes) pattern
+/// matches them (`git ls-files --cached --ignored --exclude-standard`),
+/// which [`folder_walk`] leaves out: Git still versions them, so they are
+/// the project's sources (a repository that ignores `jsonata.js` for its
+/// build output and tracks `src/jsonata.js`). A file an `.ignore` file
+/// leaves out stays out, as in the walk; so do [`SKIPPED_NAMES`] and
+/// [`skipped_file`]'s files, and only regular files count. Empty outside a
+/// Git work tree, when Git fails, or when [`tracked_ignored_setting`] says
+/// no.
+pub(crate) fn tracked_ignored(root: &Path) -> Vec<PathBuf> {
+ if !tracked_ignored_setting(None)
+ || !root.ancestors().any(|folder| folder.join(".git").exists())
+ {
+ return Vec::new();
+ }
+ let Some(listed) = crate::fresh::git(
+ root,
+ &[
+ "ls-files",
+ "-z",
+ "--cached",
+ "--ignored",
+ "--exclude-standard",
+ ],
+ ) else {
+ return Vec::new();
+ };
+ let mut dot_ignore = DotIgnore::new(root);
+ listed
+ .split(|byte| *byte == 0)
+ .filter_map(|path| std::str::from_utf8(path).ok())
+ .filter(|relative| {
+ !relative.is_empty()
+ && !relative
+ .split('/')
+ .any(|part| SKIPPED_NAMES.contains(&part))
+ && !skipped_file(relative)
+ })
+ .filter(|relative| !dot_ignore.ignores(relative))
+ .map(|relative| root.join(relative))
+ .filter(|path| std::fs::symlink_metadata(path).is_ok_and(|meta| meta.is_file()))
+ .collect()
+}
+
+/// The `.ignore` files of a folder, read once each: the walk honours them
+/// (as ripgrep does), so the tracked files they leave out stay out too.
+struct DotIgnore {
+ root: PathBuf,
+ folders: std::collections::HashMap<PathBuf, Option<ignore::gitignore::Gitignore>>,
+}
+
+impl DotIgnore {
+ fn new(root: &Path) -> Self {
+ Self {
+ root: root.to_path_buf(),
+ folders: std::collections::HashMap::new(),
+ }
+ }
+
+ /// Whether the `.ignore` files from `relative`'s folder up to the root
+ /// leave it out: the deepest one that matches decides (`!pattern`
+ /// takes it back in).
+ fn ignores(&mut self, relative: &str) -> bool {
+ let path = self.root.join(relative);
+ let mut folder = path.parent().map(Path::to_path_buf);
+ while let Some(current) = folder {
+ if !current.starts_with(&self.root) {
+ break;
+ }
+ let matcher = self.folders.entry(current.clone()).or_insert_with(|| {
+ let file = current.join(".ignore");
+ file.is_file().then(|| {
+ let mut builder = ignore::gitignore::GitignoreBuilder::new(&current);
+ builder.add(&file);
+ builder.build().ok()
+ })?
+ });
+ if let Some(matcher) = matcher {
+ let found = matcher.matched_path_or_any_parents(&path, false);
+ if found.is_ignore() {
+ return true;
+ }
+ if found.is_whitelist() {
+ return false;
+ }
+ }
+ folder = current.parent().map(Path::to_path_buf);
+ }
+ false
+ }
+}
+
+/// [`folder_walk`]'s entries, then one for each of [`tracked_ignored`]'s
+/// files: what a folder sync and the freshness scan read. The folder itself
+/// is the first entry.
+pub(crate) fn folder_entries(
+ root: &Path,
+) -> impl Iterator<Item = std::result::Result<ignore::DirEntry, ignore::Error>> {
+ let tracked = tracked_ignored(root);
+ folder_walk(root)
+ .build()
+ .chain(tracked.into_iter().flat_map(|path| {
+ ignore::WalkBuilder::new(path)
+ .standard_filters(false)
+ .follow_links(false)
+ .max_depth(Some(0))
+ .build()
+ }))
+}
+
/// Graphicle's own writes are not the project's evidence:
/// the Graphicle section of an AGENTS.md or CLAUDE.md reads as blank lines,
/// so the file's other lines keep their numbers, and a file left blank is
@@ -451,7 +596,18 @@ pub fn sync_folder(
// Past a project limit: the files and text counted so far, the rest
// counted without reading it.
let mut over: Option<(usize, usize, bool)> = None;
- for entry in folder_walk(&root).build() {
+ // The tracked files an ignore pattern matches, which the walk is
+ // followed by: counted when read (`tracked_ignored` in the result).
+ let tracked: std::collections::HashSet<PathBuf> = tracked_ignored(&root).into_iter().collect();
+ let tracked_entries = tracked.clone().into_iter().flat_map(|path| {
+ ignore::WalkBuilder::new(path)
+ .standard_filters(false)
+ .follow_links(false)
+ .max_depth(Some(0))
+ .build()
+ });
+ let mut tracked_read = 0usize;
+ for entry in folder_walk(&root).build().chain(tracked_entries) {
let entry = match entry {
Ok(entry) => entry,
Err(error) => {
@@ -463,7 +619,9 @@ pub fn sync_folder(
continue;
}
};
- if entry.depth() == 0 || entry.file_type().is_some_and(|t| t.is_dir()) {
+ // The folder, a directory, or (depth 0 too) a tracked file the walk
+ // left out, which is read.
+ if entry.path() == root.as_path() || entry.file_type().is_some_and(|t| t.is_dir()) {
continue;
}
let path = entry.path();
@@ -572,7 +730,7 @@ pub fn sync_folder(
binary_bytes += contents.len();
if binary_bytes > limits.folder_document_bytes {
return Err(Error::bad(format!(
- "This folder's documents exceed {} (PDF, Office, EPUB, HTML and image files together). Raise the limit with {}, or leave some out with .gitignore or .git/info/exclude, or set up a subfolder: graphicle setup path/to/subfolder",
+ "This folder's documents exceed {} (PDF, Office, EPUB, HTML and image files together). Raise the limit with {}, or leave untracked ones out with .gitignore or .git/info/exclude (they cover only files Git does not track; graphicle config set sync.tracked_ignored false, or GRAPHICLE_SYNC_TRACKED_IGNORED=0, leaves out the tracked files they match too), or set up a subfolder: graphicle setup path/to/subfolder",
crate::limits::size(limits.folder_document_bytes),
crate::limits::raise("folder_document_bytes")
)));
@@ -612,6 +770,9 @@ pub fn sync_folder(
continue;
}
bytes += content.len();
+ if tracked.contains(path) {
+ tracked_read += 1;
+ }
files.insert(relative, content);
}
if let Some((count, size, about)) = over {
@@ -683,6 +844,11 @@ pub fn sync_folder(
skipped.extend(not_analysed);
skipped.sort_by(|a, b| s(a, "path").cmp(s(b, "path")));
let mut result = json!({"repository_id":repository,"files":file_count,"binary_documents":binaries.len(),"original_bytes":binary_bytes,"bytes":bytes,"excluded":excluded.len(),"snapshot":prepared["snapshot"],"replayed":prepared["replayed"]});
+ // Files read although an ignore pattern matches them, because Git tracks
+ // them (`sync.tracked_ignored`).
+ if tracked_read > 0 {
+ result["tracked_ignored"] = json!(tracked_read);
+ }
if !limited.is_empty() {
result["limited"] = json!(limited);
}
@@ -1169,3 +1335,82 @@ pub fn restore(backup: &std::path::Path, directory: &std::path::Path) -> Result<
json!({"restored":true,"data_dir":directory,"next":"Use graphicle login with your saved workspace access key. Reconnect source accounts and model API keys in Connections; device credentials are excluded from portable backups."}),
)
}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ fn git(root: &Path, args: &[&str]) {
+ let status = std::process::Command::new("git")
+ .arg("-C")
+ .arg(root)
+ .args(args)
+ .env("GIT_CONFIG_NOSYSTEM", "1")
+ .stdout(std::process::Stdio::null())
+ .stderr(std::process::Stdio::null())
+ .status()
+ .unwrap();
+ assert!(status.success(), "git {args:?}");
+ }
+
+ /// A file Git tracks although `.gitignore` matches it is read by the
+ /// sync's walk; an untracked file the pattern matches is not.
+ #[test]
+ fn a_tracked_file_that_gitignore_matches_is_read() {
+ let dir = tempfile::TempDir::new().unwrap();
+ let root = std::fs::canonicalize(dir.path()).unwrap();
+ git(&root, &["init", "-q"]);
+ std::fs::create_dir_all(root.join("src")).unwrap();
+ std::fs::write(root.join(".gitignore"), "jsonata.js\n").unwrap();
+ std::fs::write(root.join("src/jsonata.js"), "function jsonata() {}\n").unwrap();
+ std::fs::write(root.join("jsonata.js"), "built output\n").unwrap();
+ std::fs::write(root.join("a.js"), "a\n").unwrap();
+ git(&root, &["add", ".gitignore", "a.js"]);
+ git(&root, &["add", "-f", "src/jsonata.js"]);
+ assert_eq!(tracked_ignored(&root), [root.join("src/jsonata.js")]);
+ let read: Vec<String> = folder_entries(&root)
+ .flatten()
+ .filter(|entry| entry.file_type().is_some_and(|t| t.is_file()))
+ .map(|entry| {
+ let path = entry.path().strip_prefix(&root).unwrap();
+ path.to_string_lossy().replace('\\', "/")
+ })
+ .collect();
+ assert!(read.contains(&"src/jsonata.js".to_string()), "{read:?}");
+ assert!(read.contains(&"a.js".to_string()), "{read:?}");
+ assert!(!read.contains(&"jsonata.js".to_string()), "{read:?}");
+ // A tracked file an `.ignore` file leaves out stays out, as in the
+ // walk; `!pattern` in a deeper one takes a file back in.
+ std::fs::create_dir_all(root.join("gen/keep")).unwrap();
+ std::fs::write(root.join(".gitignore"), "jsonata.js\ngen/\n").unwrap();
+ std::fs::write(root.join("gen/out.js"), "out\n").unwrap();
+ std::fs::write(root.join("gen/keep/kept.js"), "kept\n").unwrap();
+ git(&root, &["add", "-f", "gen/out.js", "gen/keep/kept.js"]);
+ std::fs::write(root.join(".ignore"), "gen/\n").unwrap();
+ std::fs::write(root.join("gen/keep/.ignore"), "!kept.js\n").unwrap();
+ let tracked = tracked_ignored(&root);
+ assert!(
+ tracked.contains(&root.join("src/jsonata.js")),
+ "{tracked:?}"
+ );
+ assert!(!tracked.contains(&root.join("gen/out.js")), "{tracked:?}");
+ assert!(
+ tracked.contains(&root.join("gen/keep/kept.js")),
+ "{tracked:?}"
+ );
+ // Outside a Git work tree nothing is added.
+ let plain = tempfile::TempDir::new().unwrap();
+ assert!(tracked_ignored(plain.path()).is_empty());
+ // The configuration file's sync.tracked_ignored turns it off (the
+ // environment variable, unset here, would win over it).
+ if std::env::var_os(TRACKED_IGNORED_VARIABLE).is_none() {
+ let off: crate::model::Config =
+ serde_json::from_value(serde_json::json!({"sync":{"tracked_ignored":false}}))
+ .unwrap();
+ assert!(!tracked_ignored_setting(Some(&off)));
+ assert!(tracked_ignored_setting(Some(
+ &crate::model::Config::default()
+ )));
+ }
+ }
+}
diff --git a/crates/graphicle/src/maintenance.rs b/crates/graphicle/src/maintenance.rs
index 7a241f6..b7f5ea3 100644
--- a/crates/graphicle/src/maintenance.rs
+++ b/crates/graphicle/src/maintenance.rs
@@ -30,8 +30,9 @@ fn still_present(
/// Delete one project: queue the cleanup of its published projections,
/// forget its dependency-index entries, purge its graph cache, delete its
/// rows (they cascade) and sign its receipt, with `removed` added to the
-/// receipt's `removed`.
-fn delete_project(
+/// receipt's `removed`. Offboarding runs it on its backups too
+/// ([`crate::offboard`]).
+pub(crate) fn delete_project(
db: &Connection,
p: &store::Principal,
identifier: &str,
@@ -56,6 +57,32 @@ fn delete_project(
deletion::project_receipt(db, p, identifier, &connectors, removed)
}
+/// `project.delete` of a project whose snapshot was checked: the PR scratch
+/// projects `graphicle pr` keeps for it hold copies of its code, so they go
+/// first, each with its own receipt, and the project's receipt names them;
+/// `removed` joins the project's receipt's `removed`.
+fn delete_with_copies(
+ db: &Connection,
+ p: &store::Principal,
+ identifier: &str,
+ mut removed: Value,
+) -> Result<Value> {
+ let copies = crate::folders::scratch_projects(db, identifier)?;
+ let mut scratch = Vec::with_capacity(copies.len());
+ for copy in &copies {
+ scratch.push(delete_project(db, p, copy, json!({}))?);
+ }
+ if !copies.is_empty() {
+ removed["pr_scratch_projects"] = json!(copies);
+ }
+ let receipt = delete_project(db, p, identifier, removed)?;
+ let mut result = json!({"deleted":true,"local_backups_are_separate":true,"receipt":receipt});
+ if !scratch.is_empty() {
+ result["pr_scratch_projects"] = json!(scratch);
+ }
+ Ok(result)
+}
+
/// `retention.apply` with `sources`: forget the documents the policy selects
/// through certified deletion (plan, forget, erase, verify), one receipt per
/// batch of up to 1,000 documents, each carrying the policy. The caller must
@@ -166,20 +193,7 @@ impl Store {
},
"project.delete"=>{
if args["expected_snapshot"]!=repository["snapshot"] {return Err(Error::conflict("Project snapshot changed; inspect it before deleting"));}
- // The PR scratch projects `graphicle pr` keeps for this
- // project hold copies of its code: they go
- // first, each with its own receipt, and this project's
- // receipt names them.
- let copies=crate::folders::scratch_projects(db,identifier)?;
- let mut scratch=Vec::with_capacity(copies.len());
- for copy in &copies {
- scratch.push(delete_project(db,p,copy,json!({}))?);
- }
- let removed=if copies.is_empty() {json!({})} else {json!({"pr_scratch_projects":copies})};
- let receipt=delete_project(db,p,identifier,removed)?;
- let mut result=json!({"deleted":true,"local_backups_are_separate":true,"receipt":receipt});
- if !scratch.is_empty() {result["pr_scratch_projects"]=json!(scratch);}
- Ok(result)
+ delete_with_copies(db,p,identifier,json!({}))
},
"storage.prune"=>{
let keep=integer(args,"keep_snapshots",20,1000)?.max(1);
@@ -257,6 +271,29 @@ impl Store {
}
Ok(result)
}
+ /// Offboarding's deletion of a project ([`crate::offboard`]): what
+ /// `project.delete` does, with `offboarding` (the files it removed and
+ /// what it could not reach) in the project's receipt. Only the owner.
+ pub fn offboard_project(
+ &self,
+ workspace: &str,
+ token: &str,
+ identifier: &str,
+ expected_snapshot: &str,
+ offboarding: Value,
+ ) -> Result<Value> {
+ let mut result = self.authorized(workspace, token, "admin", |db, p| {
+ let repository = repo(db, p, identifier)?;
+ if s(&repository, "snapshot") != expected_snapshot {
+ return Err(Error::conflict(
+ "Project snapshot changed since the offboarding plan was shown; run graphicle offboard again",
+ ));
+ }
+ delete_with_copies(db, p, identifier, json!({"offboarding": offboarding}))
+ })?;
+ result["storage"] = deletion::checkpoint(self)?;
+ Ok(result)
+ }
pub fn backup(&self, path: &Path) -> Result<Value> {
#[cfg(unix)]
use std::os::unix::fs::OpenOptionsExt;
diff --git a/crates/graphicle/src/memory.rs b/crates/graphicle/src/memory.rs
index c48e786..510bf0e 100644
--- a/crates/graphicle/src/memory.rs
+++ b/crates/graphicle/src/memory.rs
@@ -60,7 +60,7 @@ pub fn documents(db: &Connection, repository: &Value, p: &Principal) -> Result<V
&& !crate::permissions::allows(
db,
&p.workspace,
- s(&row, "kind"),
+ crate::connectors::identity_provider(s(&row, "kind")),
&row["metadata"]["provider_permissions"],
p,
integer(&row["config"], "permission_max_age_seconds", 300, 3600)?.max(30) as i64,
@@ -617,7 +617,7 @@ pub(crate) fn apply_review(
args: &Value,
model_review: Option<&Value>,
) -> Result<Value> {
- if !p.permits("approve") {
+ if !crate::store::permitted(db, p, "approve")? {
return Err(Error::denied());
}
let identifier = s(repository, "id");
diff --git a/crates/graphicle/src/metering.rs b/crates/graphicle/src/metering.rs
new file mode 100644
index 0000000..1c97940
--- /dev/null
+++ b/crates/graphicle/src/metering.rs
@@ -0,0 +1,1892 @@
+//! What Graphicle serves, metered: the tokens of the results it returns to a
+//! credential or an agent session.
+//!
+//! **Counted** ([`meter`]):
+//! - every MCP tool result (`tools/call`, over stdio and HTTP, on project and
+//! workspace connections), per tool: the core tools with the graph engine's
+//! navigation tools, the learning, work-state and pull-request tools, and
+//! the installed extensions' tools;
+//! - over HTTP and through `graphicle call` and `graphicle context`, per
+//! operation: every operation a published MCP tool runs, and the other
+//! reads that return a project's source, memory, evidence or graph
+//! ([`TEXT_READS`], and an installed extension's `metered_operations`).
+//! Over HTTP that covers the command routes and the repository routes that
+//! serve such an operation (the graph and impact routes, [`serve_route`]);
+//! - every MCP resource read (`resources/read`: the code-graph report and
+//! statistics a project connection lists);
+//! - the session-start context a capture hook gives a coding agent.
+//!
+//! A call that names no project but whose result names projects (a
+//! workspace connection's recall over every project it may read, or a
+//! workspace-wide report such as an installed extension's digest) is counted
+//! on those projects ([`shares`]): its tokens split by the bytes served from
+//! each, and the call once, on the largest share.
+//!
+//! **Not counted:** the other operations and routes, which return settings,
+//! counts or listings and no project text, or change state without a tool
+//! (for example `observer.status`, `retention.preview`, `connector.list`,
+//! `model.status`, `learning.review`, the project overview route and
+//! workspace administration); the other local commands, which print to the
+//! operator on the server (`graphicle status`, `graphicle work-state`,
+//! `graphicle sessions`, `graphicle ask`); and a result that names no
+//! project, such as `list_projects` (it is still admitted, below).
+//!
+//! A result's tokens are counted with cl100k_base
+//! (`graphicle_memory::text::count`) on the text served: an operation's
+//! result as compact JSON over HTTP, an MCP tool's text content, what the
+//! command line prints (its readable view on a terminal, else indented JSON),
+//! or the start context. They are the tokens Graphicle served, not the
+//! agent's bill: Graphicle does not see or count the agent's own model calls,
+//! its prompts, other tools and output are not counted here, and its model
+//! may count tokens differently.
+//!
+//! **Kept.** Counters only, in `am_served_usage`: per UTC day, project,
+//! credential (`owner` for the owner capability), agent session, channel
+//! ([`Channel`]) and tool or operation, the calls and their tokens. No
+//! question, result, source id or client session id is kept. Rows go with
+//! their project. They are kept 25 months, and rows of a session older than
+//! 90 days are folded into rows without one. `deletion.state` lists the
+//! table as history.
+//!
+//! **Agent sessions.** An MCP stdio connection (`graphicle mcp`), an MCP HTTP
+//! session (the `Mcp-Session-Id` the server issues and signs at `initialize`;
+//! an id it did not sign is labelled [`UNVERIFIED_SESSION`]), or the coding
+//! agent's own session for its start context. A label names the client and
+//! a random id, or the first 12 hex digits of the SHA-256 of the client's
+//! own session id ([`session_label`]). One credential keeps at most
+//! [`SESSIONS_PER_DAY`] session labels a UTC day: the calls of further
+//! sessions that day are counted under one shared label,
+//! [`OTHER_SESSIONS`], so a client that opens session after session cannot
+//! grow the counters without bound.
+//!
+//! **Nothing on the request path.** Metering adds no write under the store
+//! lock to a call. A result's tokens are counted on a thread of its own
+//! after it is served ([`record_text`]), and counts gather in this process.
+//! They reach the store in one write transaction per batch: from a
+//! background thread [`FLUSH_DELAY`] after the first unrecorded count, before
+//! the owner's usage report once the owner is authorized (waiting at most
+//! [`REPORT_WAIT`], [`flush_briefly`]), and when the program ends
+//! ([`flush_all`]). A process that is killed loses its unrecorded counts.
+//!
+//! **Admission.** Every call of a workspace credential goes through one
+//! admission ([`admit`]), in this order: the installed extensions authorize
+//! it (`Extension::authorize`: they may refuse it, narrow its arguments or
+//! set the most tokens one result may hold); then, for a metered call, they
+//! may refuse it as over a quota (`Extension::served_allowed`), with this
+//! process's unrecorded tokens in view ([`Served::unrecorded_tokens`]); then
+//! the call runs; then its result is served ([`Admission::serve`]): a read's
+//! result must fit the one per-call cap (`extension::within_limit`, 413), and
+//! a metered result is counted. What is a read is decided by [`meter`]
+//! ([`Meter::Read`]); a write's result is never refused once the write is
+//! saved. The caller is resolved by authentication only
+//! (`store::authenticate_hash`), so a credential is checked and counted
+//! whichever permissions its role holds. A refused HTTP call keeps the
+//! refusal's status, and a 429 carries `Retry-After` until the next UTC month
+//! ([`refusal`]). The owner capability is never asked. The local command line
+//! and capture hooks are counted, never refused for a quota. Core installs no
+//! extension, so it refuses and caps nothing.
+use crate::{
+ Error, Result,
+ extension::{Access, AccessRequest},
+ store::{Principal, Store, rows},
+};
+use axum::{
+ Json,
+ http::{HeaderMap, StatusCode},
+ response::{IntoResponse, Response},
+};
+use rusqlite::{Connection, TransactionBehavior, params};
+use serde_json::{Value, json};
+use std::{
+ borrow::Cow,
+ collections::{BTreeMap, BTreeSet},
+ future::Future,
+ path::PathBuf,
+ sync::{Condvar, Mutex, MutexGuard, OnceLock, PoisonError},
+ time::{Duration, Instant},
+};
+
+/// Core's reads that no published MCP tool runs and that return a project's
+/// source, memory, evidence or graph: metered over HTTP and the command line
+/// beside the operations the tools run ([`meter`]).
+pub const TEXT_READS: &[&str] = &[
+ "claim.history",
+ "document.original",
+ "document.versions",
+ "graph.cross_edges",
+ "graph.doc_links",
+ "graph.neo4j.search",
+ "graph.query",
+ "graph.source",
+ "history",
+ "memory.export",
+ "memory.template",
+ "observer.context",
+];
+/// Operations that run another one under a second name: metered as it is.
+const ALIASES: &[(&str, &str)] = &[("evidence.read", "read"), ("runtime.status", "status")];
+/// Operations a tool annotated read-only runs that save state all the same
+/// (`graph_link` stores the cross-repository edges): metered as writes, so
+/// their result is never refused after it is saved.
+const WRITES: &[&str] = &["graph.link"];
+/// The label of every MCP HTTP session id this server did not sign.
+pub const UNVERIFIED_SESSION: &str = "mcp:unverified";
+/// The most agent-session labels one credential keeps in a UTC day.
+pub const SESSIONS_PER_DAY: i64 = 200;
+/// The label the calls of a credential's further sessions in a day share
+/// ([`SESSIONS_PER_DAY`]). Client labels always hold a colon, so it names
+/// no client's session.
+pub const OTHER_SESSIONS: &str = "other-sessions";
+/// How long after its first unrecorded count a batch is written.
+pub const FLUSH_DELAY: Duration = Duration::from_secs(5);
+/// The longest a usage report waits for the write lock to record this
+/// process's counts first ([`flush_briefly`]).
+pub const REPORT_WAIT: Duration = Duration::from_secs(1);
+/// Days a session's own rows are kept before they are folded into rows
+/// without a session.
+pub const SESSION_DAYS: i64 = 90;
+/// Days rows are kept: 25 months, as the request counters.
+pub const KEEP_DAYS: i64 = 760;
+/// How long a flush waits for a batch another thread is writing, and for
+/// results still being counted.
+const WAIT: Duration = Duration::from_secs(15);
+/// Results counted at once on threads of their own; beyond this the caller
+/// counts.
+const COUNTING: usize = 16;
+/// Failed background writes before a batch is given up (about five minutes).
+const ATTEMPTS: u32 = 60;
+/// The longest tool or operation name a counter keeps.
+const KIND_MAX: usize = 100;
+
+/// Where a result was served.
+#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord)]
+pub enum Channel {
+ /// An MCP tool result, over stdio or HTTP.
+ Mcp,
+ /// An operation over HTTP from an API client.
+ Http,
+ /// An operation over HTTP from the web app.
+ Web,
+ /// The local command line (`graphicle context`, `graphicle call`).
+ Cli,
+ /// A capture hook's session-start context.
+ Hook,
+}
+
+impl Channel {
+ /// The name reports and the store use.
+ pub fn as_str(self) -> &'static str {
+ match self {
+ Self::Mcp => "mcp",
+ Self::Http => "http",
+ Self::Web => "web",
+ Self::Cli => "cli",
+ Self::Hook => "hook",
+ }
+ }
+ /// An HTTP request's channel: `web` when it carries the web app's
+ /// `X-Graphicle-Request: 1`, else `http`. A label for reports only:
+ /// nothing is limited or exempted by it.
+ pub fn of(headers: &HeaderMap) -> Self {
+ if headers
+ .get("x-graphicle-request")
+ .is_some_and(|value| value == "1")
+ {
+ Self::Web
+ } else {
+ Self::Http
+ }
+ }
+}
+
+/// Where one served result went.
+#[derive(Clone, Debug, PartialEq, Eq)]
+pub struct Call {
+ pub workspace: String,
+ /// The project the result came from.
+ pub repository: String,
+ /// `owner` for the owner capability, else the credential's id.
+ pub credential: String,
+ /// The agent session's label ([`session_label`]); empty for none.
+ pub session: String,
+ pub channel: Channel,
+ /// The MCP tool, the operation, or `session_start`.
+ pub kind: String,
+}
+
+/// A metered call before it runs, as `Extension::served_allowed` sees it.
+#[derive(Clone, Copy, Debug)]
+pub struct Served<'a> {
+ /// The project; empty for a call that names none (admitted, never
+ /// counted).
+ pub repository: &'a str,
+ pub session: &'a str,
+ pub channel: Channel,
+ /// The MCP tool, or the HTTP operation ([`meter`]; [`tools_for`] names
+ /// the tools that run it).
+ pub kind: &'a str,
+ /// Tokens this process served the credential this UTC month that the
+ /// store does not hold yet.
+ pub unrecorded_tokens: u64,
+}
+
+/// How a metered operation or tool is treated.
+#[derive(Clone, Copy, Debug, PartialEq, Eq)]
+pub enum Meter {
+ /// A read: the per-call cap an installed extension sets applies to its
+ /// result ([`Admission::serve`]).
+ Read,
+ /// A write a published tool runs (its tool is not read-only): counted
+ /// and admitted, never refused after it ran.
+ Write,
+}
+
+/// Every metered operation, with how it is metered and the published tools
+/// that run it.
+type Meters = BTreeMap<&'static str, (Meter, Vec<String>)>;
+
+fn meters() -> &'static Meters {
+ // The installed extensions are fixed once installed; before that (and
+ // in Core) the core tools alone.
+ static CORE: OnceLock<Meters> = OnceLock::new();
+ static EDITION: OnceLock<Meters> = OnceLock::new();
+ let extensions = crate::extension::installed();
+ let cell = if extensions.is_empty() {
+ &CORE
+ } else {
+ &EDITION
+ };
+ cell.get_or_init(|| {
+ let mut meters = Meters::new();
+ for tool in crate::api::core_mcp_tools(true, true)
+ .into_iter()
+ .chain(extensions.mcp_tools(true, true))
+ {
+ let meter = if tool.spec["annotations"]["readOnlyHint"] == true {
+ Meter::Read
+ } else {
+ Meter::Write
+ };
+ let entry = meters.entry(tool.operation).or_insert((meter, Vec::new()));
+ if meter == Meter::Write {
+ entry.0 = Meter::Write;
+ }
+ entry.1.push(tool.name().to_string());
+ }
+ for operation in TEXT_READS
+ .iter()
+ .copied()
+ .chain(extensions.metered_operations())
+ {
+ meters.entry(operation).or_insert((Meter::Read, Vec::new()));
+ }
+ for operation in WRITES {
+ if let Some(entry) = meters.get_mut(operation) {
+ entry.0 = Meter::Write;
+ }
+ }
+ for &(alias, operation) in ALIASES {
+ if let Some(entry) = meters.get(operation).cloned() {
+ meters.insert(alias, entry);
+ }
+ }
+ meters
+ })
+}
+
+/// Whether `operation` is metered over HTTP and the command line, and how:
+/// every operation a published MCP tool runs (a [`Meter::Write`] when a tool
+/// that runs it is not read-only, or the operation saves state anyway,
+/// [`WRITES`]), and the other reads that return a project's text
+/// ([`TEXT_READS`], an installed extension's `metered_operations`). `None` for
+/// any other operation. An MCP tool's result is capped only when its
+/// operation is a [`Meter::Read`].
+pub fn meter(operation: &str) -> Option<Meter> {
+ meters().get(operation).map(|(meter, _)| *meter)
+}
+
+/// The published MCP tools (the core tools, learning and work-state tools
+/// included, and the installed extensions' tools) that run `operation`; none
+/// for a metered read no tool runs, or an operation that is not metered.
+pub fn tools_for(operation: &str) -> Vec<String> {
+ meters()
+ .get(operation)
+ .map(|(_, tools)| tools.clone())
+ .unwrap_or_default()
+}
+
+#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord)]
+struct Key {
+ workspace: String,
+ repository: String,
+ day: String,
+ credential: String,
+ session: String,
+ channel: Channel,
+ kind: String,
+}
+
+#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
+struct Count {
+ calls: u64,
+ tokens: u64,
+}
+
+type Counts = BTreeMap<Key, Count>;
+
+fn merge(into: &mut Counts, from: Counts) {
+ for (key, count) in from {
+ let entry = into.entry(key).or_default();
+ entry.calls = entry.calls.saturating_add(count.calls);
+ entry.tokens = entry.tokens.saturating_add(count.tokens);
+ }
+}
+
+/// One store's counts in this process.
+struct Pending {
+ store: Store,
+ counts: Counts,
+ /// Batches being written, by number.
+ writing: BTreeMap<u64, Counts>,
+ /// Results being counted on threads of their own.
+ counting: usize,
+ /// A background flush is scheduled.
+ scheduled: bool,
+}
+
+impl Pending {
+ fn of<'a>(registry: &'a mut Registry, store: &Store) -> &'a mut Pending {
+ registry
+ .stores
+ .entry(place(store))
+ .or_insert_with(|| Pending {
+ store: store.clone(),
+ counts: Counts::new(),
+ writing: BTreeMap::new(),
+ counting: 0,
+ scheduled: false,
+ })
+ }
+ /// Nothing unrecorded, being written or being counted.
+ fn idle(&self) -> bool {
+ self.counts.is_empty() && self.writing.is_empty() && self.counting == 0
+ }
+}
+
+struct Registry {
+ next: u64,
+ stores: BTreeMap<PathBuf, Pending>,
+}
+
+static REGISTRY: Mutex<Registry> = Mutex::new(Registry {
+ next: 0,
+ stores: BTreeMap::new(),
+});
+/// Signalled when a batch has been written or given back.
+static WRITTEN: Condvar = Condvar::new();
+
+fn registry() -> MutexGuard<'static, Registry> {
+ REGISTRY.lock().unwrap_or_else(PoisonError::into_inner)
+}
+
+fn place(store: &Store) -> PathBuf {
+ store.database.as_ref().clone()
+}
+
+fn today() -> String {
+ chrono::Utc::now().format("%Y-%m-%d").to_string()
+}
+
+/// The tokens of a served text (cl100k_base).
+pub fn tokens(text: &str) -> u64 {
+ graphicle_memory::text::count(text) as u64
+}
+
+/// Count one served result of `tokens` tokens. No I/O: the count reaches the
+/// store in a later batch.
+pub fn record(store: &Store, call: &Call, tokens: u64) {
+ add(store, call, 1, tokens);
+}
+
+/// Add `calls` calls and `tokens` tokens to `call`'s counter.
+fn add(store: &Store, call: &Call, calls: u64, tokens: u64) {
+ if call.workspace.is_empty() || call.repository.is_empty() {
+ return;
+ }
+ let key = Key {
+ workspace: call.workspace.clone(),
+ repository: call.repository.clone(),
+ day: today(),
+ credential: call.credential.clone(),
+ session: call.session.clone(),
+ channel: call.channel,
+ kind: call.kind.chars().take(KIND_MAX).collect(),
+ };
+ let schedule = {
+ let mut registry = registry();
+ let pending = Pending::of(&mut registry, store);
+ let count = pending.counts.entry(key).or_default();
+ count.calls = count.calls.saturating_add(calls);
+ count.tokens = count.tokens.saturating_add(tokens);
+ !std::mem::replace(&mut pending.scheduled, true)
+ };
+ if schedule {
+ schedule_flush(store.clone());
+ }
+}
+
+/// The projects a result that names no project serves, with the bytes it
+/// serves from each: the sources of a recall packet (each names its project
+/// in `repository_id`, as an MCP connection records them) and the sections
+/// of a workspace-wide report (`repositories`, each with its
+/// `repository_id`). Empty for a result that names none, such as
+/// `list_projects`.
+pub fn shares(result: &Value) -> Vec<(String, u64)> {
+ let mut bytes: BTreeMap<String, u64> = BTreeMap::new();
+ for item in ["sources", "repositories"]
+ .into_iter()
+ .flat_map(|list| result[list].as_array().into_iter().flatten())
+ {
+ if let Some(project) = item["repository_id"].as_str().filter(|id| !id.is_empty()) {
+ let size = item.to_string().len() as u64;
+ let entry = bytes.entry(project.to_string()).or_default();
+ *entry = entry.saturating_add(size);
+ }
+ }
+ bytes.into_iter().collect()
+}
+
+/// Count `tokens` of a call that names no project on the projects its result
+/// serves ([`shares`]): the tokens split by bytes, the call once, on the
+/// largest share. Nothing is counted without a share.
+fn split(store: &Store, call: &Call, tokens: u64, shares: &[(String, u64)]) {
+ let total: u64 = shares
+ .iter()
+ .map(|(_, bytes)| *bytes)
+ .fold(0, u64::saturating_add);
+ let Some(largest) = shares
+ .iter()
+ .enumerate()
+ .max_by(|(a, (_, x)), (b, (_, y))| x.cmp(y).then(b.cmp(a)))
+ .map(|(index, _)| index)
+ else {
+ return;
+ };
+ let mut given = 0u64;
+ let portions: Vec<u64> = shares
+ .iter()
+ .map(|(_, bytes)| {
+ let portion = if total == 0 {
+ 0
+ } else {
+ (u128::from(tokens) * u128::from(*bytes) / u128::from(total)) as u64
+ };
+ given = given.saturating_add(portion);
+ portion
+ })
+ .collect();
+ for (index, ((project, _), portion)) in shares.iter().zip(portions).enumerate() {
+ // What rounding left over goes with the call, to the largest share.
+ let (calls, tokens) = if index == largest {
+ (1, portion.saturating_add(tokens.saturating_sub(given)))
+ } else {
+ (0, portion)
+ };
+ let mut on = call.clone();
+ on.repository = project.clone();
+ add(store, &on, calls, tokens);
+ }
+}
+
+/// Count a served `text` on a thread of its own, then [`record`] it, so the
+/// caller serves at once; with many results being counted already, count it
+/// here.
+pub fn record_text(store: &Store, call: Call, text: String) {
+ record_served(store, call, text, Vec::new());
+}
+
+/// [`record_text`], for a call that names no project counted on the
+/// projects its result serves ([`shares`], [`split`]).
+pub fn record_served(store: &Store, call: Call, text: String, shares: Vec<(String, u64)>) {
+ if call.repository.is_empty() && shares.is_empty() {
+ return;
+ }
+ let count = move |store: &Store, call: &Call, text: &str| {
+ if call.repository.is_empty() {
+ split(store, call, tokens(text), &shares);
+ } else {
+ record(store, call, tokens(text));
+ }
+ };
+ let threaded = {
+ let mut registry = registry();
+ let pending = Pending::of(&mut registry, store);
+ let free = pending.counting < COUNTING;
+ if free {
+ pending.counting += 1;
+ }
+ free
+ };
+ if !threaded {
+ count(store, &call, &text);
+ return;
+ }
+ let worker = store.clone();
+ let started = std::thread::Builder::new()
+ .name("graphicle-metering".into())
+ .spawn(move || {
+ count(&worker, &call, &text);
+ counted(&worker);
+ });
+ if started.is_err() {
+ // No thread to count it: this one result goes uncounted.
+ counted(store);
+ eprintln!("graphicle: a served result was not counted (no thread)");
+ }
+}
+
+/// A result being counted on its own thread is done.
+fn counted(store: &Store) {
+ if let Some(pending) = registry().stores.get_mut(&place(store)) {
+ pending.counting = pending.counting.saturating_sub(1);
+ }
+ WRITTEN.notify_all();
+}
+
+/// Write `store`'s counts [`FLUSH_DELAY`] from now, and again while more
+/// arrive; a batch that keeps failing is given up after about five minutes,
+/// at once when the store is gone.
+fn schedule_flush(store: Store) {
+ let worker = store.clone();
+ let started = std::thread::Builder::new()
+ .name("graphicle-metering".into())
+ .spawn(move || {
+ let store = worker;
+ let mut failures = 0;
+ loop {
+ std::thread::sleep(FLUSH_DELAY);
+ match flush(&store) {
+ Ok(_) => failures = 0,
+ Err(error) => {
+ failures += 1;
+ let gone = !store.database.exists();
+ if gone || failures >= ATTEMPTS {
+ let lost = discard(&store);
+ if !gone {
+ eprintln!(
+ "graphicle: {lost} served-token counts were not recorded: {}",
+ error.message
+ );
+ }
+ failures = 0;
+ }
+ }
+ }
+ let mut registry = registry();
+ let key = place(&store);
+ let Some(pending) = registry.stores.get_mut(&key) else {
+ return;
+ };
+ if pending.counts.is_empty() {
+ pending.scheduled = false;
+ if pending.idle() {
+ registry.stores.remove(&key);
+ }
+ return;
+ }
+ }
+ });
+ if started.is_err()
+ && let Some(pending) = registry().stores.get_mut(&place(&store))
+ {
+ // No thread: the next count, a report or the program's end writes.
+ pending.scheduled = false;
+ }
+}
+
+/// Drop `store`'s unrecorded counts; how many counters were dropped.
+fn discard(store: &Store) -> usize {
+ registry()
+ .stores
+ .get_mut(&place(store))
+ .map(|pending| std::mem::take(&mut pending.counts).len())
+ .unwrap_or(0)
+}
+
+/// How long a flush waits for each thing it may wait on.
+#[derive(Clone, Copy, Debug)]
+struct Waits {
+ /// Results still being counted on their own threads: this process's own
+ /// work.
+ counting: Duration,
+ /// Batches other threads are writing.
+ batches: Duration,
+ /// The write lock; `None` for the store's usual 10 seconds.
+ lock: Option<Duration>,
+}
+
+/// Write `store`'s unrecorded counts now, after the results still being
+/// counted and any batch another thread is writing (waiting at most [`WAIT`]
+/// for each); how many counters were written.
+pub fn flush(store: &Store) -> Result<usize> {
+ flush_waiting(
+ store,
+ Waits {
+ counting: WAIT,
+ batches: WAIT,
+ lock: None,
+ },
+ )
+}
+
+/// Before a usage report, once its caller is authorized: write this
+/// process's unrecorded counts without waiting for results still being
+/// counted or for batches other threads are writing, and waiting at most
+/// [`REPORT_WAIT`] for the write lock. Counts left over stay unrecorded, and
+/// the report gives them as `unrecorded_tokens` ([`unrecorded_in`]); results
+/// still being counted are in neither.
+pub fn flush_briefly(store: &Store) -> Result<usize> {
+ flush_waiting(
+ store,
+ Waits {
+ counting: Duration::ZERO,
+ batches: Duration::ZERO,
+ lock: Some(REPORT_WAIT),
+ },
+ )
+}
+
+/// [`flush`] within `waits`.
+fn flush_waiting(store: &Store, waits: Waits) -> Result<usize> {
+ let key = place(store);
+ let (number, batch) = {
+ let mut registry = registry();
+ let started = Instant::now();
+ loop {
+ let (counting, writing) = registry.stores.get(&key).map_or((false, false), |pending| {
+ (pending.counting > 0, !pending.writing.is_empty())
+ });
+ // The longest bound of what is still pending.
+ let limit = [(counting, waits.counting), (writing, waits.batches)]
+ .into_iter()
+ .filter(|(pending, _)| *pending)
+ .map(|(_, bound)| bound)
+ .max();
+ let Some(left) = limit.map(|limit| limit.saturating_sub(started.elapsed())) else {
+ break;
+ };
+ if left.is_zero() {
+ break;
+ }
+ registry = WRITTEN
+ .wait_timeout(registry, left)
+ .unwrap_or_else(PoisonError::into_inner)
+ .0;
+ }
+ registry.next += 1;
+ let number = registry.next;
+ let Some(pending) = registry.stores.get_mut(&key) else {
+ return Ok(0);
+ };
+ if pending.counts.is_empty() {
+ return Ok(0);
+ }
+ let batch = std::mem::take(&mut pending.counts);
+ pending.writing.insert(number, batch.clone());
+ (number, batch)
+ };
+ let written = match waits.lock {
+ None => store.transaction(|db| write(db, &batch)),
+ Some(wait) => write_waiting(store, &batch, wait),
+ };
+ {
+ let mut registry = registry();
+ if let Some(pending) = registry.stores.get_mut(&key)
+ && let Some(batch) = pending.writing.remove(&number)
+ && written.is_err()
+ {
+ merge(&mut pending.counts, batch);
+ }
+ }
+ WRITTEN.notify_all();
+ written.map(|()| batch.len())
+}
+
+/// When the program ends: write every store's unrecorded counts, waiting at
+/// most `wait` for each store's lock and other batches (and up to [`WAIT`]
+/// for results still being counted). A failure is reported on standard
+/// error.
+pub fn flush_all(wait: Duration) {
+ let stores: Vec<Store> = registry()
+ .stores
+ .values()
+ .filter(|pending| !pending.idle())
+ .map(|pending| pending.store.clone())
+ .collect();
+ for store in stores {
+ let waits = Waits {
+ counting: WAIT,
+ batches: wait,
+ lock: Some(wait),
+ };
+ if let Err(error) = flush_waiting(&store, waits) {
+ eprintln!(
+ "graphicle: served-token counts were not recorded: {}",
+ error.message
+ );
+ }
+ }
+}
+
+/// A write transaction that waits at most `wait` for the write lock.
+fn write_waiting(store: &Store, batch: &Counts, wait: Duration) -> Result<()> {
+ let mut db = store.connect()?;
+ db.busy_timeout(wait)?;
+ let transaction = db.transaction_with_behavior(TransactionBehavior::Immediate)?;
+ write(&transaction, batch)?;
+ transaction.commit()?;
+ Ok(())
+}
+
+/// Add a batch to the stored counters; counts of a project deleted since are
+/// dropped. Then the retention of the batch's workspaces.
+fn write(db: &Connection, batch: &Counts) -> Result<()> {
+ let mut insert = db.prepare(
+ "INSERT INTO am_served_usage(repository_id,workspace_id,day,credential_id,session,channel,kind,calls,tokens)
+ SELECT ?1,?2,?3,?4,?5,?6,?7,?8,?9 WHERE EXISTS(SELECT 1 FROM repo_projects WHERE id=?1 AND workspace_id=?2)
+ ON CONFLICT(repository_id,day,credential_id,session,channel,kind)
+ DO UPDATE SET calls=calls+excluded.calls,tokens=tokens+excluded.tokens",
+ )?;
+ let mut workspaces = BTreeSet::new();
+ for (key, count) in batch {
+ let session = day_session(db, key)?;
+ insert.execute(params![
+ key.repository,
+ key.workspace,
+ key.day,
+ key.credential,
+ session,
+ key.channel.as_str(),
+ key.kind,
+ count.calls.min(i64::MAX as u64) as i64,
+ count.tokens.min(i64::MAX as u64) as i64,
+ ])?;
+ workspaces.insert(key.workspace.as_str());
+ }
+ let now = chrono::Utc::now();
+ let fold = (now - chrono::Duration::days(SESSION_DAYS))
+ .format("%Y-%m-%d")
+ .to_string();
+ let cutoff = (now - chrono::Duration::days(KEEP_DAYS))
+ .format("%Y-%m-%d")
+ .to_string();
+ for workspace in workspaces {
+ db.execute(
+ "INSERT INTO am_served_usage(repository_id,workspace_id,day,credential_id,session,channel,kind,calls,tokens)
+ SELECT repository_id,workspace_id,day,credential_id,'',channel,kind,sum(calls),sum(tokens)
+ FROM am_served_usage WHERE workspace_id=?1 AND day<?2 AND session<>''
+ GROUP BY repository_id,workspace_id,day,credential_id,channel,kind
+ ON CONFLICT(repository_id,day,credential_id,session,channel,kind)
+ DO UPDATE SET calls=calls+excluded.calls,tokens=tokens+excluded.tokens",
+ params![workspace, fold],
+ )?;
+ db.execute(
+ "DELETE FROM am_served_usage WHERE workspace_id=? AND day<? AND session<>''",
+ params![workspace, fold],
+ )?;
+ db.execute(
+ "DELETE FROM am_served_usage WHERE workspace_id=? AND day<?",
+ params![workspace, cutoff],
+ )?;
+ }
+ Ok(())
+}
+
+/// The session label a counter is written under: its own, unless its
+/// credential already keeps [`SESSIONS_PER_DAY`] other labels that UTC day,
+/// in which case [`OTHER_SESSIONS`].
+fn day_session<'a>(db: &Connection, key: &'a Key) -> Result<&'a str> {
+ if key.session.is_empty() || key.session == UNVERIFIED_SESSION {
+ return Ok(key.session.as_str());
+ }
+ let (known, others): (bool, i64) = db.query_row(
+ "SELECT EXISTS(SELECT 1 FROM am_served_usage WHERE workspace_id=?1 AND credential_id=?2 AND day=?3 AND session=?4),
+ (SELECT count(DISTINCT session) FROM am_served_usage WHERE workspace_id=?1 AND credential_id=?2 AND day=?3
+ AND session NOT IN ('',?5,?6))",
+ params![
+ key.workspace,
+ key.credential,
+ key.day,
+ key.session,
+ UNVERIFIED_SESSION,
+ OTHER_SESSIONS
+ ],
+ |r| Ok((r.get(0)?, r.get(1)?)),
+ )?;
+ Ok(if known || others < SESSIONS_PER_DAY {
+ key.session.as_str()
+ } else {
+ OTHER_SESSIONS
+ })
+}
+
+fn this_month() -> String {
+ chrono::Utc::now().format("%Y-%m-").to_string()
+}
+
+/// Tokens this process served `credential` of `workspace` in the current
+/// UTC month that the store does not hold yet (results still being counted
+/// on their own threads are not in view).
+pub fn unrecorded(store: &Store, workspace: &str, credential: &str) -> u64 {
+ let month = this_month();
+ unrecorded_where(store, |key| {
+ key.workspace == workspace && key.credential == credential && key.day.starts_with(&month)
+ })
+}
+
+/// [`unrecorded`] for every credential of `workspace`.
+pub fn unrecorded_in(store: &Store, workspace: &str) -> u64 {
+ let month = this_month();
+ unrecorded_where(store, |key| {
+ key.workspace == workspace && key.day.starts_with(&month)
+ })
+}
+
+/// [`unrecorded_in`] for the UTC days `from` through `to` (`YYYY-MM-DD`).
+pub fn unrecorded_between(store: &Store, workspace: &str, from: &str, to: &str) -> u64 {
+ unrecorded_where(store, |key| {
+ key.workspace == workspace && key.day.as_str() >= from && key.day.as_str() <= to
+ })
+}
+
+fn unrecorded_where(store: &Store, keep: impl Fn(&Key) -> bool) -> u64 {
+ let registry = registry();
+ let Some(pending) = registry.stores.get(&place(store)) else {
+ return 0;
+ };
+ pending
+ .counts
+ .iter()
+ .chain(pending.writing.values().flatten())
+ .filter(|(key, _)| keep(key))
+ .map(|(_, count)| count.tokens)
+ .fold(0, u64::saturating_add)
+}
+
+/// A client's name as a session label keeps it: lowercase ASCII letters,
+/// digits, `.`, `_` and `-`, at most 40 characters; `agent` when nothing is
+/// left.
+pub fn client_name(name: &str) -> String {
+ let kept: String = name
+ .chars()
+ .map(|c| c.to_ascii_lowercase())
+ .filter(|c| c.is_ascii_alphanumeric() || matches!(c, '.' | '_' | '-'))
+ .take(40)
+ .collect();
+ if kept.is_empty() {
+ "agent".into()
+ } else {
+ kept
+ }
+}
+
+/// The label of a session a client names itself, such as a coding agent's
+/// session for its start context: the client's name and the first 12 hex
+/// digits of the SHA-256 of its session id, never the id.
+pub fn session_label(client: &str, id: &str) -> String {
+ format!(
+ "{}:{}",
+ client_name(client),
+ &graphicle_memory::text::sha256(id.as_bytes())[..12]
+ )
+}
+
+/// A new session label for `client`: its name and a random id.
+pub fn new_session(client: &str) -> String {
+ format!("{}:{}", client_name(client), &crate::id()[..12])
+}
+
+/// The key that signs `workspace`'s MCP HTTP session ids: derived from the
+/// digest of its owner capability, which only the store holds, so a client
+/// cannot make an id of its own pass.
+fn session_key(store: &Store, workspace: &str) -> Option<ring::hmac::Key> {
+ let digest: String = store
+ .read(|db| {
+ Ok(db.query_row(
+ "SELECT capability_hash FROM workspaces WHERE id=?",
+ [workspace],
+ |r| r.get(0),
+ )?)
+ })
+ .ok()?;
+ Some(ring::hmac::Key::new(
+ ring::hmac::HMAC_SHA256,
+ format!("graphicle mcp session\n{digest}").as_bytes(),
+ ))
+}
+
+fn hex(bytes: &[u8]) -> String {
+ bytes.iter().map(|b| format!("{b:02x}")).collect()
+}
+
+fn lower_hex(text: &str, length: usize) -> bool {
+ text.len() == length
+ && text
+ .bytes()
+ .all(|b| b.is_ascii_hexdigit() && !b.is_ascii_uppercase())
+}
+
+/// A new MCP HTTP session id for `client` in `workspace` (`Mcp-Session-Id`):
+/// `<client>.<random>.<signature>`, visible ASCII as the protocol asks. `None`
+/// when the workspace's key cannot be read.
+pub fn issue_http_session(store: &Store, workspace: &str, client: &str) -> Option<String> {
+ let key = session_key(store, workspace)?;
+ let signed = format!("{}.{}", client_name(client), crate::id());
+ let signature = ring::hmac::sign(&key, signed.as_bytes());
+ Some(format!("{signed}.{}", hex(signature.as_ref())))
+}
+
+/// The label of an MCP HTTP session from its `Mcp-Session-Id`: an id this
+/// server issued for `workspace` keeps its client's name and the first 12
+/// digits of its random part; any other value, which a client could vary on
+/// every call, is labelled [`UNVERIFIED_SESSION`].
+pub fn http_session(store: &Store, workspace: &str, id: &str) -> String {
+ let verified = id.rsplit_once('.').and_then(|(signed, signature)| {
+ let (client, random) = signed.rsplit_once('.')?;
+ if client_name(client) != client || !lower_hex(random, 32) || !lower_hex(signature, 64) {
+ return None;
+ }
+ let signature: Vec<u8> = (0..signature.len())
+ .step_by(2)
+ .map(|at| u8::from_str_radix(&signature[at..at + 2], 16))
+ .collect::<std::result::Result<_, _>>()
+ .ok()?;
+ let key = session_key(store, workspace)?;
+ ring::hmac::verify(&key, signed.as_bytes(), &signature).ok()?;
+ Some(format!("{client}:{}", &random[..12]))
+ });
+ verified.unwrap_or_else(|| UNVERIFIED_SESSION.into())
+}
+
+/// The principal `token` authenticates in `workspace`, if any, by
+/// authentication only (`store::authenticate_hash`): a credential is admitted
+/// and counted whichever permissions its role holds.
+pub fn principal(store: &Store, workspace: &str, token: &str) -> Option<Principal> {
+ if token.is_empty() || token.len() > 512 {
+ return None;
+ }
+ let hash = graphicle_memory::text::sha256(token.as_bytes());
+ store
+ .read(|db| crate::store::authenticate_hash(db, workspace, &hash))
+ .ok()
+}
+
+/// One call to admit ([`admit`]).
+#[derive(Debug)]
+pub struct Ask<'a> {
+ /// What the caller asks for, as `Extension::authorize` sees it: the
+ /// operation, or the MCP resource read as `graph.navigate`.
+ pub access: Access<'a>,
+ /// The arguments of an operation, which `Extension::authorize` may narrow.
+ pub arguments: Option<&'a Value>,
+ /// Where its result goes; `credential` is filled in from the caller.
+ pub call: Call,
+ /// Metered: the quota is asked (`Extension::served_allowed`, never for the
+ /// command line or capture hooks) and the result counted.
+ pub metered: bool,
+ /// A read: its result must fit the per-call cap ([`Admission::serve`]).
+ pub read: bool,
+}
+
+/// What [`admit`] allowed: the arguments an installed extension narrowed, and
+/// how the call's result is served ([`Admission::serve`]).
+#[derive(Debug, Default)]
+pub struct Admission {
+ arguments: Option<Value>,
+ /// The one per-call cap of a read's result: the lowest
+ /// `AccessRequest::max_tokens` the installed extensions set.
+ cap: Option<usize>,
+ /// Where a metered result of an authenticated caller is counted.
+ call: Option<Call>,
+}
+
+impl Admission {
+ /// The arguments an installed extension narrowed, if it did: the call
+ /// runs with these.
+ pub fn take_arguments(&mut self) -> Option<Value> {
+ self.arguments.take()
+ }
+ /// Nothing to check or count when the result is served.
+ pub fn is_idle(&self) -> bool {
+ self.cap.is_none() && self.call.is_none()
+ }
+ /// A metered call that names no project: it is counted on the projects
+ /// its result serves ([`shares`]).
+ pub fn needs_shares(&self) -> bool {
+ self.call
+ .as_ref()
+ .is_some_and(|call| call.repository.is_empty())
+ }
+ /// Serve `text`, the text of the admitted call's result: the size check
+ /// of a read (`extension::within_limit`, 413), then the count of a
+ /// metered result ([`record_served`]; `shares` for a call that names no
+ /// project).
+ pub fn serve(self, store: &Store, text: String, shares: Vec<(String, u64)>) -> Result<()> {
+ crate::extension::within_limit(self.cap, &text)?;
+ if let Some(call) = self.call {
+ record_served(store, call, text, shares);
+ }
+ Ok(())
+ }
+ /// [`Self::serve`] for a result served as compact JSON, serialized only
+ /// when there is something to do.
+ pub fn serve_value(self, store: &Store, result: &Value) -> Result<()> {
+ if self.is_idle() {
+ return Ok(());
+ }
+ let shares = if self.needs_shares() {
+ shares(result)
+ } else {
+ Vec::new()
+ };
+ self.serve(store, result.to_string(), shares)
+ }
+}
+
+/// The one admission of a call ([module documentation](self)): the installed
+/// extensions authorize it (`Extension::authorize`), then, for a metered call
+/// from anywhere but the command line and capture hooks, its quota
+/// (`Extension::served_allowed`). The caller then runs it, with the narrowed
+/// arguments ([`Admission::take_arguments`]), and serves its result through
+/// [`Admission::serve`]. The owner capability is never asked, and its
+/// metered results are counted. A caller that does not authenticate is
+/// admitted with nothing to check or count: the call's own authorization
+/// refuses it, as before. Core installs no extension, so it only counts.
+pub fn admit(store: &Store, token: &str, ask: Ask<'_>) -> Result<Admission> {
+ let extensions = crate::extension::installed();
+ let Ask {
+ access,
+ arguments,
+ mut call,
+ metered,
+ read,
+ } = ask;
+ if (!metered && extensions.is_empty()) || token.is_empty() || token.len() > 512 {
+ return Ok(Admission::default());
+ }
+ let hash = graphicle_memory::text::sha256(token.as_bytes());
+ store.read(|db| {
+ let principal = match crate::store::authenticate_hash(db, &call.workspace, &hash) {
+ Ok(principal) => principal,
+ // Not a usable credential: the call's own authorization refuses
+ // it.
+ Err(error) if error.status == StatusCode::FORBIDDEN => {
+ return Ok(Admission::default());
+ }
+ // Anything else fails closed.
+ Err(error) => return Err(error),
+ };
+ let mut admission = Admission::default();
+ if principal.role != "owner" && !extensions.is_empty() {
+ let mut request = AccessRequest {
+ access,
+ arguments: arguments.map(Cow::Borrowed),
+ max_tokens: None,
+ };
+ extensions.authorize(db, &principal, &mut request)?;
+ if let Some(Cow::Owned(narrowed)) = request.arguments {
+ admission.arguments = Some(narrowed);
+ }
+ admission.cap = request.max_tokens.filter(|_| read);
+ if metered && !matches!(call.channel, Channel::Cli | Channel::Hook) {
+ let served = Served {
+ repository: &call.repository,
+ session: &call.session,
+ channel: call.channel,
+ kind: &call.kind,
+ unrecorded_tokens: unrecorded(store, &call.workspace, &principal.credential),
+ };
+ extensions.served_allowed(db, &principal, &served)?;
+ }
+ }
+ if metered {
+ call.credential = principal.credential;
+ admission.call = Some(call);
+ }
+ Ok(admission)
+ })
+}
+
+/// [`admit`] for an HTTP operation, on a blocking thread when there is
+/// anything to ask: authorized as `Access::Operation`, metered when [`meter`]
+/// meters it, and size-checked when it is a [`Meter::Read`]. Its project is
+/// the arguments' `repository_id`.
+pub async fn admit_request(
+ store: &Store,
+ workspace: &str,
+ token: &str,
+ headers: &HeaderMap,
+ operation: &str,
+ args: &Value,
+) -> Result<Admission> {
+ let metered = meter(operation);
+ if metered.is_none() && crate::extension::installed().is_empty() {
+ return Ok(Admission::default());
+ }
+ let call = Call {
+ workspace: workspace.into(),
+ repository: args
+ .get("repository_id")
+ .and_then(Value::as_str)
+ .unwrap_or("")
+ .into(),
+ credential: String::new(),
+ session: String::new(),
+ channel: Channel::of(headers),
+ kind: operation.into(),
+ };
+ let (store, token, operation, args) = (
+ store.clone(),
+ token.to_owned(),
+ operation.to_owned(),
+ args.clone(),
+ );
+ crate::product::blocking(move || {
+ admit(
+ &store,
+ &token,
+ Ask {
+ access: Access::Operation(&operation),
+ arguments: Some(&args),
+ call,
+ metered: metered.is_some(),
+ read: metered == Some(Meter::Read),
+ },
+ )
+ })
+ .await
+}
+
+/// The response to an HTTP call an installed extension refused before it
+/// ran: the refusal's status and message and, for a 429 (a limit of the
+/// current UTC month), `Retry-After` until the next UTC month starts, as the
+/// request budget gives it.
+pub fn refusal(error: Error) -> Response {
+ let limited = error.status == StatusCode::TOO_MANY_REQUESTS;
+ let mut response = error.into_response();
+ if limited {
+ response.headers_mut().insert(
+ axum::http::header::RETRY_AFTER,
+ crate::product::until_next_month(),
+ );
+ }
+ response
+}
+
+/// Serve an admitted HTTP result ([`Admission::serve_value`]) off the async
+/// executor: the size check of a read and the count of a metered result.
+pub async fn served(store: &Store, admission: Admission, result: Value) -> Result<Value> {
+ if admission.is_idle() {
+ return Ok(result);
+ }
+ let store = store.clone();
+ crate::product::blocking(move || {
+ admission.serve_value(&store, &result)?;
+ Ok(result)
+ })
+ .await
+}
+
+/// Marks a response whose result the operation's admission has size-checked
+/// already, so the route boundary does not count it again.
+#[derive(Clone, Copy, Debug)]
+pub struct SizeChecked;
+
+/// Serve `operation` from a route of its own (outside the command routes) as
+/// the command routes serve it: admitted first ([`admit_request`],
+/// [`refusal`]), then `run`, then its result served ([`served`]).
+/// `repository` is empty for a route that names no project.
+pub async fn serve_route(
+ store: &Store,
+ headers: &HeaderMap,
+ workspace: &str,
+ repository: &str,
+ operation: &str,
+ run: impl Future<Output = Result<Value>>,
+) -> Response {
+ let token = match crate::api::token(headers) {
+ Ok(token) => token,
+ Err(error) => return error.into_response(),
+ };
+ let args = json!({ "repository_id": repository });
+ let admission = match admit_request(store, workspace, token, headers, operation, &args).await {
+ Ok(admission) => admission,
+ Err(error) => return refusal(error),
+ };
+ let result = match run.await {
+ Ok(value) => value,
+ Err(error) => return error.into_response(),
+ };
+ match served(store, admission, result).await {
+ Ok(value) => {
+ let mut response = Json(value).into_response();
+ response.extensions_mut().insert(SizeChecked);
+ response
+ }
+ Err(error) => error.into_response(),
+ }
+}
+
+/// The local command line printed `text`, the result of `operation` from
+/// `repository`, to `token`'s credential: count it when the operation is
+/// metered ([`meter`]). Never fails the command.
+pub fn served_locally(
+ store: &Store,
+ workspace: &str,
+ token: &str,
+ repository: &str,
+ operation: &str,
+ text: &str,
+) {
+ if meter(operation).is_some()
+ && !repository.is_empty()
+ && let Some(principal) = principal(store, workspace, token)
+ {
+ let call = Call {
+ workspace: workspace.into(),
+ repository: repository.into(),
+ credential: principal.credential,
+ session: String::new(),
+ channel: Channel::Cli,
+ kind: operation.into(),
+ };
+ record_text(store, call, text.to_string());
+ }
+}
+
+/// What [`summary`] and the reports say about the counts.
+pub const SCOPE: &str = "Tokens of what Graphicle returned: every MCP tool result and MCP resource read; over HTTP and through graphicle call and graphicle context, every operation an MCP tool runs and the other reads of a project's sources, memory, evidence or graph; and capture hooks' session-start context; counted with cl100k_base on the text served. A result that names no project but serves several (such as a recall over every project of the workspace) is counted on those projects, split by the bytes served from each. The other operations and routes, which return settings, counts or listings and no project text (for example observer.status, list_projects and the project overview), are not counted. This is what Graphicle served, not your agents' bill: Graphicle does not see or count their own model calls, their prompts, other tools and output are not counted here, and their models may count tokens differently.";
+
+/// The served counters of `workspace` from day `from` through day `to`
+/// (UTC, `YYYY-MM-DD`): totals, and by channel, tool or operation,
+/// credential, agent session, project and day. Sessions and the other lists
+/// are cut to their largest entries.
+pub fn summary(db: &Connection, workspace: &str, from: &str, to: &str) -> Result<Value> {
+ let scope = params![workspace, from, to];
+ let totals = rows(
+ db,
+ "SELECT coalesce(sum(calls),0) AS calls,coalesce(sum(tokens),0) AS tokens FROM am_served_usage WHERE workspace_id=? AND day>=? AND day<=?",
+ scope,
+ )?
+ .pop()
+ .unwrap_or_else(|| json!({"calls":0,"tokens":0}));
+ let by_channel = rows(
+ db,
+ "SELECT channel,sum(calls) AS calls,sum(tokens) AS tokens FROM am_served_usage WHERE workspace_id=? AND day>=? AND day<=? GROUP BY channel ORDER BY tokens DESC,channel",
+ scope,
+ )?;
+ let by_kind = rows(
+ db,
+ "SELECT channel,kind,sum(calls) AS calls,sum(tokens) AS tokens FROM am_served_usage WHERE workspace_id=? AND day>=? AND day<=? GROUP BY channel,kind ORDER BY tokens DESC,channel,kind LIMIT 100",
+ scope,
+ )?;
+ let by_credential = rows(
+ db,
+ "SELECT u.credential_id,CASE WHEN u.credential_id='owner' THEN 'Workspace owner' ELSE c.label END AS label,
+ CASE WHEN u.credential_id='owner' THEN 'owner' ELSE c.role END AS role,c.revoked_at,
+ sum(u.calls) AS calls,sum(u.tokens) AS tokens
+ FROM am_served_usage u LEFT JOIN credentials c ON c.id=u.credential_id AND c.workspace_id=u.workspace_id
+ WHERE u.workspace_id=? AND u.day>=? AND u.day<=? GROUP BY u.credential_id ORDER BY tokens DESC,u.credential_id LIMIT 200",
+ scope,
+ )?;
+ let by_session = rows(
+ db,
+ "SELECT session,credential_id,group_concat(DISTINCT channel) AS channels,min(day) AS first_day,max(day) AS last_day,
+ sum(calls) AS calls,sum(tokens) AS tokens FROM am_served_usage
+ WHERE workspace_id=? AND day>=? AND day<=? AND session<>'' GROUP BY session,credential_id ORDER BY tokens DESC,session LIMIT 50",
+ scope,
+ )?;
+ let by_project = rows(
+ db,
+ "SELECT u.repository_id,r.name,sum(u.calls) AS calls,sum(u.tokens) AS tokens FROM am_served_usage u
+ JOIN repo_projects r ON r.id=u.repository_id WHERE u.workspace_id=? AND u.day>=? AND u.day<=?
+ GROUP BY u.repository_id ORDER BY tokens DESC,u.repository_id LIMIT 100",
+ scope,
+ )?;
+ let daily = rows(
+ db,
+ "SELECT day,sum(calls) AS calls,sum(tokens) AS tokens FROM am_served_usage WHERE workspace_id=? AND day>=? AND day<=? GROUP BY day ORDER BY day",
+ scope,
+ )?;
+ Ok(json!({
+ "calls":totals["calls"],"tokens":totals["tokens"],"counted_with":"cl100k_base",
+ "by_channel":by_channel,"by_kind":by_kind,"by_credential":by_credential,
+ "by_session":by_session,"by_project":by_project,"daily":daily,"scope":SCOPE
+ }))
+}
+
+/// The model calls Graphicle made for `workspace` from day `from` through
+/// day `to` (UTC), uncached and recorded: by credential (the job's
+/// requester; `owner` for the owner capability, null for calls outside a
+/// job) and by provider protocol and model. Tokens only, no cost.
+pub fn model_usage(db: &Connection, workspace: &str, from: &str, to: &str) -> Result<Value> {
+ let end = next_day(to)?;
+ let by_credential = rows(
+ db,
+ "SELECT CASE WHEN j.principal_hash IS NULL THEN NULL WHEN j.principal_hash=w.capability_hash THEN 'owner' ELSE cr.id END AS credential_id,
+ count(*) AS calls,coalesce(sum(c.input_tokens),0) AS input_tokens,coalesce(sum(c.output_tokens),0) AS output_tokens
+ FROM am_model_calls c JOIN repo_projects r ON r.id=c.repository_id JOIN workspaces w ON w.id=r.workspace_id
+ LEFT JOIN am_jobs j ON j.id=c.job_id
+ LEFT JOIN credentials cr ON cr.capability_hash=j.principal_hash AND cr.workspace_id=r.workspace_id
+ WHERE r.workspace_id=? AND c.cached=0 AND c.created_at>=? AND c.created_at<?
+ GROUP BY 1 ORDER BY input_tokens+output_tokens DESC LIMIT 200",
+ params![workspace, from, end],
+ )?;
+ let by_model = rows(
+ db,
+ "SELECT c.provider,c.model,count(*) AS calls,coalesce(sum(c.input_tokens),0) AS input_tokens,coalesce(sum(c.output_tokens),0) AS output_tokens
+ FROM am_model_calls c JOIN repo_projects r ON r.id=c.repository_id
+ WHERE r.workspace_id=? AND c.cached=0 AND c.created_at>=? AND c.created_at<?
+ GROUP BY c.provider,c.model ORDER BY input_tokens+output_tokens DESC,c.provider,c.model LIMIT 200",
+ params![workspace, from, end],
+ )?;
+ Ok(json!({"by_credential":by_credential,"by_model":by_model}))
+}
+
+/// The UTC day after `day` (`YYYY-MM-DD`).
+pub fn next_day(day: &str) -> Result<String> {
+ chrono::NaiveDate::parse_from_str(day, "%Y-%m-%d")
+ .ok()
+ .and_then(|date| date.succ_opt())
+ .map(|date| date.format("%Y-%m-%d").to_string())
+ .ok_or_else(|| crate::Error::bad("Expected a UTC day as YYYY-MM-DD"))
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ fn fixture() -> (tempfile::TempDir, Store, String, String, String) {
+ let dir = tempfile::tempdir().unwrap();
+ let store = Store::open(dir.path()).unwrap();
+ let created = store.create_workspace("Metering").unwrap();
+ let workspace = created["id"].as_str().unwrap().to_string();
+ let owner = created["capability"].as_str().unwrap().to_string();
+ let project = store
+ .register(
+ &workspace,
+ &owner,
+ &json!({"project_key":"metering","name":"Metering"}),
+ )
+ .unwrap();
+ let repository = project["id"].as_str().unwrap().to_string();
+ (dir, store, workspace, owner, repository)
+ }
+
+ fn call(workspace: &str, repository: &str, credential: &str, session: &str) -> Call {
+ Call {
+ workspace: workspace.into(),
+ repository: repository.into(),
+ credential: credential.into(),
+ session: session.into(),
+ channel: Channel::Mcp,
+ kind: "recall_project".into(),
+ }
+ }
+
+ #[test]
+ fn counts_gather_in_memory_until_a_flush_writes_them_once() {
+ let (_dir, store, workspace, _, repository) = fixture();
+ let first = call(&workspace, &repository, "owner", "claude-code:abc");
+ record(&store, &first, 120);
+ record(&store, &first, 30);
+ record(&store, &call(&workspace, &repository, "key-1", ""), 7);
+ assert_eq!(unrecorded(&store, &workspace, "owner"), 150);
+ assert_eq!(unrecorded(&store, &workspace, "key-1"), 7);
+ assert_eq!(unrecorded(&store, "elsewhere", "owner"), 0);
+ let stored = |store: &Store| -> Vec<Value> {
+ store
+ .read(|db| {
+ rows(
+ db,
+ "SELECT credential_id,session,channel,kind,calls,tokens FROM am_served_usage ORDER BY credential_id,session",
+ [],
+ )
+ })
+ .unwrap()
+ };
+ assert!(stored(&store).is_empty(), "nothing is written on record");
+ assert_eq!(flush(&store).unwrap(), 2);
+ assert_eq!(unrecorded(&store, &workspace, "owner"), 0);
+ let written = stored(&store);
+ assert_eq!(written.len(), 2);
+ assert_eq!(written[0]["credential_id"], "key-1");
+ assert_eq!(written[0]["tokens"], 7);
+ assert_eq!(written[1]["session"], "claude-code:abc");
+ assert_eq!(written[1]["calls"], 2);
+ assert_eq!(written[1]["tokens"], 150);
+ // A second batch adds to the same counters.
+ record(&store, &first, 50);
+ flush(&store).unwrap();
+ assert_eq!(stored(&store)[1]["tokens"], 200);
+ assert_eq!(flush(&store).unwrap(), 0, "nothing left");
+ }
+
+ #[test]
+ fn served_text_is_counted_off_the_callers_path_and_a_flush_waits_for_it() {
+ let (_dir, store, workspace, _, repository) = fixture();
+ let text = "evidence ".repeat(4000);
+ let expected = tokens(&text);
+ for _ in 0..3 {
+ record_text(
+ &store,
+ call(&workspace, &repository, "key-2", ""),
+ text.clone(),
+ );
+ }
+ flush(&store).unwrap();
+ let (calls, total): (i64, i64) = store
+ .read(|db| {
+ Ok(db.query_row(
+ "SELECT sum(calls),sum(tokens) FROM am_served_usage WHERE credential_id='key-2'",
+ [],
+ |r| Ok((r.get(0)?, r.get(1)?)),
+ )?)
+ })
+ .unwrap();
+ assert_eq!((calls, total as u64), (3, 3 * expected));
+ }
+
+ #[test]
+ fn a_failed_write_keeps_its_counts_and_a_deleted_project_drops_them() {
+ let (_dir, store, workspace, owner, repository) = fixture();
+ let blocker = store.connect().unwrap();
+ blocker.execute_batch("BEGIN IMMEDIATE").unwrap();
+ record(&store, &call(&workspace, &repository, "owner", ""), 10);
+ let short = Waits {
+ counting: WAIT,
+ batches: Duration::from_millis(50),
+ lock: Some(Duration::from_millis(50)),
+ };
+ assert!(flush_waiting(&store, short).is_err());
+ assert_eq!(unrecorded(&store, &workspace, "owner"), 10, "kept");
+ blocker.execute_batch("ROLLBACK").unwrap();
+ // The project goes before its counts are written: they are dropped,
+ // and the rest of the batch is written.
+ let other = store
+ .register(
+ &workspace,
+ &owner,
+ &json!({"project_key":"other","name":"Other"}),
+ )
+ .unwrap();
+ let other = other["id"].as_str().unwrap();
+ record(&store, &call(&workspace, other, "owner", ""), 5);
+ store
+ .connect()
+ .unwrap()
+ .execute("DELETE FROM repo_projects WHERE id=?", [other])
+ .unwrap();
+ assert_eq!(flush(&store).unwrap(), 2);
+ let total: i64 = store
+ .read(|db| {
+ Ok(db.query_row("SELECT sum(tokens) FROM am_served_usage", [], |r| r.get(0))?)
+ })
+ .unwrap();
+ assert_eq!(total, 10);
+ }
+
+ #[test]
+ fn old_session_rows_fold_into_rows_without_a_session_and_old_rows_go() {
+ let (_dir, store, workspace, _, repository) = fixture();
+ let db = store.connect().unwrap();
+ let day = |days: i64| {
+ (chrono::Utc::now() - chrono::Duration::days(days))
+ .format("%Y-%m-%d")
+ .to_string()
+ };
+ for (session, days, tokens) in [
+ ("a:1", SESSION_DAYS + 5, 10),
+ ("b:2", SESSION_DAYS + 5, 20),
+ ("", SESSION_DAYS + 5, 1),
+ ("c:3", 1, 40),
+ ("d:4", KEEP_DAYS + 3, 50),
+ ] {
+ db.execute(
+ "INSERT INTO am_served_usage VALUES(?,?,?,'owner',?,'mcp','recall_project',1,?)",
+ params![repository, workspace, day(days), session, tokens],
+ )
+ .unwrap();
+ }
+ record(&store, &call(&workspace, &repository, "owner", ""), 0);
+ flush(&store).unwrap();
+ let left = rows(
+ &db,
+ "SELECT day,session,calls,tokens FROM am_served_usage WHERE tokens>0 ORDER BY day",
+ [],
+ )
+ .unwrap();
+ assert_eq!(
+ left,
+ vec![
+ json!({"day":day(SESSION_DAYS + 5),"session":"","calls":3,"tokens":31}),
+ json!({"day":day(1),"session":"c:3","calls":1,"tokens":40}),
+ ]
+ );
+ }
+
+ #[test]
+ fn session_labels_never_keep_a_clients_own_id() {
+ let (_dir, store, workspace, _, _) = fixture();
+ let label = session_label("Claude Code", "8c1f-secret-session");
+ assert!(label.starts_with("claudecode:"), "{label}");
+ assert_eq!(label.len(), "claudecode:".len() + 12);
+ assert!(!label.contains("secret"));
+ assert_eq!(client_name(" "), "agent");
+ assert_eq!(client_name("Cursor/1.2 (beta)"), "cursor1.2beta");
+ let issued = issue_http_session(&store, &workspace, "Cursor/1.2").unwrap();
+ let (signed, signature) = issued.rsplit_once('.').unwrap();
+ let random = signed.strip_prefix("cursor1.2.").unwrap();
+ assert_eq!((random.len(), signature.len()), (32, 64), "{issued}");
+ assert!(issued.len() <= 200, "the route reads ids up to 200 bytes");
+ assert_eq!(
+ http_session(&store, &workspace, &issued),
+ format!("cursor1.2:{}", &random[..12])
+ );
+ assert_ne!(
+ issue_http_session(&store, &workspace, "Cursor/1.2"),
+ Some(issued.clone())
+ );
+ assert!(new_session("codex").starts_with("codex:"));
+ assert_ne!(new_session("codex"), new_session("codex"));
+ }
+
+ /// A client could send a new `Mcp-Session-Id` with every call and so add
+ /// a counter row each time; only ids this server signed for the
+ /// workspace keep a label of their own.
+ #[test]
+ fn session_ids_this_server_did_not_sign_share_one_label() {
+ let (_dir, store, workspace, _, _) = fixture();
+ let issued = issue_http_session(&store, &workspace, "claude-code").unwrap();
+ let other = store.create_workspace("Other").unwrap();
+ let elsewhere = other["id"].as_str().unwrap();
+ let (signed, signature) = issued.rsplit_once('.').unwrap();
+ let mut flipped = signature.to_string();
+ flipped.replace_range(..1, if signature.starts_with('0') { "1" } else { "0" });
+ let random = &signed["claude-code.".len()..];
+ for forged in [
+ "Client-Chosen-Session".to_string(),
+ format!("claude-code.{random}"),
+ format!("{signed}.{flipped}"),
+ format!("codex.{random}.{signature}"),
+ format!("{signed}.{}", signature.to_uppercase()),
+ format!("{signed}.{signature}0"),
+ format!("{signed}.{}", "é".repeat(32)),
+ String::new(),
+ ] {
+ assert_eq!(
+ http_session(&store, &workspace, &forged),
+ UNVERIFIED_SESSION,
+ "{forged}"
+ );
+ }
+ // Another workspace's key does not sign this one's ids.
+ assert_eq!(http_session(&store, elsewhere, &issued), UNVERIFIED_SESSION);
+ assert_eq!(issue_http_session(&store, "no-such-workspace", "x"), None);
+ }
+
+ #[test]
+ fn every_operation_a_tool_runs_and_the_other_text_reads_are_metered() {
+ for (operation, expected) in [
+ ("context", Some(Meter::Read)),
+ ("read", Some(Meter::Read)),
+ ("evidence.read", Some(Meter::Read)),
+ ("status", Some(Meter::Read)),
+ ("runtime.status", Some(Meter::Read)),
+ ("memories", Some(Meter::Read)),
+ ("memory.history", Some(Meter::Read)),
+ ("interpretation.prepare", Some(Meter::Read)),
+ ("learning.refresh.prepare", Some(Meter::Read)),
+ ("session.timeline", Some(Meter::Read)),
+ ("work_state.read", Some(Meter::Read)),
+ ("workflow.status", Some(Meter::Read)),
+ ("memory.export", Some(Meter::Read)),
+ ("document.original", Some(Meter::Read)),
+ ("claim.history", Some(Meter::Read)),
+ ("graph.source", Some(Meter::Read)),
+ ("graph.neo4j.search", Some(Meter::Read)),
+ ("graph.doc_links", Some(Meter::Read)),
+ ("graph.navigate", Some(Meter::Read)),
+ ("project.list", Some(Meter::Read)),
+ ("graph.link", Some(Meter::Write)),
+ ("memory.propose", Some(Meter::Write)),
+ ("interpretation.propose", Some(Meter::Write)),
+ ("learning.refresh.propose", Some(Meter::Write)),
+ ("work_state.write", Some(Meter::Write)),
+ ("observer.status", None),
+ ("connector.list", None),
+ ("model.status", None),
+ ("learning.review", None),
+ ("memory.import", None),
+ ("build.info", None),
+ ("retention.preview", None),
+ ("graph.project", None),
+ ] {
+ assert_eq!(meter(operation), expected, "{operation}");
+ }
+ assert_eq!(tools_for("read"), ["read_project_source"]);
+ assert_eq!(tools_for("evidence.read"), ["read_project_source"]);
+ assert_eq!(tools_for("memories"), ["project_memory"]);
+ // The graph engine's navigation tools run one operation.
+ let navigation = tools_for("graph.navigate");
+ assert!(
+ ["query_graph", "get_node", "get_neighbors"]
+ .iter()
+ .all(|tool| navigation.iter().any(|listed| listed == tool)),
+ "{navigation:?}"
+ );
+ assert!(tools_for("memory.export").is_empty());
+ assert!(tools_for("observer.status").is_empty());
+ // The other reads are Core operations no published tool runs.
+ for operation in TEXT_READS {
+ assert!(
+ crate::api::CORE_OPERATIONS.contains(operation),
+ "{operation}"
+ );
+ assert!(tools_for(operation).is_empty(), "{operation}");
+ }
+ for (alias, operation) in ALIASES {
+ assert!(crate::api::CORE_OPERATIONS.contains(alias));
+ assert_eq!(meter(alias), meter(operation));
+ }
+ // A write a read-only tool runs: its result is never refused.
+ for operation in WRITES {
+ assert!(!tools_for(operation).is_empty(), "{operation}");
+ assert_eq!(meter(operation), Some(Meter::Write));
+ }
+ }
+
+ /// A usage report records this process's counts first, but waits neither
+ /// for results still being counted nor long for a busy store: what is
+ /// left is reported as unrecorded.
+ #[test]
+ fn a_reports_flush_is_brief_and_leaves_what_it_cannot_write_unrecorded() {
+ let (_dir, store, workspace, _, repository) = fixture();
+ record(&store, &call(&workspace, &repository, "key-1", ""), 12);
+ // A result still being counted on its thread is not waited for.
+ Pending::of(&mut registry(), &store).counting += 1;
+ let started = Instant::now();
+ assert_eq!(flush_briefly(&store).unwrap(), 1);
+ assert!(started.elapsed() < Duration::from_secs(2));
+ counted(&store);
+ assert_eq!(unrecorded_in(&store, &workspace), 0);
+ // A busy store: the report goes on at once, and the counts stay.
+ let blocker = store.connect().unwrap();
+ blocker.execute_batch("BEGIN IMMEDIATE").unwrap();
+ record(&store, &call(&workspace, &repository, "key-1", ""), 30);
+ let started = Instant::now();
+ assert!(flush_briefly(&store).is_err());
+ assert!(started.elapsed() < REPORT_WAIT + Duration::from_secs(2));
+ assert_eq!(unrecorded_in(&store, &workspace), 30);
+ let today = today();
+ assert_eq!(unrecorded_between(&store, &workspace, &today, &today), 30);
+ assert_eq!(
+ unrecorded_between(&store, &workspace, "2020-01-01", "2020-01-31"),
+ 0
+ );
+ blocker.execute_batch("ROLLBACK").unwrap();
+ assert_eq!(flush(&store).unwrap(), 1);
+ }
+
+ /// Only the owner's usage report records counts, and only once the owner
+ /// is authorized; its `unrecorded_tokens` names what is left.
+ #[test]
+ fn the_usage_report_authorizes_the_owner_before_it_writes() {
+ let (_dir, store, workspace, owner, repository) = fixture();
+ let key = store
+ .grant(&workspace, &owner, &json!({"role":"agent","label":"Agent"}))
+ .unwrap();
+ let key = key["capability"].as_str().unwrap();
+ record(&store, &call(&workspace, &repository, "key-1", ""), 40);
+ let refused = store.product_usage(&workspace, key).unwrap_err();
+ assert_eq!(refused.status, StatusCode::FORBIDDEN);
+ assert_eq!(unrecorded_in(&store, &workspace), 40, "nothing written");
+ let usage = store.product_usage(&workspace, &owner).unwrap();
+ assert_eq!(usage["served"]["tokens"], 40);
+ assert_eq!(usage["served"]["unrecorded_tokens"], 0);
+ // A busy store: the report still answers, with the counts left over.
+ let blocker = store.connect().unwrap();
+ blocker.execute_batch("BEGIN IMMEDIATE").unwrap();
+ record(&store, &call(&workspace, &repository, "key-1", ""), 2);
+ let usage = store.product_usage(&workspace, &owner).unwrap();
+ assert_eq!(usage["served"]["tokens"], 40);
+ assert_eq!(usage["served"]["unrecorded_tokens"], 2);
+ blocker.execute_batch("ROLLBACK").unwrap();
+ flush(&store).unwrap();
+ }
+
+ #[test]
+ fn a_quota_refusal_gives_retry_after_until_the_next_utc_month() {
+ let limited = refusal(Error {
+ status: StatusCode::TOO_MANY_REQUESTS,
+ message: "quota".into(),
+ provider_failure: None,
+ });
+ assert_eq!(limited.status(), StatusCode::TOO_MANY_REQUESTS);
+ let seconds: i64 = limited.headers()["retry-after"]
+ .to_str()
+ .unwrap()
+ .parse()
+ .unwrap();
+ assert!((1..=31 * 86_400).contains(&seconds), "{seconds}");
+ let denied = refusal(Error::denied());
+ assert_eq!(denied.status(), StatusCode::FORBIDDEN);
+ assert!(denied.headers().get("retry-after").is_none());
+ }
+
+ /// A call that names no project (a workspace recall) is counted on the
+ /// projects its result serves: tokens split by bytes, the call once on
+ /// the largest share; a result that names none is not counted.
+ #[test]
+ fn a_call_that_names_no_project_is_counted_on_the_projects_it_serves() {
+ let (_dir, store, workspace, owner, a) = fixture();
+ let b = store
+ .register(&workspace, &owner, &json!({"project_key":"b","name":"B"}))
+ .unwrap();
+ let b = b["id"].as_str().unwrap().to_string();
+ let packet = json!({"sources":[
+ {"repository_id":a,"text":"x".repeat(300)},
+ {"repository_id":b,"text":"y".repeat(100)},
+ {"id":"no project"}
+ ]});
+ let parts = shares(&packet);
+ assert_eq!(parts.len(), 2);
+ let text = "evidence ".repeat(500);
+ let expected = tokens(&text);
+ record_served(&store, call(&workspace, "", "key-1", ""), text, parts);
+ record_served(
+ &store,
+ call(&workspace, "", "key-1", ""),
+ "listing".into(),
+ shares(&json!({"projects":[{"id":a}]})),
+ );
+ flush(&store).unwrap();
+ let counted = store
+ .read(|db| {
+ rows(
+ db,
+ "SELECT repository_id,calls,tokens FROM am_served_usage ORDER BY tokens DESC",
+ [],
+ )
+ })
+ .unwrap();
+ assert_eq!(counted.len(), 2, "{counted:?}");
+ assert_eq!(counted[0]["repository_id"], a.as_str());
+ assert_eq!(counted[0]["calls"], 1);
+ assert_eq!(counted[1]["calls"], 0);
+ let total: u64 = counted
+ .iter()
+ .map(|row| row["tokens"].as_u64().unwrap())
+ .sum();
+ assert_eq!(total, expected);
+ assert!(counted[1]["tokens"].as_u64().unwrap() > 0);
+ // Digest sections name their projects too.
+ let digest = json!({"repositories":[{"repository_id":b,"changes":[1,2,3]}]});
+ assert_eq!(shares(&digest)[0].0, b);
+ }
+
+ /// One credential keeps at most SESSIONS_PER_DAY session labels a day;
+ /// further sessions share one label, and known ones keep theirs.
+ #[test]
+ fn a_credential_keeps_at_most_its_daily_sessions() {
+ let (_dir, store, workspace, _, repository) = fixture();
+ for n in 0..SESSIONS_PER_DAY + 3 {
+ record(
+ &store,
+ &call(&workspace, &repository, "key-1", &format!("agent:{n:04}")),
+ 1,
+ );
+ }
+ record(
+ &store,
+ &call(&workspace, &repository, "key-2", "agent:0000"),
+ 1,
+ );
+ flush(&store).unwrap();
+ // A session kept earlier keeps its label in a later batch.
+ record(
+ &store,
+ &call(&workspace, &repository, "key-1", "agent:0000"),
+ 1,
+ );
+ record(
+ &store,
+ &call(&workspace, &repository, "key-1", "agent:9999"),
+ 1,
+ );
+ flush(&store).unwrap();
+ let sessions = |credential: &str| -> Vec<Value> {
+ store
+ .read(|db| {
+ rows(
+ db,
+ "SELECT session,calls FROM am_served_usage WHERE credential_id=? ORDER BY session",
+ [credential],
+ )
+ })
+ .unwrap()
+ };
+ let kept = sessions("key-1");
+ assert_eq!(kept.len() as i64, SESSIONS_PER_DAY + 1);
+ let other = kept
+ .iter()
+ .find(|row| row["session"] == OTHER_SESSIONS)
+ .unwrap();
+ assert_eq!(other["calls"], 4);
+ assert_eq!(kept[0]["session"], "agent:0000");
+ assert_eq!(kept[0]["calls"], 2);
+ assert_eq!(sessions("key-2").len(), 1, "another credential's own day");
+ }
+
+ /// The caller is resolved by authentication only: a credential whose
+ /// role grants no `read` is still known, so it is checked and counted.
+ #[test]
+ fn a_principal_is_resolved_by_authentication_only() {
+ let (_dir, store, workspace, owner, _) = fixture();
+ let granted = store
+ .grant(
+ &workspace,
+ &owner,
+ &json!({"role":"agent","label":"Narrow"}),
+ )
+ .unwrap();
+ let token = granted["capability"].as_str().unwrap();
+ store
+ .connect()
+ .unwrap()
+ .execute(
+ "UPDATE credentials SET role='writer-only' WHERE id=?",
+ [granted["id"].as_str().unwrap()],
+ )
+ .unwrap();
+ assert!(
+ store
+ .authorized_read(&workspace, token, "read", |_, _| Ok(()))
+ .is_err()
+ );
+ let found = principal(&store, &workspace, token).unwrap();
+ assert_eq!(found.credential, granted["id"].as_str().unwrap());
+ assert!(principal(&store, &workspace, "not-a-token").is_none());
+ assert_eq!(principal(&store, &workspace, &owner).unwrap().role, "owner");
+ }
+
+ #[test]
+ fn the_web_app_is_labelled_apart_from_api_clients() {
+ let mut headers = HeaderMap::new();
+ assert_eq!(Channel::of(&headers), Channel::Http);
+ headers.insert("x-graphicle-request", "1".parse().unwrap());
+ assert_eq!(Channel::of(&headers), Channel::Web);
+ assert_eq!(next_day("2026-12-31").unwrap(), "2027-01-01");
+ assert!(next_day("tomorrow").is_err());
+ }
+}
diff --git a/crates/graphicle/src/model.rs b/crates/graphicle/src/model.rs
index 743ca91..c2b7099 100644
--- a/crates/graphicle/src/model.rs
+++ b/crates/graphicle/src/model.rs
@@ -90,6 +90,21 @@ pub struct Config {
/// variable `GRAPHICLE_NO_UPDATE_NOTIFIER` does.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub update_notifier: Option<bool>,
+ /// The folder sync's settings ([`SyncSettings`]).
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ pub sync: Option<SyncSettings>,
+}
+
+/// The folder sync's settings (`sync.*` in the configuration file).
+#[derive(Clone, Debug, Default, Deserialize, Serialize)]
+#[serde(deny_unknown_fields)]
+pub struct SyncSettings {
+ /// `sync.tracked_ignored`: whether a sync reads the files Git tracks
+ /// although an ignore pattern matches them (left out: yes;
+ /// [`crate::local::tracked_ignored_setting`]). The environment variable
+ /// `GRAPHICLE_SYNC_TRACKED_IGNORED` wins over it.
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ pub tracked_ignored: Option<bool>,
}
fn concurrency_default() -> usize {
1
@@ -108,6 +123,7 @@ impl Default for Config {
freshness: None,
limits: BTreeMap::new(),
update_notifier: None,
+ sync: None,
}
}
}
@@ -140,6 +156,7 @@ impl Config {
"confluence",
]
.contains(&kind.as_str())
+ && crate::extension::installed().source(kind).is_none()
{
return Err(Error::bad("Unknown connector endpoint"));
}
diff --git a/crates/graphicle/src/notes_first.rs b/crates/graphicle/src/notes_first.rs
new file mode 100644
index 0000000..d1a55cf
--- /dev/null
+++ b/crates/graphicle/src/notes_first.rs
@@ -0,0 +1,527 @@
+//! Notes first, and one excerpt per file: how `context` (and so
+//! `recall_project` and a pushed prompt card) treats a project's notes.
+//!
+//! Notes are imported as plain documents, so 0.1.1 ranked them for a
+//! question in prose only by passage BM25, beside code that shared the
+//! question's common words; the same file often took two slots; and a
+//! prompt hook that printed the packet could lose excerpts at Claude Code's
+//! 10,000-character hook limit.
+//!
+//! - [`rerank`]: for a question that names no code ([`names_code`]), the
+//! first [`DEPTH`] files of the fused order, one passage each, keep their
+//! places, except that the notes and documents ([`note_path`]) among them
+//! are ordered again among the notes' own places: each note keeps its
+//! fused reciprocal rank and adds how well its file name and folder match
+//! the question's words (Porter stems, so close variants match), its
+//! headings, and its recency among the candidate notes (the latest ISO
+//! date, up to today, in its path or text). A code file never moves, so a
+//! question in prose about code finds its code where the fused ranking
+//! put it. A question that names code keeps the fused ranking unchanged.
+//! - [`one_per_file`]: a packet quotes at most one window of a file, and one
+//! copy of identical files (the same bytes under other paths), so the
+//! budget goes to more files.
+//!
+//! Both apply only with the `notes_first` switch ([`switch`]), which is off
+//! unless a call turns it on ([`crate::query::NOTES_FIRST_DEFAULT`]).
+use crate::store::s;
+use crate::{Error, Result};
+use serde_json::{Value, json};
+use std::collections::{BTreeMap, BTreeSet};
+use std::sync::LazyLock;
+
+/// The packet field that reports what this module did, and the switch that
+/// turns it on.
+pub const FIELD: &str = "notes_first";
+
+/// The call's `notes_first` switch, and whether the call left it out (then
+/// it is [`crate::query::NOTES_FIRST_DEFAULT`]).
+pub fn switch(args: &Value) -> Result<(bool, bool)> {
+ match args.get(FIELD) {
+ None | Some(Value::Null) => Ok((crate::query::NOTES_FIRST_DEFAULT, true)),
+ Some(Value::Bool(on)) => Ok((*on, false)),
+ Some(_) => Err(Error::bad("notes_first must be true or false")),
+ }
+}
+
+/// Files of the fused order [`rerank`] orders again.
+pub const DEPTH: usize = 50;
+/// Weight of a note's file name and folder that match the question: the
+/// stems it matches over the square root of the name's stem count plus one.
+pub const NAME_WEIGHT: f64 = 0.02;
+/// Weight of headings that match: matched stems over the square root of
+/// one plus the headings' length in units of 20 words.
+pub const HEADING_WEIGHT: f64 = 0.003;
+/// Weight of recency among the candidate notes' distinct dates: the newest
+/// adds all of it, the oldest 1/n of it (n dates), the others their share
+/// by place, an undated note nothing; with fewer than two dates there is no
+/// order, and nothing is added.
+pub const RECENCY_WEIGHT: f64 = 0.02;
+/// Headings read per document (front matter fields, then `#` lines).
+pub const HEADINGS: usize = 12;
+/// The fused order's reciprocal-rank constant: rank r (from 0) keeps
+/// 1/(RRF_K + r + 1).
+const RRF_K: f64 = 60.0;
+
+/// Whether `question` names code: a backtick span, a snake_case,
+/// SCREAMING_CASE or camelCase identifier, a PascalCase name of three or
+/// more parts, a `Type::member` path, a call `name(...)`, a code file
+/// (`parser.py`) or a path to one (`web/app.js`). Names that only look
+/// like code do not count: `Acme_Docs`, `macOS`, `next.js`. Such a
+/// question keeps the code ranking (and the packet 0.1.1 built for it);
+/// only questions in prose rank notes again.
+pub fn names_code(question: &str) -> bool {
+ static CODE: LazyLock<regex::Regex> = LazyLock::new(|| {
+ regex::Regex::new(concat!(
+ r"`[^`\n]+`",
+ r"|\b[a-z][a-z0-9]*(?:_[a-z0-9]+)+\b",
+ r"|\b[A-Z][A-Z0-9]*(?:_[A-Z0-9]+)+\b",
+ // camelCase with two lowercase letters before the capital
+ // (`getChoices`; not `iPhone`, `iPad`, `eBay`).
+ r"|\b[a-z]{2}[a-z0-9]*[A-Z][a-z0-9]+[A-Za-z0-9]*\b",
+ r"|\b[A-Z][a-z0-9]+(?:[A-Z][a-z0-9]+){2,}\b",
+ r"|\b[A-Za-z_][A-Za-z0-9_]*::[A-Za-z_]",
+ r"|\b[A-Za-z_][A-Za-z0-9_.]*\([^()\n]{0,80}\)",
+ r"|\b[A-Za-z0-9_-]+\.(?:rs|py|pyi|go|java|kt|c|h|cc|cpp|hpp|rb|swift|cs|php|scala|sh)\b",
+ r"|[A-Za-z0-9_.-]*/[A-Za-z0-9_./-]*\.(?:ts|tsx|js|jsx|mjs|cjs|vue|svelte)\b",
+ ))
+ .expect("the names-code rule")
+ });
+ CODE.is_match(question)
+}
+
+/// A note or document by its file name: Markdown, plain text,
+/// reStructuredText, AsciiDoc, Org, PDF, Word or HTML.
+pub fn note_path(path: &str) -> bool {
+ let name = path.rsplit('/').next().unwrap_or(path);
+ let Some((_, extension)) = name.rsplit_once('.') else {
+ return false;
+ };
+ matches!(
+ extension.to_ascii_lowercase().as_str(),
+ "md" | "markdown"
+ | "mdx"
+ | "txt"
+ | "text"
+ | "rst"
+ | "adoc"
+ | "org"
+ | "pdf"
+ | "docx"
+ | "html"
+ | "htm"
+ )
+}
+
+/// Words a match ignores: question words and common function words.
+const COMMON: [&str; 70] = [
+ "the", "and", "for", "with", "what", "which", "where", "when", "does", "how", "why", "who",
+ "whom", "that", "this", "these", "those", "from", "into", "are", "was", "were", "has", "have",
+ "had", "not", "can", "could", "about", "there", "their", "they", "them", "then", "than", "its",
+ "our", "your", "you", "all", "any", "did", "should", "would", "will", "may", "might", "must",
+ "been", "being", "now", "each", "both", "also", "but", "use", "used", "using", "one", "two",
+ "get", "got", "say", "said", "after", "before", "since", "until", "over", "it",
+];
+
+/// The Porter stems of `text`'s words that match: at least three characters
+/// or a digit, without [`COMMON`] words.
+fn stems(text: &str) -> BTreeSet<String> {
+ graphicle_memory::text::words(text)
+ .into_iter()
+ .filter(|w| {
+ (w.chars().count() >= 3 || w.chars().any(|c| c.is_ascii_digit()))
+ && !COMMON.contains(&w.as_str())
+ })
+ .map(|w| graphicle_memory::stem::stem(&w))
+ .collect()
+}
+
+/// A document's name words: its file name without the extension and the
+/// name of its folder (`docs/setup/INSTALL-GUIDE.md`: install, guide, setup).
+fn name_text(path: &str) -> String {
+ let mut parts = path.rsplit('/');
+ let file = parts.next().unwrap_or(path);
+ let stem = file.rsplit_once('.').map_or(file, |(stem, _)| stem);
+ format!("{stem} {}", parts.next().unwrap_or(""))
+}
+
+/// A document's headings: the `title`, `name` and `description` fields of
+/// a leading front matter block, then its first [`HEADINGS`] Markdown `#`
+/// lines. A log or a generated summary with hundreds of headings would
+/// match every question; its first headings say what it is.
+fn heading_text(content: &str) -> String {
+ let mut out = String::new();
+ let mut lines = content.lines();
+ if content.starts_with("---") {
+ lines.next();
+ for line in lines.by_ref().take(60) {
+ if line.trim_end() == "---" {
+ break;
+ }
+ for key in ["title:", "name:", "description:"] {
+ if let Some(value) = line.trim_start().strip_prefix(key) {
+ out.push_str(value);
+ out.push('\n');
+ }
+ }
+ }
+ }
+ let mut headings = 0;
+ for line in lines {
+ let trimmed = line.trim_start();
+ if trimmed.starts_with('#') && trimmed.trim_start_matches('#').starts_with(' ') {
+ out.push_str(trimmed.trim_start_matches('#'));
+ out.push('\n');
+ headings += 1;
+ if headings == HEADINGS {
+ break;
+ }
+ }
+ }
+ out
+}
+
+/// The latest ISO date (`2026-10-15`) in a document's path or text, up to
+/// `today` (a plan's later dates say nothing of how current a note is):
+/// notes that log work name their dates, and the newest says how current
+/// it is.
+fn newest_date(path: &str, content: &str, today: &str) -> String {
+ static DATE: LazyLock<regex::Regex> = LazyLock::new(|| {
+ regex::Regex::new(r"\b(?:19|20)\d\d-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]\d|3[01])\b")
+ .expect("the date rule")
+ });
+ DATE.find_iter(path)
+ .chain(DATE.find_iter(content))
+ .map(|m| m.as_str())
+ .filter(|date| *date <= today)
+ .max()
+ .unwrap_or("")
+ .to_string()
+}
+
+/// One file of the fused order, as [`rerank`] scores it.
+struct Candidate<'a> {
+ rank: usize,
+ path: &'a str,
+ identity: &'a str,
+ note: bool,
+ score: f64,
+ name: usize,
+ headings: usize,
+ date: String,
+}
+
+/// The fused order (`rows`: passages in rank order, memories left out)
+/// for a question that names no code, one passage per file: the first
+/// [`DEPTH`] files, each with its best-ranked passage. Code files keep their
+/// places. The notes ([`note_path`]) are ordered again among the notes'
+/// places, by fused reciprocal rank plus [`NAME_WEIGHT`] times the name
+/// match, [`HEADING_WEIGHT`] times the heading match and [`RECENCY_WEIGHT`]
+/// times the date's place among the candidate notes' dates up to `today`
+/// (`YYYY-MM-DD`); equal scores keep the fused order. `None` when the
+/// question names code; the report says what was done.
+pub fn rerank(
+ rows: &[&Value],
+ documents: &[Value],
+ question: &str,
+ today: &str,
+) -> (Option<Vec<String>>, Value) {
+ if names_code(question) {
+ return (None, json!({"status":"code_question"}));
+ }
+ let terms = stems(question);
+ let content: BTreeMap<&str, &str> = documents
+ .iter()
+ .map(|d| (s(d, "id"), s(d, "content")))
+ .collect();
+ let mut seen = BTreeSet::new();
+ let mut files: Vec<Candidate<'_>> = Vec::new();
+ for row in rows {
+ let source = &row["source"];
+ if !seen.insert(s(source, "id")) {
+ continue;
+ }
+ let path = s(source, "path");
+ let rank = files.len();
+ let mut file = Candidate {
+ rank,
+ path,
+ identity: s(row, "identity"),
+ note: note_path(path),
+ score: 1.0 / (RRF_K + rank as f64 + 1.0),
+ name: 0,
+ headings: 0,
+ date: String::new(),
+ };
+ if file.note {
+ let name = stems(&name_text(path));
+ file.name = name.intersection(&terms).count();
+ file.score += NAME_WEIGHT * file.name as f64 / (1.0 + name.len() as f64).sqrt();
+ let text = content.get(s(source, "id")).copied().unwrap_or("");
+ let heading = heading_text(text);
+ let length = graphicle_memory::text::words(&heading).len() as f64;
+ file.headings = stems(&heading).intersection(&terms).count();
+ file.score += HEADING_WEIGHT * file.headings as f64 / (1.0 + length / 20.0).sqrt();
+ file.date = newest_date(path, text, today);
+ }
+ files.push(file);
+ if files.len() == DEPTH {
+ break;
+ }
+ }
+ let mut dates: Vec<&str> = files
+ .iter()
+ .map(|f| f.date.as_str())
+ .filter(|d| !d.is_empty())
+ .collect();
+ dates.sort_unstable();
+ dates.dedup();
+ let places: Vec<Option<usize>> = files
+ .iter()
+ .map(|f| dates.binary_search(&f.date.as_str()).ok())
+ .collect();
+ if dates.len() > 1 {
+ let count = dates.len() as f64;
+ for (file, place) in files.iter_mut().zip(places) {
+ if let Some(place) = place {
+ file.score += RECENCY_WEIGHT * (place + 1) as f64 / count;
+ }
+ }
+ }
+ // Code files keep their places; the notes fill the notes' places, best
+ // first.
+ let places: Vec<usize> = (0..files.len()).filter(|&i| files[i].note).collect();
+ let mut notes = places.clone();
+ notes.sort_by(|&a, &b| {
+ files[b]
+ .score
+ .total_cmp(&files[a].score)
+ .then(files[a].rank.cmp(&files[b].rank))
+ });
+ let mut order: Vec<usize> = (0..files.len()).collect();
+ for (&place, &note) in places.iter().zip(&notes) {
+ order[place] = note;
+ }
+ let moved = order.iter().enumerate().filter(|(i, f)| i != *f).count();
+ let report = json!({"status":"reranked","files":files.len(),"notes":places.len(),"notes_moved":moved,
+ "first":order.iter().take(3).map(|&i| &files[i]).map(|f| json!({
+ "path":f.path,"fused_rank":f.rank + 1,"name_matches":f.name,"heading_matches":f.headings,
+ "newest_date":f.date})).collect::<Vec<_>>()});
+ (
+ Some(
+ order
+ .iter()
+ .map(|&i| files[i].identity.to_string())
+ .collect(),
+ ),
+ report,
+ )
+}
+
+/// Keep the first window of each file among `candidates` (in rank order)
+/// and the first of files with identical bytes; how many windows of an
+/// already quoted file, and how many copies, were dropped.
+pub fn one_per_file(candidates: &mut Vec<Value>, documents: &[Value]) -> (usize, usize) {
+ let sha: BTreeMap<&str, &str> = documents
+ .iter()
+ .map(|d| (s(d, "id"), s(d, "sha256")))
+ .collect();
+ let mut files = BTreeSet::new();
+ let mut contents = BTreeSet::new();
+ let (mut repeated, mut copies) = (0, 0);
+ candidates.retain(|c| {
+ let id = s(&c["source"], "id").to_string();
+ if files.contains(&id) {
+ repeated += 1;
+ return false;
+ }
+ if let Some(digest) = sha.get(id.as_str()).filter(|d| !d.is_empty())
+ && !contents.insert(digest.to_string())
+ {
+ copies += 1;
+ return false;
+ }
+ files.insert(id);
+ true
+ });
+ (repeated, copies)
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ fn doc(path: &str, content: &str) -> Value {
+ json!({"id":format!("file:{path}"),"path":path,"content":content,
+ "sha256":graphicle_memory::text::sha256(content.as_bytes())})
+ }
+ fn row(path: &str, start: u64, text: &str) -> Value {
+ json!({"identity":format!("{path}#{start}"),"kind":"source","text":text,
+ "source":{"id":format!("file:{path}"),"path":path,"byte_start":start}})
+ }
+
+ #[test]
+ fn code_names_keep_the_code_ranking() {
+ for q in [
+ "Why does `parse_header` fail?",
+ "Where is parse_header defined?",
+ "Where is getChoices called?",
+ "What does Field.get_choices() return?",
+ "Who calls Store::project_context?",
+ "Fix the bug in src/query.rs",
+ "What changed in ModelAdminChecks?",
+ "Why is MAX_RANK_LIMIT 60?",
+ "What does src/web/app.js render?",
+ ] {
+ assert!(names_code(q), "{q}");
+ }
+ for q in [
+ "Where is the Windows port plan and the Windows sprint log?",
+ "Which GitHub org hosts Graphicle's public repository, and what is the Homebrew install command?",
+ "What is the SSH user (build-...) of the test host now?",
+ "Which release tag/commit did the maintainers push as the public v0.1.0?",
+ "How long should we expect a build machine to live (about 10 h)?",
+ "Where is the tooling that moved the old stages into the Acme_Docs repository?",
+ "What did the memory rewrite achieve on the Kubernetes and next.js extracts?",
+ "Does the iPhone app sync with the iPad and eBay listings?",
+ "How should the cache folder be protected from macOS's nightly /tmp cleanup?",
+ ] {
+ assert!(!names_code(q), "{q}");
+ }
+ }
+
+ #[test]
+ fn notes_are_named_by_file_folder_and_headings() {
+ assert!(note_path("notes/build-checklist.md") && note_path("docs/a.rst"));
+ assert!(!note_path("src/query.rs") && !note_path("Makefile"));
+ assert_eq!(
+ stems(&name_text("docs/guides/install-step3/GUIDE.md")),
+ stems("GUIDE install-step3")
+ );
+ let head = heading_text(
+ "---\nname: cache-folder-cleaner\ndescription: \"keep verified backups\"\n---\n\n# Status log\nbody words\n## Release plan\n",
+ );
+ for word in ["cache", "verified", "backups", "status", "release"] {
+ assert!(head.to_lowercase().contains(word), "{word}: {head}");
+ }
+ assert!(!head.contains("body"));
+ let many: String = (0..40).map(|i| format!("# heading{i}\n")).collect();
+ assert_eq!(heading_text(&many).lines().count(), HEADINGS);
+ assert_eq!(
+ newest_date(
+ "notes/a-2026-10-01.md",
+ "seen 2026-10-14, then 2025-01-02, plan 2027-04-17",
+ "2026-10-15"
+ ),
+ "2026-10-14"
+ );
+ }
+
+ #[test]
+ fn prose_reranks_notes_by_name_and_recency_one_passage_per_file() {
+ let documents = vec![
+ doc("notes/windows-port.md", "# Windows port plan\n2026-10-01"),
+ doc("notes/log.md", "# Log\nwindows port 2026-10-14"),
+ doc("src/windows_port.rs", "fn windows_port_plan() {}"),
+ doc("notes/other.md", "# Other\n2026-09-01"),
+ ];
+ let rows = [
+ row("src/windows_port.rs", 0, "fn windows_port_plan() {}"),
+ row("notes/other.md", 0, "other"),
+ row("notes/other.md", 50, "other again"),
+ row("notes/log.md", 0, "windows port"),
+ row("notes/windows-port.md", 0, "Windows port plan"),
+ ];
+ let refs: Vec<&Value> = rows.iter().collect();
+ let (order, report) = rerank(
+ &refs,
+ &documents,
+ "Where is the Windows port plan?",
+ "2026-10-15",
+ );
+ let order = order.expect("reranked");
+ // The code file keeps its fused place; among the notes' places the
+ // named note comes first, then the newest note, the old note last,
+ // once.
+ assert_eq!(
+ order,
+ [
+ "src/windows_port.rs#0",
+ "notes/windows-port.md#0",
+ "notes/log.md#0",
+ "notes/other.md#0"
+ ],
+ "{report}"
+ );
+ let (none, report) = rerank(
+ &refs,
+ &documents,
+ "Where is `windows_port_plan` defined?",
+ "2026-10-15",
+ );
+ assert!(none.is_none());
+ assert_eq!(report["status"], "code_question");
+ }
+
+ #[test]
+ fn code_files_keep_their_fused_places() {
+ // The fused first file is code: neither a test file whose name
+ // matches the question nor a newer note moves it; the notes trade
+ // places among themselves.
+ let documents = vec![
+ doc("src/terminal.rs", "fn render() {}"),
+ doc(
+ "CHANGELOG.md",
+ "# Changelog\n## 2026-10-14\nterminal colours",
+ ),
+ doc("tests/terminal_colours.rs", "fn colours() {}"),
+ doc(
+ "notes/terminal-colours.md",
+ "# Terminal colours\n2026-10-01",
+ ),
+ ];
+ let rows = [
+ row("src/terminal.rs", 0, "fn render() {}"),
+ row("CHANGELOG.md", 0, "terminal colours"),
+ row("tests/terminal_colours.rs", 0, "fn colours() {}"),
+ row("notes/terminal-colours.md", 0, "Terminal colours"),
+ ];
+ let refs: Vec<&Value> = rows.iter().collect();
+ let (order, report) = rerank(
+ &refs,
+ &documents,
+ "Why are the terminal colours wrong?",
+ "2026-10-15",
+ );
+ assert_eq!(
+ order.expect("reranked"),
+ [
+ "src/terminal.rs#0",
+ "notes/terminal-colours.md#0",
+ "tests/terminal_colours.rs#0",
+ "CHANGELOG.md#0"
+ ],
+ "{report}"
+ );
+ assert_eq!(report["notes"], 2);
+ assert_eq!(report["notes_moved"], 2);
+ }
+
+ #[test]
+ fn one_window_per_file_and_one_copy_of_identical_files() {
+ let documents = vec![
+ doc("a.md", "same"),
+ doc("copy/a.md", "same"),
+ doc("b.md", "other"),
+ ];
+ let hit = |path: &str, start: u64| json!({"source":{"id":format!("file:{path}"),"byte_start":start}});
+ let mut candidates = vec![
+ hit("a.md", 0),
+ hit("a.md", 10),
+ hit("copy/a.md", 0),
+ hit("b.md", 0),
+ ];
+ assert_eq!(one_per_file(&mut candidates, &documents), (1, 1));
+ let kept: Vec<&str> = candidates.iter().map(|c| s(&c["source"], "id")).collect();
+ assert_eq!(kept, ["file:a.md", "file:b.md"]);
+ }
+}
diff --git a/crates/graphicle/src/oauth.rs b/crates/graphicle/src/oauth.rs
index 470a9c3..d1d6311 100644
--- a/crates/graphicle/src/oauth.rs
+++ b/crates/graphicle/src/oauth.rs
@@ -38,8 +38,12 @@ fn providers(store: &Store, workspace: &str) -> Result<BTreeMap<String, Provider
}
serde_json::from_slice(&bytes).map_err(Into::into)
}
+/// The OAuth providers of the core's connectors; an installed extension's
+/// sources may use others (`extension::Source::oauth_provider`).
+const CORE_PROVIDERS: &[&str] = &["github", "slack", "notion", "gdrive", "atlassian"];
fn validate(name: &str, p: &Provider) -> Result<()> {
- if !["github", "slack", "notion", "gdrive", "atlassian"].contains(&name)
+ if !(CORE_PROVIDERS.contains(&name)
+ || crate::extension::installed().oauth_source(name).is_some())
|| p.client_id.is_empty()
|| p.client_id.len() > 1000
|| p.scopes.len() > 30
@@ -259,6 +263,14 @@ pub async fn callback(
if who.get("ok") == Some(&json!(false)) {
return Err(Error::bad("Could not verify provider account"));
}
+ // A provider an extension's source uses reads its own identity response.
+ let added = if CORE_PROVIDERS.contains(&name) {
+ None
+ } else {
+ crate::extension::installed()
+ .oauth_source(name)
+ .and_then(|source| source.oauth_identity(&who))
+ };
let external = match name {
"github" => who["id"]
.as_i64()
@@ -271,16 +283,19 @@ pub async fn callback(
.as_str()
.or(who["id"].as_str())
.map(str::to_string),
- _ => None,
+ _ => added.as_ref().map(|(account, _)| account.clone()),
}
.filter(|v| !v.is_empty())
.ok_or_else(|| Error::bad("Provider did not return a stable account identity"))?;
- let display = who["name"]
- .as_str()
- .or(who["login"].as_str())
- .or(who["user"].as_str())
- .unwrap_or(&external)
- .to_string();
+ let display = match added {
+ Some((_, display)) if !display.is_empty() => display,
+ _ => who["name"]
+ .as_str()
+ .or(who["login"].as_str())
+ .or(who["user"].as_str())
+ .unwrap_or(&external)
+ .to_string(),
+ };
let email = if name == "gdrive" && who["email_verified"] == true {
who["email"].as_str()
} else {
diff --git a/crates/graphicle/src/offboard.rs b/crates/graphicle/src/offboard.rs
new file mode 100644
index 0000000..844a4d0
--- /dev/null
+++ b/crates/graphicle/src/offboard.rs
@@ -0,0 +1,745 @@
+//! `graphicle offboard`: remove one project (one client's data) from this
+//! data folder, with a hash-chained receipt that lists what was removed.
+//!
+//! It covers, all inside Graphicle's own data folder:
+//! - the project in the store, with its PR scratch copies: the certified
+//! project deletion of [`crate::deletion`] (sources, memory, graph,
+//! history and what was derived from them), whose receipt joins the
+//! workspace's receipt chain and lists the files below;
+//! - its graph cache (`gf-cache/<project>`), the materialized copy of its
+//! code and graph;
+//! - its copies in the backups `graphicle backup` keeps in the data folder
+//! (`backups/`): the project is deleted from each backup the same way, with
+//! a receipt in that backup's own chain, and the backup is compacted.
+//! Other projects in the backup stay.
+//!
+//! Nothing outside the data folder is touched: a symbolic link, a backup
+//! file with another name (a hard link, which may lie outside the data
+//! folder), or a path that resolves outside it, is refused (listed, never
+//! followed or changed); on Windows, which gives no link count, so is every
+//! backup. Backups and
+//! exports written elsewhere, what Graphicle added in the project's folders
+//! (`graphicle disconnect` removes it) and provider-side retention are named
+//! as not covered.
+//!
+//! The plan comes first: [`plan`] changes nothing and ends with a hash;
+//! [`apply`] takes that hash and carries out exactly that plan, or refuses
+//! when anything in it changed.
+use crate::platform::CanonicalExt;
+use crate::store::{Principal, Store, one, rows, s};
+use crate::{Error, Result, digest, local};
+use rusqlite::{Connection, OpenFlags, TransactionBehavior};
+use serde_json::{Value, json};
+use std::collections::BTreeMap;
+use std::path::{Path, PathBuf};
+
+/// The folder of the data folder where `graphicle backup` without a path
+/// writes, and where offboarding looks for backups.
+pub const BACKUPS: &str = "backups";
+/// The graph cache folder ([`crate::graph_projection::cache_root`]).
+const CACHE: &str = "gf-cache";
+/// What offboarding cannot reach.
+pub const NOT_COVERED: &[&str] = &[
+ "backups and exports written outside the data folder",
+ "what Graphicle added in the project's folders: agent entries, hooks and their .graphicle-bak backups (graphicle disconnect removes them)",
+ "the graph engine's output folder in the project's folders (.graphicle/, or the folder GRAPHICLE_OUT names)",
+ "model-provider retention of requests already sent",
+ "memories that memory.import_pack or memory.import copied into other projects, which belong to those projects",
+];
+
+/// Where `graphicle backup` without a path writes:
+/// `backups/graphicle-<UTC time>.sqlite3` in the data folder, which is
+/// created private. A `backups` that is not a folder (a symbolic link
+/// included) is refused.
+pub fn backup_path(store: &Store) -> Result<PathBuf> {
+ let folder = store.directory.join(BACKUPS);
+ match std::fs::symlink_metadata(&folder) {
+ Ok(meta) if !meta.is_dir() => {
+ return Err(Error::bad(format!(
+ "{} is not a folder (Graphicle keeps its backups there); name the backup file instead",
+ folder.display()
+ )));
+ }
+ Ok(_) => {}
+ Err(_) => {
+ #[cfg(unix)]
+ {
+ use std::os::unix::fs::DirBuilderExt;
+ std::fs::DirBuilder::new().mode(0o700).create(&folder)?;
+ }
+ #[cfg(not(unix))]
+ std::fs::create_dir(&folder)?;
+ }
+ }
+ Ok(folder.join(format!(
+ "graphicle-{}.sqlite3",
+ chrono::Utc::now().format("%Y%m%dT%H%M%S%.3fZ")
+ )))
+}
+
+/// `parts` joined under the canonical data folder `root` when no step is a
+/// symbolic link and the result resolves inside `root`: `Ok(None)` when it
+/// does not exist, `Err(reason)` when it is refused.
+fn inside(root: &Path, parts: &[&str]) -> std::result::Result<Option<PathBuf>, &'static str> {
+ let mut path = root.to_path_buf();
+ for part in parts {
+ if part.is_empty() || *part == "." || *part == ".." || part.contains('/') {
+ return Err("not a plain name");
+ }
+ path.push(part);
+ match std::fs::symlink_metadata(&path) {
+ Err(_) => return Ok(None),
+ Ok(meta) if meta.file_type().is_symlink() => {
+ return Err(
+ "a symbolic link: Graphicle does not follow links out of its data folder",
+ );
+ }
+ Ok(_) => {}
+ }
+ }
+ match path.canonical() {
+ Ok(canonical) if canonical.starts_with(root) => Ok(Some(path)),
+ _ => Err("outside the data folder"),
+ }
+}
+
+/// Why the file at `path` may have another name, which may lie outside the
+/// data folder and which changing the file would change too: it is a hard
+/// link (more than one name). Windows gives no link count through the
+/// standard library, so there every backup counts as possibly linked and is
+/// left as it is.
+fn other_name(path: &Path) -> Option<&'static str> {
+ #[cfg(unix)]
+ {
+ use std::os::unix::fs::MetadataExt;
+ std::fs::metadata(path)
+ .is_ok_and(|meta| meta.nlink() > 1)
+ .then_some("a hard link: the same file may have another name outside the data folder")
+ }
+ #[cfg(not(unix))]
+ {
+ let _ = path;
+ Some(
+ "Graphicle cannot tell on this system whether the file has another name (a hard link) outside the data folder",
+ )
+ }
+}
+
+/// Files and bytes under `folder`, links not followed.
+fn tally(folder: &Path) -> (u64, u64) {
+ let (mut files, mut bytes) = (0, 0);
+ let mut stack = vec![folder.to_path_buf()];
+ while let Some(dir) = stack.pop() {
+ let Ok(entries) = std::fs::read_dir(&dir) else {
+ continue;
+ };
+ for entry in entries.flatten() {
+ let Ok(meta) = std::fs::symlink_metadata(entry.path()) else {
+ continue;
+ };
+ if meta.is_dir() {
+ stack.push(entry.path());
+ } else {
+ files += 1;
+ bytes += meta.len();
+ }
+ }
+ }
+ (files, bytes)
+}
+
+/// SHA-256 and length of a file, read in pieces.
+fn file_sha256(path: &Path) -> Result<(String, u64)> {
+ use sha2::{Digest, Sha256};
+ use std::io::Read;
+ let mut file = std::fs::File::open(path)?;
+ let mut hasher = Sha256::new();
+ let mut buffer = vec![0u8; 1 << 16];
+ let mut length = 0u64;
+ loop {
+ let n = file.read(&mut buffer)?;
+ if n == 0 {
+ break;
+ }
+ hasher.update(&buffer[..n]);
+ length += n as u64;
+ }
+ Ok((format!("{:x}", hasher.finalize()), length))
+}
+
+/// Rows the store holds for `scope`, by table: every table with a
+/// `repository_id` column.
+fn counts(db: &Connection, scope: &[String]) -> Result<BTreeMap<String, i64>> {
+ let mut counts = BTreeMap::new();
+ for table in rows(
+ db,
+ "SELECT name FROM sqlite_master WHERE type='table' ORDER BY name",
+ [],
+ )? {
+ let table = s(&table, "name");
+ let has = one(
+ db,
+ "SELECT 1 AS yes FROM pragma_table_info(?) WHERE name='repository_id'",
+ [table],
+ )?
+ .is_some();
+ if !has {
+ continue;
+ }
+ let sql = format!(
+ "SELECT count(*) FROM \"{}\" WHERE repository_id=?",
+ table.replace('"', "\"\"")
+ );
+ let mut n = 0i64;
+ for repository in scope {
+ n += db.query_row(&sql, [repository], |r| r.get::<_, i64>(0))?;
+ }
+ if n > 0 {
+ counts.insert(table.to_string(), n);
+ }
+ }
+ Ok(counts)
+}
+
+/// The projects of `scope` (and the PR scratch copies of `project` only the
+/// backup still records) that a backup holds, how many other projects it
+/// holds, and whether any of them belongs to another workspace.
+struct Held {
+ ids: Vec<String>,
+ others: i64,
+ foreign: bool,
+}
+
+fn held_in(db: &Connection, project: &str, scope: &[String], workspace: &str) -> Result<Held> {
+ let mut ids = scope.to_vec();
+ let scratch = one(
+ db,
+ "SELECT 1 AS yes FROM sqlite_master WHERE type='table' AND name='repo_pr_scratch'",
+ [],
+ )?
+ .is_some();
+ if scratch {
+ for row in rows(
+ db,
+ "SELECT repository_id FROM repo_pr_scratch WHERE project_id=? ORDER BY repository_id",
+ [project],
+ )? {
+ let copy = s(&row, "repository_id").to_string();
+ if !ids.contains(&copy) {
+ ids.push(copy);
+ }
+ }
+ }
+ let (mut present, mut foreign) = (Vec::new(), false);
+ for id in ids {
+ if let Some(row) = one(
+ db,
+ "SELECT workspace_id FROM repo_projects WHERE id=?",
+ [&id],
+ )? {
+ foreign |= s(&row, "workspace_id") != workspace;
+ present.push(id);
+ }
+ }
+ let total: i64 = db.query_row("SELECT count(*) FROM repo_projects", [], |r| r.get(0))?;
+ Ok(Held {
+ others: total - present.len() as i64,
+ ids: present,
+ foreign,
+ })
+}
+
+/// [`held_in`] for a backup file, opened immutable so that reading it
+/// changes nothing; `None` when it is not a readable Graphicle store.
+fn held(path: &Path, project: &str, scope: &[String], workspace: &str) -> Option<Held> {
+ let mut uri = String::from("file:");
+ for c in path.to_str()?.chars() {
+ match c {
+ '%' => uri.push_str("%25"),
+ '?' => uri.push_str("%3f"),
+ '#' => uri.push_str("%23"),
+ c => uri.push(c),
+ }
+ }
+ uri.push_str("?immutable=1");
+ let db = Connection::open_with_flags(
+ &uri,
+ OpenFlags::SQLITE_OPEN_READ_ONLY | OpenFlags::SQLITE_OPEN_URI,
+ )
+ .ok()?;
+ held_in(&db, project, scope, workspace).ok()
+}
+
+/// The backups in the data folder's `backups` folder that hold a project of
+/// `scope`; links and files outside the data folder are added to `refused`,
+/// files that are not readable Graphicle stores to `skipped`.
+fn backups(
+ root: &Path,
+ project: &str,
+ scope: &[String],
+ workspace: &str,
+ refused: &mut Vec<Value>,
+ skipped: &mut Vec<Value>,
+) -> Result<Vec<Value>> {
+ let folder = match inside(root, &[BACKUPS]) {
+ Ok(Some(folder)) => folder,
+ Ok(None) => return Ok(Vec::new()),
+ Err(reason) => {
+ refused.push(json!({"path": BACKUPS, "reason": reason}));
+ return Ok(Vec::new());
+ }
+ };
+ let mut names = Vec::new();
+ for entry in std::fs::read_dir(&folder)?.flatten() {
+ match entry.file_name().into_string() {
+ Ok(name) => names.push(name),
+ Err(name) => refused.push(json!({
+ "path": format!("{BACKUPS}/{}", name.to_string_lossy()),
+ "reason": "not a UTF-8 name",
+ })),
+ }
+ }
+ names.sort();
+ let mut found = Vec::new();
+ for name in names {
+ if ["-wal", "-shm", "-journal"]
+ .iter()
+ .any(|suffix| name.ends_with(suffix))
+ {
+ continue;
+ }
+ let relative = format!("{BACKUPS}/{name}");
+ let path = match inside(root, &[BACKUPS, &name]) {
+ Ok(Some(path)) if path.is_file() => path,
+ Ok(_) => continue,
+ Err(reason) => {
+ refused.push(json!({"path": relative, "reason": reason}));
+ continue;
+ }
+ };
+ if let Some(reason) = other_name(&path) {
+ refused.push(json!({"path": relative, "reason": reason}));
+ continue;
+ }
+ let Some(held) = held(&path, project, scope, workspace) else {
+ skipped.push(json!({"path": relative, "reason": "not a readable Graphicle store"}));
+ continue;
+ };
+ if held.ids.is_empty() {
+ continue;
+ }
+ if held.foreign {
+ refused.push(
+ json!({"path": relative, "reason": "holds the project for another workspace"}),
+ );
+ continue;
+ }
+ let (sha256, bytes) = file_sha256(&path)?;
+ found.push(json!({
+ "path": relative,
+ "sha256": sha256,
+ "bytes": bytes,
+ "projects": held.ids.len(),
+ "other_projects": held.others,
+ }));
+ }
+ Ok(found)
+}
+
+/// The offboarding plan for the project `requested` (an id, a key or a
+/// synced folder): what goes, what is refused and what is not covered,
+/// with the hash [`apply`] needs. Nothing changes. Only the workspace's
+/// owner may offboard.
+pub fn plan(store: &Store, session: &local::Session, requested: &str) -> Result<Value> {
+ let id = local::project(store, session, Some(requested))?;
+ let root = store.directory.canonical()?;
+ let (project, copies, store_rows, folders) = store.authorized_read(
+ &session.workspace,
+ &session.capability,
+ "admin",
+ |db, p| {
+ let project = crate::store::repo(db, p, &id)?;
+ let copies = crate::folders::scratch_projects(db, &id)?;
+ let scope: Vec<String> = std::iter::once(id.clone())
+ .chain(copies.iter().cloned())
+ .collect();
+ let store_rows = counts(db, &scope)?;
+ let folders: Vec<String> = rows(
+ db,
+ "SELECT path FROM repo_folders WHERE repository_id=? AND path IS NOT NULL ORDER BY path",
+ [&id],
+ )?
+ .iter()
+ .map(|r| s(r, "path").to_string())
+ .collect();
+ Ok((project, copies, store_rows, folders))
+ },
+ )?;
+ let scope: Vec<String> = std::iter::once(id.clone())
+ .chain(copies.iter().cloned())
+ .collect();
+ let (mut refused, mut skipped, mut cache) = (Vec::new(), Vec::new(), Vec::new());
+ let mut blocked = false;
+ for repository in &scope {
+ let relative = format!("{CACHE}/{repository}");
+ match inside(&root, &[CACHE, repository]) {
+ Ok(Some(path)) => {
+ let (files, bytes) = tally(&path);
+ cache.push(json!({"path": relative, "files": files, "bytes": bytes}));
+ }
+ Ok(None) => {}
+ Err(reason) => {
+ // The project deletion removes this folder: refuse it all.
+ blocked = true;
+ refused.push(json!({"path": relative, "reason": reason, "blocks": true}));
+ }
+ }
+ }
+ let found = backups(
+ &root,
+ &id,
+ &scope,
+ &session.workspace,
+ &mut refused,
+ &mut skipped,
+ )?;
+ let snapshot = s(&project, "snapshot").to_string();
+ let material = json!({
+ "project": id, "snapshot": snapshot, "pr_scratch_projects": copies,
+ "store_rows": store_rows, "graph_cache": cache, "backups": found,
+ "refused": refused,
+ });
+ let plan_hash = digest(&material);
+ let next = if blocked {
+ "Remove the refused links, then run graphicle offboard again".to_string()
+ } else {
+ format!("graphicle offboard --project {id} --apply {plan_hash}")
+ };
+ Ok(json!({
+ "dry_run": true,
+ "project": {
+ "id": id, "key": project["project_key"], "name": project["name"],
+ "snapshot": snapshot, "folders": folders,
+ },
+ "pr_scratch_projects": copies,
+ "store_rows": store_rows,
+ "graph_cache": cache,
+ "backups": found,
+ "refused": refused,
+ "skipped": skipped,
+ "blocked": blocked,
+ "not_covered": NOT_COVERED,
+ "data_dir": root.to_string_lossy(),
+ "plan_hash": plan_hash,
+ "before_you_apply": "Run graphicle disconnect in the project's folders first, so that its Git hooks and agents do not sync it again.",
+ "next": next,
+ }))
+}
+
+/// Carry out the plan [`plan`] showed with hash `expected`: delete the
+/// project from each backup that holds it, then from the store (its graph
+/// cache with it), and forget it as the saved default project. Refused when
+/// the plan changed or a refused path blocks it. `verified` holds only when
+/// every deletion checks out and no path was refused: a refused path was
+/// never changed and may still hold the project.
+pub fn apply(
+ store: &Store,
+ session: &local::Session,
+ requested: &str,
+ expected: &str,
+) -> Result<Value> {
+ let shown = plan(store, session, requested)?;
+ if shown["plan_hash"].as_str() != Some(expected) {
+ return Err(Error::conflict(format!(
+ "The offboarding plan changed since it was shown, or {expected} is not its hash: run graphicle offboard --project {requested} again and pass the plan hash it prints"
+ )));
+ }
+ if shown["blocked"] == true {
+ return Err(Error::bad(
+ "A path the offboarding would remove is a symbolic link or lies outside the data folder; Graphicle removes nothing outside its data folder. Remove the link and run graphicle offboard again",
+ ));
+ }
+ let id = s(&shown["project"], "id").to_string();
+ let root = store.directory.canonical()?;
+ let scope: Vec<String> = std::iter::once(id.clone())
+ .chain(
+ shown["pr_scratch_projects"]
+ .as_array()
+ .into_iter()
+ .flatten()
+ .filter_map(Value::as_str)
+ .map(str::to_string),
+ )
+ .collect();
+ let principal =
+ store.authorized_read(&session.workspace, &session.capability, "admin", |_, p| {
+ Ok(p.clone())
+ })?;
+ let mut cleaned = Vec::new();
+ for backup in shown["backups"].as_array().into_iter().flatten() {
+ cleaned.push(scrub(
+ &root,
+ s(backup, "path"),
+ s(backup, "sha256"),
+ &id,
+ &scope,
+ &principal,
+ )?);
+ }
+ let offboarding = json!({
+ "plan_hash": expected,
+ "graph_cache": shown["graph_cache"],
+ "backups": cleaned,
+ "refused": shown["refused"],
+ "not_covered": NOT_COVERED,
+ });
+ // The backups are cleaned first so that the store's receipt can list
+ // them. Should the store's deletion then fail (the project changed in the
+ // meantime, say), the error names the backups already cleaned, whose own
+ // receipt chains record it; running offboard again finishes the store.
+ let deleted = store
+ .offboard_project(
+ &session.workspace,
+ &session.capability,
+ &id,
+ s(&shown["project"], "snapshot"),
+ offboarding,
+ )
+ .map_err(|error| {
+ if cleaned.is_empty() {
+ return error;
+ }
+ let paths: Vec<&str> = cleaned.iter().map(|backup| s(backup, "path")).collect();
+ Error {
+ message: format!(
+ "{} The project was already removed from {} (each with a receipt in that backup's own chain), but not from the store: run graphicle offboard --project {id} again to remove it there.",
+ error.message,
+ paths.join(", ")
+ ),
+ ..error
+ }
+ })?;
+ let cache_left: Vec<&str> = shown["graph_cache"]
+ .as_array()
+ .into_iter()
+ .flatten()
+ .map(|entry| s(entry, "path"))
+ .filter(|path| root.join(path).exists())
+ .collect();
+ if session.project.as_deref() == Some(id.as_str()) {
+ local::save_session(
+ store,
+ &local::Session {
+ project: None,
+ ..session.clone()
+ },
+ )?;
+ }
+ // A refused path was never changed, so it may still hold the project.
+ let refused = shown["refused"].as_array().map_or(0, Vec::len);
+ let verified = deleted["receipt"]["verified_local"] == true
+ && cache_left.is_empty()
+ && cleaned.iter().all(|backup| backup["verified"] == true)
+ && refused == 0;
+ Ok(json!({
+ "offboarded": true,
+ "project": id,
+ "verified": verified,
+ "receipt": deleted["receipt"],
+ "pr_scratch_projects": deleted["pr_scratch_projects"],
+ "graph_cache": shown["graph_cache"],
+ "graph_cache_left": cache_left,
+ "backups": cleaned,
+ "refused": shown["refused"],
+ "not_covered": NOT_COVERED,
+ "storage": deleted["storage"],
+ }))
+}
+
+/// Delete the projects of `scope` (and the PR scratch copies only the
+/// backup records) from the backup `relative`, as the store deletes them,
+/// with receipts in the backup's own chain; then pause its pending external
+/// cleanup as `graphicle backup` does, compact it and check it.
+fn scrub(
+ root: &Path,
+ relative: &str,
+ planned_sha256: &str,
+ project: &str,
+ scope: &[String],
+ p: &Principal,
+) -> Result<Value> {
+ let changed = || {
+ Error::conflict(format!(
+ "{relative} changed since the plan was shown; run graphicle offboard again"
+ ))
+ };
+ let name = relative
+ .strip_prefix(&format!("{BACKUPS}/"))
+ .ok_or_else(changed)?;
+ let Ok(Some(path)) = inside(root, &[BACKUPS, name]) else {
+ return Err(changed());
+ };
+ if other_name(&path).is_some() {
+ return Err(changed());
+ }
+ // The bytes the plan was shown for, opened as they are: never created.
+ let (before, bytes_before) = file_sha256(&path)?;
+ if before != planned_sha256 {
+ return Err(changed());
+ }
+ let mut db = Connection::open_with_flags(
+ &path,
+ OpenFlags::SQLITE_OPEN_READ_WRITE | OpenFlags::SQLITE_OPEN_NO_MUTEX,
+ )?;
+ db.busy_timeout(std::time::Duration::from_secs(10))?;
+ db.pragma_update(None, "foreign_keys", true)?;
+ db.pragma_update(None, "secure_delete", true)?;
+ let transaction = db.transaction_with_behavior(TransactionBehavior::Immediate)?;
+ let held = held_in(&transaction, project, scope, &p.workspace)?;
+ if held.foreign {
+ return Err(changed());
+ }
+ // The PR scratch copies first, then the project, as `project.delete`.
+ let mut order = held.ids.clone();
+ order.sort_by_key(|id| id == project);
+ let mut receipts = Vec::with_capacity(order.len());
+ for id in &order {
+ let receipt = crate::maintenance::delete_project(
+ &transaction,
+ p,
+ id,
+ json!({"offboarding": {"backup": relative}}),
+ )?;
+ receipts.push(json!({
+ "sequence": receipt["sequence"],
+ "digest": receipt["digest"],
+ "verified_local": receipt["verified_local"],
+ }));
+ }
+ transaction.execute(
+ "UPDATE am_projection_cleanup SET state='paused',lease_token=NULL,lease_until=NULL WHERE state!='complete'",
+ [],
+ )?;
+ transaction.commit()?;
+ db.execute_batch("VACUUM;")?;
+ db.query_row("PRAGMA wal_checkpoint(TRUNCATE)", [], |_| Ok(()))?;
+ let integrity: String = db.query_row("PRAGMA integrity_check", [], |r| r.get(0))?;
+ let left = held_in(&db, project, scope, &p.workspace)?.ids.len();
+ drop(db);
+ let (after, bytes_after) = file_sha256(&path)?;
+ let verified =
+ integrity == "ok" && left == 0 && receipts.iter().all(|r| r["verified_local"] == true);
+ Ok(json!({
+ "path": relative,
+ "sha256_before": before,
+ "bytes_before": bytes_before,
+ "sha256_after": after,
+ "bytes_after": bytes_after,
+ "projects_removed": order.len(),
+ "other_projects_kept": held.others,
+ "integrity": integrity,
+ "verified": verified,
+ "receipts": receipts,
+ }))
+}
+
+/// The readable view of [`plan`] and [`apply`].
+pub fn text(value: &Value, _: crate::terminal::Style) -> String {
+ let mut out = Vec::new();
+ let list = |key: &str| value[key].as_array().cloned().unwrap_or_default();
+ if value["offboarded"] == true {
+ let receipt = &value["receipt"];
+ out.push(format!(
+ "Offboarded project {}. Deletion receipt {} (digest {}){}.",
+ s(value, "project"),
+ receipt["sequence"],
+ s(receipt, "digest"),
+ if value["verified"] == true {
+ ", verified"
+ } else {
+ ", NOT fully verified: see the receipt with --json"
+ }
+ ));
+ let refused = list("refused").len();
+ if refused > 0 {
+ out.push(format!(
+ " {refused} refused {} not changed and may still hold the project",
+ if refused == 1 {
+ "path was"
+ } else {
+ "paths were"
+ }
+ ));
+ }
+ for backup in list("backups") {
+ out.push(format!(
+ " removed from backup {} ({} other projects kept)",
+ s(&backup, "path"),
+ backup["other_projects_kept"]
+ ));
+ }
+ for cache in list("graph_cache") {
+ out.push(format!(" removed graph cache {}", s(&cache, "path")));
+ }
+ } else {
+ let project = &value["project"];
+ out.push(format!(
+ "Offboarding plan for project {} ({}). Nothing has been changed.",
+ s(project, "name"),
+ s(project, "id")
+ ));
+ let tables: Vec<String> = value["store_rows"]
+ .as_object()
+ .into_iter()
+ .flatten()
+ .map(|(table, n)| format!("{table} {n}"))
+ .collect();
+ out.push(format!(" store rows: {}", tables.join(", ")));
+ let copies = list("pr_scratch_projects").len();
+ if copies > 0 {
+ out.push(format!(" PR scratch copies: {copies}"));
+ }
+ for cache in list("graph_cache") {
+ out.push(format!(
+ " graph cache {} ({} files, {} bytes)",
+ s(&cache, "path"),
+ cache["files"],
+ cache["bytes"]
+ ));
+ }
+ for backup in list("backups") {
+ out.push(format!(
+ " backup {}: the project is removed from it; its {} other projects stay",
+ s(&backup, "path"),
+ backup["other_projects"]
+ ));
+ }
+ }
+ for refused in list("refused") {
+ out.push(format!(
+ " refused, never touched: {} ({})",
+ s(&refused, "path"),
+ s(&refused, "reason")
+ ));
+ }
+ out.push(" not covered:".to_string());
+ for item in NOT_COVERED {
+ out.push(format!(" - {item}"));
+ }
+ if value["offboarded"] != true {
+ let folders: Vec<&str> = value["project"]["folders"]
+ .as_array()
+ .into_iter()
+ .flatten()
+ .filter_map(Value::as_str)
+ .collect();
+ if !folders.is_empty() {
+ out.push(format!(
+ "Before you apply, run graphicle disconnect in {}, so that its Git hooks and agents do not sync it again.",
+ folders.join(", ")
+ ));
+ }
+ out.push(format!("Next: {}", s(value, "next")));
+ }
+ out.join("\n")
+}
diff --git a/crates/graphicle/src/operations.rs b/crates/graphicle/src/operations.rs
index b3e0a28..bed1de3 100644
--- a/crates/graphicle/src/operations.rs
+++ b/crates/graphicle/src/operations.rs
@@ -116,6 +116,12 @@ impl Store {
if known.is_some(){Ok(json!({"memory":versions.last(),"historical":true}))}else{Ok(json!({"versions":versions}))}
},
"memory.export"=>Ok(json!({"format":"graphicle.memories.v1","repository_id":identifier,"memories":memory::list(db,&repository,p,true)?})),
+ // Reviewed procedures and decisions with an allow-list of
+ // fields and no client-identifying text.
+ "memory.template"=>{
+ let docs=memory::documents(db,&repository,p)?;let memories=memory::list_of(db,&repository,&docs,false)?;
+ crate::packs::template(db,&p.workspace,&repository,&docs,&memories,args)
+ },
"history"=>Ok(json!({"snapshots":rows(db,"SELECT sha256,metadata,created_at FROM repo_snapshots WHERE repository_id=? ORDER BY created_at DESC LIMIT 100",[identifier])?})),
_=>Err(Error::bad("Unsupported project read"))
}
@@ -129,7 +135,10 @@ impl Store {
args: &Value,
) -> Result<Value> {
let permission = match operation {
- "learning.refresh.propose" | "memory.import" | "memory.propose" => "propose",
+ "learning.refresh.propose"
+ | "memory.import"
+ | "memory.import_pack"
+ | "memory.propose" => "propose",
"sync.abort" => "collect",
_ => "approve",
};
@@ -226,6 +235,13 @@ impl Store {
if regrounded+unresolved>0{result["symbol_links"]=json!({"regrounded":regrounded,"unresolved":unresolved});}
Ok(result)
},
+ // Reviewed memories of another project, as drafts whose
+ // evidence and symbol links are rebuilt here.
+ "memory.import_pack"=>{
+ let values=args["memories"].as_array().ok_or_else(||Error::bad("Expected memories, a list"))?;
+ let docs=memory::documents(db,&repository,p)?;
+ crate::packs::import(db,identifier,&docs,values)
+ },
_=>Err(Error::bad("Unsupported project mutation"))
}
})?;
diff --git a/crates/graphicle/src/packs.rs b/crates/graphicle/src/packs.rs
new file mode 100644
index 0000000..b4d2345
--- /dev/null
+++ b/crates/graphicle/src/packs.rs
@@ -0,0 +1,557 @@
+//! Reuse across engagements: engagement templates and knowledge packs.
+//!
+//! **Templates** (`memory.template`). A project's reviewed procedures and
+//! decisions, each built field by field from an allow-list
+//! ([`TEMPLATE_FIELDS`]): kind, title, body and state. Nothing else leaves:
+//! no source quote, link, dependency, id, date or author. In the title and
+//! body, the memory's own quotes, the sources and symbols it cites, the
+//! project's and workspace's names, terms the caller names, URLs, e-mail
+//! addresses, credentials, path-like words, and the project's file names and
+//! code-shaped symbol names are replaced by placeholders. The template
+//! counts each kind of replacement and nothing more.
+//!
+//! **Knowledge packs** (`memory.import_pack`). Reviewed memories (a
+//! `memory.export`, or a template) imported into another project as drafts
+//! a member reviews. Nothing of the exported record is copied but its kind,
+//! title and body: evidence and links are rebuilt here. Each symbol anchor
+//! lands through its logical identity ([`symbols::land`]): the same
+//! relpath, qualified name, kind and ordinal, or the only symbol of that
+//! qualified name and kind elsewhere (moved). A quote stays evidence only
+//! when a current source here holds it: the same source, or the file its
+//! anchored symbol moved to, inside that symbol. Everything else is dropped
+//! and counted by reason in the draft's `data.pack`.
+use crate::{
+ Error, Result, memory,
+ store::{one, s},
+ string,
+ symbols::{self, Landed},
+};
+use regex::{Regex, RegexBuilder};
+use rusqlite::Connection;
+use serde_json::{Map, Value, json};
+use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet};
+use std::sync::OnceLock;
+
+/// `memory.template`'s format.
+pub const TEMPLATE_FORMAT: &str = "graphicle.template.v1";
+/// The kinds of memory a template carries.
+pub const TEMPLATE_KINDS: &[&str] = &["procedure", "decision"];
+/// The only fields of a template memory.
+pub const TEMPLATE_FIELDS: &[&str] = &["kind", "title", "body", "state"];
+/// The only top-level fields of a template.
+pub const TEMPLATE_KEYS: &[&str] = &["format", "memories", "redactions"];
+/// Terms a caller can name for removal.
+pub const MAX_TERMS: usize = 200;
+/// Memories one pack imports.
+pub const MAX_PACK: usize = 500;
+/// The kinds of memory a pack imports.
+const PACK_KINDS: &[&str] = &["decision", "preference", "procedure", "task_state", "note"];
+/// Words of project keys and locations too generic to remove.
+const GENERIC: &[&str] = &[
+ "local",
+ "git",
+ "http",
+ "https",
+ "www",
+ "com",
+ "org",
+ "net",
+ "github",
+ "gitlab",
+ "bitbucket",
+ "users",
+ "home",
+ "src",
+ "main",
+ "master",
+ "repo",
+ "repos",
+ "project",
+ "projects",
+ "folder",
+ "workspace",
+ "code",
+ "dev",
+ "developer",
+ "tmp",
+];
+
+fn regex(cell: &'static OnceLock<Regex>, pattern: &str) -> &'static Regex {
+ cell.get_or_init(|| Regex::new(pattern).unwrap())
+}
+
+fn urls() -> &'static Regex {
+ static CELL: OnceLock<Regex> = OnceLock::new();
+ regex(&CELL, r"(?i)\b[a-z][a-z0-9+.-]*://[^\s<>()\[\]{}`'\x22]+")
+}
+
+fn emails() -> &'static Regex {
+ static CELL: OnceLock<Regex> = OnceLock::new();
+ regex(&CELL, r"[\w.+-]+@[\w-]+(?:\.[\w-]+)+")
+}
+
+/// Words with a path separator: `src/ledger.py`, `/home/acme`, `C:\work`.
+fn paths() -> &'static Regex {
+ static CELL: OnceLock<Regex> = OnceLock::new();
+ regex(&CELL, r"[\w.@~+:-]*(?:[/\\][\w.@~+-]+)+[/\\]?")
+}
+
+/// Code-shaped words: identifiers, dotted or `::` paths, file names.
+fn words() -> &'static Regex {
+ static CELL: OnceLock<Regex> = OnceLock::new();
+ regex(&CELL, r"[A-Za-z_$][\w$-]*(?:(?:\.|::)[A-Za-z_$][\w$-]*)*")
+}
+
+/// A word that reads as code rather than prose: an underscore, a separator,
+/// a digit, or a capital after the first letter.
+fn code_shaped(word: &str) -> bool {
+ word.chars().count() >= 4
+ && (word.contains(['_', '.', ':', '-', '$'])
+ || word.chars().any(|c| c.is_ascii_digit())
+ || word.chars().skip(1).any(char::is_uppercase))
+}
+
+/// Literal terms (ignoring case when asked), bounded as words where they
+/// start or end with a word character.
+fn literals(terms: &BTreeSet<String>, insensitive: bool) -> Result<Option<Regex>> {
+ let mut terms: Vec<&String> = terms.iter().collect();
+ if terms.is_empty() {
+ return Ok(None);
+ }
+ // The longest first, so a longer term is never cut by a shorter one.
+ terms.sort_by(|a, b| b.len().cmp(&a.len()).then(a.cmp(b)));
+ let word = |c: Option<char>| c.is_some_and(|c| c.is_alphanumeric() || c == '_');
+ let pattern: Vec<String> = terms
+ .iter()
+ .map(|term| {
+ let mut p = regex::escape(term);
+ if word(term.chars().next()) {
+ p = format!(r"\b{p}");
+ }
+ if word(term.chars().last()) {
+ p = format!(r"{p}\b");
+ }
+ p
+ })
+ .collect();
+ RegexBuilder::new(&pattern.join("|"))
+ .case_insensitive(insensitive)
+ .size_limit(64 << 20)
+ .build()
+ .map(Some)
+ .map_err(|e| Error::bad(format!("Too many terms to remove: {e}")))
+}
+
+/// Replacements shared by every memory of one template.
+struct Scrubber {
+ terms: Option<Regex>,
+ names: Option<Regex>,
+ /// Code-shaped symbol names (qualified and last part) of the project.
+ symbols: HashSet<String>,
+ /// File names, and code-shaped file stems, of the project's files.
+ files: HashSet<String>,
+ counts: BTreeMap<&'static str, u64>,
+}
+
+fn replace(text: &str, pattern: &Regex, placeholder: &str, count: &mut u64) -> String {
+ pattern
+ .replace_all(text, |_: &regex::Captures<'_>| {
+ *count += 1;
+ placeholder.to_string()
+ })
+ .into_owned()
+}
+
+impl Scrubber {
+ fn scrub(&mut self, text: &str, own: &Own) -> String {
+ let mut text = text.to_string();
+ let mut tally: Vec<(&'static str, u64)> = Vec::new();
+ for quote in &own.quotes {
+ let found = text.matches(quote.as_str()).count() as u64;
+ if found > 0 {
+ text = text.replace(quote.as_str(), "[quote]");
+ tally.push(("[quote]", found));
+ }
+ }
+ for (pattern, placeholder) in [
+ (own.sources.as_ref(), "[source]"),
+ (own.symbols.as_ref(), "[symbol]"),
+ (self.terms.as_ref(), "[term]"),
+ (self.names.as_ref(), "[project]"),
+ ] {
+ if let Some(pattern) = pattern {
+ let mut found = 0;
+ text = replace(&text, pattern, placeholder, &mut found);
+ tally.push((placeholder, found));
+ }
+ }
+ let before = text.matches("[credential redacted]").count();
+ text = crate::operations::redact(&text);
+ let after = text.matches("[credential redacted]").count();
+ tally.push(("[credential redacted]", after.saturating_sub(before) as u64));
+ for (pattern, placeholder) in [
+ (urls(), "[url]"),
+ (emails(), "[email]"),
+ (paths(), "[path]"),
+ ] {
+ let mut found = 0;
+ text = replace(&text, pattern, placeholder, &mut found);
+ tally.push((placeholder, found));
+ }
+ let (mut symbols, mut files) = (0, 0);
+ text = words()
+ .replace_all(&text, |found: &regex::Captures<'_>| {
+ let word = &found[0];
+ if self.files.contains(word) {
+ files += 1;
+ return "[path]".to_string();
+ }
+ let symbol = self.symbols.contains(word)
+ || word
+ .split([':', '.', '-'])
+ .any(|part| self.symbols.contains(part));
+ if symbol {
+ symbols += 1;
+ "[symbol]".to_string()
+ } else {
+ word.to_string()
+ }
+ })
+ .into_owned();
+ tally.push(("[symbol]", symbols));
+ tally.push(("[path]", files));
+ for (placeholder, n) in tally {
+ *self.counts.entry(placeholder).or_default() += n;
+ }
+ text
+ }
+}
+
+/// What one memory cites: its quotes, its sources and its linked symbols.
+struct Own {
+ quotes: Vec<String>,
+ sources: Option<Regex>,
+ symbols: Option<Regex>,
+}
+
+fn own(data: &Value) -> Result<Own> {
+ let mut quotes: Vec<String> = data["evidence"]
+ .as_array()
+ .into_iter()
+ .flatten()
+ .map(|c| s(c, "quote").trim().to_string())
+ .filter(|q| q.chars().count() >= 4)
+ .collect();
+ quotes.sort_by(|a, b| b.len().cmp(&a.len()).then(a.cmp(b)));
+ quotes.dedup();
+ let mut sources = BTreeSet::new();
+ for citation in data["evidence"].as_array().into_iter().flatten() {
+ let id = s(citation, "id");
+ sources.insert(id.to_string());
+ if let Some(path) = id.strip_prefix("file:") {
+ sources.insert(path.to_string());
+ }
+ }
+ for key in [
+ "dependencies",
+ "evidence_links",
+ "native_sources",
+ "symbol_files",
+ ] {
+ for id in data[key].as_object().into_iter().flat_map(Map::keys) {
+ sources.insert(id.clone());
+ if let Some(path) = id.strip_prefix("file:") {
+ sources.insert(path.to_string());
+ }
+ }
+ }
+ let mut names = BTreeSet::new();
+ for link in data["symbols"].as_array().into_iter().flatten() {
+ for path in [&link["identity"]["relpath"], &link["relpath"]] {
+ if let Some(path) = path.as_str().filter(|p| !p.is_empty()) {
+ sources.insert(path.to_string());
+ }
+ }
+ if let Some(qualified) = link["identity"]["qualified_name"].as_str() {
+ names.insert(qualified.to_string());
+ for part in qualified.split(['.', ':']) {
+ if part.chars().count() >= 3 {
+ names.insert(part.to_string());
+ }
+ }
+ }
+ }
+ sources.retain(|t| t.chars().count() >= 3);
+ names.retain(|t| t.chars().count() >= 3);
+ Ok(Own {
+ quotes,
+ sources: literals(&sources, false)?,
+ symbols: literals(&names, false)?,
+ })
+}
+
+/// The project's names: its name, its key and the locations its metadata
+/// records, with their distinctive parts.
+fn project_names(repository: &Value, workspace: &str) -> BTreeSet<String> {
+ let mut names = BTreeSet::new();
+ let mut add = |value: &str, split: bool| {
+ let value = value.trim();
+ if value.chars().count() >= 3 {
+ names.insert(value.to_string());
+ }
+ if split {
+ for part in value.split(|c: char| !(c.is_alphanumeric() || c == '_' || c == '-')) {
+ let part = part.trim_end_matches(".git");
+ if part.chars().count() >= 4 && !GENERIC.contains(&part.to_lowercase().as_str()) {
+ names.insert(part.to_string());
+ }
+ }
+ }
+ };
+ add(s(repository, "name"), false);
+ add(workspace, false);
+ add(s(repository, "project_key"), true);
+ // Locations in the project's metadata (folder, remote, URL).
+ let mut pending = vec![&repository["metadata"]];
+ while let Some(value) = pending.pop() {
+ match value {
+ Value::Object(map) => {
+ for (key, value) in map {
+ let key = key.to_lowercase();
+ let location = ["root", "remote", "url", "origin", "path", "folder", "name"]
+ .iter()
+ .any(|k| key.contains(k));
+ match value {
+ Value::String(text) if location => add(text, true),
+ Value::Object(_) | Value::Array(_) => pending.push(value),
+ _ => {}
+ }
+ }
+ }
+ Value::Array(items) => pending.extend(items),
+ _ => {}
+ }
+ }
+ names
+}
+
+/// `memory.template`: the reviewed procedures and decisions of a project,
+/// with only [`TEMPLATE_FIELDS`] and the replacements described above.
+pub fn template(
+ db: &Connection,
+ workspace: &str,
+ repository: &Value,
+ documents: &[Value],
+ memories: &[Value],
+ args: &Value,
+) -> Result<Value> {
+ let terms: BTreeSet<String> = match args.get("terms") {
+ None | Some(Value::Null) => BTreeSet::new(),
+ Some(Value::Array(items)) if items.len() <= MAX_TERMS => items
+ .iter()
+ .map(|t| {
+ t.as_str()
+ .filter(|t| !t.trim().is_empty() && t.len() <= 200)
+ .map(|t| t.trim().to_string())
+ .ok_or_else(|| Error::bad("Each term is a string of 1 to 200 bytes"))
+ })
+ .collect::<Result<_>>()?,
+ Some(_) => {
+ return Err(Error::bad(format!(
+ "terms must be a list of at most {MAX_TERMS} strings"
+ )));
+ }
+ };
+ let name = one(db, "SELECT name FROM workspaces WHERE id=?", [workspace])?
+ .map(|row| s(&row, "name").to_string())
+ .unwrap_or_default();
+ let identifier = s(repository, "id");
+ let mut symbols = HashSet::new();
+ let mut statement = db.prepare_cached(
+ "SELECT DISTINCT qualified_name FROM gf_symbol_heads WHERE repository_id=?1",
+ )?;
+ let names = statement.query_map([identifier], |row| row.get::<_, String>(0))?;
+ for qualified in names {
+ let qualified = qualified?;
+ for part in qualified.split(['.', ':']).filter(|p| code_shaped(p)) {
+ symbols.insert(part.to_string());
+ }
+ if code_shaped(&qualified) {
+ symbols.insert(qualified);
+ }
+ }
+ let mut files = HashSet::new();
+ for doc in documents {
+ if let Some(path) = s(doc, "id").strip_prefix("file:") {
+ let file = path.rsplit(['/', '\\']).next().unwrap_or(path);
+ if file.contains('.') || code_shaped(file) {
+ files.insert(file.to_string());
+ }
+ let stem = file.split('.').next().unwrap_or(file);
+ if code_shaped(stem) {
+ files.insert(stem.to_string());
+ }
+ }
+ }
+ let mut scrubber = Scrubber {
+ terms: literals(&terms, true)?,
+ names: literals(&project_names(repository, &name), true)?,
+ symbols,
+ files,
+ counts: BTreeMap::new(),
+ };
+ let mut out = Vec::new();
+ for memory in memories {
+ if memory["state"] != "reviewed" || !TEMPLATE_KINDS.contains(&s(memory, "kind")) {
+ continue;
+ }
+ let own = own(&memory["data"])?;
+ out.push(json!({
+ "kind": s(memory, "kind"),
+ "title": scrubber.scrub(s(memory, "title"), &own),
+ "body": scrubber.scrub(s(memory, "body"), &own),
+ "state": "reviewed",
+ }));
+ }
+ scrubber.counts.retain(|_, n| *n > 0);
+ Ok(json!({"format":TEMPLATE_FORMAT,"memories":out,"redactions":scrubber.counts}))
+}
+
+fn bump(counts: &mut Value, key: &str) {
+ let n = counts[key].as_u64().unwrap_or(0);
+ counts[key] = json!(n + 1);
+}
+
+/// `memory.import_pack`: import the reviewed memories of `items` as drafts
+/// (see the module documentation). Other states are skipped and counted.
+pub fn import(
+ db: &Connection,
+ repository: &str,
+ documents: &[Value],
+ items: &[Value],
+) -> Result<Value> {
+ if items.len() > MAX_PACK {
+ return Err(Error::bad(format!("Import at most {MAX_PACK} memories")));
+ }
+ let mut imported = Vec::new();
+ let mut skipped = 0;
+ let mut totals = json!({"evidence":{"kept":0,"moved":0,"dropped":{}},"anchors":{"landed":0,"moved":0,"dropped":{}}});
+ // One lander and one index of the documents for the whole pack, not one
+ // per memory.
+ let mut lander = symbols::Lander::new(db, repository, documents);
+ let by_id: HashMap<&str, &Value> = documents.iter().map(|d| (s(d, "id"), d)).collect();
+ for item in items {
+ if item["state"] != "reviewed" {
+ skipped += 1;
+ continue;
+ }
+ let kind = string(item, "kind", 100)?;
+ if !PACK_KINDS.contains(&kind) {
+ return Err(Error::bad(
+ "Choose decision, preference, procedure, task_state or note",
+ ));
+ }
+ let title = string(item, "title", 500)?;
+ let body = string(item, "body", 64000)?;
+ let old = match item.get("data") {
+ None | Some(Value::Null) => json!({}),
+ Some(value @ Value::Object(_)) => value.clone(),
+ Some(_) => return Err(Error::bad("Invalid memory data")),
+ };
+ let mut marks = json!({"evidence":{"kept":0,"moved":0,"dropped":{}},"anchors":{"landed":0,"moved":0,"dropped":{}}});
+ // Each symbol identity once, whatever rungs linked it.
+ let mut seen = BTreeSet::new();
+ let anchors: Vec<Value> = old["symbols"]
+ .as_array()
+ .into_iter()
+ .flatten()
+ .filter(|link| link["identity"].is_object())
+ .map(|link| link["identity"].clone())
+ .filter(|identity| seen.insert(identity.to_string()))
+ .take(symbols::MAX_LINKS)
+ .collect();
+ let landings = lander.land(&anchors)?;
+ let mut landed: Vec<&Landed> = Vec::new();
+ for landing in &landings {
+ match landing {
+ Ok(found) => {
+ bump(&mut marks["anchors"], "landed");
+ if found.moved {
+ bump(&mut marks["anchors"], "moved");
+ }
+ landed.push(found);
+ }
+ Err(reason) => bump(&mut marks["anchors"]["dropped"], reason),
+ }
+ }
+ let doc = |id: &str| by_id.get(id).copied();
+ let mut kept = Vec::new();
+ for citation in old["evidence"].as_array().into_iter().flatten() {
+ let (Some(id), Some(quote)) = (citation["id"].as_str(), citation["quote"].as_str())
+ else {
+ bump(&mut marks["evidence"]["dropped"], "invalid");
+ continue;
+ };
+ if quote.trim().is_empty() || id.len() > 1500 || quote.len() > 12000 {
+ bump(&mut marks["evidence"]["dropped"], "invalid");
+ continue;
+ }
+ let here = doc(id);
+ if here.is_some_and(|d| s(d, "content").contains(quote)) {
+ bump(&mut marks["evidence"], "kept");
+ kept.push(json!({"id":id,"quote":quote}));
+ continue;
+ }
+ // The file its anchored symbol moved to, inside that symbol.
+ let moved = id.strip_prefix("file:").and_then(|from| {
+ landed.iter().find_map(|l| {
+ let to = format!("file:{}", l.row.identity.relpath);
+ let content = s(doc(&to)?, "content");
+ let range = l.row.range(
+ &graphicle_memory::graph::span::line_starts(content),
+ content.len(),
+ );
+ (l.from == from && to != id && content.get(range)?.contains(quote))
+ .then_some(to)
+ })
+ });
+ match moved {
+ Some(to) => {
+ bump(&mut marks["evidence"], "kept");
+ bump(&mut marks["evidence"], "moved");
+ kept.push(json!({"id":to,"quote":quote}));
+ }
+ None if here.is_none() => bump(&mut marks["evidence"]["dropped"], "source_missing"),
+ None => bump(&mut marks["evidence"]["dropped"], "quote_missing"),
+ }
+ }
+ let mut data = memory::dependencies(db, repository, &kept, documents)?;
+ symbols::link_landed(db, repository, &landed, documents, &mut data)?;
+ data["authority"] = json!("unreviewed_pack");
+ data["notes"] = json!({});
+ for part in ["evidence", "anchors"] {
+ for (key, value) in marks[part].as_object().unwrap().clone() {
+ match value {
+ Value::Object(reasons) => {
+ for (reason, n) in reasons {
+ let total = totals[part][&key][&reason].as_u64().unwrap_or(0);
+ totals[part][&key][&reason] = json!(total + n.as_u64().unwrap_or(0));
+ }
+ }
+ n => {
+ let total = totals[part][&key].as_u64().unwrap_or(0);
+ totals[part][&key] = json!(total + n.as_u64().unwrap_or(0));
+ }
+ }
+ }
+ }
+ data["pack"] = marks;
+ imported.push(memory::save(
+ db, repository, None, None, kind, title, body, "draft", &data,
+ )?);
+ }
+ let mut result = json!({"imported":imported,"skipped":skipped,"approval_required":true});
+ result["evidence"] = totals["evidence"].take();
+ result["anchors"] = totals["anchors"].take();
+ Ok(result)
+}
diff --git a/crates/graphicle/src/permissions.rs b/crates/graphicle/src/permissions.rs
index a96a70b..c9abfb0 100644
--- a/crates/graphicle/src/permissions.rs
+++ b/crates/graphicle/src/permissions.rs
@@ -10,6 +10,10 @@ use crate::{
use rusqlite::{Connection, params};
use serde_json::Value;
+/// Whether `p` may read a document whose provider permissions are
+/// `permission`. `provider` is the provider of the verified identities and
+/// connected accounts the principals name
+/// (`connectors::identity_provider`, Atlassian for Jira and Confluence).
pub fn allows(
db: &Connection,
workspace: &str,
diff --git a/crates/graphicle/src/product.rs b/crates/graphicle/src/product.rs
index 00e4f7c..21cd123 100644
--- a/crates/graphicle/src/product.rs
+++ b/crates/graphicle/src/product.rs
@@ -87,7 +87,7 @@ async fn commands(
Path((workspace, repository)): Path<(String, String)>,
headers: HeaderMap,
Json(mut body): Json<Command>,
-) -> Result<Json<Value>> {
+) -> Result<Response> {
let capability = api::token(&headers)?.to_owned();
if !body.arguments.is_object() {
return Err(Error::bad("arguments must be an object"));
@@ -112,16 +112,32 @@ async fn commands(
store.authorized_read(&w, &c, "read", |db, p| repo(db, p, &repository).map(|_| ()))
})
.await?;
- Ok(Json(
- api::command_async(
- &app,
- &workspace,
- &capability,
- &body.operation,
- &body.arguments,
- )
- .await?,
- ))
+ // The one admission, as the command routes (`crate::metering::admit`):
+ // authorized, then a metered operation's quota; run; then a read's result
+ // size-checked and a metered result counted.
+ let mut admission = match crate::metering::admit_request(
+ &app.worker.store,
+ &workspace,
+ &capability,
+ &headers,
+ &body.operation,
+ &body.arguments,
+ )
+ .await
+ {
+ Ok(admission) => admission,
+ Err(error) => return Ok(crate::metering::refusal(error)),
+ };
+ let narrowed = admission.take_arguments();
+ let value = api::dispatch_async(
+ &app,
+ &workspace,
+ &capability,
+ &body.operation,
+ narrowed.as_ref().unwrap_or(&body.arguments),
+ )
+ .await?;
+ Ok(Json(crate::metering::served(&app.worker.store, admission, value).await?).into_response())
}
pub async fn blocking<T: Send + 'static>(
@@ -172,6 +188,23 @@ async fn budget(
fn month() -> String {
Utc::now().format("%Y-%m").to_string()
}
+/// `Retry-After` for a limit of the current UTC month (the request budget,
+/// an installed edition's served-token quota): the seconds until the next one
+/// starts.
+pub fn until_next_month() -> HeaderValue {
+ let now = Utc::now();
+ let (year, month) = if now.month() == 12 {
+ (now.year() + 1, 1)
+ } else {
+ (now.year(), now.month() + 1)
+ };
+ let reset = chrono::NaiveDate::from_ymd_opt(year, month, 1)
+ .unwrap()
+ .and_hms_opt(0, 0, 0)
+ .unwrap()
+ .and_utc();
+ HeaderValue::from_str(&(reset - now).num_seconds().max(1).to_string()).unwrap()
+}
fn day() -> String {
Utc::now().format("%Y-%m-%d").to_string()
}
@@ -304,6 +337,11 @@ impl Store {
}
pub fn product_usage(&self, workspace: &str, cap: &str) -> Result<Value> {
+ // The owner first, with a read; then this process's served counts,
+ // briefly, so the report holds them. What a busy store leaves is
+ // reported as `unrecorded_tokens` (`metering::flush_briefly`).
+ self.authorized_read(workspace, cap, "admin", |_, _| Ok(()))?;
+ crate::metering::flush_briefly(self).ok();
self.authorized_read(workspace, cap, "admin", |db, p| {
let period = month();
let start = format!("{period}-01");
@@ -328,6 +366,15 @@ impl Store {
"scope":"Authenticated HTTP requests, including MCP tool calls. Failed requests consume the request budget. Sign-in, navigation, usage, billing, export, deletion and cancellation are exempt. Local CLI and background model calls are separate.",
"cost":null,"cost_note":"Provider charges are not estimated. Model budgets are enforced per workflow; missing usage is shown separately."
});
+ // What Graphicle served this month (`metering`), beside the model
+ // tokens it spent, by credential and model. Counts, no cost.
+ let mut served = crate::metering::summary(db, &p.workspace, &start, &day())?;
+ served["unrecorded_tokens"] =
+ json!(crate::metering::unrecorded_in(self, &p.workspace));
+ usage["served"] = served;
+ let models = crate::metering::model_usage(db, &p.workspace, &start, &day())?;
+ usage["model_usage_by_credential"] = models["by_credential"].clone();
+ usage["model_usage_by_model"] = models["by_model"].clone();
crate::extension::installed().usage_details(db, &p.workspace, &mut usage)?;
Ok(usage)
})
@@ -441,7 +488,7 @@ pub async fn meter(State(app): State<App>, request: Request<Body>, next: Next) -
|| (!mcp
&& parts
.get(3)
- .is_some_and(|v| matches!(*v, "billing" | "credentials")))
+ .is_some_and(|v| matches!(*v, "billing" | "credentials" | "usage")))
{
return next.run(request).await;
}
@@ -479,21 +526,9 @@ pub async fn meter(State(app): State<App>, request: Request<Body>, next: Next) -
let limited = error.status == StatusCode::TOO_MANY_REQUESTS;
let mut response = error.into_response();
if limited {
- let now = Utc::now();
- let (year, month) = if now.month() == 12 {
- (now.year() + 1, 1)
- } else {
- (now.year(), now.month() + 1)
- };
- let reset = chrono::NaiveDate::from_ymd_opt(year, month, 1)
- .unwrap()
- .and_hms_opt(0, 0, 0)
- .unwrap()
- .and_utc();
- response.headers_mut().insert(
- "retry-after",
- HeaderValue::from_str(&(reset - now).num_seconds().max(1).to_string()).unwrap(),
- );
+ response
+ .headers_mut()
+ .insert("retry-after", until_next_month());
}
return response;
}
diff --git a/crates/graphicle/src/product_schema.sql b/crates/graphicle/src/product_schema.sql
index 4bf7703..7b4b9e0 100644
--- a/crates/graphicle/src/product_schema.sql
+++ b/crates/graphicle/src/product_schema.sql
@@ -8,3 +8,15 @@ CREATE TABLE IF NOT EXISTS am_product_policy (
workspace_id TEXT PRIMARY KEY REFERENCES workspaces(id) ON DELETE CASCADE,
monthly_request_budget INTEGER CHECK(monthly_request_budget >= 0),
updated_at TEXT NOT NULL);
+-- What Graphicle served (crate::metering): counters only, never a question,
+-- a result, a source id or a client's own session id.
+CREATE TABLE IF NOT EXISTS am_served_usage (
+ repository_id TEXT NOT NULL REFERENCES repo_projects(id) ON DELETE CASCADE,
+ workspace_id TEXT NOT NULL REFERENCES workspaces(id) ON DELETE CASCADE,
+ day TEXT NOT NULL, credential_id TEXT NOT NULL, session TEXT NOT NULL,
+ channel TEXT NOT NULL, kind TEXT NOT NULL,
+ calls INTEGER NOT NULL DEFAULT 0, tokens INTEGER NOT NULL DEFAULT 0,
+ PRIMARY KEY(repository_id,day,credential_id,session,channel,kind));
+CREATE INDEX IF NOT EXISTS am_served_usage_workspace ON am_served_usage(workspace_id,day);
+-- A credential's month (an installed edition's quotas, the reports).
+CREATE INDEX IF NOT EXISTS am_served_usage_credential ON am_served_usage(workspace_id,credential_id,day);
diff --git a/crates/graphicle/src/prompt_hook.rs b/crates/graphicle/src/prompt_hook.rs
new file mode 100644
index 0000000..ffc3abb
--- /dev/null
+++ b/crates/graphicle/src/prompt_hook.rs
@@ -0,0 +1,193 @@
+//! Claude Code's prompt-context hook (`graphicle setup --prompt-context`,
+//! off by default): on UserPromptSubmit, `graphicle hook claude-code
+//! prompt-context` runs `graphicle context` on the prompt and hands Claude
+//! Code the packet's Markdown as `additionalContext`, so the agent starts
+//! with the retrieval's excerpts. `graphicle context` keeps a packet within
+//! [`crate::query::PUSH_CHARS`] (8,400) characters, below the 10,000 that
+//! Claude Code shows of a hook's output (it shows a longer one as a 2 KB
+//! preview).
+//!
+//! The hook adds nothing, and never holds the prompt up for long: when the
+//! prompt has fewer than [`MIN_CHARS`] characters besides spaces, when it is
+//! not a code question ([`crate::code_question::is_code_question`], the
+//! classifier `context` itself uses), when the folder is in no Graphicle
+//! project, when `graphicle context` fails or prints no Markdown, and when
+//! it has not answered within [`SECONDS`] seconds (it is then stopped).
+use serde_json::{Value, json};
+use std::path::{Path, PathBuf};
+use std::time::{Duration, Instant};
+
+/// Characters a prompt needs, spaces left out, to get context: shorter
+/// ones ("yes", "go on", "run the tests") are replies, not questions.
+pub const MIN_CHARS: usize = 16;
+
+/// Seconds the hook waits for `graphicle context` before it gives up and
+/// adds nothing.
+pub const SECONDS: u64 = 10;
+
+/// The timeout of the hook's entry in Claude Code's settings, in seconds:
+/// a backstop above [`SECONDS`], so Claude Code never waits longer.
+pub const HOOK_TIMEOUT: u64 = 15;
+
+/// The question the hook asks for `payload` (Claude Code's UserPromptSubmit
+/// input): its `prompt`, when that is long enough and a code question,
+/// shortened as `context` would shorten it past 16,000 bytes; `None`
+/// otherwise.
+pub fn question(payload: &Value) -> Option<String> {
+ let prompt = payload["prompt"].as_str()?.trim();
+ if prompt.chars().filter(|c| !c.is_whitespace()).count() < MIN_CHARS
+ || !crate::code_question::is_code_question(prompt)
+ {
+ return None;
+ }
+ Some(
+ crate::code_question::shorten(prompt)
+ .map_or_else(|| prompt.to_string(), |(shortened, _)| shortened),
+ )
+}
+
+/// Claude Code's output for `markdown`: the packet as the prompt's
+/// additional context.
+pub fn output(markdown: &str) -> Value {
+ json!({"hookSpecificOutput":{"hookEventName":"UserPromptSubmit","additionalContext":markdown}})
+}
+
+/// Run the hook for the data folder `directory` on `payload`: print
+/// [`output`] when the prompt gets context, else nothing.
+pub fn run(directory: &Path, payload: &Value) {
+ use std::io::Write;
+ let Some(question) = question(payload) else {
+ return;
+ };
+ let Some(cwd) = payload["cwd"]
+ .as_str()
+ .map(PathBuf::from)
+ .filter(|cwd| cwd.is_dir())
+ .or_else(|| std::env::current_dir().ok())
+ else {
+ return;
+ };
+ let Some(project) = project(directory, &cwd) else {
+ return;
+ };
+ if let Some(markdown) = context(
+ directory,
+ &cwd,
+ &project,
+ &question,
+ Duration::from_secs(SECONDS),
+ ) {
+ let _ = writeln!(std::io::stdout(), "{}", output(&markdown));
+ }
+}
+
+/// The project whose registered folder holds `cwd`; never the saved default
+/// project, so a prompt in another folder gets nothing.
+fn project(directory: &Path, cwd: &Path) -> Option<String> {
+ let store = crate::store::Store::open(directory).ok()?;
+ let session = crate::local::session(&store, false).ok()?;
+ crate::capture::project_for_cwd(&store, &session, cwd)
+ .ok()
+ .flatten()
+}
+
+/// `graphicle --data-dir <directory> context --json --project <project> -`
+/// in `cwd`, the question on its standard input, at most `wait`: the
+/// packet's Markdown, at most [`crate::query::PUSH_CHARS`] characters, or
+/// `None` when it fails, prints none or runs past `wait` (it is then
+/// stopped).
+fn context(
+ directory: &Path,
+ cwd: &Path,
+ project: &str,
+ question: &str,
+ wait: Duration,
+) -> Option<String> {
+ use std::io::{Read, Write};
+ let mut command = std::process::Command::new(std::env::current_exe().ok()?);
+ command
+ .arg("--data-dir")
+ .arg(directory)
+ .args(["context", "--json", "--project", project, "-"])
+ .current_dir(cwd)
+ .stdin(std::process::Stdio::piped())
+ .stdout(std::process::Stdio::piped())
+ .stderr(std::process::Stdio::null());
+ let mut child = command.spawn().ok()?;
+ // The question (at most 16,000 bytes, below a pipe's buffer), then the
+ // end of the input.
+ let written = child
+ .stdin
+ .take()
+ .is_some_and(|mut input| input.write_all(question.as_bytes()).is_ok());
+ if !written {
+ let _ = child.kill();
+ let _ = child.wait();
+ return None;
+ }
+ let mut stdout = child.stdout.take()?;
+ // Read as it is written: a packet larger than the pipe's buffer would
+ // otherwise hold the process up.
+ let reader = std::thread::spawn(move || {
+ let mut printed = Vec::new();
+ stdout.read_to_end(&mut printed).ok().map(|_| printed)
+ });
+ let started = Instant::now();
+ loop {
+ match child.try_wait() {
+ Ok(Some(status)) if status.success() => break,
+ Ok(None) if started.elapsed() < wait => std::thread::sleep(Duration::from_millis(20)),
+ Ok(None) => {
+ let _ = child.kill();
+ let _ = child.wait();
+ return None;
+ }
+ _ => return None,
+ }
+ }
+ let printed = reader.join().ok()??;
+ let packet: Value = serde_json::from_slice(&printed).ok()?;
+ let markdown = packet["markdown"].as_str()?.trim();
+ (!markdown.is_empty()).then(|| markdown.chars().take(crate::query::PUSH_CHARS).collect())
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ #[test]
+ fn only_a_code_question_of_some_length_gets_context() {
+ let ask = |prompt: &str| question(&json!({"prompt": prompt}));
+ // Short replies and questions in plain words get nothing.
+ for prompt in [
+ "",
+ "yes",
+ "fix `x`",
+ "parse_config?",
+ "Please summarise what we decided about caching last week",
+ ] {
+ assert_eq!(ask(prompt), None, "{prompt}");
+ }
+ assert_eq!(question(&json!({})), None);
+ assert_eq!(question(&json!({"prompt": 3})), None);
+ // A prompt that names code, or reads like a bug report, does.
+ let named = "Why does `parse_config` drop the last line?";
+ assert_eq!(ask(named).as_deref(), Some(named));
+ let report = "The export crashes with an error when the folder is empty";
+ assert_eq!(ask(report).as_deref(), Some(report));
+ // A long one is shortened as `context` shortens it.
+ let long = format!("`parse_config` fails.\n{}", "word ".repeat(5000));
+ let asked = ask(&long).unwrap();
+ assert!(asked.len() <= crate::code_question::MAX_QUESTION_BYTES);
+ assert!(asked.starts_with("`parse_config` fails."));
+ }
+
+ #[test]
+ fn the_output_is_the_markdown_as_additional_context() {
+ assert_eq!(
+ output("Graphicle project evidence"),
+ json!({"hookSpecificOutput":{"hookEventName":"UserPromptSubmit",
+ "additionalContext":"Graphicle project evidence"}})
+ );
+ }
+}
diff --git a/crates/graphicle/src/query.rs b/crates/graphicle/src/query.rs
index 440ae96..bde4023 100644
--- a/crates/graphicle/src/query.rs
+++ b/crates/graphicle/src/query.rs
@@ -24,6 +24,53 @@ pub const SEMANTIC_WEIGHT: f64 = 0.5;
/// order.
pub const MAX_RERANK_DEPTH: usize = 300;
+/// `graphicle context`'s default `max_chars`. A UserPromptSubmit hook
+/// prints the packet as JSON (`additionalContext`) under a short header, and
+/// Claude Code (2.1.287) shows the model only a preview of hook output over
+/// 10,000 characters. 0.1.1's default (4 characters per `max_tokens` token,
+/// 12,000 at 3,000 tokens) could go over; at 8,400 characters the escaped
+/// JSON, header included, stays below 9,500.
+pub const PUSH_CHARS: usize = 8_400;
+
+/// `notes_first` when a call leaves it out: off, so `context` (and so
+/// `recall_project`, `graphicle context` and answers) builds 0.1.2's packet.
+/// `notes_first: true` turns on, for one call, the notes-first order of a
+/// question in prose and one window per file ([`crate::notes_first`]), and
+/// dated excerpts ([`crate::source_age`], which `source_age` also turns on or
+/// off by itself). The packet's `notes_first` says what applied.
+pub const NOTES_FIRST_DEFAULT: bool = false;
+
+/// `identifier_route` when a call to `context` leaves it out: off, so the
+/// HTTP API, `graphicle call context`, the SDKs and the app's evidence
+/// button keep the retrieval unless a call asks for the route
+/// (`identifier_route: true`). `recall_project` in the essentials set
+/// ([`crate::api::identifier_route_default`]) and `graphicle context` ask
+/// for it unless told otherwise: a question that is an identifier, or only
+/// asks where named identifiers are defined or used, then gets their
+/// definitions and references from the code graph instead of the full
+/// retrieval ([`crate::identifier_route`]). The packet's `route` says which
+/// path ran.
+pub const IDENTIFIER_ROUTE_DEFAULT: bool = false;
+
+/// Sources `rank` offers past a call's `limit`, so the windows that
+/// [`crate::notes_first::one_per_file`] drops are replaced.
+pub const EXTRA_SOURCES: usize = 4;
+
+/// Passages of the fused order `rank` returns for a question in prose, from
+/// which [`crate::notes_first::rerank`] takes its first files.
+pub const NOTES_FUSED: usize = 400;
+
+/// `more_files` when a call leaves it out, for a code question
+/// ([`crate::code_question::is_code_question`]); other questions list none.
+/// After its excerpts a packet lists the paths of this many files that rank
+/// next (one line each, from at most an eighth of the budget), so an agent
+/// sees the files the budget cut.
+pub const MORE_FILES_DEFAULT: usize = 10;
+
+/// Passages of the fused order `rank` returns for the files a packet lists
+/// after its excerpts.
+pub const MORE_FILES_FUSED: usize = 200;
+
/// Retrieval options that are on unless a call turns them off. An absent or
/// `null` option takes its value here and is listed in the packet's
/// `retrieval_defaults`; `false` turns it off. Porter-stemmed BM25 (Lucene's
@@ -489,7 +536,7 @@ impl Filter {
};
Ok((include.is_some() || metadata.is_some()).then_some(Self { include, metadata }))
}
- fn keeps(&self, document: &Value) -> bool {
+ pub(crate) fn keeps(&self, document: &Value) -> bool {
let id = s(document, "id");
self.include
.as_ref()
@@ -574,10 +621,13 @@ pub fn passages(snapshot: &Snapshot) -> Result<Passages> {
/// ([`graphicle_memory::ingest::MAX_DOCUMENTS`] documents and
/// [`graphicle_memory::ingest::MAX_PASSAGES`] passages) this is
/// [`passages`]. Past them, which documents are read is decided by the
-/// question: the documents are ordered so those that match more of its
-/// words (in the path or title twice) are taken first among documents of
-/// equal time, and the coverage says so (`selected_by_question`), instead
-/// of leaving out the earliest listed paths of a large project.
+/// question: the documents are ordered by a BM25 score of the question's
+/// words in each (a word in the path or title counts twice more), so the
+/// best are taken first among documents of equal time, and the coverage
+/// says so (`selected_by_question`), instead of leaving out the earliest
+/// listed paths of a large project. The score divides by length as BM25
+/// does: a long file that holds many of the words no longer fills the bound
+/// before a short one that holds the rare ones.
pub fn passages_for(snapshot: &mut Snapshot, question: &str) -> Result<Passages> {
if snapshot.documents.len() <= graphicle_memory::ingest::MAX_DOCUMENTS {
let within = passages(snapshot)?;
@@ -595,8 +645,14 @@ pub fn passages_for(snapshot: &mut Snapshot, question: &str) -> Result<Passages>
Ok(selected)
}
+/// Most words of a question that choose the documents read past the bounds.
+const SELECTION_TERMS: usize = 64;
+
/// The words of a question that select documents: letters, digits and `_`,
-/// at least three characters, without common words, at most 24.
+/// at least three characters, without common words, each once, at most
+/// [`SELECTION_TERMS`]: words written as code (with `_`, a digit or a
+/// capital inside) first, then the others in the question's order. The
+/// scores weigh each by how few documents hold it.
fn question_terms(question: &str) -> Vec<String> {
const COMMON: [&str; 40] = [
"the", "and", "for", "with", "what", "which", "where", "when", "does", "how", "why", "who",
@@ -604,29 +660,46 @@ fn question_terms(question: &str) -> Vec<String> {
"about", "there", "their", "they", "them", "then", "than", "its", "our", "your", "you",
"all", "any", "did", "should", "would",
];
- let mut terms = Vec::new();
+ let coded = |word: &str| {
+ word.contains('_')
+ || word.chars().any(|c| c.is_ascii_digit())
+ || word.chars().skip(1).any(char::is_uppercase)
+ };
+ let mut code = Vec::new();
+ let mut plain = Vec::new();
for word in question.split(|c: char| !(c.is_alphanumeric() || c == '_')) {
- let word = word.to_lowercase();
- if word.chars().count() >= 3 && !COMMON.contains(&word.as_str()) && !terms.contains(&word) {
- terms.push(word);
+ let lower = word.to_lowercase();
+ if lower.chars().count() < 3
+ || COMMON.contains(&lower.as_str())
+ || code.contains(&lower)
+ || plain.contains(&lower)
+ {
+ continue;
}
- if terms.len() == 24 {
- break;
+ if coded(word) {
+ code.push(lower);
+ } else {
+ plain.push(lower);
}
}
- terms
+ code.extend(plain);
+ code.truncate(SELECTION_TERMS);
+ code
}
-/// Order `documents` by how many of the question's words each matches
-/// (its path or title counts twice), fewest first: the chunker takes
-/// documents of equal time from the end of the list. Stable, so documents
-/// that match equally keep their order. False when the question has no
-/// words to select by.
+/// Order `documents` by a BM25 score (k1 1.2, b 0.75, case-insensitive
+/// matches of the question's words in the content, each word's weight by
+/// how few documents hold it, plus twice the weight of a word in the path
+/// or title), lowest first: the chunker takes documents of equal time from
+/// the end of the list. Stable, so documents that score equally keep their
+/// order. False when the question has no words to select by.
fn order_by_question(documents: &mut Vec<Value>, question: &str) -> bool {
- let terms = question_terms(question);
+ let mut terms = question_terms(question);
if terms.is_empty() {
return false;
}
+ // Longest first, so `parse_config` is counted before `config`.
+ terms.sort_by_key(|term| std::cmp::Reverse(term.len()));
let pattern: Vec<String> = terms.iter().map(|term| regex::escape(term)).collect();
let Ok(matcher) = regex::RegexBuilder::new(&format!("(?:{})", pattern.join("|")))
.case_insensitive(true)
@@ -634,25 +707,62 @@ fn order_by_question(documents: &mut Vec<Value>, question: &str) -> bool {
else {
return false;
};
- let matched = |text: &str| {
- let mut found = BTreeSet::new();
- for hit in matcher.find_iter(text) {
- found.insert(hit.as_str().to_lowercase());
- if found.len() == terms.len() {
- break;
+ let index: std::collections::HashMap<&str, usize> = terms
+ .iter()
+ .enumerate()
+ .map(|(i, term)| (term.as_str(), i))
+ .collect();
+ // Per document: each word's count in the content, the words of its
+ // path or title, and its length.
+ let counted: Vec<(Vec<u32>, BTreeSet<usize>, usize)> = documents
+ .iter()
+ .map(|document| {
+ let mut counts = vec![0u32; terms.len()];
+ let content = s(document, "content");
+ for hit in matcher.find_iter(content) {
+ if let Some(&i) = index.get(hit.as_str().to_lowercase().as_str()) {
+ counts[i] += 1;
+ }
}
- }
- found.len()
- };
- let mut scored: Vec<(usize, Value)> = documents
+ let named = format!("{}\n{}", s(document, "path"), s(document, "title"));
+ let names = matcher
+ .find_iter(&named)
+ .filter_map(|hit| index.get(hit.as_str().to_lowercase().as_str()).copied())
+ .collect();
+ (counts, names, content.len())
+ })
+ .collect();
+ let n = counted.len() as f64;
+ let average =
+ (counted.iter().map(|(_, _, length)| *length).sum::<usize>() as f64 / n.max(1.0)).max(1.0);
+ let weights: Vec<f64> = (0..terms.len())
+ .map(|i| {
+ let held = counted
+ .iter()
+ .filter(|(counts, names, _)| counts[i] > 0 || names.contains(&i))
+ .count() as f64;
+ (1.0 + (n - held + 0.5) / (held + 0.5)).ln()
+ })
+ .collect();
+ let mut scored: Vec<(f64, Value)> = documents
.drain(..)
- .map(|document| {
- let named = format!("{}\n{}", s(&document, "path"), s(&document, "title"));
- let score = 2 * matched(&named) + matched(s(&document, "content"));
+ .zip(counted)
+ .map(|(document, (counts, names, length))| {
+ let norm = 1.2 * (0.25 + 0.75 * length as f64 / average);
+ let mut score = 0.0;
+ for (i, &weight) in weights.iter().enumerate() {
+ let tf = f64::from(counts[i]);
+ if tf > 0.0 {
+ score += weight * tf * 2.2 / (tf + norm);
+ }
+ if names.contains(&i) {
+ score += 2.0 * weight;
+ }
+ }
(score, document)
})
.collect();
- scored.sort_by_key(|(score, _)| *score);
+ scored.sort_by(|a, b| a.0.total_cmp(&b.0));
documents.extend(scored.into_iter().map(|(_, document)| document));
true
}
@@ -796,10 +906,61 @@ pub fn context_scored(
)
}
+/// The recall switches in force for one call, echoed in every packet's
+/// `mechanisms.switches` so a caller can verify them (a server's fixed
+/// values arrive as the request's): `graph_retrieval`, `memory_retrieval`,
+/// `cross_repo` (which follows `graph_retrieval` when left out) and
+/// `notes_first` (left out: [`NOTES_FIRST_DEFAULT`]) and `identifier_route`
+/// (left out: [`IDENTIFIER_ROUTE_DEFAULT`]) as booleans;
+/// `doc_links` and `symbol_links` as `true`, `false` or `"counted"` (left
+/// out: counted, not followed); `code_first`, `query_focus`,
+/// `identifier_arm` and `more_files` as asked, else `"auto"`; and `scope`.
+/// A switch outside its values ([`crate::api::switch_refusal`]) is refused.
+pub fn switches(args: &Value, scope: &str) -> Result<Value> {
+ for field in crate::api::RECALL_SWITCHES {
+ if let Some(refused) = args
+ .get(field)
+ .filter(|v| !v.is_null())
+ .and_then(|v| crate::api::switch_refusal(field, v))
+ {
+ return Err(Error::bad(refused));
+ }
+ }
+ let graph = args["graph_retrieval"] != false;
+ let linked = |field: &str| match args.get(field) {
+ Some(Value::Bool(on)) => json!(on),
+ _ => json!("counted"),
+ };
+ // The code-question switches: as asked, else "auto".
+ let auto = |field: &str| {
+ args.get(field)
+ .filter(|v| !v.is_null())
+ .cloned()
+ .unwrap_or(json!("auto"))
+ };
+ Ok(json!({
+ "graph_retrieval": graph,
+ "memory_retrieval": args["memory_retrieval"] != false,
+ "doc_links": linked("doc_links"),
+ "symbol_links": linked("symbol_links"),
+ "cross_repo": args["cross_repo"].as_bool().unwrap_or(graph),
+ "notes_first": args["notes_first"].as_bool().unwrap_or(NOTES_FIRST_DEFAULT),
+ "identifier_route": args["identifier_route"].as_bool().unwrap_or(IDENTIFIER_ROUTE_DEFAULT),
+ "code_first": auto("code_first"),
+ "query_focus": auto("query_focus"),
+ "identifier_arm": auto("identifier_arm"),
+ "more_files": auto("more_files"),
+ "scope": scope,
+ }))
+}
+
/// [`context_scored`] over passages already chunked from `snapshot`
/// ([`passages`]); `None` chunks the snapshot here. `doc_links` reads the
/// project's document links ([`crate::doc_links::lift`]): followed with
-/// `doc_links: true`, else only counted; without it no link is read.
+/// `doc_links: true`, else only counted; without it no link is read. The
+/// same lookup reads reviewed memory's links to code symbols
+/// ([`crate::symbol_links::lift`]): followed with `symbol_links: true`,
+/// else only counted (`false` reads none).
pub fn context_on(
snapshot: &Snapshot,
args: &Value,
@@ -816,11 +977,20 @@ pub fn context_on(
}
}
let links = crate::doc_links::Options::parse(args)?;
+ let symbol_links = crate::symbol_links::Mode::parse(args)?;
// `graph_local`'s status when it did not rank (degraded past its
// budget), passed beside the rankings; never fused.
let local_status = extra_rankings
.as_object_mut()
.and_then(|m| m.shift_remove(crate::graph::LOCAL_STATUS));
+ // The files that define a code name the question names when no source
+ // file defines it (the identifier arm), which the code-first prior
+ // leaves their weight; never fused.
+ let defining: Vec<String> = extra_rankings
+ .as_object_mut()
+ .and_then(|m| m.shift_remove(crate::code_question::DEFINING))
+ .and_then(|files| serde_json::from_value(files).ok())
+ .unwrap_or_default();
let graph_enabled = args["graph_retrieval"] != false;
if !graph_enabled && let Some(rankings) = extra_rankings.as_object_mut() {
// A precomputed property-graph arm must obey the same switch as the
@@ -861,15 +1031,60 @@ pub fn context_on(
}
let question = string(args, "question", 16000)?;
let (include_tests, tests_defaulted) = IncludeTests::parse(args)?;
+ // A code question's query is its content, not its instructions
+ // (crate::code_question::focus): what `rank`, the reranker and the
+ // packer's focus read. The packet keeps the question.
+ let focus = crate::code_question::focus(args, question)?;
+ let query = focus.text.as_str();
+ // A code question ranks source files ahead of documentation, tests and
+ // vendored code (crate::code_question), in `rank` itself.
+ let code_first = crate::code_question::decide(args, question, query)?;
let max_tokens = integer(args, "max_tokens", 3000, 16000)?.max(256);
let max_chars = integer(args, "max_chars", 12000, 64000)?.max(2000);
let limit = integer(args, "limit", 8, 40)?.max(1);
let rerank_depth = integer(args, "rerank_depth", 32, MAX_RERANK_DEPTH)?.max(limit.min(32));
let debug_candidates = integer(args, "debug_candidates", 0, 400)?;
+ // Files listed after the excerpts: `more_files` (0 to 40), left out
+ // MORE_FILES_DEFAULT for a code question and none for another.
+ let more_files = match args.get("more_files") {
+ None | Some(Value::Null) => {
+ if crate::code_question::is_code_question(question) {
+ MORE_FILES_DEFAULT
+ } else {
+ 0
+ }
+ }
+ Some(_) => integer(
+ args,
+ "more_files",
+ 0,
+ graphicle_memory::packing::MAX_NEXT_FILES,
+ )?,
+ };
+ // `notes_first: true` (left out: NOTES_FIRST_DEFAULT) asks for the
+ // notes-first order of a question in prose and one window per file.
+ // Windows stay as ranked without it, and also with `include_tests: true`
+ // (`--tools all` sends it: 0.1.0's packet) or an explicit `origin_quota`
+ // (its windows per origin).
+ let (notes_first, notes_first_defaulted) = crate::notes_first::switch(args)?;
+ let as_ranked = !notes_first
+ || include_tests == IncludeTests::Yes
+ || args.get("origin_quota").is_some_and(|v| !v.is_null());
+ // Dated excerpts: `source_age` when the call sets it, else `notes_first`.
+ let dated = match args.get("source_age") {
+ None | Some(Value::Null) => notes_first,
+ Some(Value::Bool(on)) => *on,
+ Some(_) => return Err(Error::bad("source_age must be true or false")),
+ };
+ // Past the call's limit, `rank` offers EXTRA_SOURCES more sources, so
+ // the windows [`crate::notes_first::one_per_file`] drops (a second window
+ // of a file, a copy of another file) are replaced from the fused order.
let rank_limit = if rescoring {
rerank_depth.min(graphicle_memory::retrieval::MAX_RANK_LIMIT)
- } else {
+ } else if as_ranked {
limit
+ } else {
+ (limit + EXTRA_SOURCES).min(graphicle_memory::retrieval::MAX_RANK_LIMIT)
};
for (field, check) in [
("compact_citations", Value::is_boolean as fn(&Value) -> bool),
@@ -977,12 +1192,16 @@ pub fn context_on(
.map(|r| r["identity"].clone())
.take(12)
.collect();
- let mut rank_request = json!({"scope":snapshot.repository["id"],"question":question,"rows":[],"needs":args.get("needs").cloned().unwrap_or(json!([])),
+ let mut rank_request = json!({"scope":snapshot.repository["id"],"question":query,"rows":[],"needs":args.get("needs").cloned().unwrap_or(json!([])),
"limit":rank_limit,"mode":args["mode"].as_str().unwrap_or("auto"),"edges":[],"global_notes":global,"rankings":extra_rankings});
// Plain copies: `json!` would serialize every passage row and graph edge
// one by one.
rank_request["rows"] = Value::Array(rows.clone());
rank_request["edges"] = edges.clone();
+ let (priors, code_first_report) = code_first.priors(&rows, &defining);
+ if !priors.is_empty() {
+ rank_request["origin_prior"] = Value::Object(priors);
+ }
// Retrieval tuning, validated by `rank`: weighted fusion, per-origin
// quotas, stemmed BM25, a ranking of one speaker's turns and
// caller-supplied query variants (rephrasings, keywords, hypothetical
@@ -1032,6 +1251,19 @@ pub fn context_on(
} else {
0
});
+ // A question that names no code takes its sources from the fused order
+ // ordered again (crate::notes_first), so `rank` returns that order.
+ let prose = !rescoring && !as_ranked && !crate::notes_first::names_code(question);
+ let fused_depth = if prose {
+ fused_depth.max(NOTES_FUSED)
+ } else {
+ fused_depth
+ };
+ let fused_depth = if more_files > 0 {
+ fused_depth.max(MORE_FILES_FUSED)
+ } else {
+ fused_depth
+ };
if fused_depth > 0 {
rank_request["debug_fused"] = json!(fused_depth);
}
@@ -1048,7 +1280,11 @@ pub fn context_on(
bound("max", 3).max(bound("min", 1))
});
let mut ranked = native("rank", rank_request)?;
- let strength = ranked["evidence_strength"].clone();
+ let mut strength = ranked["evidence_strength"].clone();
+ // `rank` was asked for EXTRA_SOURCES more; the packet's limit is the call's.
+ if !rescoring {
+ strength["limit"] = json!(limit);
+ }
let by_id: BTreeMap<&str, &Value> = rows.iter().map(|r| (s(r, "identity"), r)).collect();
let mut reranker_usage = Value::Null;
if let Some(reranker) = reranker {
@@ -1104,7 +1340,7 @@ pub fn context_on(
let mut scores = Vec::with_capacity(texts.len());
let mut tokens = 0;
for chunk in texts.chunks(32) {
- let (part, used) = crate::local_inference::rerank_counted(reranker, question, chunk)?;
+ let (part, used) = crate::local_inference::rerank_counted(reranker, query, chunk)?;
scores.extend(part);
tokens += used;
}
@@ -1136,6 +1372,38 @@ pub fn context_on(
memories.truncate(limit);
}
}
+ // Notes first: the sources of a question in prose are the first files of
+ // the fused order, one passage each; code files keep their places, and
+ // the notes are ordered again among the notes' places by name, headings
+ // and recency.
+ let mut notes_report = json!({"status": if !notes_first {
+ "off"
+ } else if rescoring {
+ "local_reranker"
+ } else if as_ranked {
+ "windows_as_ranked"
+ } else {
+ "code_question"
+ }});
+ if prose {
+ let fused: Vec<&Value> = ranked["fused"]
+ .as_array()
+ .into_iter()
+ .flatten()
+ .filter_map(|id| by_id.get(id.as_str()?).copied())
+ .collect();
+ let today = crate::now();
+ let (order, report) = crate::notes_first::rerank(
+ &fused,
+ &snapshot.documents,
+ question,
+ today.get(..10).unwrap_or(&today),
+ );
+ notes_report = report;
+ if let Some(order) = order {
+ ranked["sources"] = json!(order.into_iter().take(limit).collect::<Vec<_>>());
+ }
+ }
let selected = |key: &str| {
ranked[key]
.as_array()
@@ -1146,6 +1414,14 @@ pub fn context_on(
.collect::<Vec<_>>()
};
let mut sources = selected("sources");
+ // One window per file and one copy of identical files, then the call's
+ // limit (`rank` offered EXTRA_SOURCES more).
+ let (mut repeated, mut copies) = if as_ranked {
+ (0, 0)
+ } else {
+ crate::notes_first::one_per_file(&mut sources, &snapshot.documents)
+ };
+ sources.truncate(limit);
for source in &mut sources {
if let Some(facts) = code_graph_facts.get(s(source, "identity")) {
source["source"][crate::code_graph_arm::ARM] = facts.clone();
@@ -1232,6 +1508,38 @@ pub fn context_on(
Err(error) => doc_links_report = json!({"status":"error","error":error.message}),
}
}
+ // Reviewed memory's links to code symbols, one hop, after the document
+ // links (with `symbol_links: true`; left out, they are counted and
+ // nothing is lifted; `false` reads none). A failed read leaves the
+ // packet as it was and says so. A caller that reads no link at all (no
+ // lookup) reports the step `unavailable`, never as if it had not been
+ // asked for.
+ let mut symbol_links_report = json!({"status": match symbol_links {
+ crate::symbol_links::Mode::Off => "disabled",
+ _ => "unavailable",
+ }});
+ let mut linked_memories = Vec::new();
+ if symbol_links != crate::symbol_links::Mode::Off
+ && let Some(lookup) = doc_links
+ {
+ match crate::symbol_links::lift(
+ lookup.db(),
+ lookup.repository(),
+ symbol_links,
+ snapshot,
+ &rows,
+ &sources,
+ &selected_memories,
+ &candidates,
+ ) {
+ Ok(lifted) => {
+ candidates.extend(lifted.windows);
+ linked_memories = lifted.memories;
+ symbol_links_report = lifted.report;
+ }
+ Err(error) => symbol_links_report = json!({"status":"error","error":error.message}),
+ }
+ }
// Test files after the other excerpts (`include_tests`): the packer
// presents them last once the budget has gone to the windows in rank
// order, so the bound and the budget below see 0.1.0's order.
@@ -1240,12 +1548,33 @@ pub fn context_on(
IncludeTests::Yes => false,
IncludeTests::No => true,
IncludeTests::Auto => {
- let named = question_names_tests(question);
+ let named = question_names_tests(query);
test_files["question_names_tests"] = json!(named);
!named
}
};
+ // Linked memories' windows, the code arm's anchors and lifted windows of
+ // a file already quoted give way too.
+ if !as_ranked {
+ let (more_repeated, more_copies) =
+ crate::notes_first::one_per_file(&mut candidates, &snapshot.documents);
+ repeated += more_repeated;
+ copies += more_copies;
+ notes_report["one_per_file"] =
+ json!({"repeated_windows":repeated,"identical_copies":copies});
+ }
candidates.truncate(40);
+ if let Some(offered) = symbol_links_report
+ .get("lifted_windows")
+ .and_then(Value::as_u64)
+ {
+ let kept = candidates
+ .iter()
+ .filter(|c| c["source"].get(crate::symbol_links::ARM).is_some())
+ .count() as u64;
+ symbol_links_report["lifted_windows"] = json!(kept);
+ symbol_links_report["over_candidate_limit"] = json!(offered.saturating_sub(kept));
+ }
// Lifted windows come last: count those the candidate bound kept.
if let Some(offered) = doc_links_report.get("lifted").and_then(Value::as_u64) {
let kept = candidates
@@ -1264,7 +1593,22 @@ pub fn context_on(
if demote {
mark_test_files_last(&mut hits);
}
- let mut pack_request = json!({"repo":snapshot.repository,"question":question,"hits":hits,"memories":selected_memories,
+ // Each excerpt's age, when dated: its file's last change in the
+ // citation, and code it names whose file changed since. Reads files and
+ // Git only; the order stays the ranking's.
+ let source_age = match doc_links {
+ Some(lookup) if dated => crate::phase::phase("context_age", || {
+ crate::source_age::annotate(lookup, &mut hits)
+ })
+ .unwrap_or_else(|error| json!({"status":"error","error":error.message})),
+ Some(_) => json!({"status":"disabled"}),
+ None => json!({"status":"not_requested"}),
+ };
+ // Memories lifted through links follow the selected ones.
+ let pack_memories: Vec<&Value> = selected_memories.iter().chain(&linked_memories).collect();
+ // The packer centres excerpts on the query's words; the packet names the
+ // question (below).
+ let mut pack_request = json!({"repo":snapshot.repository,"question":query,"hits":hits,"memories":pack_memories,
"max_tokens":max_tokens,"max_chars":max_chars,"reasons":ranked["reasons"],"coverage":coverage,"needs":args.get("needs").cloned().unwrap_or(json!([])),
"semantic":{"loaded":extra_rankings.get("semantic").is_some()},"mode":ranked["mode"]});
let focus_options = args.get("pack_focus").filter(|v| v.is_object());
@@ -1292,7 +1636,27 @@ pub fn context_on(
pack_request[option] = value.clone();
}
}
+ // The project files of the fused order, each once: the packer lists
+ // those its excerpts do not quote after them.
+ if more_files > 0 {
+ let mut seen = BTreeSet::new();
+ let paths: Vec<&str> = ranked["fused"]
+ .as_array()
+ .into_iter()
+ .flatten()
+ .filter_map(|id| by_id.get(id.as_str()?))
+ .filter(|row| s(&row["source"], "id").starts_with("file:"))
+ .map(|row| s(&row["source"], "path"))
+ .filter(|path| !path.is_empty() && seen.insert(*path))
+ .take(limit + 3 * more_files)
+ .collect();
+ pack_request["next_files"] = json!({"paths": paths, "limit": more_files});
+ }
let mut packet = native("pack", pack_request)?;
+ packet["question"] = json!(question);
+ if let Some(listed) = packet.as_object_mut().and_then(|p| p.remove("next_files")) {
+ packet["more_files"] = listed;
+ }
// How many delivered test-file excerpts had another excerpt after them
// in rank order (0 under chronological presentation).
if demote {
@@ -1316,7 +1680,11 @@ pub fn context_on(
.get(a..b)
.ok_or_else(|| Error::bad("Invalid packed source coordinates"))?;
let mut window = crate::evidence::from_range(doc, a, b)?;
- for arm in [crate::code_graph_arm::ARM, crate::doc_links::ARM] {
+ for arm in [
+ crate::code_graph_arm::ARM,
+ crate::doc_links::ARM,
+ crate::symbol_links::ARM,
+ ] {
if let Some(facts) = source.get(arm) {
window[arm] = facts.clone();
}
@@ -1389,6 +1757,42 @@ pub fn context_on(
let before = mechanisms["links_pending_projection"].as_u64().unwrap_or(0);
mechanisms["links_pending_projection"] = json!(before + pending);
mechanisms["doc_links_pending_documents"] = json!(pending_documents);
+ // Memory links used: the lifted memories the packet kept and the lifted
+ // code windows it cites, by the rung of the link followed.
+ let mut memory_rungs: BTreeMap<String, u64> = BTreeMap::new();
+ let mut memories_included = 0u64;
+ for memory in packet["memories"].as_array().into_iter().flatten() {
+ if memory["via"] == "link" {
+ memories_included += 1;
+ *memory_rungs
+ .entry(s(&memory["link"], "rung").to_string())
+ .or_default() += 1;
+ }
+ }
+ let mut windows_cited = 0u64;
+ for window in &evidence {
+ if let Some(facts) = window.get(crate::symbol_links::ARM) {
+ windows_cited += 1;
+ *memory_rungs
+ .entry(s(facts, "rung").to_string())
+ .or_default() += 1;
+ }
+ }
+ if symbol_links_report.get("considered").is_some() {
+ symbol_links_report["memories_included"] = json!(memories_included);
+ symbol_links_report["cited"] = json!(windows_cited);
+ }
+ packet[crate::symbol_links::ARM] = symbol_links_report;
+ let mechanisms = &mut packet["mechanisms"];
+ mechanisms["symbol_links_enabled"] = json!(symbol_links.enabled());
+ mechanisms["switches"] = switches(args, "project")?;
+ let used = &mut mechanisms["links_used"];
+ used["memory"] =
+ json!(used["memory"].as_u64().unwrap_or(0) + memories_included + windows_cited);
+ for (rung, count) in memory_rungs {
+ let before = used["by_rung"][&rung].as_u64().unwrap_or(0);
+ used["by_rung"][rung] = json!(before + count);
+ }
packet["evidence"] = json!(evidence);
packet["source_state"] = json!(snapshot.state);
packet["evidence_strength"] = strength;
@@ -1396,6 +1800,11 @@ pub fn context_on(
packet["arm_weights"] = arm_weights;
packet["retrieval_defaults"] = json!(defaulted);
packet["test_files"] = test_files;
+ packet["code_first"] = code_first_report;
+ packet["query_focus"] = focus.report;
+ packet["source_age"] = source_age;
+ notes_report["defaulted"] = json!(notes_first_defaulted);
+ packet[crate::notes_first::FIELD] = notes_report;
if let Some(stemmer) = ranked.get("stemmer") {
packet["stemmer"] = stemmer.clone();
}
@@ -1437,7 +1846,8 @@ pub fn context_on(
/// other `mechanisms`:
/// - one switch per mechanism: `code_graph_enabled`, `static_edges_enabled`
/// and `graph_local_enabled` (today all follow `graph_retrieval`), and
-/// `symbol_links_enabled`, `doc_links_enabled` and `scope`, reserved;
+/// `symbol_links_enabled`, `doc_links_enabled` and `scope`, which the
+/// query fills after the links steps;
/// - the guards: `static_edges_aggregated` and `static_edges_capped` (with
/// `static_edges_bound` when either applied) and `graph_local_status`
/// (`searched`, `not_requested`, `disabled` or `degraded`, with
@@ -1448,9 +1858,9 @@ pub fn context_on(
/// `links_followed_through_move` (links of served reviewed memories that
/// followed an exact move) and `links_pending_projection` (links and
/// quotes of reviewed memories waiting for a projection: their own
-/// `symbol_links.pending`); 0 until a later
-/// batch fills them: `links_used` and `workspace` (one project searched
-/// until workspace scope).
+/// `symbol_links.pending`); 0 until the links steps add theirs:
+/// `links_used` (`memory` and `document`, and `by_rung`), and `workspace`
+/// (one project searched until workspace scope).
fn graph_mechanisms(
mechanisms: &mut Value,
graph_enabled: bool,
@@ -1617,22 +2027,65 @@ impl Store {
}
}
let scope = crate::workspace::Scope::parse(args)?;
+ // A question over the bound is shortened, keeping its content and
+ // the names it gives, instead of refused (crate::code_question).
+ let shortened = args
+ .get("question")
+ .and_then(Value::as_str)
+ .and_then(crate::code_question::shorten);
+ let owned;
+ let args = match &shortened {
+ Some((question, _)) => {
+ let mut copy = args.clone();
+ copy["question"] = json!(question);
+ owned = copy;
+ &owned
+ }
+ None => args,
+ };
+ let report = shortened.map(|(_, report)| report);
// Retrieval runs on a read-only snapshot and records nothing about the
// request, so a query never takes the write lock.
- self.authorized_read(workspace, token, "read", |db, p| match scope {
+ let mut packet = self.authorized_read(workspace, token, "read", |db, p| match scope {
crate::workspace::Scope::Project => {
if args.get("max_projects").is_some() {
return Err(Error::bad("max_projects applies only with scope workspace"));
}
let repository = repo(db, p, string(args, "repository_id", 100)?)?;
- Ok(project_packet(db, p, &repository, args, embedding, reranker)?.1)
+ // An identifier, or a question that only asks where named
+ // identifiers are defined or used: their definitions and
+ // references from the code graph (crate::identifier_route).
+ let route = match crate::identifier_route::answer(db, p, &repository, args)? {
+ crate::identifier_route::Routed::Answered(packet) => return Ok(packet),
+ crate::identifier_route::Routed::Retrieval(route) => route,
+ };
+ let mut packet = project_packet(db, p, &repository, args, embedding, reranker)?.1;
+ let mut route = route;
+ // A question that asks more about the names it gives keeps
+ // them: the identifier arm ranks their files.
+ if route["reason"] == "asks_more" {
+ route["names_fused"] = json!(packet["identifier_arm"]["status"] == "fused");
+ }
+ packet[crate::identifier_route::REPORT] = route;
+ Ok(packet)
}
// Every project of the workspace the principal may read, each
- // read as this project is above.
+ // read as this project is above; the identifier route answers
+ // one project's questions only.
crate::workspace::Scope::Workspace => {
- crate::workspace::context(db, p, args, embedding, reranker)
+ let (on, defaulted) = crate::identifier_route::switch(args)?;
+ let mut packet = crate::workspace::context(db, p, args, embedding, reranker)?;
+ let mut route =
+ json!({"path":"retrieval","reason":"workspace","defaulted":defaulted});
+ route[crate::identifier_route::FIELD] = json!(on);
+ packet[crate::identifier_route::REPORT] = route;
+ Ok(packet)
}
- })
+ })?;
+ if let Some(report) = report {
+ packet["question_shortened"] = report;
+ }
+ Ok(packet)
}
}
@@ -1658,14 +2111,18 @@ pub fn project_packet(
crate::graph::for_query(db, repository, p, &snap, args)
})?;
let question = string(args, "question", 16000)?;
+ // What the arms read: a code question's content, not its instructions
+ // (crate::code_question::focus).
+ let focus = crate::code_question::focus(args, question)?;
+ let query = focus.text.as_str();
// One chunking of the snapshot serves `graph_local`'s seed and
// walk, the dense arm and the query itself; past
// the per-question bounds the question chooses what it reads.
let shared = crate::phase::phase("context_passages", || {
- passages_for(&mut snap, question).map(Some)
+ passages_for(&mut snap, query).map(Some)
})?;
let mut rankings = crate::phase::phase("context_rankings", || {
- crate::graph::add_rankings_on(&snap, graph.as_ref(), question, json!({}), shared.as_ref())
+ crate::graph::add_rankings_on(&snap, graph.as_ref(), query, json!({}), shared.as_ref())
})?;
let mut dense_report = json!({"status":"disabled"});
let mut dense_calls = 0;
@@ -1696,7 +2153,7 @@ pub fn project_packet(
if !vectors.is_empty() {
let started = std::time::Instant::now();
let (query, tokens, _) =
- crate::local_inference::embed_query(profile, &[question.to_string()])?;
+ crate::local_inference::embed_query(profile, &[query.to_string()])?;
if crate::model::key(profile) != key {
return Err(Error::conflict(
"Local embedding manifest changed during query",
@@ -1754,8 +2211,10 @@ pub fn project_packet(
}
}
// A degraded graph arm never fails an interactive query. With
- // `doc_links: false` it leaves document nodes out.
+ // `doc_links: false` it leaves document nodes out, and so does a code
+ // question that ranks source files first (crate::code_question).
let links = crate::doc_links::Options::parse(args)?;
+ let code_first = crate::code_question::decide(args, question, query)?;
let arm = if args["graph_retrieval"] == false {
crate::code_graph_arm::Arm::skipped("disabled")
} else {
@@ -1764,8 +2223,8 @@ pub fn project_packet(
db,
s(repository, "id"),
&snap,
- question,
- links.documents(),
+ query,
+ links.documents() && !code_first.applied,
)
})
.unwrap_or_else(|error| {
@@ -1774,7 +2233,31 @@ pub fn project_packet(
arm
})
};
- let lookup = crate::doc_links::Lookup::new(db, s(repository, "id"));
+ // The identifiers and paths a code question names, found in the
+ // passages and at their definitions, as one more arm
+ // (crate::identifier_arm).
+ let identifier_report = match &shared {
+ Some(passages) => {
+ let found = crate::phase::phase("context_identifiers", || {
+ crate::identifier_arm::arm(db, s(repository, "id"), passages, args, question, query)
+ })?;
+ if !rankings.is_object() {
+ rankings = json!({});
+ }
+ if let Some(ranking) = found.ranking {
+ rankings[crate::identifier_arm::ARM] = json!(ranking);
+ }
+ // Beside the rankings, never fused: files the code-first prior
+ // leaves their weight.
+ if !found.defining.is_empty() {
+ rankings[crate::code_question::DEFINING] = json!(found.defining);
+ }
+ found.report
+ }
+ None => json!({"status":"no_passages"}),
+ };
+ let lookup = crate::doc_links::Lookup::new(db, s(repository, "id"))
+ .with_folder(crate::folders::current_folder(db, s(repository, "id"))?);
if crate::observer::KeyMode::parse(args.get("note_keys"))?.is_some() {
rankings[crate::observer::NOTE_KEYS] = json!(crate::observer::notes_for(
db,
@@ -1794,6 +2277,7 @@ pub fn project_packet(
)
})?;
packet["local_dense"] = dense_report;
+ packet["identifier_arm"] = identifier_report;
if let Some(filter) = filter {
packet["filter"] = filter;
}
@@ -2270,7 +2754,7 @@ mod tests {
);
// Reserved until their batches: switches and counters at null or 0.
assert_eq!(mechanisms["code_graph_enabled"], true);
- assert_eq!(mechanisms["symbol_links_enabled"], serde_json::Value::Null);
+ assert_eq!(mechanisms["symbol_links_enabled"], false);
assert_eq!(mechanisms["scope"], "project");
assert_eq!(
mechanisms["memories_withheld"],
diff --git a/crates/graphicle/src/schema.sql b/crates/graphicle/src/schema.sql
index 81c2864..c736983 100644
--- a/crates/graphicle/src/schema.sql
+++ b/crates/graphicle/src/schema.sql
@@ -310,6 +310,15 @@
episode TEXT NOT NULL, ecosystem TEXT NOT NULL, name TEXT NOT NULL, version TEXT,
created_at TEXT NOT NULL,
PRIMARY KEY(repository_id,episode,ecosystem,name));
+ -- Incremental cross-repository linking: per project, the
+ -- export index of the episode it last took part with, and
+ -- the digest of what its own imports were last linked
+ -- against, with the live row counts that link left.
+ CREATE TABLE IF NOT EXISTS gf_cross_link_state (
+ repository_id TEXT PRIMARY KEY REFERENCES repo_projects(id) ON DELETE CASCADE,
+ workspace_id TEXT NOT NULL REFERENCES workspaces(id) ON DELETE CASCADE,
+ episode TEXT NOT NULL, format TEXT NOT NULL, export_index TEXT NOT NULL,
+ inputs TEXT, edges INTEGER, unresolved INTEGER, created_at TEXT NOT NULL);
CREATE TABLE IF NOT EXISTS gf_repo_access (
workspace_id TEXT NOT NULL REFERENCES workspaces(id) ON DELETE CASCADE,
repository_id TEXT NOT NULL REFERENCES repo_projects(id) ON DELETE CASCADE,
diff --git a/crates/graphicle/src/search.rs b/crates/graphicle/src/search.rs
index 79be5db..3365b95 100644
--- a/crates/graphicle/src/search.rs
+++ b/crates/graphicle/src/search.rs
@@ -280,6 +280,9 @@ async fn basic_inner(worker: &Worker, job: &Job) -> Result<Value> {
// (`doc_links: true`); left out, an integrated answer counts them, and a
// source-only answer reads none unless asked to.
let links_switch = switch("doc_links");
+ // Reviewed memory's links to code symbols likewise: counted by an
+ // integrated answer, read by a source-only answer only when asked.
+ let symbol_switch = switch("symbol_links");
// Explicitly requested (or integrated) reviewed memory may guide
// retrieval back to its original evidence.
if memory_switch == Some(false) {
@@ -350,6 +353,7 @@ async fn basic_inner(worker: &Worker, job: &Job) -> Result<Value> {
("memory_retrieval", memory_switch),
("graph_retrieval", graph_switch),
("doc_links", links_switch),
+ ("symbol_links", symbol_switch),
] {
if let Some(on) = switch {
bounded[field] = json!(on);
@@ -358,14 +362,20 @@ async fn basic_inner(worker: &Worker, job: &Job) -> Result<Value> {
let context_args = crate::workflow_retrieval::arguments(&job.payload, bounded);
let mut packet =
crate::workflow_retrieval::context(worker, job, &snap, context_args, rankings, reserve)?;
- let requested: Vec<&str> = ["graph_retrieval", "memory_retrieval", "doc_links"]
- .into_iter()
- .filter(|field| job.payload[*field].is_boolean())
- .collect();
+ let requested: Vec<&str> = [
+ "graph_retrieval",
+ "memory_retrieval",
+ "doc_links",
+ "symbol_links",
+ ]
+ .into_iter()
+ .filter(|field| job.payload[*field].is_boolean())
+ .collect();
packet["integration"] = json!({"default": if integrated { "integrated" } else { "source_only" },
"reason": integration["reason"], "episode": integration["episode"],
"graph_retrieval": graph_switch.unwrap_or(true), "memory_retrieval": memory_switch.unwrap_or(true),
- "doc_links": links_switch.unwrap_or(false), "requested": requested});
+ "doc_links": links_switch.unwrap_or(false), "symbol_links": job.payload["symbol_links"] == true,
+ "requested": requested});
if let Some(error) = integration.get("error") {
packet["integration"]["error"] = error.clone();
}
diff --git a/crates/graphicle/src/setup.rs b/crates/graphicle/src/setup.rs
index 4c385f7..9923ca8 100644
--- a/crates/graphicle/src/setup.rs
+++ b/crates/graphicle/src/setup.rs
@@ -123,6 +123,10 @@ pub struct Options {
/// `--guards`: Claude Code's guard hooks (off unless asked for; a run
/// without it removes those an earlier setup installed).
pub guards: bool,
+ /// `--prompt-context`: Claude Code's prompt-context hook
+ /// ([`crate::prompt_hook`]; off unless asked for; a run without it
+ /// leaves an earlier setup's hook as it is).
+ pub prompt_context: bool,
/// `--tools`: the tools every connected client's entry publishes;
/// `None` is each client's default ([`agent_setup::default_tools`]).
pub tools: Option<ToolSet>,
@@ -290,6 +294,25 @@ pub fn setup_report(
},
);
}
+ // Claude Code's prompt-context hook (`--prompt-context`, off by
+ // default), beside its other hooks.
+ let prompt_context = if !options.prompt_context {
+ Value::Null
+ } else if clients
+ .iter()
+ .any(|client| client["client"] == "claude-code" && client["state"] != "failed")
+ {
+ match agent_setup::connect_prompt_context(store, &folder) {
+ Ok(hook) => {
+ let added = hook["installed"].as_array().is_some_and(|i| !i.is_empty());
+ json!({"state":if added { "added" } else { "already set" },"file":hook["configuration"],
+ "context":hook["context"],"next":hook["next"]})
+ }
+ Err(error) => json!({"state":"failed","error":error.message}),
+ }
+ } else {
+ json!({"state":"skipped","reason":"Claude Code was not connected"})
+ };
let capture = capture_report(&clients, &chosen, options.no_capture);
let connected: Vec<&str> = clients
.iter()
@@ -439,6 +462,9 @@ pub fn setup_report(
if let Some(note) = clients_note {
report["clients_note"] = json!(note);
}
+ if !prompt_context.is_null() {
+ report["prompt_context"] = prompt_context;
+ }
Ok(report)
}
@@ -1365,6 +1391,22 @@ pub fn render_setup(report: &Value) -> String {
{
line(" The guard hooks are off unless asked for: graphicle setup --guards turns them on".into());
}
+ // Claude Code's prompt-context hook (`--prompt-context`).
+ let prompt = &report["prompt_context"];
+ if let Some(state) = prompt["state"].as_str() {
+ let detail = match state {
+ "added" | "already set" => show(&prompt["file"]),
+ _ => prompt["reason"]
+ .as_str()
+ .or(prompt["error"].as_str())
+ .unwrap_or_default()
+ .to_string(),
+ };
+ line(format!(" Prompt hook {state}: {detail}"));
+ if matches!(state, "added" | "already set") {
+ line(" Before each prompt that is a code question, Claude Code gets graphicle context's packet".into());
+ }
+ }
for (index, written) in report["instructions"]
.as_array()
.into_iter()
diff --git a/crates/graphicle/src/source_age.rs b/crates/graphicle/src/source_age.rs
new file mode 100644
index 0000000..213d382
--- /dev/null
+++ b/crates/graphicle/src/source_age.rs
@@ -0,0 +1,414 @@
+//! How old each excerpt of a `context` packet is, said in its citation.
+//!
+//! Imported notes and documents are plain sources: they carry no review
+//! state, so the stale flags of reviewed memory never reach them. Before a
+//! packet is packed, [`annotate`] gives every repository-file excerpt (with
+//! `source_age: true`, or when the call leaves it out and turns
+//! `notes_first` on):
+//! - the date of its file's last change (`changed`, `changed_at`,
+//! `changed_basis`): the last commit that touched the file when Git
+//! tracks it and the working tree has no change to it; otherwise the
+//! file's modification time. The packer prints it in the citation.
+//! - `may be stale: <file> (defines <name>) changed <date>` when the excerpt
+//! names code (a linked mention of `doc_links` written as code,
+//! [`code_shaped`]) whose file changed after the excerpt's file last did.
+//! A file's date is never older than any of its lines, so the excerpt's
+//! text is older than that change. The date is the file's: the change may
+//! not touch the named definition itself.
+//!
+//! Excerpts are not compared with one another: no excerpt is marked as
+//! replaced by another, and the packet keeps the ranking's order.
+//!
+//! Dates come from the folder the project was last synced from; a project
+//! with no recorded folder (one synced over HTTP) gets no dates and no
+//! marks. Git runs only for the packet's files, within [`GIT_BUDGET`]; a
+//! file Git has not dated by then keeps no date.
+use crate::Result;
+use crate::store::s;
+use serde_json::{Value, json};
+use std::collections::{BTreeMap, BTreeSet};
+use std::io::BufRead;
+use std::path::Path;
+use std::time::{Duration, Instant};
+
+/// The longest a packet waits for `git log` to date its files.
+pub const GIT_BUDGET: Duration = Duration::from_millis(1500);
+/// Code names marked per excerpt; the rest are counted.
+const MAX_STALE_NAMES: usize = 3;
+
+/// When a file last changed and how that is known.
+#[derive(Clone, Copy, Debug, PartialEq, Eq)]
+pub struct FileDate {
+ /// Seconds since the Unix epoch.
+ pub at: i64,
+ /// `git` (the last commit that touched it) or `mtime`.
+ pub basis: &'static str,
+}
+
+/// `2026-10-15 07:22 UTC`.
+pub fn display(at: i64) -> String {
+ chrono::DateTime::from_timestamp(at, 0)
+ .map(|t| t.format("%Y-%m-%d %H:%M UTC").to_string())
+ .unwrap_or_default()
+}
+
+fn rfc3339(at: i64) -> Value {
+ chrono::DateTime::from_timestamp(at, 0)
+ .map(|t| json!(t.to_rfc3339_opts(chrono::SecondsFormat::Secs, true)))
+ .unwrap_or(Value::Null)
+}
+
+fn git(root: &Path) -> std::process::Command {
+ let mut command = std::process::Command::new("git");
+ command
+ .arg("-C")
+ .arg(root)
+ .args(["--literal-pathspecs", "-c", "core.quotePath=false"])
+ .stdin(std::process::Stdio::null())
+ .stderr(std::process::Stdio::null());
+ command
+}
+
+/// The paths `git <args> -- <paths>` prints, NUL-separated; `None` when Git
+/// fails.
+fn listed(root: &Path, args: &[&str], paths: &BTreeSet<String>) -> Option<BTreeSet<String>> {
+ let output = git(root).args(args).arg("--").args(paths).output().ok()?;
+ if !output.status.success() {
+ return None;
+ }
+ Some(
+ output
+ .stdout
+ .split(|b| *b == 0)
+ .filter(|p| !p.is_empty())
+ .filter_map(|p| std::str::from_utf8(p).ok())
+ .map(str::to_string)
+ .collect(),
+ )
+}
+
+/// The last commit date of each of `paths` (relative to `root`, tracked and
+/// unchanged in the working tree): one `git log` walk, stopped once every
+/// path is dated or `budget` has passed.
+fn commit_dates(root: &Path, paths: &BTreeSet<String>, budget: Duration) -> BTreeMap<String, i64> {
+ let mut found = BTreeMap::new();
+ // No pathspec would make `git log` list every file of every commit.
+ if paths.is_empty() {
+ return found;
+ }
+ let Ok(mut child) = git(root)
+ .args([
+ "log",
+ "--relative",
+ "--no-renames",
+ "--format=%x01%ct",
+ "--name-only",
+ "--",
+ ])
+ .args(paths)
+ .stdout(std::process::Stdio::piped())
+ .spawn()
+ else {
+ return found;
+ };
+ let Some(stdout) = child.stdout.take() else {
+ let _ = child.kill();
+ let _ = child.wait();
+ return found;
+ };
+ let (sender, receiver) = std::sync::mpsc::channel::<(String, i64)>();
+ let reader = std::thread::spawn(move || {
+ let mut at = None;
+ for line in std::io::BufReader::new(stdout).lines() {
+ let Ok(line) = line else { break };
+ if let Some(stamp) = line.strip_prefix('\u{1}') {
+ at = stamp.trim().parse::<i64>().ok();
+ } else if let Some(at) = at
+ && !line.is_empty()
+ && sender.send((line, at)).is_err()
+ {
+ break;
+ }
+ }
+ });
+ let deadline = Instant::now() + budget;
+ while found.len() < paths.len() {
+ let Some(left) = deadline.checked_duration_since(Instant::now()) else {
+ break;
+ };
+ match receiver.recv_timeout(left) {
+ Ok((path, at)) => {
+ if paths.contains(&path) {
+ found.entry(path).or_insert(at);
+ }
+ }
+ Err(_) => break,
+ }
+ }
+ drop(receiver);
+ let _ = child.kill();
+ let _ = child.wait();
+ let _ = reader.join();
+ found
+}
+
+/// When each of `paths` (relative to `root`) last changed: Git's last
+/// commit date for a tracked file the working tree has not changed, else
+/// the file's modification time. A path with neither is left out.
+pub fn file_dates(
+ root: &Path,
+ paths: &BTreeSet<String>,
+ budget: Duration,
+) -> BTreeMap<String, FileDate> {
+ let mut dates = BTreeMap::new();
+ if paths.is_empty() {
+ return dates;
+ }
+ let mut git_dated = BTreeSet::new();
+ let has_head = git(root)
+ .args(["rev-parse", "-q", "--verify", "HEAD"])
+ .stdout(std::process::Stdio::null())
+ .status()
+ .is_ok_and(|status| status.success());
+ if has_head
+ && let Some(tracked) = listed(root, &["ls-files", "-z"], paths)
+ && let Some(changed) = listed(
+ root,
+ &["diff", "--relative", "--name-only", "-z", "HEAD"],
+ paths,
+ )
+ {
+ let clean: BTreeSet<String> = tracked.difference(&changed).cloned().collect();
+ for (path, at) in commit_dates(root, &clean, budget) {
+ dates.insert(path.clone(), FileDate { at, basis: "git" });
+ git_dated.insert(path);
+ }
+ // A tracked, unchanged file Git did not date in time keeps no date:
+ // its modification time says when it was checked out, not changed.
+ for path in clean {
+ git_dated.insert(path);
+ }
+ }
+ for path in paths {
+ if git_dated.contains(path) {
+ continue;
+ }
+ let modified = std::fs::symlink_metadata(root.join(path))
+ .and_then(|meta| meta.modified())
+ .ok()
+ .and_then(|t| t.duration_since(std::time::UNIX_EPOCH).ok());
+ if let Some(since) = modified {
+ dates.insert(
+ path.clone(),
+ FileDate {
+ at: since.as_secs() as i64,
+ basis: "mtime",
+ },
+ );
+ }
+ }
+ dates
+}
+
+/// A mention that reads as code rather than a word: four characters or more
+/// with `_`, `::`, `.`, `/` or `(`, or a capital inside it (`parseHeader`,
+/// `DocLinks`). `ask` or `Context` may name a definition, but read as words.
+fn code_shaped(mention: &str) -> bool {
+ let inner_capital = mention
+ .chars()
+ .zip(mention.chars().skip(1))
+ .any(|(a, b)| a.is_lowercase() && b.is_uppercase());
+ mention.chars().count() >= 4
+ && (inner_capital || mention.contains(['_', '.', '/', '(']) || mention.contains("::"))
+}
+
+/// Date the packet's repository-file `hits` and mark those that name code
+/// whose file changed later. `links` reads the project's document links and
+/// names its folder. Returns the packet's `source_age` report.
+pub fn annotate(links: &crate::doc_links::Lookup<'_>, hits: &mut [Value]) -> Result<Value> {
+ let Some(root) = links.folder().filter(|r| r.is_dir()) else {
+ return Ok(json!({"status":"no_folder"}));
+ };
+ let started = Instant::now();
+ let files = |hit: &Value| {
+ (hit["source"]["source_kind"] == "repository_file")
+ .then(|| s(&hit["source"], "path").to_string())
+ .filter(|p| !p.is_empty())
+ };
+ // The code each excerpt names, read before the dates so one Git walk
+ // dates the excerpts' files and the named code's files together.
+ let mut named: Vec<Vec<(String, String)>> = Vec::with_capacity(hits.len());
+ for hit in hits.iter() {
+ let source = &hit["source"];
+ let mentions = match (
+ files(hit),
+ source["byte_start"].as_u64(),
+ source["byte_end"].as_u64(),
+ ) {
+ (Some(_), Some(a), Some(b)) => {
+ links.code_named_in(s(source, "id"), s(source, "sha256"), a as usize, b as usize)?
+ }
+ _ => Vec::new(),
+ };
+ named.push(mentions);
+ }
+ let mut paths: BTreeSet<String> = hits.iter().filter_map(files).collect();
+ for mentions in &named {
+ paths.extend(mentions.iter().map(|(_, path)| path.clone()));
+ }
+ let dates = file_dates(root, &paths, GIT_BUDGET);
+ let mut by_basis: BTreeMap<&str, u64> = BTreeMap::new();
+ let mut stale_marks = 0u64;
+ for (hit, mentions) in hits.iter_mut().zip(&named) {
+ let Some(path) = files(hit) else { continue };
+ let Some(date) = dates.get(&path) else {
+ continue;
+ };
+ *by_basis.entry(date.basis).or_default() += 1;
+ let source = &mut hit["source"];
+ source["changed"] = json!(display(date.at));
+ source["changed_at"] = rfc3339(date.at);
+ source["changed_basis"] = json!(date.basis);
+ let mut marks = Vec::new();
+ let mut seen = BTreeSet::new();
+ for (mention, target) in mentions {
+ if target == &path || !code_shaped(mention) || !seen.insert(mention.as_str()) {
+ continue;
+ }
+ if let Some(code) = dates.get(target)
+ && code.at > date.at
+ {
+ // The date is the defining file's, not the definition's.
+ marks.push(json!(format!(
+ "may be stale: {target} (defines `{mention}`) changed {}",
+ display(code.at)
+ )));
+ }
+ }
+ let over = marks.len().saturating_sub(MAX_STALE_NAMES);
+ marks.truncate(MAX_STALE_NAMES);
+ if over > 0 {
+ marks.push(json!(format!(
+ "may be stale: {over} more names of code whose files changed since"
+ )));
+ }
+ stale_marks += marks.len() as u64;
+ if !marks.is_empty() {
+ source["age_marks"] = json!(marks);
+ }
+ }
+ let report = json!({"status":"dated","dated":by_basis.values().sum::<u64>(),"basis":by_basis,
+ "stale_code_marks":stale_marks,"elapsed_ms":started.elapsed().as_millis() as u64});
+ Ok(report)
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ #[test]
+ fn only_code_shaped_mentions_are_marked() {
+ for (mention, shaped) in [
+ ("ask", false),
+ ("Context", false),
+ ("header", false),
+ ("a_b", false),
+ ("parse_header", true),
+ ("parseHeader", true),
+ ("DocLinks", true),
+ ("wire.py::parse", true),
+ ("reply()", true),
+ ] {
+ assert_eq!(code_shaped(mention), shaped, "{mention}");
+ }
+ }
+
+ #[test]
+ fn git_dates_tracked_files_and_mtime_dates_the_rest() {
+ let folder = tempfile::tempdir().unwrap();
+ let root = folder.path();
+ let run = |args: &[&str], date: &str| {
+ let status = std::process::Command::new("git")
+ .arg("-C")
+ .arg(root)
+ .args(args)
+ .env("GIT_AUTHOR_DATE", date)
+ .env("GIT_COMMITTER_DATE", date)
+ .env("GIT_CONFIG_GLOBAL", "/dev/null")
+ .env("GIT_CONFIG_NOSYSTEM", "1")
+ .stdout(std::process::Stdio::null())
+ .stderr(std::process::Stdio::null())
+ .status()
+ .unwrap();
+ assert!(status.success(), "git {args:?}");
+ };
+ let commit = |message: &str, date: &str| {
+ run(&["add", "-A"], date);
+ run(
+ &[
+ "-c",
+ "user.name=t",
+ "-c",
+ "user.email=t@t",
+ "commit",
+ "-q",
+ "-m",
+ message,
+ ],
+ date,
+ );
+ };
+ run(&["init", "-q"], "@0 +0000");
+ std::fs::create_dir_all(root.join("notes")).unwrap();
+ std::fs::write(root.join("notes/old.md"), "old\n").unwrap();
+ std::fs::write(root.join("edited.md"), "one\n").unwrap();
+ commit("first", "@1700000000 +0000");
+ std::fs::write(root.join("new.md"), "new\n").unwrap();
+ commit("second", "@1700003600 +0000");
+ std::fs::write(root.join("edited.md"), "two\n").unwrap();
+ std::fs::write(root.join("untracked.md"), "loose\n").unwrap();
+ let paths: BTreeSet<String> = [
+ "notes/old.md",
+ "new.md",
+ "edited.md",
+ "untracked.md",
+ "gone.md",
+ ]
+ .into_iter()
+ .map(str::to_string)
+ .collect();
+ let dates = file_dates(root, &paths, GIT_BUDGET);
+ assert_eq!(
+ dates["notes/old.md"],
+ FileDate {
+ at: 1_700_000_000,
+ basis: "git"
+ }
+ );
+ assert_eq!(
+ dates["new.md"],
+ FileDate {
+ at: 1_700_003_600,
+ basis: "git"
+ }
+ );
+ // Changed in the working tree, or never committed: the file's time.
+ assert_eq!(dates["edited.md"].basis, "mtime");
+ assert_eq!(dates["untracked.md"].basis, "mtime");
+ assert!(!dates.contains_key("gone.md"));
+ // Outside Git, every file has its modification time.
+ let plain = tempfile::tempdir().unwrap();
+ std::fs::write(plain.path().join("a.md"), "a\n").unwrap();
+ let one: BTreeSet<String> = [String::from("a.md")].into();
+ assert_eq!(
+ file_dates(plain.path(), &one, GIT_BUDGET)["a.md"].basis,
+ "mtime"
+ );
+ }
+
+ #[test]
+ fn dates_display_in_utc_minutes() {
+ assert_eq!(display(1_760_513_520), "2025-10-15 07:32 UTC");
+ assert_eq!(rfc3339(0), json!("1970-01-01T00:00:00Z"));
+ }
+}
diff --git a/crates/graphicle/src/store.rs b/crates/graphicle/src/store.rs
index 39c616f..97cdee1 100644
--- a/crates/graphicle/src/store.rs
+++ b/crates/graphicle/src/store.rs
@@ -112,7 +112,13 @@ pub struct Principal {
pub hash: String,
pub role: String,
}
+/// The roles a workspace credential may have in Core, besides the owner
+/// capability. An installed extension may define more
+/// (`Extension::role_permits`).
+pub const CREDENTIAL_ROLES: &[&str] = &["reader", "agent", "reviewer", "collector", "runner"];
impl Principal {
+ /// Whether the core's role grants `permission`; false for a role the core
+ /// does not define.
pub fn permits(&self, permission: &str) -> bool {
match self.role.as_str() {
"owner" => true,
@@ -346,7 +352,11 @@ impl Store {
limits: None,
};
let db = store.connect()?;
+ // A store that needs a newer program is refused before anything in
+ // it changes.
+ check_reader(&db)?;
db.pragma_update(None, "journal_mode", "WAL")?;
+ db.execute_batch(READERS)?;
db.execute_batch(include_str!("schema.sql"))?;
db.execute_batch(include_str!("workflow_schema.sql"))?;
db.execute_batch(include_str!("expansion_schema.sql"))?;
@@ -510,7 +520,13 @@ impl Store {
pub fn grant(&self, workspace: &str, token: &str, args: &Value) -> Result<Value> {
self.authorized(workspace,token,"admin",|db,_| {
let role=string(args,"role",30)?;
- if !["reader","agent","reviewer","collector","runner"].contains(&role) {return Err(Error::bad("Invalid credential role"));}
+ if !CREDENTIAL_ROLES.contains(&role) {
+ // A role an installed extension defines, which it may refuse
+ // a new credential on.
+ let extensions=crate::extension::installed();
+ if extensions.role_permits(db,workspace,role,"read")?.is_none() {return Err(Error::bad("Invalid credential role"));}
+ extensions.grant_role(db,workspace,role)?;
+ }
let label=string(args,"label",100)?; let token=format!("{}{}",id(),id()); let identifier=id();
let expiry=args.get("expires_at").and_then(Value::as_str);
if let Some(value)=expiry && graphicle_memory::temporal::instant(value).map_err(Error::bad)?<=chrono::Utc::now().fixed_offset() {return Err(Error::bad("Expiry must be in the future"));}
@@ -913,8 +929,9 @@ impl Store {
/// Connector documents whose sharing policy names `credential` exactly: an
/// entry of the document's ACL credential list, or a provider-side principal
/// (`am_source_permissions`) that maps to one of the credential's verified
-/// provider identities. Both are joins on the identifier, never text search
-/// over the JSON, so `cred-a` does not match `cred-ab`.
+/// provider identities (of the kind's identity provider,
+/// `connectors::identity_provider`). Both are joins on the identifier, never
+/// text search over the JSON, so `cred-a` does not match `cred-ab`.
pub fn credential_sources(
db: &Connection,
workspace: &str,
@@ -942,14 +959,18 @@ pub fn credential_sources(
JOIN repo_projects r ON r.id=c.repository_id \
JOIN am_source_permissions p ON p.connector_id=d.connector_id AND p.source_id=d.id \
JOIN json_each(p.principals) grant_ \
- JOIN am_provider_identities i ON i.workspace_id=r.workspace_id AND i.provider=c.kind AND i.credential_id=? \
+ JOIN am_provider_identities i ON i.workspace_id=r.workspace_id AND i.provider=coalesce(json_extract(?,'$.\"'||c.kind||'\"'),c.kind) AND i.credential_id=? \
LEFT JOIN am_provider_emails e ON e.workspace_id=i.workspace_id AND e.provider=i.provider AND e.external_id=i.external_id \
LEFT JOIN am_oauth_accounts o ON o.workspace_id=i.workspace_id AND o.provider=i.provider AND o.external_id=i.external_id AND o.state='active' \
WHERE r.workspace_id=? AND d.present=1 AND ( \
(json_extract(grant_.value,'$.type')='user' AND json_extract(grant_.value,'$.id')=i.external_id) OR \
(json_extract(grant_.value,'$.type')='email' AND coalesce(json_extract(grant_.value,'$.email'),'')!='' \
AND lower(json_extract(grant_.value,'$.email')) IN (lower(coalesce(e.email,'')),lower(coalesce(o.email,'')))))",
- params![credential, workspace],
+ params![
+ crate::connectors::identity_providers().to_string(),
+ credential,
+ workspace
+ ],
)? {
sources.insert(crate::invalidation::connector_document_id(
s(&row, "connector_id"),
@@ -959,6 +980,72 @@ pub fn credential_sources(
Ok(sources.into_iter().collect())
}
+/// The store format this program reads ([`require_reader`]). Format 1 is
+/// Graphicle 0.1.3's: the first program that checks the format when it opens
+/// a store, and one that honours the `credential_requirements` contract
+/// ([`required_capabilities`]).
+pub const READER_FORMAT: i64 = 1;
+
+/// The formats a store requires of the programs that open it, by reason.
+const READERS: &str = "CREATE TABLE IF NOT EXISTS store_readers (
+ reason TEXT PRIMARY KEY, format INTEGER NOT NULL, version TEXT NOT NULL,
+ updated_at TEXT NOT NULL);";
+
+/// Record, under `reason`, that a program must read store format `format`
+/// (first released in Graphicle `version`) to honour what this store holds,
+/// for example restrictions an older program would not enforce. From
+/// Graphicle 0.1.3 on, a program that reads only an older format refuses to
+/// open the store ([`Store::open`]) instead of ignoring them; programs before
+/// 0.1.3 do not check. Writes only when the record changes.
+pub fn require_reader(db: &Connection, reason: &str, format: i64, version: &str) -> Result<()> {
+ let current: Option<(i64, String)> = db
+ .query_row(
+ "SELECT format,version FROM store_readers WHERE reason=?",
+ [reason],
+ |r| Ok((r.get(0)?, r.get(1)?)),
+ )
+ .optional()?;
+ if current
+ .as_ref()
+ .is_some_and(|(f, v)| *f == format && v == version)
+ {
+ return Ok(());
+ }
+ db.execute(
+ "INSERT INTO store_readers(reason,format,version,updated_at) VALUES(?,?,?,?)
+ ON CONFLICT(reason) DO UPDATE SET format=excluded.format,version=excluded.version,updated_at=excluded.updated_at",
+ params![reason, format, version, now()],
+ )?;
+ Ok(())
+}
+
+/// Refuse a store that requires a newer store format than this program reads
+/// ([`require_reader`]).
+fn check_reader(db: &Connection) -> Result<()> {
+ let declared: bool = db.query_row(
+ "SELECT EXISTS(SELECT 1 FROM sqlite_master WHERE type='table' AND name='store_readers')",
+ [],
+ |r| r.get(0),
+ )?;
+ if !declared {
+ return Ok(());
+ }
+ let needed: Option<(i64, String)> = db
+ .query_row(
+ "SELECT format,version FROM store_readers ORDER BY format DESC LIMIT 1",
+ [],
+ |r| Ok((r.get(0)?, r.get(1)?)),
+ )
+ .optional()?;
+ match needed {
+ Some((format, version)) if format > READER_FORMAT => Err(Error::bad(format!(
+ "This store needs Graphicle {version} or newer (store format {format}); this is Graphicle {} (store format {READER_FORMAT}). Open it with Graphicle {version} or newer.",
+ env!("CARGO_PKG_VERSION")
+ ))),
+ _ => Ok(()),
+ }
+}
+
/// Additive column migration for tables created by an earlier schema:
/// `CREATE TABLE IF NOT EXISTS` never alters an existing table, so a column
/// added later is appended here when `pragma_table_info` lacks it.
@@ -972,12 +1059,14 @@ pub fn ensure_column(db: &Connection, table: &str, column: &str, ddl: &str) -> R
Ok(())
}
-pub fn authorize_hash(
- db: &Connection,
- workspace: &str,
- hash: &str,
- permission: &str,
-) -> Result<Principal> {
+/// The principal `hash` authenticates in `workspace`, whatever its role
+/// grants: the owner capability, a usable workspace credential (not revoked,
+/// expired or refused by its member's sign-in rules or the store's
+/// credential requirements), or a token an installed extension knows, such as
+/// a browser session. No permission is checked: admission and metering resolve their
+/// caller with this, so a credential is checked and counted whichever
+/// permissions its role holds ([`authorize_hash`] checks one).
+pub fn authenticate_hash(db: &Connection, workspace: &str, hash: &str) -> Result<Principal> {
let owner: String = db
.query_row(
"SELECT capability_hash FROM workspaces WHERE id=?",
@@ -1010,9 +1099,12 @@ pub fn authorize_hash(
return Err(Error::denied());
}
// A member's credential follows the member and team sign-in on any
- // store that has the team tables, whichever edition reads it.
+ // store that has the team tables, whichever edition reads it, and a
+ // credential the store requires capabilities for needs a program
+ // that has them ([`required_capabilities`]).
if !crate::store_compat::credential_allowed(db, s(&row, "id"))?
|| !crate::extension::installed().credential_allowed(db, s(&row, "id"))?
+ || !requirements_met(db, s(&row, "id"))?
{
return Err(Error::denied());
}
@@ -1029,11 +1121,94 @@ pub fn authorize_hash(
role: s(&row, "role").into(),
}
};
- if !principal.permits(permission) {
+ Ok(principal)
+}
+/// The principal `hash` authenticates in `workspace` ([`authenticate_hash`]),
+/// once its role grants `permission` and every installed extension allows it.
+pub fn authorize_hash(
+ db: &Connection,
+ workspace: &str,
+ hash: &str,
+ permission: &str,
+) -> Result<Principal> {
+ let principal = authenticate_hash(db, workspace, hash)?;
+ if !role_grants(db, &principal, permission)? {
return Err(Error::denied());
}
+ extensions_allow(db, &principal, permission)?;
Ok(principal)
}
+/// Whether the role of `p` grants `permission`: a core role as
+/// [`Principal::permits`] says, and a role the core does not define only as
+/// the installed extension that defines it says (`Extension::role_permits`).
+pub fn role_grants(db: &Connection, p: &Principal, permission: &str) -> Result<bool> {
+ if p.permits(permission) {
+ return Ok(true);
+ }
+ if p.role == "owner" || CREDENTIAL_ROLES.contains(&p.role.as_str()) {
+ return Ok(false);
+ }
+ Ok(
+ crate::extension::installed().role_permits(db, &p.workspace, &p.role, permission)?
+ == Some(true),
+ )
+}
+/// Every installed extension allows `p` the permission
+/// (`Extension::authorize`); the owner capability is never asked about.
+fn extensions_allow(db: &Connection, p: &Principal, permission: &str) -> Result<()> {
+ if p.role == "owner" {
+ return Ok(());
+ }
+ crate::extension::installed().authorize(
+ db,
+ p,
+ &mut crate::extension::AccessRequest::new(crate::extension::Access::Permission(permission)),
+ )
+}
+/// Whether `p` holds `permission` as [`authorize_hash`] decides it, for checks
+/// inside an authorized transaction that need a further permission.
+pub fn permitted(db: &Connection, p: &Principal, permission: &str) -> Result<bool> {
+ Ok(role_grants(db, p, permission)? && extensions_allow(db, p, permission).is_ok())
+}
+/// The `build.info` capabilities a program needs to honour `credential`,
+/// sorted. A store may hold a table or view `credential_requirements`
+/// (`credential_id`, `capability`), which an installed extension keeps for
+/// the credentials it restricts in ways the core cannot enforce, each with a
+/// capability that extension sets. A program without the capability refuses
+/// the credential ([`authorize_hash`]) instead of granting its role in full,
+/// so the restriction holds, failing closed, wherever the store or a
+/// portable backup of it is opened; a program with it leaves the credential
+/// to its extensions' hooks. Empty when the store declares none.
+pub fn required_capabilities(db: &Connection, credential: &str) -> Result<Vec<String>> {
+ let declared: bool = db.query_row(
+ "SELECT EXISTS(SELECT 1 FROM sqlite_master WHERE type IN ('table','view') AND name='credential_requirements')",
+ [],
+ |r| r.get(0),
+ )?;
+ if !declared {
+ return Ok(Vec::new());
+ }
+ Ok(rows(
+ db,
+ "SELECT DISTINCT capability FROM credential_requirements WHERE credential_id=? ORDER BY capability",
+ [credential],
+ )?
+ .iter()
+ .map(|row| s(row, "capability").to_string())
+ .collect())
+}
+/// Whether this program has every capability `credential` requires
+/// ([`required_capabilities`]).
+fn requirements_met(db: &Connection, credential: &str) -> Result<bool> {
+ let required = required_capabilities(db, credential)?;
+ if required.is_empty() {
+ return Ok(true);
+ }
+ let capabilities = crate::core_capabilities::capabilities();
+ Ok(required
+ .iter()
+ .all(|capability| capabilities[capability.as_str()] == true))
+}
pub fn repo(db: &Connection, p: &Principal, identifier: &str) -> Result<Value> {
let mut row = one(
db,
@@ -1214,3 +1389,110 @@ mod client_path_tests {
}
}
}
+
+#[cfg(test)]
+mod reader_format_tests {
+ use super::{READER_FORMAT, Store, require_reader};
+
+ /// A store that requires a newer store format is refused at open,
+ /// before anything in it changes; one this program reads opens.
+ #[test]
+ fn a_store_that_needs_a_newer_program_is_refused_at_open() {
+ let dir = tempfile::tempdir().unwrap();
+ let store = Store::open(dir.path()).unwrap();
+ let db = store.connect().unwrap();
+ require_reader(&db, "restrictions", READER_FORMAT, "0.1.3").unwrap();
+ drop(db);
+ assert!(Store::open(dir.path()).is_ok());
+ let db = store.connect().unwrap();
+ require_reader(&db, "later", READER_FORMAT + 1, "9.9.9").unwrap();
+ let changed: i64 = db
+ .query_row("SELECT total_changes()", [], |r| r.get(0))
+ .unwrap();
+ // Unchanged records are not rewritten.
+ require_reader(&db, "later", READER_FORMAT + 1, "9.9.9").unwrap();
+ let again: i64 = db
+ .query_row("SELECT total_changes()", [], |r| r.get(0))
+ .unwrap();
+ assert_eq!(changed, again);
+ drop(db);
+ let error = Store::open(dir.path()).err().expect("refused");
+ assert!(
+ error
+ .message
+ .starts_with("This store needs Graphicle 9.9.9 or newer (store format 2)"),
+ "{}",
+ error.message
+ );
+ store
+ .connect()
+ .unwrap()
+ .execute("DELETE FROM store_readers WHERE reason='later'", [])
+ .unwrap();
+ assert!(Store::open(dir.path()).is_ok());
+ }
+}
+
+#[cfg(test)]
+mod credential_requirement_tests {
+ use super::{Store, required_capabilities, s};
+ use serde_json::json;
+
+ /// A credential the store requires a capability for is refused by a
+ /// program without it (this Core build), also for a permission its role
+ /// grants; one this program has leaves it usable, as are credentials the
+ /// store names no requirement for and the owner capability.
+ #[test]
+ fn a_credential_needs_the_capabilities_the_store_requires_for_it() {
+ let dir = tempfile::tempdir().unwrap();
+ let store = Store::open(dir.path()).unwrap();
+ let created = store.create_workspace("Requirements").unwrap();
+ let (workspace, owner) = (s(&created, "id"), s(&created, "capability"));
+ let grant = |label: &str| {
+ let granted = store
+ .grant(workspace, owner, &json!({"label":label,"role":"agent"}))
+ .unwrap();
+ (
+ s(&granted, "id").to_string(),
+ s(&granted, "capability").to_string(),
+ )
+ };
+ let (restricted, restricted_token) = grant("restricted");
+ let (_, plain_token) = grant("plain");
+ let usable = |token: &str, permission: &str| {
+ store
+ .authorized(workspace, token, permission, |_, _| Ok(()))
+ .is_ok()
+ };
+ let db = store.connect().unwrap();
+ assert!(required_capabilities(&db, &restricted).unwrap().is_empty());
+ db.execute_batch(
+ "CREATE TABLE credential_requirements(credential_id TEXT, capability TEXT)",
+ )
+ .unwrap();
+ // A capability every build has.
+ db.execute(
+ "INSERT INTO credential_requirements VALUES(?,'memory')",
+ [&restricted],
+ )
+ .unwrap();
+ assert!(usable(&restricted_token, "propose"));
+ // One no installed extension sets.
+ db.execute(
+ "INSERT INTO credential_requirements VALUES(?,'unknown_restriction')",
+ [&restricted],
+ )
+ .unwrap();
+ assert_eq!(
+ required_capabilities(&db, &restricted).unwrap(),
+ ["memory", "unknown_restriction"]
+ );
+ assert!(!usable(&restricted_token, "read"));
+ assert!(!usable(&restricted_token, "propose"));
+ assert!(usable(&plain_token, "propose"));
+ assert!(usable(owner, "admin"));
+ db.execute("DELETE FROM credential_requirements", [])
+ .unwrap();
+ assert!(usable(&restricted_token, "propose"));
+ }
+}
diff --git a/crates/graphicle/src/symbol_links.rs b/crates/graphicle/src/symbol_links.rs
new file mode 100644
index 0000000..0ee793f
--- /dev/null
+++ b/crates/graphicle/src/symbol_links.rs
@@ -0,0 +1,525 @@
+//! Reviewed memory and code symbols, read in both directions.
+//!
+//! A memory's links to code symbols are its `data.symbols` and the quotes
+//! pinned after it was written (`gf_symbol_pins`; see [`crate::symbols`]).
+//! This module reads them the other way round, without a table of its own:
+//!
+//! - **Back-links** ([`attach`]): for the code symbols a graph tool's
+//! `get_node` answer names, the current reviewed memories that link them
+//! and the documents the reader may read that mention them (`linked`). A
+//! connection to one project shows only that project's ([`confine`]).
+//! - **The links step of a query** ([`lift`]), switched by `symbol_links`:
+//! after the fusion, each selected code window lifts the current reviewed
+//! memories linked to a symbol inside it (`code_to_memory`), and each
+//! selected memory lifts the current windows of the symbols it links
+//! (`memory_to_code`). One hop: a lifted item lifts nothing. At most
+//! [`MEMORY_LIMIT`] memories and [`WINDOW_LIMIT`] windows, after the fused
+//! results, the code arm's anchors and the document links' windows, never
+//! one already there. A link counts only while the live-symbol table
+//! describes the bytes the reader reads (the file's sha256) and the symbol
+//! keeps the revision the link recorded, and only memories the query may
+//! serve are lifted (reviewed, current, allowed by its filters, within the
+//! recall bound).
+//!
+//! The `symbol_links` switch: left out, the links of the selected items are
+//! counted (`withheld`) and nothing is lifted, since whether lifted items
+//! help answers has not been measured; `true` follows them; `false` reads
+//! none. A store whose memories carry no code links reads nothing here, so
+//! its packets keep their evidence. A query only reads.
+use crate::{
+ Error, Result,
+ query::Snapshot,
+ store::{Principal, rows, s},
+ symbols::{self, Live},
+};
+use graphicle_memory::graph::span;
+use rusqlite::{Connection, params};
+use serde_json::{Value, json};
+use std::collections::{BTreeMap, BTreeSet, HashMap};
+
+/// The switch, the packet field and the facts of the links followed.
+pub const ARM: &str = "symbol_links";
+/// Memories one query lifts through code windows.
+pub const MEMORY_LIMIT: usize = 4;
+/// Code windows one query lifts through memories, as the document links'
+/// `LIFT_LIMIT` bounds theirs.
+pub const WINDOW_LIMIT: usize = 6;
+/// Memories and documents a back-link listing names per symbol.
+pub const BACK_LINK_LIMIT: usize = 20;
+
+/// The `symbol_links` switch of a query.
+#[derive(Clone, Copy, Debug, PartialEq, Eq)]
+pub enum Mode {
+ /// Left out: the links of the selected items are counted, not followed.
+ Counted,
+ /// `true`: followed one hop.
+ Follow,
+ /// `false`: no link is read.
+ Off,
+}
+
+impl Mode {
+ pub fn parse(args: &Value) -> Result<Self> {
+ match args.get(ARM) {
+ None | Some(Value::Null) => Ok(Self::Counted),
+ Some(Value::Bool(true)) => Ok(Self::Follow),
+ Some(Value::Bool(false)) => Ok(Self::Off),
+ Some(_) => Err(Error::bad("symbol_links must be true or false")),
+ }
+ }
+ /// Whether links are followed (lifted into the packet).
+ pub fn enabled(self) -> bool {
+ self == Self::Follow
+ }
+}
+
+fn resolved(entries: &[Value]) -> impl Iterator<Item = &Value> {
+ entries
+ .iter()
+ .filter(|entry| entry["state"] == "resolved" && entry["stable_id"].is_string())
+}
+
+/// The resolved links of each memory that has code links: its own
+/// (`data.symbols`) and its pinned quotes', one per `stable_id` (the first
+/// recorded).
+fn links_of<'m>(
+ db: &Connection,
+ repository: &str,
+ memories: impl Iterator<Item = &'m Value>,
+) -> Result<HashMap<String, Vec<Value>>> {
+ let mut out: HashMap<String, Vec<Value>> = HashMap::new();
+ for memory in memories {
+ let entries = memory["data"]["symbols"]
+ .as_array()
+ .map(Vec::as_slice)
+ .unwrap_or(&[]);
+ if !entries.is_empty() {
+ out.entry(s(memory, "id").to_string())
+ .or_default()
+ .extend(resolved(entries).cloned());
+ }
+ }
+ if out.is_empty() {
+ return Ok(out);
+ }
+ let ids: BTreeSet<&String> = out.keys().collect();
+ for row in rows(
+ db,
+ "SELECT memory_id,symbols FROM gf_symbol_pins WHERE repository_id=?1 AND state='pinned' \
+ AND memory_id IN (SELECT value FROM json_each(?2)) ORDER BY memory_id,relpath,byte_start",
+ params![repository, json!(ids).to_string()],
+ )? {
+ let pinned: Vec<Value> = serde_json::from_str(s(&row, "symbols")).unwrap_or_default();
+ if let Some(links) = out.get_mut(s(&row, "memory_id")) {
+ links.extend(resolved(&pinned).cloned());
+ }
+ }
+ for links in out.values_mut() {
+ let mut seen = BTreeSet::new();
+ links.retain(|link| seen.insert(s(link, "stable_id").to_string()));
+ }
+ out.retain(|_, links| !links.is_empty());
+ Ok(out)
+}
+
+/// What the `symbol_links` step added to a query.
+pub struct Lifted {
+ /// Code windows, as candidates no passage covers.
+ pub windows: Vec<Value>,
+ /// Memory rows as `rank` takes them, marked `via: link`, the link
+ /// followed under `link`.
+ pub memories: Vec<Value>,
+ pub report: Value,
+}
+
+#[derive(Default)]
+struct Counts {
+ considered: usize,
+ withheld: usize,
+ covered: usize,
+ pending: usize,
+ changed: usize,
+ unavailable: usize,
+ over_limit: usize,
+}
+
+/// One file's live symbols and line starts, when the table describes the
+/// bytes the reader reads.
+struct File<'a> {
+ document: &'a Value,
+ live: Vec<Live>,
+ starts: Vec<usize>,
+}
+
+/// The links step of a query (see the module documentation). `rows` are the
+/// query's candidate rows (its memory rows are the memories it may serve),
+/// `sources` and `selected_memories` what the fusion selected, in rank
+/// order, and `candidates` the windows already taken.
+#[allow(clippy::too_many_arguments)]
+pub fn lift(
+ db: &Connection,
+ repository: &str,
+ mode: Mode,
+ snapshot: &Snapshot,
+ rows: &[Value],
+ sources: &[Value],
+ selected_memories: &[Value],
+ candidates: &[Value],
+) -> Result<Lifted> {
+ let servable: Vec<&Value> = rows.iter().filter(|row| row["kind"] == "memory").collect();
+ let links = if mode == Mode::Off {
+ HashMap::new()
+ } else {
+ links_of(db, repository, servable.iter().map(|row| &row["memory"]))?
+ };
+ if links.is_empty() {
+ return Ok(Lifted {
+ windows: Vec::new(),
+ memories: Vec::new(),
+ report: json!({"status": if mode == Mode::Off { "disabled" } else { "no_links" }}),
+ });
+ }
+ let follow = mode.enabled();
+ let documents: HashMap<&str, &Value> =
+ snapshot.documents.iter().map(|d| (s(d, "id"), d)).collect();
+ // stable_id → the servable memories linking it, in recall order.
+ let mut index: HashMap<&str, Vec<(&Value, &Value)>> = HashMap::new();
+ for row in servable.iter().copied() {
+ for link in links.get(s(&row["memory"], "id")).into_iter().flatten() {
+ index
+ .entry(s(link, "stable_id"))
+ .or_default()
+ .push((row, link));
+ }
+ }
+ let mut counts = Counts::default();
+ // A code window: the memories linked to a symbol inside it.
+ let mut taken: BTreeSet<String> = selected_memories
+ .iter()
+ .map(|row| s(row, "identity").to_string())
+ .collect();
+ let mut memories = Vec::new();
+ let mut files: HashMap<String, Option<File<'_>>> = HashMap::new();
+ for hit in sources {
+ let source = &hit["source"];
+ let id = s(source, "id");
+ let (Some(relpath), Some(a), Some(b)) = (
+ id.strip_prefix("file:"),
+ source["byte_start"].as_u64(),
+ source["byte_end"].as_u64(),
+ ) else {
+ continue;
+ };
+ let (a, b) = (a as usize, b as usize);
+ if !files.contains_key(relpath) {
+ let file = match documents.get(id) {
+ Some(document) => Some(File {
+ document,
+ live: symbols::in_file(db, repository, relpath)?,
+ starts: span::line_starts(s(document, "content")),
+ }),
+ None => None,
+ };
+ files.insert(relpath.to_string(), file);
+ }
+ let Some(file) = files[relpath].as_ref() else {
+ continue;
+ };
+ let sha = s(file.document, "sha256");
+ let length = s(file.document, "content").len();
+ for live in &file.live {
+ let Some(linked) = index.get(live.stable_id.as_str()) else {
+ continue;
+ };
+ // The table describes other bytes of this file: wait for the
+ // projection.
+ if live.sha256 != sha {
+ counts.pending += linked.len();
+ continue;
+ }
+ let range = live.range(&file.starts, length);
+ if !(range.start < b && a < range.end) {
+ continue;
+ }
+ for (row, link) in linked {
+ counts.considered += 1;
+ if s(link, "revision") != live.revision {
+ counts.changed += 1;
+ continue;
+ }
+ // Already selected, or lifted through another window.
+ if taken.contains(s(row, "identity")) {
+ counts.covered += 1;
+ continue;
+ }
+ if !follow {
+ counts.withheld += 1;
+ continue;
+ }
+ taken.insert(s(row, "identity").to_string());
+ if memories.len() >= MEMORY_LIMIT {
+ counts.over_limit += 1;
+ continue;
+ }
+ // `link`, not `symbol_links`: a memory record with links
+ // already carries its own `symbol_links` summary.
+ let mut lifted = (*row).clone();
+ lifted["memory"]["via"] = json!("link");
+ lifted["memory"]["link"] = json!({"direction":"code_to_memory","from":hit["identity"],
+ "stable_id":live.stable_id,"revision":live.revision,
+ "qualified_name":live.identity.qualified_name,"rung":link["rung"]});
+ memories.push(lifted);
+ }
+ }
+ }
+ // A memory: the current windows of the symbols it links.
+ let mut ranges: Vec<(String, usize, usize)> = candidates
+ .iter()
+ .filter_map(|c| {
+ Some((
+ s(&c["source"], "id").to_string(),
+ c["source"]["byte_start"].as_u64()? as usize,
+ c["source"]["byte_end"].as_u64()? as usize,
+ ))
+ })
+ .collect();
+ let wanted: BTreeSet<String> = selected_memories
+ .iter()
+ .filter_map(|row| links.get(s(&row["memory"], "id")))
+ .flatten()
+ .map(|link| s(link, "stable_id").to_string())
+ .collect();
+ let live: BTreeMap<String, Live> = symbols::by_ids(db, repository, &wanted)?
+ .into_iter()
+ .map(|row| (row.stable_id.clone(), row))
+ .collect();
+ let mut windows = Vec::new();
+ for row in selected_memories {
+ for link in links.get(s(&row["memory"], "id")).into_iter().flatten() {
+ counts.considered += 1;
+ let Some(symbol) = live.get(s(link, "stable_id")) else {
+ counts.changed += 1;
+ continue;
+ };
+ if symbol.revision != s(link, "revision") {
+ counts.changed += 1;
+ continue;
+ }
+ let id = format!("file:{}", symbol.identity.relpath);
+ let Some(document) = documents.get(id.as_str()) else {
+ counts.unavailable += 1;
+ continue;
+ };
+ if s(document, "sha256") != symbol.sha256 {
+ counts.pending += 1;
+ continue;
+ }
+ let content = s(document, "content");
+ let range = symbol.range(&span::line_starts(content), content.len());
+ // A window already taken covers it.
+ if ranges
+ .iter()
+ .any(|(other, x, y)| *other == id && *x < range.end && range.start < *y)
+ {
+ counts.covered += 1;
+ continue;
+ }
+ if !follow {
+ counts.withheld += 1;
+ continue;
+ }
+ if windows.len() >= WINDOW_LIMIT {
+ counts.over_limit += 1;
+ continue;
+ }
+ let facts = json!({"via":"link","direction":"memory_to_code","from":row["identity"],
+ "stable_id":symbol.stable_id,"revision":symbol.revision,
+ "qualified_name":symbol.identity.qualified_name,"rung":link["rung"]});
+ let identity = format!("{id}:{}#{ARM}", range.start);
+ if let Some(window) = crate::doc_links::window_with(
+ ARM,
+ document,
+ range.start,
+ range.end,
+ identity,
+ facts,
+ ) {
+ ranges.push((id, range.start, range.end));
+ windows.push(window);
+ }
+ }
+ }
+ let report = json!({"status": if follow { "followed" } else { "counted" },
+ "considered":counts.considered,"lifted_memories":memories.len(),"lifted_windows":windows.len(),
+ "withheld":counts.withheld,"covered":counts.covered,"pending":counts.pending,
+ "changed":counts.changed,"unavailable":counts.unavailable,"over_limit":counts.over_limit});
+ Ok(Lifted {
+ windows,
+ memories,
+ report,
+ })
+}
+
+/// Back-links: each node fact (a graph tool's citation) with a
+/// `stable_id` gains `linked`, the current reviewed memories of the project
+/// that link that symbol (`memories`: id, kind, title, the memory's
+/// revision, and the link's rung and recorded symbol revision) and the
+/// documents the reader may read that mention it (`documents`, as
+/// `graph.doc_links` lists them), at most [`BACK_LINK_LIMIT`] of each. A
+/// memory the reader's view withholds (stale, a draft, retired) is never
+/// listed. Read-only.
+pub fn attach(
+ db: &Connection,
+ p: &Principal,
+ repository: &Value,
+ nodes: &mut [Value],
+) -> Result<()> {
+ let project = s(repository, "id");
+ let ids: BTreeSet<String> = nodes
+ .iter()
+ .filter_map(|node| node["stable_id"].as_str())
+ .map(str::to_string)
+ .collect();
+ if ids.is_empty() {
+ return Ok(());
+ }
+ // Which reviewed memories name these symbols at all: only then is the
+ // reader's view of the project's memories read.
+ let named: BTreeSet<String> = rows(
+ db,
+ "SELECT m.id AS id FROM repo_memories m, json_each(m.data,'$.symbols') j \
+ WHERE m.repository_id=?1 AND m.state='reviewed' \
+ AND json_extract(j.value,'$.stable_id') IN (SELECT value FROM json_each(?2)) \
+ UNION SELECT g.memory_id AS id FROM gf_symbol_pins g, json_each(g.symbols) j \
+ WHERE g.repository_id=?1 AND g.state='pinned' \
+ AND json_extract(j.value,'$.stable_id') IN (SELECT value FROM json_each(?2))",
+ params![project, json!(ids).to_string()],
+ )?
+ .iter()
+ .map(|row| s(row, "id").to_string())
+ .collect();
+ // One view of what the reader may read for every node: each project's
+ // documents are listed at most once per call (the project's own once,
+ // shared with its memory listing).
+ let mut naming = crate::doc_links::Naming::new(db, p);
+ let memories: Vec<Value> = if named.is_empty() {
+ Vec::new()
+ } else {
+ let documents = crate::memory::documents(db, repository, p)?;
+ naming = naming.knowing(project, &documents);
+ crate::memory::list_of(db, repository, &documents, false)?
+ .into_iter()
+ .filter(|m| {
+ named.contains(s(m, "id")) && m["state"] == "reviewed" && m["stale"] != true
+ })
+ .collect()
+ };
+ let links = links_of(db, project, memories.iter())?;
+ for node in nodes.iter_mut() {
+ let Some(stable) = node["stable_id"].as_str().map(str::to_string) else {
+ continue;
+ };
+ let listed: Vec<Value> = memories
+ .iter()
+ .filter_map(|memory| {
+ let link = links
+ .get(s(memory, "id"))?
+ .iter()
+ .find(|link| s(link, "stable_id") == stable)?;
+ Some(json!({"id":memory["id"],"kind":memory["kind"],"title":memory["title"],
+ "revision":memory["revision"],"rung":link["rung"],"symbol_revision":link["revision"]}))
+ })
+ .take(BACK_LINK_LIMIT)
+ .collect();
+ let documents = naming.documents(project, &stable, BACK_LINK_LIMIT)?;
+ node["linked"] = json!({"memories":listed,"documents":documents});
+ }
+ Ok(())
+}
+
+/// Back-links as a connection to one project shows them: such a connection
+/// keeps memory and documents on its project (`own`), while a graph tool's
+/// `repo` may read another project's code graph. A graph tool's `reply`
+/// keeps the reviewed memories of its nodes only when it read `own`'s graph,
+/// and only `own`'s documents; the citations text, built from the reply,
+/// follows.
+pub fn confine(reply: &mut Value, own: &str) {
+ let own_graph = reply["repo"] == own;
+ for node in reply["nodes"].as_array_mut().into_iter().flatten() {
+ let Some(linked) = node.get_mut("linked").and_then(Value::as_object_mut) else {
+ continue;
+ };
+ if !own_graph {
+ linked.insert("memories".into(), json!([]));
+ }
+ if let Some(documents) = linked.get_mut("documents").and_then(Value::as_array_mut) {
+ documents.retain(|document| document["repository_id"] == own);
+ }
+ }
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ #[test]
+ fn the_switch_counts_when_left_out_follows_when_true_and_reads_none_when_false() {
+ assert_eq!(Mode::parse(&json!({})).unwrap(), Mode::Counted);
+ assert_eq!(
+ Mode::parse(&json!({"symbol_links":null})).unwrap(),
+ Mode::Counted
+ );
+ assert_eq!(
+ Mode::parse(&json!({"symbol_links":true})).unwrap(),
+ Mode::Follow
+ );
+ assert_eq!(
+ Mode::parse(&json!({"symbol_links":false})).unwrap(),
+ Mode::Off
+ );
+ assert!(Mode::parse(&json!({"symbol_links":"yes"})).is_err());
+ assert!(Mode::Follow.enabled());
+ assert!(!Mode::Counted.enabled() && !Mode::Off.enabled());
+ }
+
+ #[test]
+ fn a_project_connection_keeps_back_links_on_its_project() {
+ let linked = || {
+ json!({"memories":[{"id":"m1"}],"documents":[
+ {"repository_id":"own","document_id":"file:a.md"},
+ {"repository_id":"other","document_id":"file:b.md"}]})
+ };
+ let reply = |repo: &str| json!({"repo":repo,"nodes":[{"stable_id":"s1","linked":linked()},{"stable_id":"s2"}]});
+ // The connection's own graph: its memories stay, other projects'
+ // documents go.
+ let mut own = reply("own");
+ confine(&mut own, "own");
+ assert_eq!(own["nodes"][0]["linked"]["memories"], json!([{"id":"m1"}]));
+ assert_eq!(
+ own["nodes"][0]["linked"]["documents"],
+ json!([{"repository_id":"own","document_id":"file:a.md"}])
+ );
+ assert!(own["nodes"][1].get("linked").is_none());
+ // Another project's graph (`repo`): no memory, its own documents only.
+ let mut other = reply("other");
+ confine(&mut other, "own");
+ assert_eq!(other["nodes"][0]["linked"]["memories"], json!([]));
+ assert_eq!(
+ other["nodes"][0]["linked"]["documents"],
+ json!([{"repository_id":"own","document_id":"file:a.md"}])
+ );
+ }
+
+ #[test]
+ fn only_resolved_links_with_a_stable_id_count() {
+ let entries = vec![
+ json!({"state":"resolved","stable_id":"s1","rung":"named"}),
+ json!({"state":"pending","relpath":"a.py"}),
+ json!({"state":"resolved"}),
+ ];
+ let found: Vec<&str> = resolved(&entries)
+ .map(|entry| s(entry, "stable_id"))
+ .collect();
+ assert_eq!(found, ["s1"]);
+ }
+}
diff --git a/crates/graphicle/src/symbols.rs b/crates/graphicle/src/symbols.rs
index 35177f2..e600b3e 100644
--- a/crates/graphicle/src/symbols.rs
+++ b/crates/graphicle/src/symbols.rs
@@ -138,7 +138,8 @@ fn select(db: &Connection, filter: &str, arguments: impl rusqlite::Params) -> Re
Ok(found.collect::<rusqlite::Result<Vec<_>>>()?)
}
-fn by_ids(db: &Connection, repository: &str, ids: &BTreeSet<String>) -> Result<Vec<Live>> {
+/// The live code symbols with these `stable_id`s.
+pub fn by_ids(db: &Connection, repository: &str, ids: &BTreeSet<String>) -> Result<Vec<Live>> {
if ids.is_empty() {
return Ok(Vec::new());
}
@@ -149,6 +150,15 @@ fn by_ids(db: &Connection, repository: &str, ids: &BTreeSet<String>) -> Result<V
)
}
+/// The live code symbols of one file (`relpath`), by the indexed file column.
+pub fn in_file(db: &Connection, repository: &str, relpath: &str) -> Result<Vec<Live>> {
+ select(
+ db,
+ "repository_id=?1 AND relpath=?2",
+ params![repository, relpath],
+ )
+}
+
/// The head set (episode) `gf_symbol_heads` describes, if any.
pub fn table_episode(db: &Connection, repository: &str) -> Result<Option<String>> {
Ok(rows(
@@ -1287,6 +1297,167 @@ pub fn reground(
Ok(json!({"regrounded":regrounded,"unresolved":failed}))
}
+/// A knowledge pack's anchor names no symbol of this project.
+pub const LAND_MISSING: &str = "symbol_missing";
+/// Several symbols here could be the anchor's.
+pub const LAND_AMBIGUOUS: &str = "ambiguous";
+/// The anchor's symbol is not built for its file's current content yet.
+pub const LAND_PENDING: &str = "projection_pending";
+/// The anchor carries no complete logical identity.
+pub const LAND_INCOMPLETE: &str = "identity_incomplete";
+
+/// A knowledge pack's symbol anchor, landed on a live symbol here.
+#[derive(Clone, Debug)]
+pub struct Landed {
+ /// The file the anchor named in the pack.
+ pub from: String,
+ pub row: Live,
+ /// Not at the anchor's relpath and ordinal: found by qualified name and
+ /// kind elsewhere.
+ pub moved: bool,
+}
+
+/// Land a knowledge pack's symbol anchors (logical identities: relpath,
+/// qualified name, kind, ordinal) on this project's live symbols: the one
+/// live symbol of the same identity, else, as a move, the only live symbol
+/// of that qualified name and kind anywhere in the project. The symbol's
+/// file must be a current source whose code graph is built for its content.
+/// Revisions are not compared: the code is another project's, and the
+/// import is a draft a member reviews against this code. Per anchor, the
+/// landed symbol or the reason it was dropped.
+pub fn land(
+ db: &Connection,
+ repository: &str,
+ anchors: &[Value],
+ documents: &[Value],
+) -> Result<Vec<std::result::Result<Landed, &'static str>>> {
+ Lander::new(db, repository, documents).land(anchors)
+}
+
+/// [`land`] for the anchors of many memories (one knowledge pack): the
+/// project's symbols are brought up to date once, the map of its live
+/// symbols by qualified name and kind is read at most once, and its
+/// documents are looked up by id.
+pub struct Lander<'a> {
+ db: &'a Connection,
+ repository: &'a str,
+ documents: HashMap<&'a str, &'a Value>,
+ by_name: Option<HashMap<(String, String), Vec<Live>>>,
+}
+
+impl<'a> Lander<'a> {
+ pub fn new(db: &'a Connection, repository: &'a str, documents: &'a [Value]) -> Self {
+ let _ = ensure_current(db, repository);
+ Self {
+ db,
+ repository,
+ documents: documents.iter().map(|d| (s(d, "id"), d)).collect(),
+ by_name: None,
+ }
+ }
+ /// Per anchor, the landed symbol or the reason it was dropped ([`land`]).
+ pub fn land(
+ &mut self,
+ anchors: &[Value],
+ ) -> Result<Vec<std::result::Result<Landed, &'static str>>> {
+ let (db, repository) = (self.db, self.repository);
+ let mut out = Vec::with_capacity(anchors.len());
+ for anchor in anchors {
+ let Ok(identity) = serde_json::from_value::<LogicalIdentity>(anchor.clone()) else {
+ out.push(Err(LAND_INCOMPLETE));
+ continue;
+ };
+ let mut rows = select(
+ db,
+ "repository_id=?1 AND relpath=?2 AND qualified_name=?3",
+ params![repository, identity.relpath, identity.qualified_name],
+ )?;
+ rows.retain(|r| {
+ r.identity.kind == identity.kind && r.identity.ordinal == identity.ordinal
+ });
+ let (candidates, moved) = if rows.len() == 1 {
+ (rows, false)
+ } else {
+ // Every live symbol by qualified name and kind, read once
+ // and only when an anchor is not where the pack had it.
+ if self.by_name.is_none() {
+ let mut all: HashMap<(String, String), Vec<Live>> = HashMap::new();
+ for row in select(db, "repository_id=?1", params![repository])? {
+ all.entry((
+ row.identity.qualified_name.clone(),
+ row.identity.kind.clone(),
+ ))
+ .or_default()
+ .push(row);
+ }
+ self.by_name = Some(all);
+ }
+ let key = (identity.qualified_name.clone(), identity.kind.clone());
+ let found = self.by_name.as_ref().and_then(|all| all.get(&key));
+ (found.cloned().unwrap_or_default(), true)
+ };
+ let row = match candidates.as_slice() {
+ [row] => row.clone(),
+ [] => {
+ out.push(Err(LAND_MISSING));
+ continue;
+ }
+ _ => {
+ out.push(Err(LAND_AMBIGUOUS));
+ continue;
+ }
+ };
+ let file = format!("file:{}", row.identity.relpath);
+ match self.documents.get(file.as_str()) {
+ None => out.push(Err(LAND_MISSING)),
+ Some(doc) if s(doc, "sha256") != row.sha256 => out.push(Err(LAND_PENDING)),
+ Some(_) => out.push(Ok(Landed {
+ from: identity.relpath,
+ row,
+ moved,
+ })),
+ }
+ }
+ Ok(out)
+ }
+}
+
+/// Link landed symbols as `named` links at this project's ids, revisions
+/// and byte ranges; a symbol a quote already linked keeps that link. Their
+/// files become dependencies judged by their symbols.
+pub fn link_landed(
+ db: &Connection,
+ repository: &str,
+ landed: &[&Landed],
+ documents: &[Value],
+ data: &mut Value,
+) -> Result<()> {
+ if landed.is_empty() {
+ return Ok(());
+ }
+ let resolver = Resolver::new(db, repository)?;
+ for landed in landed {
+ let row = &landed.row;
+ if entries(data).any(|e| e["stable_id"] == row.stable_id.as_str()) {
+ continue;
+ }
+ let path = &row.identity.relpath;
+ let Some(doc) = documents
+ .iter()
+ .find(|d| s(d, "id") == format!("file:{path}"))
+ else {
+ continue;
+ };
+ let content = s(doc, "content");
+ let range = row.range(&span::line_starts(content), content.len());
+ data["dependencies"][path.as_str()] = doc["sha256"].clone();
+ push(data, link(row, RUNG_NAMED, resolver.episode(), range));
+ set_rule(data, path, RULE_SYMBOLS);
+ }
+ tidy(data);
+ Ok(())
+}
+
/// A memory whose state, freshness and links make it a trigger for
/// `basic` (the second trigger): reviewed, current, with symbol links.
pub fn current_links(memories: &[Value]) -> bool {
diff --git a/crates/graphicle/src/terminal.rs b/crates/graphicle/src/terminal.rs
index 574331b..4c16c2f 100644
--- a/crates/graphicle/src/terminal.rs
+++ b/crates/graphicle/src/terminal.rs
@@ -122,11 +122,24 @@ pub fn color_with(no_color: Option<&OsStr>, term: Option<&str>, terminal: bool)
/// Print `value` as JSON, or its readable view (`render`) when [`human`].
pub fn emit(value: &Value, json: bool, render: impl FnOnce(&Value, Style) -> String) -> Result<()> {
- if human(json) {
- say(&render(value, Style::detect()))
+ emit_text(value, json, render).map(|_| ())
+}
+
+/// [`emit`], returning the text it printed (without the newline [`say`]
+/// ends it with), for a command that counts what it serves
+/// (`crate::metering`).
+pub fn emit_text(
+ value: &Value,
+ json: bool,
+ render: impl FnOnce(&Value, Style) -> String,
+) -> Result<String> {
+ let text = if human(json) {
+ render(value, Style::detect())
} else {
- crate::cli::print(value)
- }
+ serde_json::to_string_pretty(value)?
+ };
+ say(&text)?;
+ Ok(text)
}
/// Print `text` on standard output, ending with one newline.
@@ -268,7 +281,10 @@ pub const GROUPS: &[(&str, &[&str])] = &[
),
("Agents", &["connect", "disconnect", "mcp"]),
("Code graph", &["graph", "pr"]),
- ("Data", &["sync", "sessions", "backup", "restore"]),
+ (
+ "Data",
+ &["sync", "sessions", "backup", "restore", "offboard"],
+ ),
("Server", &["serve", "init", "login"]),
];
@@ -321,6 +337,10 @@ const SUMMARIES: &[(&str, &str)] = &[
),
("backup", "Back up the store without stopping the app"),
("restore", "Restore a backup into a new data folder"),
+ (
+ "offboard",
+ "Remove one project's data, its backups included, with a receipt",
+ ),
("serve", "Run the app and the HTTP MCP server"),
(
"init",
@@ -2959,6 +2979,9 @@ pub fn config_command(
let answering = configured_model(directory, &config);
let mut shown = config_show(&path, answering.as_ref())?;
shown["freshness"] = json!(crate::fresh::mode(&config));
+ // GRAPHICLE_SYNC_TRACKED_IGNORED overrides the file.
+ shown["sync"] =
+ json!({"tracked_ignored": crate::local::tracked_ignored_setting(Some(&config))});
shown["limits"] = crate::limits::Limits::from_environment(&config.limits)?.view();
emit(&shown, json, config_show_text)
}
@@ -2969,6 +2992,9 @@ pub fn config_command(
} else if key == "freshness" {
// GRAPHICLE_FRESHNESS overrides the file (ux-fresh).
Some(json!(crate::fresh::mode(&load()?)))
+ } else if key == "sync.tracked_ignored" {
+ // GRAPHICLE_SYNC_TRACKED_IGNORED overrides the file.
+ Some(json!(crate::local::tracked_ignored_setting(Some(&load()?))))
} else if key == crate::update_notice::SETTING {
// GRAPHICLE_NO_UPDATE_NOTIFIER overrides the file.
Some(json!(crate::update_notice::on(&path)))
@@ -3054,10 +3080,15 @@ fn location(source: &Value) -> String {
.or_else(|| source["title"].as_str())
.or_else(|| source["id"].as_str())
.unwrap_or("source");
- match (source["line"].as_u64(), source["end_line"].as_u64()) {
+ let place = match (source["line"].as_u64(), source["end_line"].as_u64()) {
(Some(line), Some(end)) if end > line => format!("{path}:{line}-{end}"),
(Some(line), _) => format!("{path}:{line}"),
_ => path.to_string(),
+ };
+ // The date its file last changed, when the packet dated it.
+ match source["changed"].as_str().filter(|c| !c.is_empty()) {
+ Some(changed) => format!("{place} (changed {changed})"),
+ None => place,
}
}
@@ -3122,6 +3153,33 @@ fn excerpts_of(packet: &Value) -> Vec<(&Value, &str)> {
/// A `context` packet for people: the numbered excerpts with their place
/// and why each was chosen, the reviewed memories and the budget.
pub fn context_text(packet: &Value, style: Style) -> String {
+ // The identifier route's answer: definitions and references, as
+ // path:line lines (crate::identifier_route).
+ if packet[crate::identifier_route::REPORT]["path"] == "identifier" {
+ let mut out = format!(
+ "{} {}\n",
+ style.bold("Definitions and references for"),
+ style.bold(&format!("\"{}\"", s(packet, "question")))
+ );
+ let _ = writeln!(
+ out,
+ "{}",
+ style.dim(&format!(
+ "from the code graph · {} of {} tokens",
+ count(packet["tokens"].as_u64().unwrap_or(0)),
+ count(packet["max_tokens"].as_u64().unwrap_or(0))
+ ))
+ );
+ // The lines between the header and the footer: the footer tells an
+ // agent which tool reads on, and the budget, which the line above
+ // gives.
+ for line in s(packet, "markdown").lines().skip(1).filter(|line| {
+ *line != crate::identifier_route::READ_ON && !line.starts_with("Budget: ")
+ }) {
+ let _ = writeln!(out, "{line}");
+ }
+ return out;
+ }
let sources = excerpts_of(packet);
let mut out = format!(
"{} {}\n",
@@ -3154,8 +3212,29 @@ pub fn context_text(packet: &Value, style: Style) -> String {
style.bold(&format!("[{}]", index + 1)),
location(source)
);
+ for mark in source["age_marks"]
+ .as_array()
+ .into_iter()
+ .flatten()
+ .filter_map(Value::as_str)
+ {
+ let _ = writeln!(out, " {} {mark}", style.warn("!"));
+ }
out.push_str(&excerpt(text, 12, " "));
}
+ // The files that rank next, which the excerpts do not quote.
+ let more: Vec<&str> = packet["more_files"]
+ .as_array()
+ .into_iter()
+ .flatten()
+ .filter_map(Value::as_str)
+ .collect();
+ if !more.is_empty() {
+ let _ = writeln!(out, "\n{}", style.bold("Next ranked files:"));
+ for path in more {
+ let _ = writeln!(out, " - {path}");
+ }
+ }
let memories = packet["memories"].as_array().cloned().unwrap_or_default();
if !memories.is_empty() {
let _ = writeln!(out, "\n{}", style.bold("Reviewed memory:"));
diff --git a/crates/graphicle/src/vault.rs b/crates/graphicle/src/vault.rs
index ab8f905..b294ba0 100644
--- a/crates/graphicle/src/vault.rs
+++ b/crates/graphicle/src/vault.rs
@@ -1,4 +1,6 @@
-//! Workspace-bound authenticated encryption for provider secrets.
+//! Workspace-bound authenticated encryption for provider secrets. The key is
+//! the device key file `vault.key`, unless an installed extension holds it
+//! ([`crate::extension::Extension::vault_key`]).
use crate::{
Error, Result, id, now,
store::{Store, one, s},
@@ -15,6 +17,10 @@ use std::io::{Read, Write};
impl Store {
fn vault_key(&self) -> Result<[u8; 32]> {
+ // An extension that holds the key answers for it, errors included.
+ if let Some(key) = crate::extension::installed().vault_key(self) {
+ return key;
+ }
let path = self.directory.join("vault.key");
let mut temporary = tempfile::NamedTempFile::new_in(&*self.directory)?;
let mut new_key = [0u8; 32];
diff --git a/crates/graphicle/src/workflow_retrieval.rs b/crates/graphicle/src/workflow_retrieval.rs
index 35b98d5..4fcbbad 100644
--- a/crates/graphicle/src/workflow_retrieval.rs
+++ b/crates/graphicle/src/workflow_retrieval.rs
@@ -34,6 +34,11 @@ const OPTIONS: &[&str] = &[
"memory_retrieval",
"graph_retrieval",
"doc_links",
+ "symbol_links",
+ "notes_first",
+ "code_first",
+ "query_focus",
+ "more_files",
"mode",
"needs",
];
@@ -150,13 +155,16 @@ pub(crate) fn context(
} else {
jobs::guarded_read(&worker.store, job, |db, _, _| {
let question = crate::string(&args, "question", 8000)?;
- // `doc_links: false` leaves document nodes out of the arm too.
+ // The arm reads a code question's content, and leaves document
+ // nodes out for it as for `doc_links: false`, as `context` does.
+ let focus = crate::code_question::focus(&args, question)?;
+ let code_first = crate::code_question::decide(&args, question, &focus.text)?;
Ok(crate::code_graph_arm::arm_with(
db,
&job.repository,
snapshot,
- question,
- links.documents(),
+ &focus.text,
+ links.documents() && !code_first.applied,
)
.unwrap_or_else(|error| {
let mut arm = crate::code_graph_arm::Arm::skipped("error");
@@ -165,10 +173,13 @@ pub(crate) fn context(
}))
})?
};
- // The documents' mention links, read on a
- // connection of their own: rows only, checked against the snapshot
- // (followed with `doc_links: true`, else counted).
- let links_db = if links.documents() {
+ // The documents' mention links and reviewed memory's links to code
+ // symbols, read on a connection of their own: rows only, checked against
+ // the snapshot (each followed with its switch `true`, else counted). The
+ // memory links are read with `doc_links: false` too; `context_on` reads
+ // the document links only when documents take part.
+ let symbol_links = crate::symbol_links::Mode::parse(&args)?;
+ let links_db = if links.documents() || symbol_links != crate::symbol_links::Mode::Off {
let db = worker.store.connect()?;
db.pragma_update(None, "query_only", true)?;
Some(db)
diff --git a/crates/graphicle/src/workspace.rs b/crates/graphicle/src/workspace.rs
index 1449b2c..596d0a9 100644
--- a/crates/graphicle/src/workspace.rs
+++ b/crates/graphicle/src/workspace.rs
@@ -28,7 +28,8 @@
//! symbol lifts the importing project's use of it. A lifted window follows
//! the window that led to it and carries `cross_repo` facts (the edge, both
//! ends and their stable ids). It is a graph mechanism: `graph_retrieval:
-//! false` turns it off.
+//! false` turns it off, and `cross_repo` turns it alone off or on (left
+//! out, it follows `graph_retrieval`).
//! - **A project the principal may not read takes no part**: it is not
//! searched, no edge to or from it is followed, and no count includes it.
//! - **A project whose read fails is left out** and listed in `projects`
@@ -251,8 +252,9 @@ pub fn context(
}
}
}
- let graph_on = args["graph_retrieval"] != false;
- let step = if graph_on {
+ // The cross-repository step's own switch, else `graph_retrieval`'s.
+ let switches = query::switches(args, "workspace")?;
+ let step = if switches["cross_repo"] == true {
// A graph mechanism: like the code arm, it degrades (and says why)
// rather than failing the query.
cross_step(db, p, &reads, &order).unwrap_or_else(|error| Step::failed(&error))
@@ -299,6 +301,13 @@ pub fn context(
let id = s(included, "id");
let full = read.snapshot.memories.iter().find(|m| s(m, "id") == id)?;
let mut record = full.clone();
+ // A memory the project's read lifted through a link to
+ // code keeps how it came (`via`, `link`).
+ for key in ["via", "link"] {
+ if let Some(value) = included.get(key) {
+ record[key] = value.clone();
+ }
+ }
record["repository_id"] = json!(read.id());
record["project"] = json!(read.name());
Some(json!({"identity":format!("{}:memory:{id}", read.id()),"kind":"memory","memory":record}))
@@ -365,7 +374,12 @@ pub fn context(
let mut window = evidence::from_range(document, a, b)?;
// The code arm's and the step's facts, and the document links each
// project's read followed.
- for key in [code_graph_arm::ARM, crate::doc_links::ARM, FACTS] {
+ for key in [
+ code_graph_arm::ARM,
+ crate::doc_links::ARM,
+ crate::symbol_links::ARM,
+ FACTS,
+ ] {
if let Some(facts) = source.get(key) {
window[key] = facts.clone();
}
@@ -386,6 +400,7 @@ pub fn context(
packet["arms"] = arms(&reads, &packet, &step);
packet[code_graph_arm::ARM] = code_graph(&searched, &evidence);
packet[crate::doc_links::ARM] = doc_links(&reads, &evidence);
+ packet[crate::symbol_links::ARM] = symbol_links(&reads, &evidence, &packet);
// Each project of the scope in its order: searched, or left out with
// the error that stopped its read.
let mut projects: Vec<(usize, Value)> = reads
@@ -419,17 +434,34 @@ pub fn context(
"workspace".into(),
json!({"projects_searched":reads.len(),"cross_edges_used":edges_used.len()}),
);
- // Links used, by the windows this packet holds, as `query::context_on`
- // counts one project's (document links are the only
- // links windows carry).
+ fields.insert("switches".into(), switches);
+ // Links used, by what this packet holds, as `query::context_on`
+ // counts one project's: the windows a document link reached, and
+ // the memories and windows a link to code symbols reached.
let mut rungs: BTreeMap<String, u64> = BTreeMap::new();
+ let mut documents = 0u64;
+ let mut memory = 0u64;
for window in &evidence {
if let Some(facts) = window.get(crate::doc_links::ARM) {
+ documents += 1;
+ *rungs.entry(s(facts, "rung").to_string()).or_default() += 1;
+ }
+ if let Some(facts) = window.get(crate::symbol_links::ARM) {
+ memory += 1;
*rungs.entry(s(facts, "rung").to_string()).or_default() += 1;
}
}
+ for included in packet["memories"].as_array().into_iter().flatten() {
+ if included["via"] == "link" {
+ memory += 1;
+ *rungs
+ .entry(s(&included["link"], "rung").to_string())
+ .or_default() += 1;
+ }
+ }
if let Some(used) = fields.get_mut("links_used").and_then(Value::as_object_mut) {
- used.insert("document".into(), json!(rungs.values().sum::<u64>()));
+ used.insert("document".into(), json!(documents));
+ used.insert("memory".into(), json!(memory));
used.insert("by_rung".into(), json!(rungs));
}
}
@@ -600,6 +632,52 @@ fn doc_links(reads: &[Read], evidence: &[Value]) -> Value {
report
}
+/// The workspace packet's `symbol_links`: the searched projects' own
+/// reports merged (counts add up), `followed` when one followed links and
+/// none failed (else `counted`, `disabled` or `not_requested` as they all
+/// say), with what this packet kept: the windows that carry link facts
+/// (`cited`) and the memories lifted through a link (`memories_included`).
+fn symbol_links(reads: &[Read], evidence: &[Value], packet: &Value) -> Value {
+ let reports: Vec<&Value> = reads
+ .iter()
+ .map(|read| &read.packet[crate::symbol_links::ARM])
+ .collect();
+ let mut report = merge(&reports);
+ let statuses: Vec<&str> = reports
+ .iter()
+ .map(|report| report["status"].as_str().unwrap_or(""))
+ .collect();
+ let status = if statuses.contains(&"error") {
+ "error"
+ } else if statuses.contains(&"followed") {
+ "followed"
+ } else if statuses.contains(&"counted") {
+ "counted"
+ } else if !statuses.is_empty() && statuses.iter().all(|status| *status == "disabled") {
+ "disabled"
+ } else {
+ "not_requested"
+ };
+ report["status"] = json!(status);
+ if report.get("considered").is_some() {
+ report["cited"] = json!(
+ evidence
+ .iter()
+ .filter(|w| w.get(crate::symbol_links::ARM).is_some())
+ .count()
+ );
+ report["memories_included"] = json!(
+ packet["memories"]
+ .as_array()
+ .into_iter()
+ .flatten()
+ .filter(|m| m["via"] == "link")
+ .count()
+ );
+ }
+ report
+}
+
/// The workspace packet's `code_graph`: `fused` when every project's arm
/// read its graph (`fused` or `no_match`) and one fused, `no_match` or
/// `disabled` when all did so, else `mixed`; the largest `episode_lag`
diff --git a/crates/graphicle/src/workspace_map.rs b/crates/graphicle/src/workspace_map.rs
new file mode 100644
index 0000000..00f7c8c
--- /dev/null
+++ b/crates/graphicle/src/workspace_map.rs
@@ -0,0 +1,216 @@
+//! The workspace map (`graph.map`; MCP `workspace_map` on workspace
+//! connections): the projects of a workspace that the caller may read, the
+//! import edges `graph.link` recorded between them, and what each project
+//! holds.
+//!
+//! - **Projects** are the ones `list_projects` lists, in its order (creation
+//! order), without PR scratch projects unless `include_scratch`: `limit` of
+//! them ([`PAGE`] by default, at most [`MAX_PAGE`]: a page reads each of
+//! its projects' documents, as many as one workspace recall reads) from
+//! `offset`. Each is
+//! authorized exactly as a single-project read of it is (`store::repo`). A
+//! project the caller may not read is not listed, and no edge or count
+//! includes it.
+//! - **Counts per project** are what the caller's own single-project reads
+//! of it show: its files and the connector documents the caller may read
+//! now (`memory::documents`, as `repository_files` and recall read them),
+//! the code symbols of its projected graph (`gf_symbol_heads`, with the
+//! file set they were projected from and whether that is the current one),
+//! the memories `project_memory` lists, and its links: import edges out of
+//! it and into it (both ends in the map), its documents' mentions linked to
+//! code as `graph.doc_links` counts them for the caller, and the code
+//! symbols its listed memories are anchored to.
+//! - **Imports**: one entry per pair of projects in which a project of the
+//! page imports from another project of the map (the edges' source is on
+//! the page), with the number of live edges and the modules they import,
+//! read through the permission-filtered reader that `graph.cross_edges`
+//! and workspace recall share ([`graph_projection::live_cross_edges`]).
+//! Paging through the map lists each pair once.
+//! - **A project whose counts cannot be read** is listed with
+//! `status: "error"` and no counts, as workspace recall reports a project
+//! whose read fails; the other projects are mapped.
+//!
+//! Read-only: everything runs in the caller's read-only snapshot.
+use crate::{
+ Error, Result, doc_links, graph_projection,
+ graph_projection::CrossDirection,
+ integer, memory,
+ store::{Principal, Store, one, repo, rows, s},
+ symbols,
+};
+use rusqlite::Connection;
+use serde_json::{Value, json};
+use std::collections::{BTreeMap, BTreeSet};
+
+/// Projects one page of the map holds by default: as many as one workspace
+/// recall searches by default ([`crate::workspace::FANOUT`]), since mapping
+/// a project reads its documents as recalling from it does.
+pub const PAGE: usize = crate::workspace::FANOUT;
+/// The most one page may hold (`limit`): the most one workspace recall may
+/// search ([`crate::workspace::MAX_FANOUT`]).
+pub const MAX_PAGE: usize = crate::workspace::MAX_FANOUT;
+/// Modules one import entry names, at most (`modules_total` counts them all).
+pub const MODULES: usize = 20;
+
+impl Store {
+ /// `graph.map` (see the module comment).
+ pub fn workspace_map(&self, workspace: &str, token: &str, args: &Value) -> Result<Value> {
+ if args
+ .get("include_scratch")
+ .is_some_and(|v| !v.is_null() && !v.is_boolean())
+ {
+ return Err(Error::bad("include_scratch must be true or false"));
+ }
+ let include_scratch = args["include_scratch"] == true;
+ let offset = integer(args, "offset", 0, 100000)?;
+ let limit = integer(args, "limit", PAGE, MAX_PAGE)?.max(1);
+ self.authorized_read(workspace, token, "read", |db, p| {
+ map(db, p, include_scratch, offset, limit)
+ })
+ }
+}
+
+/// The live import edges from one project of the map to another, by pair.
+#[derive(Default)]
+struct Pair {
+ edges: usize,
+ modules: BTreeSet<String>,
+}
+
+fn map(
+ db: &Connection,
+ p: &Principal,
+ include_scratch: bool,
+ offset: usize,
+ limit: usize,
+) -> Result<Value> {
+ let scratch = graph_projection::pr_scratch_projects(db, &p.workspace)?;
+ // The map's projects, each authorized as a direct read of it is.
+ let mut listed: Vec<Value> = Vec::new();
+ for row in rows(
+ db,
+ "SELECT id FROM repo_projects WHERE workspace_id=? ORDER BY created_at,id",
+ [&p.workspace],
+ )? {
+ let id = s(&row, "id");
+ if (scratch.contains(id) && !include_scratch)
+ || !graph_projection::repo_readable(db, p, id)?
+ {
+ continue;
+ }
+ listed.push(repo(db, p, id)?);
+ }
+ let members: BTreeSet<&str> = listed.iter().map(|row| s(row, "id")).collect();
+ let page: BTreeSet<&str> = listed
+ .iter()
+ .skip(offset)
+ .take(limit)
+ .map(|row| s(row, "id"))
+ .collect();
+ // Every live import edge between two projects of the map: the counts of
+ // each end, and the pairs whose source is on the page.
+ let mut pairs: BTreeMap<(&str, String), Pair> = BTreeMap::new();
+ let mut outgoing: BTreeMap<&str, usize> = BTreeMap::new();
+ let mut incoming: BTreeMap<String, usize> = BTreeMap::new();
+ let mut edges = 0usize;
+ for &source in &members {
+ for edge in graph_projection::live_cross_edges(db, p, source, CrossDirection::Outgoing)? {
+ let target = s(&edge, "target_repository_id");
+ if target == source || !members.contains(target) {
+ continue;
+ }
+ edges += 1;
+ *outgoing.entry(source).or_default() += 1;
+ *incoming.entry(target.to_string()).or_default() += 1;
+ if page.contains(source) {
+ let pair = pairs.entry((source, target.to_string())).or_default();
+ pair.edges += 1;
+ let module = s(&edge, "module_path");
+ if !module.is_empty() {
+ pair.modules.insert(module.to_string());
+ }
+ }
+ }
+ }
+ let mut projects = Vec::new();
+ for repository in listed.iter().skip(offset).take(limit) {
+ let id = s(repository, "id");
+ let mut project = json!({"id":id,"name":repository["name"],"snapshot":repository["snapshot"],
+ "created_at":repository["created_at"],"updated_at":repository["updated_at"]});
+ if scratch.contains(id) {
+ project["role"] = json!(graph_projection::PR_SCRATCH);
+ if let Some(of) = crate::folders::scratch_of(db, id)? {
+ project["scratch_of"] = json!(of);
+ }
+ }
+ match counts(db, p, repository) {
+ Ok(mut counts) => {
+ counts["links"]["imports_out"] = json!(outgoing.get(id).copied().unwrap_or(0));
+ counts["links"]["imports_in"] = json!(incoming.get(id).copied().unwrap_or(0));
+ project["graph"] = graph(db, id)?;
+ project["counts"] = counts;
+ project["status"] = json!("ok");
+ }
+ Err(error) => {
+ project["status"] = json!("error");
+ project["error"] = json!(error.message);
+ }
+ }
+ projects.push(project);
+ }
+ let imports: Vec<Value> = pairs
+ .into_iter()
+ .map(|((source, target), pair)| {
+ json!({"source_repository_id":source,"target_repository_id":target,"edges":pair.edges,
+ "modules":pair.modules.iter().take(MODULES).collect::<Vec<_>>(),
+ "modules_total":pair.modules.len()})
+ })
+ .collect();
+ let total = listed.len();
+ Ok(
+ json!({"workspace_id":p.workspace,"projects":projects,"imports":imports,
+ "import_edges":edges,"total":total,
+ "next_offset":if offset + limit < total { Some(offset + limit) } else { None }}),
+ )
+}
+
+/// The file set the project's symbols were projected from, and whether it is
+/// the project's current one (otherwise its graph waits for a projection).
+fn graph(db: &Connection, id: &str) -> Result<Value> {
+ Ok(match symbols::table_episode(db, id)? {
+ Some(episode) => {
+ let current = episode == graph_projection::current_episode(db, id)?;
+ json!({"episode":episode,"current":current})
+ }
+ None => json!({"episode":null,"current":false}),
+ })
+}
+
+/// What one project holds, as the caller's own reads of it show (see the
+/// module comment); the import counts are added by the caller.
+fn counts(db: &Connection, p: &Principal, repository: &Value) -> Result<Value> {
+ let id = s(repository, "id");
+ let documents = memory::documents(db, repository, p)?;
+ let files = documents
+ .iter()
+ .filter(|d| d["source_kind"] == "repository_file")
+ .count();
+ let memories = memory::list_of(db, repository, &documents, false)?;
+ let memory_symbols: u64 = memories
+ .iter()
+ .map(|m| m["symbol_links"]["links"].as_u64().unwrap_or(0))
+ .sum();
+ let symbols = one(
+ db,
+ "SELECT COUNT(*) AS n FROM gf_symbol_heads WHERE repository_id=?",
+ [id],
+ )?
+ .and_then(|row| row["n"].as_u64())
+ .unwrap_or(0);
+ let mentions = doc_links::linked_mentions(db, p, id, &documents)?;
+ Ok(
+ json!({"files":files,"documents":documents.len() - files,"symbols":symbols,
+ "memories":memories.len(),
+ "links":{"document_mentions":mentions,"memory_symbols":memory_symbols}}),
+ )
+}
diff --git a/crates/graphicle/tests/extension.rs b/crates/graphicle/tests/extension.rs
index 41a176a..1204565 100644
--- a/crates/graphicle/tests/extension.rs
+++ b/crates/graphicle/tests/extension.rs
@@ -4,20 +4,22 @@
use axum::{
Json, Router,
body::{Body, to_bytes},
- extract::State,
- http::{Request, StatusCode, header},
- routing::get,
+ extract::{Path, State},
+ http::{HeaderMap, Request, StatusCode, header},
+ routing::{get, post},
};
use graphicle_runtime::{
Error, Result,
api::{self, App},
connectors::Remote,
extension::{
- self, BoxFuture, CliContext, Edition, Extension, Extensions, JobKind, McpTool, ServeContext,
+ self, Access, AccessRequest, BoxFuture, CliContext, Edition, Extension, Extensions,
+ JobKind, McpTool, ServeContext, Source,
},
jobs::{Job, Worker},
+ metering::Served,
model,
- store::{Store, one, s},
+ store::{Principal, Store, one, s},
};
use rusqlite::{Connection, OptionalExtension};
use serde_json::{Map, Value, json};
@@ -104,12 +106,18 @@ impl Extension for Probe {
}))
}
fn routes(&self) -> Router<App> {
- Router::new().route(
- "/probe",
- get(|State(app): State<App>| async move {
- Json(json!({"probe":true,"hosted":app.public_origin.is_some()}))
- }),
- )
+ Router::new()
+ .route(
+ "/probe",
+ get(|State(app): State<App>| async move {
+ Json(json!({"probe":true,"hosted":app.public_origin.is_some()}))
+ }),
+ )
+ .route("/probe/form", post(session_seen))
+ .route("/probe/other", post(session_seen))
+ }
+ fn cross_site_post(&self, path: &str) -> bool {
+ path == "/probe/form"
}
fn mcp_tools(&self, _learning: bool, _work_state: bool) -> Vec<McpTool> {
vec![McpTool::new(
@@ -158,6 +166,100 @@ impl Extension for Probe {
.optional()?;
Ok(label.as_deref() != Some("blocked"))
}
+ fn role_permits(
+ &self,
+ _db: &Connection,
+ _workspace: &str,
+ role: &str,
+ permission: &str,
+ ) -> Result<Option<bool>> {
+ Ok(match role {
+ "probe-role" => Some(["read", "propose"].contains(&permission)),
+ // An attempt to widen a Core role: the core never asks.
+ "reader" => Some(true),
+ _ => None,
+ })
+ }
+ /// Credentials labelled `guarded…` are recorded and restricted: no
+ /// `collect`, no repository whose key is `hidden`, no episodes route, no
+ /// `graph.stats`, `graph.navigate` or `graph.pull_requests`, no
+ /// `repository_status` tool; `probe.echo` runs with
+ /// narrowed arguments, and responses of `guarded-capped` are limited.
+ /// Credentials labelled `metered` get a per-call cap of 5 tokens for
+ /// `probe.echo` and `work_state.write`, and a large one otherwise.
+ fn authorize(
+ &self,
+ db: &Connection,
+ principal: &Principal,
+ request: &mut AccessRequest<'_>,
+ ) -> Result<()> {
+ if principal.role == "owner" {
+ record("access:owner".into());
+ }
+ let label: Option<String> = db
+ .query_row(
+ "SELECT label FROM credentials WHERE id=?",
+ [&principal.credential],
+ |r| r.get(0),
+ )
+ .optional()?;
+ if label.as_deref() == Some("metered") {
+ if let Access::Operation(operation) = request.access {
+ request.max_tokens = Some(match operation {
+ "probe.echo" | "work_state.write" => 5,
+ _ => 1_000_000,
+ });
+ }
+ return Ok(());
+ }
+ let Some(label) = label.filter(|label| label.starts_with("guarded")) else {
+ return Ok(());
+ };
+ record(format!("access:{label}:{:?}", request.access));
+ let refuse = |what: &str| -> Result<()> {
+ Err(Error {
+ status: StatusCode::FORBIDDEN,
+ message: format!("probe refuses {what}"),
+ provider_failure: None,
+ })
+ };
+ match request.access {
+ Access::Permission("collect") => return refuse("collect"),
+ Access::Repository(repository) => {
+ let key: Option<String> = db
+ .query_row(
+ "SELECT project_key FROM repo_projects WHERE id=?",
+ [repository],
+ |r| r.get(0),
+ )
+ .optional()?;
+ if key.as_deref() == Some("hidden") {
+ return refuse("the hidden repository");
+ }
+ }
+ Access::Route { pattern, .. } if pattern.ends_with("/graph/episodes") => {
+ return refuse("the episodes route");
+ }
+ Access::Operation("graph.stats") => return refuse("graph.stats"),
+ Access::Operation(operation @ ("graph.navigate" | "graph.pull_requests")) => {
+ return refuse(operation);
+ }
+ Access::Operation("probe.echo") => {
+ if let Some(arguments) = request.arguments.as_mut() {
+ arguments.to_mut()["narrowed"] = json!(true);
+ }
+ }
+ Access::Tool {
+ name: "repository_status",
+ ..
+ } => return refuse("repository_status"),
+ _ => {}
+ }
+ if label == "guarded-capped" {
+ request.max_tokens = Some(120);
+ }
+ Ok(())
+ }
fn credential_revoked(&self, db: &Connection, workspace: &str, credential: &str) -> Result<()> {
// Inside the revoking transaction: the credential is already revoked.
let revoked: bool = db.query_row(
@@ -175,10 +277,57 @@ impl Extension for Probe {
usage["probe"] = json!("usage");
Ok(())
}
+ fn served_allowed(
+ &self,
+ db: &Connection,
+ principal: &Principal,
+ served: &Served<'_>,
+ ) -> Result<()> {
+ // Only for credentials labelled "metered", so other tests are untouched.
+ let label: Option<String> = db
+ .query_row(
+ "SELECT label FROM credentials WHERE id=?",
+ [&principal.credential],
+ |r| r.get(0),
+ )
+ .optional()?;
+ if label.as_deref() != Some("metered") {
+ return Ok(());
+ }
+ record(format!(
+ "served:{}:{}:{}:{}:{}",
+ principal.credential,
+ served.channel.as_str(),
+ served.kind,
+ served.session,
+ served.repository
+ ));
+ match served.kind {
+ "repository_files" | "files" | "graph.cross_edges" => Err(Error {
+ status: StatusCode::TOO_MANY_REQUESTS,
+ message: format!("probe refuses {}", served.kind),
+ provider_failure: None,
+ }),
+ _ => Ok(()),
+ }
+ }
+ fn metered_operations(&self) -> &'static [&'static str] {
+ &["probe.async"]
+ }
fn scrub_backup(&self, db: &Connection) -> Result<()> {
db.execute("DELETE FROM probe_rows", [])?;
Ok(())
}
+ fn vault_key(&self, store: &Store) -> Option<Result<[u8; 32]>> {
+ // Only the stores a test marks keep their vault key in the probe.
+ if store.directory.join("probe-vault-key").exists() {
+ Some(Ok([7; 32]))
+ } else if store.directory.join("probe-vault-down").exists() {
+ Some(Err(Error::bad("Probe key service unavailable")))
+ } else {
+ None
+ }
+ }
fn job_kinds(&self) -> &'static [JobKind] {
const KINDS: &[JobKind] = &[
JobKind::new("probe", "read", true),
@@ -247,6 +396,9 @@ impl Extension for Probe {
Ok(permissions)
}))
}
+ fn sources(&self) -> &'static [&'static dyn Source] {
+ PROBE_SOURCES
+ }
fn serve(&self, context: &mut ServeContext<'_>) -> Result<()> {
let store = context.store.clone();
context.background.push(Box::pin(async move {
@@ -297,6 +449,69 @@ impl Extension for Probe {
}
}
+/// Whether the boundary mapped a browser session into the request.
+async fn session_seen(headers: HeaderMap) -> Json<Value> {
+ Json(json!({"session":headers.contains_key("x-graphicle-browser-session")}))
+}
+
+/// A connector kind the probe extension adds: two listing pages of one
+/// document each, read from `docs/{id}`.
+struct ProbeDocs;
+static PROBE_SOURCES: &[&dyn Source] = &[&ProbeDocs];
+impl Source for ProbeDocs {
+ fn kind(&self) -> &'static str {
+ "probe_docs"
+ }
+ fn oauth_provider(&self) -> &'static str {
+ "probe_accounts"
+ }
+ fn oauth_identity(&self, identity: &Value) -> Option<(String, String)> {
+ Some((identity["sub"].as_str()?.to_string(), String::new()))
+ }
+ fn fields(&self) -> &'static [&'static str] {
+ &["topic"]
+ }
+ fn validate(&self, config: &Value) -> Result<()> {
+ graphicle_runtime::string(config, "topic", 50).map(|_| ())
+ }
+ fn base_url(&self, _config: &Value) -> Result<String> {
+ Ok("https://probe-docs.invalid".into())
+ }
+ fn listing<'a>(
+ &'a self,
+ _remote: &'a mut Remote<'_>,
+ cursor: &'a Value,
+ ) -> BoxFuture<'a, Result<(Vec<Value>, Value)>> {
+ Box::pin(async move {
+ Ok(if cursor.is_null() {
+ (vec![json!({"id":"d1"})], json!({"page":2}))
+ } else {
+ (vec![json!({"id":"d2"})], Value::Null)
+ })
+ })
+ }
+ fn document<'a>(
+ &'a self,
+ remote: &'a mut Remote<'_>,
+ item: &'a Value,
+ ) -> BoxFuture<'a, Result<Option<Value>>> {
+ Box::pin(async move {
+ let id = s(item, "id").to_string();
+ let doc = remote.get(&format!("docs/{id}"), vec![]).await?;
+ Ok(Some(
+ json!({"id":id,"title":doc["title"],"content":doc["text"],
+ "url":null,"source_timestamp":null,"metadata":{}}),
+ ))
+ })
+ }
+ fn probe<'a>(&'a self, remote: &'a mut Remote<'_>) -> BoxFuture<'a, Result<(Value, Value)>> {
+ Box::pin(async move {
+ let who = remote.get("whoami", vec![]).await?;
+ Ok((who, json!({"topic":remote.connector["config"]["topic"]})))
+ })
+ }
+}
+
struct Fixture {
_dir: tempfile::TempDir,
store: Store,
@@ -518,6 +733,92 @@ async fn extension_routes_sit_inside_the_host_boundary() {
assert_eq!(&body[..], b"window.graphicleProbe = true;");
}
+#[tokio::test]
+async fn a_declared_cross_site_form_post_skips_only_the_origin_checks() {
+ let f = Fixture::new();
+ let router = api::router(f.app());
+ let post = |path: &str, host: &str, origin: Option<&str>, cookie: bool| {
+ let mut request = Request::post(path).header(header::HOST, host);
+ if let Some(origin) = origin {
+ request = request.header(header::ORIGIN, origin);
+ }
+ if cookie {
+ request = request.header(header::COOKIE, format!("graphicle_session={SESSION_TOKEN}"));
+ }
+ request.body(Body::empty()).unwrap()
+ };
+ let seen = |reply: axum::response::Response| async move {
+ assert_eq!(reply.status(), StatusCode::OK);
+ assert_eq!(
+ reply.headers()[header::CACHE_CONTROL],
+ "no-store",
+ "boundary headers apply"
+ );
+ let body = to_bytes(reply.into_body(), 4096).await.unwrap();
+ serde_json::from_slice::<Value>(&body).unwrap()["session"].clone()
+ };
+ // The declared path takes a post from another origin, even with a
+ // session cookie and no request header, and is given no session.
+ let reply = router
+ .clone()
+ .oneshot(post(
+ "/probe/form",
+ "localhost",
+ Some("https://idp.example"),
+ true,
+ ))
+ .await
+ .unwrap();
+ assert_eq!(seen(reply).await, false);
+ // Its host check stays.
+ let foreign_host = router
+ .clone()
+ .oneshot(post(
+ "/probe/form",
+ "attacker.example",
+ Some("https://idp.example"),
+ false,
+ ))
+ .await
+ .unwrap();
+ assert_eq!(foreign_host.status(), StatusCode::FORBIDDEN);
+ // A GET to the declared path, and a post to any other path, keep the
+ // origin and browser-mutation checks.
+ let get = Request::get("/probe/form")
+ .header(header::HOST, "localhost")
+ .header(header::ORIGIN, "https://idp.example")
+ .body(Body::empty())
+ .unwrap();
+ assert_eq!(
+ router.clone().oneshot(get).await.unwrap().status(),
+ StatusCode::FORBIDDEN
+ );
+ for (origin, cookie) in [(Some("https://idp.example"), false), (None, true)] {
+ let reply = router
+ .clone()
+ .oneshot(post("/probe/other", "localhost", origin, cookie))
+ .await
+ .unwrap();
+ assert_eq!(reply.status(), StatusCode::FORBIDDEN, "{origin:?} {cookie}");
+ }
+ let same_origin = router
+ .clone()
+ .oneshot(post(
+ "/probe/other",
+ "localhost",
+ Some("http://localhost"),
+ false,
+ ))
+ .await
+ .unwrap();
+ assert_eq!(seen(same_origin).await, false);
+ let mut browser = post("/probe/other", "localhost", None, true);
+ browser
+ .headers_mut()
+ .insert("x-graphicle-request", "1".parse().unwrap());
+ assert_eq!(seen(router.oneshot(browser).await.unwrap()).await, true);
+}
+
#[test]
fn mcp_tools_follow_the_core_tools_and_run_their_operation() {
let f = Fixture::new();
@@ -629,6 +930,200 @@ fn usage_reports_the_extension_allowance_and_details() {
assert_eq!(budget["effective_limit"], 10, "the lowest limit applies");
}
+/// `served_allowed` is asked before every metered call of a credential other
+/// than the owner capability, with the call's channel, tool or operation,
+/// session and project. Its refusal reaches the caller instead of the result
+/// (a 429 with `Retry-After` over HTTP), and a read's result larger than its
+/// per-call cap is refused, not served or counted; a write's result is served.
+/// Over HTTP every operation a published tool runs is metered, and so are
+/// the other text reads (Core's and the extension's `metered_operations`),
+/// through the command routes and the graph routes alike.
+#[tokio::test]
+async fn metered_calls_are_admitted_and_capped_by_the_extension() {
+ let f = Fixture::new();
+ let key = f.grant("metered");
+ let (token, id) = (s(&key, "capability").to_string(), s(&key, "id").to_string());
+ let agent = f
+ .store
+ .grant(
+ &f.workspace,
+ &f.owner,
+ &json!({"label":"metered","role":"agent"}),
+ )
+ .unwrap();
+ let (agent_token, agent_id) = (
+ s(&agent, "capability").to_string(),
+ s(&agent, "id").to_string(),
+ );
+ let mut app = f.app();
+ app.mcp_work_state = true;
+ let tool = |token: &str, name: &str, arguments: Value| {
+ let reply = api::mcp(
+ &app,
+ &f.workspace,
+ token,
+ &f.repo,
+ &json!({"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":name,"arguments":arguments}}),
+ )
+ .unwrap();
+ (
+ reply["result"]["isError"] == true,
+ s(&reply["result"]["content"][0], "text").to_string(),
+ )
+ };
+ let (failed, text) = tool(&token, "repository_status", json!({}));
+ assert!(!failed, "{text}");
+ assert!(recorded(&format!(
+ "served:{id}:mcp:repository_status::{}",
+ f.repo
+ )));
+ let (failed, text) = tool(&token, "repository_files", json!({}));
+ assert!(failed);
+ assert_eq!(text, "probe refuses repository_files");
+ let (failed, text) = tool(&token, "probe_tool", json!({"word":"hello"}));
+ assert!(failed);
+ assert!(
+ text.contains("this credential may receive at most 5 per call"),
+ "{text}"
+ );
+ // A write tool's result is served whatever the cap: it is saved by then.
+ let (failed, text) = tool(
+ &agent_token,
+ "work_state_write",
+ json!({"list":"release","fields":{"status":"doing"}}),
+ );
+ assert!(!failed, "{text}");
+ assert!(graphicle_memory::text::count(&text) > 5, "{text}");
+ assert!(recorded(&format!(
+ "served:{agent_id}:mcp:work_state_write::{}",
+ f.repo
+ )));
+ // The owner capability is never asked.
+ let (failed, text) = tool(&f.owner, "repository_files", json!({}));
+ assert!(!failed, "{text}");
+ // Over HTTP, metered operations are asked with their operation and
+ // channel; the extension's refusal keeps its status.
+ let router = api::router(app.clone());
+ let send = |request: Request<Body>| {
+ let router = router.clone();
+ async move { router.oneshot(request).await.unwrap() }
+ };
+ let post = |token: &str, body: Value| {
+ Request::post(format!(
+ "/api/workspaces/{}/repositories/command",
+ f.workspace
+ ))
+ .header(header::HOST, "localhost")
+ .header(header::CONTENT_TYPE, "application/json")
+ .header("x-workspace-capability", token)
+ .body(Body::from(body.to_string()))
+ .unwrap()
+ };
+ let get = |path: &str| {
+ Request::get(format!(
+ "/api/workspaces/{}/repositories/{}/{path}",
+ f.workspace, f.repo
+ ))
+ .header(header::HOST, "localhost")
+ .header("x-workspace-capability", token.as_str())
+ .body(Body::empty())
+ .unwrap()
+ };
+ // A read a tool runs, a read no tool runs, and the extension's own
+ // metered read are asked.
+ for operation in ["memory.search", "memories", "memory.export", "probe.async"] {
+ let reply = send(post(
+ &token,
+ json!({"operation":operation,"arguments":{"repository_id":f.repo,"question":"probe"}}),
+ ))
+ .await;
+ assert_eq!(reply.status(), StatusCode::OK, "{operation}");
+ assert!(
+ recorded(&format!("served:{id}:http:{operation}::{}", f.repo)),
+ "{operation}"
+ );
+ }
+ // An operation that returns no project text is not metered, nor asked.
+ let reply = send(post(
+ &token,
+ json!({"operation":"observer.status","arguments":{"repository_id":f.repo,"include":["file:"]}}),
+ ))
+ .await;
+ assert_eq!(reply.status(), StatusCode::OK);
+ assert!(!recorded(&format!(
+ "served:{id}:http:observer.status::{}",
+ f.repo
+ )));
+ // A refusal with 429 says when to retry: the next UTC month.
+ let reply = send(post(
+ &token,
+ json!({"operation":"files","arguments":{"repository_id":f.repo}}),
+ ))
+ .await;
+ assert_eq!(reply.status(), StatusCode::TOO_MANY_REQUESTS);
+ let retry: i64 = reply.headers()["retry-after"]
+ .to_str()
+ .unwrap()
+ .parse()
+ .unwrap();
+ assert!((1..=31 * 86_400).contains(&retry), "{retry}");
+ // A write the agent's tool runs is served over HTTP whatever the cap.
+ let reply = send(post(
+ &agent_token,
+ json!({"operation":"work_state.write","arguments":{"repository_id":f.repo,"list":"release","fields":{"owner":"ada"}}}),
+ ))
+ .await;
+ assert_eq!(reply.status(), StatusCode::OK);
+ let body = to_bytes(reply.into_body(), 1 << 20).await.unwrap();
+ assert!(graphicle_memory::text::count(&String::from_utf8_lossy(&body)) > 5);
+ // The graph routes are metered as the operations they serve.
+ let reply = send(get("graph/stats")).await;
+ assert_eq!(reply.status(), StatusCode::OK);
+ assert!(recorded(&format!(
+ "served:{id}:http:graph.stats::{}",
+ f.repo
+ )));
+ let reply = send(get("graph/cross_edges")).await;
+ assert_eq!(reply.status(), StatusCode::TOO_MANY_REQUESTS);
+ assert!(reply.headers().contains_key("retry-after"));
+ // Only what was served is counted (recorded first: a usage report does
+ // not wait for results still being counted).
+ graphicle_runtime::metering::flush(&f.store).unwrap();
+ let usage = f.store.product_usage(&f.workspace, &f.owner).unwrap();
+ let mut kinds: Vec<(String, String, u64)> = usage["served"]["by_kind"]
+ .as_array()
+ .unwrap()
+ .iter()
+ .map(|row| {
+ (
+ s(row, "channel").to_string(),
+ s(row, "kind").to_string(),
+ row["calls"].as_u64().unwrap(),
+ )
+ })
+ .collect();
+ kinds.sort();
+ let expected: Vec<(String, String, u64)> = [
+ ("http", "graph.stats"),
+ ("http", "memories"),
+ ("http", "memory.export"),
+ ("http", "memory.search"),
+ ("http", "probe.async"),
+ ("http", "work_state.write"),
+ ("mcp", "repository_files"),
+ ("mcp", "repository_status"),
+ ("mcp", "work_state_write"),
+ ]
+ .into_iter()
+ .map(|(channel, kind)| (channel.to_string(), kind.to_string(), 1))
+ .collect();
+ assert_eq!(
+ kinds, expected,
+ "the owner's repository_files call and nothing refused"
+ );
+ assert_eq!(usage["cost"], Value::Null);
+}
+
#[test]
fn backups_are_scrubbed_by_the_extension_too() {
let f = Fixture::new();
@@ -647,6 +1142,61 @@ fn backups_are_scrubbed_by_the_extension_too() {
assert_eq!(count(&f.store.connect().unwrap()), 1);
}
+/// The vault seals with the key of the extension that holds a store's,
+/// never with a device key the core makes beside it; a store the extension
+/// does not hold keeps the device key file, as in Core.
+#[test]
+fn the_vault_key_comes_from_the_extension_that_holds_it() {
+ let f = Fixture::new();
+ let directory = f.store.directory.to_path_buf();
+ let device = directory.join("vault.key");
+ let plain = f
+ .store
+ .save_secret(&f.workspace, "plain", "device-sealed")
+ .unwrap();
+ assert_eq!(
+ f.store.secret(&f.workspace, &plain).unwrap(),
+ "device-sealed"
+ );
+ assert_eq!(std::fs::metadata(&device).unwrap().len(), 32);
+
+ std::fs::remove_file(&device).unwrap();
+ std::fs::write(directory.join("probe-vault-key"), b"").unwrap();
+ let held = f
+ .store
+ .save_secret(&f.workspace, "held", "probe-sealed")
+ .unwrap();
+ assert_eq!(f.store.secret(&f.workspace, &held).unwrap(), "probe-sealed");
+ assert!(!device.exists(), "no device key is made for a held store");
+ // It was sealed with the probe's key: a device key does not open it.
+ std::fs::remove_file(directory.join("probe-vault-key")).unwrap();
+ let error = f.store.secret(&f.workspace, &held).unwrap_err();
+ assert_eq!(error.message, "Credential integrity check failed");
+
+ // An unavailable key fails the operation, with no fallback.
+ std::fs::remove_file(&device).unwrap();
+ std::fs::write(directory.join("probe-vault-down"), b"").unwrap();
+ let error = f
+ .store
+ .save_secret(&f.workspace, "down", "never-sealed")
+ .unwrap_err();
+ assert_eq!(error.message, "Probe key service unavailable");
+ assert!(!device.exists(), "no device key is made as a fallback");
+ std::fs::remove_file(directory.join("probe-vault-down")).unwrap();
+
+ // A vault.key that holds no key fails closed and is left alone: what a
+ // program without the extension meets on a store whose key it holds.
+ std::fs::write(&device, b"held by an extension").unwrap();
+ let error = f.store.secret(&f.workspace, &plain).unwrap_err();
+ assert_eq!(error.message, "Invalid local vault key");
+ let error = f
+ .store
+ .save_secret(&f.workspace, "new", "value")
+ .unwrap_err();
+ assert_eq!(error.message, "Invalid local vault key");
+ assert_eq!(std::fs::read(&device).unwrap(), b"held by an extension");
+}
+
#[tokio::test]
async fn job_kinds_the_core_does_not_run_go_to_the_extension() {
let f = Fixture::new();
@@ -917,6 +1467,119 @@ async fn provider_permissions_of_a_sync_come_from_the_extension() {
server.abort();
}
+/// A connector kind an extension adds is configured, probed, synced, shared
+/// and connected through OAuth by the core like its own kinds.
+#[tokio::test]
+async fn connector_kinds_an_extension_adds_run_through_the_core() {
+ let f = Fixture::new();
+ let credential = f
+ .store
+ .put_credential(
+ &f.workspace,
+ &f.owner,
+ &json!({"name":"Probe token","value":"fixture-only-access"}),
+ )
+ .unwrap();
+ let acl = json!({"workspace_readers":true,"credentials":[]});
+ let add = |config: Value| {
+ f.store.connector_add(
+ &f.workspace,
+ &f.owner,
+ &json!({"repository_id":f.repo,"name":"Docs","kind":"probe_docs",
+ "credential_ref":credential["credential_ref"],"config":config}),
+ )
+ };
+ assert_eq!(
+ add(json!({"topic":"probes","acl":acl,"other":1}))
+ .unwrap_err()
+ .message,
+ "Unknown connector configuration field"
+ );
+ assert!(
+ add(json!({"acl":acl})).is_err(),
+ "the source checks its fields"
+ );
+ assert!(
+ add(json!({"topic":"probes","acl":acl,"permission_mode":"provider"})).is_err(),
+ "no extension syncs this kind's provider permissions"
+ );
+ let connector = add(json!({"topic":"probes","acl":acl})).unwrap();
+ let listener = tokio::net::TcpListener::bind("127.0.0.1:0").await.unwrap();
+ let base = format!("http://{}", listener.local_addr().unwrap());
+ let router = Router::new()
+ .route(
+ "/docs/{id}",
+ get(|Path(id): Path<String>| async move {
+ Json(json!({"title":format!("Doc {id}"),"text":format!("Probe document {id}.")}))
+ }),
+ )
+ .route(
+ "/whoami",
+ get(|| async { Json(json!({"id":"probe-user"})) }),
+ );
+ let server = tokio::spawn(async move { axum::serve(listener, router).await.unwrap() });
+ let mut config = model::Config::default();
+ config.connector_endpoints.insert("probe_docs".into(), base);
+ let worker = Worker::new(f.store.clone(), config.clone()).unwrap();
+ for kind in ["connector_probe", "connector"] {
+ let job = f
+ .store
+ .enqueue(
+ &f.workspace,
+ &f.owner,
+ &json!({"repository_id":f.repo,"kind":kind,"connector_id":connector["id"]}),
+ &config,
+ )
+ .unwrap();
+ assert!(worker.once().await.unwrap());
+ let status = f
+ .store
+ .job_status(
+ &f.workspace,
+ &f.owner,
+ &json!({"repository_id":f.repo,"job_id":job["id"]}),
+ )
+ .unwrap();
+ assert_eq!(status["state"], "complete", "{status}");
+ if kind == "connector_probe" {
+ assert_eq!(status["result"]["identity"]["id"], "probe-user");
+ assert_eq!(status["result"]["target"]["topic"], "probes");
+ } else {
+ assert_eq!(status["result"]["listed_documents"], 2, "{status}");
+ assert_eq!(status["result"]["complete"], true, "{status}");
+ }
+ }
+ let reader = f.grant("Reader");
+ let titles = f
+ .store
+ .authorized(&f.workspace, s(&reader, "capability"), "read", |db, p| {
+ let repository = graphicle_runtime::store::repo(db, p, &f.repo)?;
+ Ok(graphicle_runtime::memory::documents(db, &repository, p)?
+ .iter()
+ .map(|doc| s(doc, "title").to_string())
+ .collect::<Vec<_>>())
+ })
+ .unwrap();
+ assert_eq!(titles, ["Doc d1", "Doc d2"]);
+ assert_eq!(
+ graphicle_runtime::connectors::identity_provider("probe_docs"),
+ "probe_accounts"
+ );
+ let oauth = |provider: &str| {
+ graphicle_runtime::oauth::configure(
+ &f.store,
+ &f.workspace,
+ &f.owner,
+ &json!({"provider":provider,"config":{"client_id":"probe",
+ "authorization_url":"https://login.invalid/authorize","token_url":"https://login.invalid/token",
+ "identity_url":"https://login.invalid/me","scopes":["read"],"pkce":true}}),
+ )
+ };
+ oauth("probe_accounts").unwrap();
+ assert!(oauth("unknown_accounts").is_err());
+ server.abort();
+}
+
fn args(items: &[&std::ffi::OsStr]) -> Vec<OsString> {
items.iter().map(|item| item.to_os_string()).collect()
}
@@ -972,3 +1635,339 @@ async fn serve_prepares_extensions_and_runs_their_background_tasks() {
}
assert!(recorded("serve:loopback"));
}
+
+#[test]
+fn a_role_an_extension_defines_grants_only_what_it_says() {
+ let f = Fixture::new();
+ // `Store::grant` accepts a role an installed extension defines, and
+ // nothing else beyond the core's roles.
+ let probe = f
+ .store
+ .grant(
+ &f.workspace,
+ &f.owner,
+ &json!({"label":"probe role","role":"probe-role"}),
+ )
+ .unwrap();
+ assert_eq!(probe["role"], "probe-role");
+ let error = f
+ .store
+ .grant(
+ &f.workspace,
+ &f.owner,
+ &json!({"label":"nobody's","role":"undefined-role"}),
+ )
+ .unwrap_err();
+ assert_eq!(error.message, "Invalid credential role");
+ let capability = s(&probe, "capability");
+ let allowed = |token: &str, permission: &str| {
+ f.store
+ .authorized(&f.workspace, token, permission, |_, _| Ok(()))
+ .is_ok()
+ };
+ assert!(allowed(capability, "read"));
+ assert!(allowed(capability, "propose"));
+ assert!(!allowed(capability, "collect"));
+ assert!(!allowed(capability, "admin"));
+ // The core's roles keep their meaning: the probe's answer for `reader`
+ // is never asked.
+ let reader = f.grant("plain reader");
+ assert!(allowed(s(&reader, "capability"), "read"));
+ assert!(!allowed(s(&reader, "capability"), "propose"));
+ // A role no one defines is denied everything.
+ f.store
+ .connect()
+ .unwrap()
+ .execute(
+ "UPDATE credentials SET role='undefined-role' WHERE id=?",
+ [s(&probe, "id")],
+ )
+ .unwrap();
+ assert!(!allowed(capability, "read"));
+}
+
+/// A credential the store requires a capability for is usable where an
+/// installed extension sets the capability, and refused where none does,
+/// whatever its role grants; the owner capability is never refused.
+#[test]
+fn a_credential_the_store_requires_a_capability_for_needs_it() {
+ let f = Fixture::new();
+ let restricted = f.grant("restricted");
+ let token = s(&restricted, "capability");
+ let allowed = |token: &str| {
+ f.store
+ .authorized(&f.workspace, token, "read", |_, _| Ok(()))
+ .is_ok()
+ };
+ let db = f.store.connect().unwrap();
+ db.execute_batch("CREATE TABLE credential_requirements(credential_id TEXT, capability TEXT)")
+ .unwrap();
+ db.execute(
+ "INSERT INTO credential_requirements VALUES(?,'probe')",
+ [s(&restricted, "id")],
+ )
+ .unwrap();
+ assert_eq!(
+ graphicle_runtime::store::required_capabilities(&db, s(&restricted, "id")).unwrap(),
+ ["probe"]
+ );
+ assert!(allowed(token), "the probe sets the capability");
+ db.execute(
+ "INSERT INTO credential_requirements VALUES(?,'absent_capability')",
+ [s(&restricted, "id")],
+ )
+ .unwrap();
+ assert!(!allowed(token), "no installed extension sets it");
+ assert!(allowed(s(&f.grant("unrestricted"), "capability")));
+ assert!(allowed(&f.owner));
+}
+
+/// A credential of the probe's that `authorize` restricts, with `role`.
+fn guarded(f: &Fixture, label: &str, role: &str) -> String {
+ let credential = f
+ .store
+ .grant(&f.workspace, &f.owner, &json!({"label":label,"role":role}))
+ .unwrap();
+ s(&credential, "capability").to_string()
+}
+
+async fn send(router: &axum::Router, request: Request<Body>) -> (StatusCode, Value) {
+ let reply = router.clone().oneshot(request).await.unwrap();
+ let status = reply.status();
+ let body = to_bytes(reply.into_body(), 1 << 20).await.unwrap();
+ (status, serde_json::from_slice(&body).unwrap_or(Value::Null))
+}
+
+#[tokio::test]
+async fn authorize_is_asked_wherever_a_credential_is_authorized() {
+ let f = Fixture::new();
+ let app = f.app();
+ let token = guarded(&f, "guarded", "reviewer");
+ let hidden = f
+ .store
+ .register(
+ &f.workspace,
+ &f.owner,
+ &json!({"project_key":"hidden","name":"Hidden"}),
+ )
+ .unwrap();
+ // Every authorization: a permission the role grants can be refused.
+ let collect = f
+ .store
+ .authorized(&f.workspace, &token, "collect", |_, _| Ok(()))
+ .unwrap_err();
+ assert_eq!(collect.message, "probe refuses collect");
+ assert!(recorded("access:guarded:Permission(\"collect\")"));
+ // Every repository opened or listed.
+ let listed = f.store.projects(&f.workspace, &token).unwrap();
+ let ids: Vec<&str> = listed
+ .as_array()
+ .unwrap()
+ .iter()
+ .map(|p| s(p, "id"))
+ .collect();
+ assert_eq!(ids, [f.repo.as_str()]);
+ let owner_listed = f.store.projects(&f.workspace, &f.owner).unwrap();
+ assert_eq!(owner_listed.as_array().unwrap().len(), 2);
+ assert!(
+ api::command(
+ &app,
+ &f.workspace,
+ &token,
+ "status",
+ &json!({"repository_id":hidden["id"]})
+ )
+ .is_err()
+ );
+ // Every operation, on the synchronous and the async path.
+ let args = json!({"repository_id":f.repo});
+ let stats = api::command(&app, &f.workspace, &token, "graph.stats", &args).unwrap_err();
+ assert_eq!(stats.message, "probe refuses graph.stats");
+ let stats = api::command_async(&app, &f.workspace, &token, "graph.stats", &args)
+ .await
+ .unwrap_err();
+ assert_eq!(stats.message, "probe refuses graph.stats");
+ api::command(&app, &f.workspace, &f.owner, "graph.stats", &args).unwrap();
+ // Narrowed arguments reach the operation.
+ let echo = api::command(&app, &f.workspace, &token, "probe.echo", &args).unwrap();
+ assert_eq!(echo["args"]["narrowed"], true, "{echo}");
+ let echo = api::command(&app, &f.workspace, &f.owner, "probe.echo", &args).unwrap();
+ assert!(echo["args"].get("narrowed").is_none(), "{echo}");
+ // Every MCP tool listed or called.
+ let mcp = |token: &str, method: &str, params: Value| {
+ api::mcp(
+ &app,
+ &f.workspace,
+ token,
+ &f.repo,
+ &json!({"jsonrpc":"2.0","id":1,"method":method,"params":params}),
+ )
+ .unwrap()
+ };
+ let names = |reply: Value| -> Vec<String> {
+ reply["result"]["tools"]
+ .as_array()
+ .unwrap()
+ .iter()
+ .map(|t| s(t, "name").to_string())
+ .collect()
+ };
+ let listed = names(mcp(&token, "tools/list", json!({})));
+ assert!(!listed.iter().any(|n| n == "repository_status"));
+ assert!(listed.iter().any(|n| n == "recall_project"));
+ assert!(
+ names(mcp(&f.owner, "tools/list", json!({})))
+ .iter()
+ .any(|n| n == "repository_status")
+ );
+ let refused = mcp(
+ &token,
+ "tools/call",
+ json!({"name":"repository_status","arguments":{}}),
+ );
+ assert_eq!(
+ refused["error"]["message"], "probe refuses repository_status",
+ "{refused}"
+ );
+ let stats = mcp(
+ &token,
+ "tools/call",
+ json!({"name":"graph_history_stats","arguments":{}}),
+ );
+ assert_eq!(stats["result"]["isError"], true, "{stats}");
+ assert_eq!(
+ stats["result"]["content"][0]["text"], "probe refuses graph.stats",
+ "{stats}"
+ );
+ assert!(recorded(
+ "access:guarded:Tool { name: \"graph_history_stats\", writes: false }"
+ ));
+ // Resource reads are admitted as the navigation tools' operation.
+ let resource = mcp(
+ &token,
+ "resources/read",
+ json!({"uri":"graphicle-graph://stats"}),
+ );
+ assert_eq!(
+ resource["error"]["message"], "probe refuses graph.navigate",
+ "{resource}"
+ );
+ // The pull-request tools, which run no `api::command` operation, are
+ // admitted as theirs.
+ let mut pull_requests = app.clone();
+ pull_requests.mcp.pull_requests = true;
+ let prs = api::mcp(
+ &pull_requests,
+ &f.workspace,
+ &token,
+ &f.repo,
+ &json!({"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"list_prs","arguments":{}}}),
+ )
+ .unwrap();
+ assert_eq!(
+ prs["result"]["content"][0]["text"], "probe refuses graph.pull_requests",
+ "{prs}"
+ );
+ // A workspace connection lists only the allowed tools too.
+ let workspace_tools = names(
+ api::mcp_workspace(
+ &app,
+ &f.workspace,
+ &token,
+ &json!({"jsonrpc":"2.0","id":1,"method":"tools/list","params":{}}),
+ )
+ .unwrap(),
+ );
+ assert!(workspace_tools.iter().any(|n| n == "recall_project"));
+ assert!(!workspace_tools.iter().any(|n| n == "repository_status"));
+ // Every route that names a workspace, before its handler.
+ let router = api::router(app.clone());
+ let get = |path: String, token: &str| {
+ Request::get(path)
+ .header(header::HOST, "localhost")
+ .header("x-workspace-capability", token)
+ .body(Body::empty())
+ .unwrap()
+ };
+ let episodes = format!(
+ "/api/workspaces/{}/repositories/{}/graph/episodes",
+ f.workspace, f.repo
+ );
+ let (status, body) = send(&router, get(episodes.clone(), &token)).await;
+ assert_eq!(status, StatusCode::FORBIDDEN);
+ assert_eq!(body["error"], "probe refuses the episodes route");
+ assert_eq!(
+ send(&router, get(episodes, &f.owner)).await.0,
+ StatusCode::OK
+ );
+ let (status, _) = send(
+ &router,
+ get(format!("/api/workspaces/{}", f.workspace), &token),
+ )
+ .await;
+ assert_eq!(status, StatusCode::OK);
+ assert!(recorded(
+ "access:guarded:Route { method: \"GET\", pattern: \"/api/workspaces/{workspace}\" }"
+ ));
+ // The HTTP command endpoint runs the same operation check.
+ let command = Request::post(format!(
+ "/api/workspaces/{}/repositories/command",
+ f.workspace
+ ))
+ .header(header::HOST, "localhost")
+ .header(header::CONTENT_TYPE, "application/json")
+ .header("x-workspace-capability", &token)
+ .body(Body::from(
+ json!({"operation":"graph.stats","arguments":args}).to_string(),
+ ))
+ .unwrap();
+ assert_eq!(send(&router, command).await.0, StatusCode::FORBIDDEN);
+ // The owner capability is never asked about.
+ assert!(!recorded("access:owner"));
+}
+
+#[tokio::test]
+async fn an_extension_may_limit_the_tokens_of_a_response() {
+ let f = Fixture::new();
+ let app = f.app();
+ let token = guarded(&f, "guarded-capped", "reader");
+ let short = json!({"repository_id":f.repo});
+ // Each response holds at most 120 tokens for this credential.
+ api::command(&app, &f.workspace, &token, "probe.echo", &short).unwrap();
+ let long = json!({"repository_id":f.repo,"word":"lorem ipsum dolor sit amet ".repeat(40)});
+ let error = api::command(&app, &f.workspace, &token, "probe.echo", &long).unwrap_err();
+ assert_eq!(error.status, StatusCode::PAYLOAD_TOO_LARGE);
+ assert!(
+ error.message.contains("at most 120 per call"),
+ "{}",
+ error.message
+ );
+ api::command(&app, &f.workspace, &f.owner, "probe.echo", &long).unwrap();
+ // Route responses too.
+ for index in 0..6 {
+ f.store
+ .register(
+ &f.workspace,
+ &f.owner,
+ &json!({"project_key":format!("listed-{index}"),"name":format!("Listed {index}")}),
+ )
+ .unwrap();
+ }
+ let router = api::router(app);
+ let listing = |token: &str| {
+ Request::get(format!("/api/workspaces/{}/repositories", f.workspace))
+ .header(header::HOST, "localhost")
+ .header("x-workspace-capability", token)
+ .body(Body::empty())
+ .unwrap()
+ };
+ let (status, body) = send(&router, listing(&f.owner)).await;
+ assert_eq!(status, StatusCode::OK);
+ assert!(
+ graphicle_memory::text::count(&body.to_string()) > 120,
+ "{body}"
+ );
+ let (status, body) = send(&router, listing(&token)).await;
+ assert_eq!(status, StatusCode::PAYLOAD_TOO_LARGE, "{body}");
+ assert!(s(&body, "error").contains("at most 120 per call"), "{body}");
+}
diff --git a/crates/graphicle/tests/fixtures/one_server_essentials_tools.json b/crates/graphicle/tests/fixtures/one_server_essentials_tools.json
index 5e15343..d40c546 100644
--- a/crates/graphicle/tests/fixtures/one_server_essentials_tools.json
+++ b/crates/graphicle/tests/fixtures/one_server_essentials_tools.json
@@ -1,10 +1,10 @@
{
"server": "graphicle mcp --project . --tools essentials, as graphicle setup writes it for Claude Code (Core)",
- "instructions": "When you do not yet know where the code for a task is, who calls it or why it was written that way, call query_graph (the code graph) or recall_project (code, documents and reviewed memory) with the question before searching files by hand; get_node and get_neighbors show one symbol with its callers and callees, and every answer cites file and lines.",
+ "instructions": "Use recall_project (code, documents and reviewed memory) or query_graph (the code graph) for where or how something works, for questions across files or history, and before changing unfamiliar code; get_node and get_neighbors show one symbol with its callers and callees. For an exact identifier you already know, grep is enough. Every answer cites file and lines.",
"tools": [
{
"name": "recall_project",
- "description": "Search the project's code, documents, captured agent sessions and reviewed memory together for a question: excerpts cited by path, line and source id within a token budget (max_tokens); read_project_source continues any excerpt, and structured: true returns the whole packet, whose code excerpts carry the stable_id the graph tools cite. Memory is evidence, not permission: no tool can approve memory or run commands.",
+ "description": "Search the project's code, documents, captured agent sessions and reviewed memory together for a question: excerpts cited by path, line and source id within a token budget (max_tokens); read_project_source continues any excerpt, and structured: true returns the whole packet, whose code excerpts carry the stable_id the graph tools cite. Memory is evidence, not permission: no tool can approve memory or run commands. An identifier, or a question that only asks where one is defined or used, gets its definitions and references from the code graph as path:line citations. Use it instead of grep when you do not know the exact name, or when the answer spans files, documents or history.",
"inputSchema": {
"type": "object",
"properties": {
@@ -146,7 +146,7 @@
},
{
"name": "query_graph",
- "description": "Find where the code for a question is and how it connects: walks the project's code graph from the functions, classes and files that match the question, with what calls, imports or contains what. The text ends with citations: the code-graph episode read and, for each node it names, its file: path, lines and stable_id (recall_project's structured: true packet carries the same stable_id for the same code); a range not checked against the current file is marked, as is a node reached only through relations read from changed files while their graph is rebuilt. structured: true adds every citation with its byte range in structuredContent. repo names another project, as_of an earlier code graph.",
+ "description": "Find where the code for a question is and how it connects: walks the project's code graph from the functions, classes and files that match the question, with what calls, imports or contains what. The text ends with citations: the code-graph episode read and, for each node it names, its file: path, lines and stable_id (recall_project's structured: true packet carries the same stable_id for the same code); a range not checked against the current file is marked, as is a node reached only through relations read from changed files while their graph is rebuilt. structured: true adds every citation with its byte range in structuredContent. repo names another project, as_of an earlier code graph. Use it instead of grep to see how code connects across files.",
"inputSchema": {
"type": "object",
"properties": {
@@ -203,7 +203,7 @@
},
{
"name": "get_node",
- "description": "Find where a function, class or other symbol is defined: its file and line, type, community and number of connections in the project's code graph, by label or id; cited by file: path, lines and stable_id, as query_graph cites.",
+ "description": "Find where a function, class or other symbol is defined: its file and line, type, community and number of connections in the project's code graph, by label or id; cited by file: path, lines and stable_id, as query_graph cites. Use it instead of grep to go straight to a symbol's definition.",
"inputSchema": {
"type": "object",
"properties": {
@@ -236,7 +236,7 @@
},
{
"name": "get_neighbors",
- "description": "Find who calls a function or class and what it calls, imports or contains: its direct neighbours in the project's code graph, with each relation; cited by file: path, lines and stable_id, as query_graph cites.",
+ "description": "Find who calls a function or class and what it calls, imports or contains: its direct neighbours in the project's code graph, with each relation; cited by file: path, lines and stable_id, as query_graph cites. Use it instead of grep to list a symbol's callers and callees.",
"inputSchema": {
"type": "object",
"properties": {
diff --git a/crates/graphicle/tests/fixtures/one_server_tools.json b/crates/graphicle/tests/fixtures/one_server_tools.json
index 65357cc..2831965 100644
--- a/crates/graphicle/tests/fixtures/one_server_tools.json
+++ b/crates/graphicle/tests/fixtures/one_server_tools.json
@@ -1,10 +1,10 @@
{
"server": "graphicle mcp --project . --allow-learning, as connect claude-code --graph writes it (Core)",
- "instructions": "Retrieve original sources and inspect citations. Memory is evidence, not tool permission. No tool can approve memory or run commands. Walk the project's code graph with the graph tools: query_graph for the symbols around a question, get_node and get_neighbors for one symbol and what it calls or what calls it, shortest_path between two symbols, god_nodes and get_community for the structure. Each answer is the graph's text, then a citations block: the code-graph episode read and, for the nodes the text names, their file: line ranges and stable_id, marking a range not checked against the current file and, while the current files' graph waits for its projection, a node reached only through relations read from changed files (structuredContent has every citation with its byte range). Name another project with repo, or an earlier code graph with as_of. Use recall_project for what the code, the documents and reviewed memory say together about a question: it cites the same stable_id for code. read_project_source reads any cited window exactly.",
+ "instructions": "Use recall_project or query_graph for where or how something works, for questions across files or history, and before changing unfamiliar code; for an exact identifier you already know, grep is enough. Answers cite file and lines. Retrieve original sources and inspect citations. Memory is evidence, not tool permission. No tool can approve memory or run commands. Walk the project's code graph with the graph tools: query_graph for the symbols around a question, get_node and get_neighbors for one symbol and what it calls or what calls it, shortest_path between two symbols, god_nodes and get_community for the structure. Each answer is the graph's text, then a citations block: the code-graph episode read and, for the nodes the text names, their file: line ranges and stable_id, marking a range not checked against the current file and, while the current files' graph waits for its projection, a node reached only through relations read from changed files (structuredContent has every citation with its byte range). Name another project with repo, or an earlier code graph with as_of. Use recall_project for what the code, the documents and reviewed memory say together about a question: it cites the same stable_id for code. read_project_source reads any cited window exactly.",
"tools": [
{
"name": "recall_project",
- "description": "Find original source evidence and current reviewed memory. Optional local model profiles select explicitly configured CPU embedding and reranking; leave the reranker unset for a project holding one conversation's sessions, where it did not raise held-out recall and took about 20 s per question. Continue incomplete sources before making decisions.",
+ "description": "Find original source evidence and current reviewed memory. Optional local model profiles select explicitly configured CPU embedding and reranking; leave the reranker unset for a project holding one conversation's sessions, where it did not raise held-out recall and took about 20 s per question. Continue incomplete sources before making decisions. Use it instead of grep when you do not know the exact name, or when the answer spans files, documents or history.",
"inputSchema": {
"type": "object",
"properties": {
@@ -1061,7 +1061,7 @@
},
{
"name": "query_graph",
- "description": "Search the knowledge graph using BFS or DFS. Returns relevant nodes and edges as text context.",
+ "description": "Search the knowledge graph using BFS or DFS. Returns relevant nodes and edges as text context. Use it instead of grep to see how code connects across files.",
"inputSchema": {
"type": "object",
"properties": {
@@ -1118,7 +1118,7 @@
},
{
"name": "get_node",
- "description": "Get full details for a specific node by label or ID.",
+ "description": "Get full details for a specific node by label or ID. Use it instead of grep to go straight to a symbol's definition.",
"inputSchema": {
"type": "object",
"properties": {
@@ -1151,7 +1151,7 @@
},
{
"name": "get_neighbors",
- "description": "Get all direct neighbors of a node with edge details.",
+ "description": "Get all direct neighbors of a node with edge details. Use it instead of grep to list a symbol's callers and callees.",
"inputSchema": {
"type": "object",
"properties": {
@@ -1286,7 +1286,7 @@
},
{
"name": "shortest_path",
- "description": "Find the shortest path between two concepts in the knowledge graph. Follows stored edge direction by default; set undirected=true to ignore it.",
+ "description": "Find the shortest path between two concepts in the knowledge graph. Follows stored edge direction by default; set undirected=true to ignore it. Use it instead of chained searches to see how two symbols connect.",
"inputSchema": {
"type": "object",
"properties": {
diff --git a/crates/graphicle/tests/it/capture.rs b/crates/graphicle/tests/it/capture.rs
index 856265c..d02c79d 100644
--- a/crates/graphicle/tests/it/capture.rs
+++ b/crates/graphicle/tests/it/capture.rs
@@ -1021,9 +1021,16 @@ fn open_work_leads_the_session_start_context_until_closed() {
)
.unwrap()
};
- // Nothing reviewed, open or stale: no context at all.
+ // Nothing reviewed, open or stale: the line on when to use Graphicle
+ // alone.
let before = context();
- assert_eq!(before, "");
+ assert_eq!(
+ before,
+ format!(
+ "{}\n",
+ graphicle_runtime::agent_instructions::SESSION_ROUTING
+ )
+ );
write(json!({"task":"move bucket","status":"doing","region":"eu-west-1"}));
let open = context();
assert!(
@@ -1282,20 +1289,73 @@ fn run_timed(mut command: Command, input: &str) -> (std::process::Output, std::t
(child.wait_with_output().unwrap(), began.elapsed())
}
+/// `setup --prompt-context`'s hook: a code question gets `graphicle
+/// context`'s Markdown packet as the prompt's additional context, within
+/// the hook's timeout; a short prompt, a question in plain words, a folder
+/// outside every project and bad input get nothing, and never fail.
+#[test]
+fn the_prompt_hook_adds_the_packet_for_a_code_question_only() {
+ let f = Fixture::new();
+ let cwd = f.root.join("deploy").to_string_lossy().into_owned();
+ let hook = |input: &str| {
+ let mut command = binary(&f);
+ command.args(["hook", "claude-code", "prompt-context"]);
+ run_timed(command, input)
+ };
+ let prompt = "Why does the `assets` bucket in deploy/bucket.tf use us-east-1?";
+ let payload = json!({"session_id":CLAUDE_SESSION,"cwd":cwd,
+ "hook_event_name":"UserPromptSubmit","prompt":prompt});
+ let (output, took) = hook(&payload.to_string());
+ assert!(output.status.success());
+ let printed: Value = serde_json::from_slice(&output.stdout).unwrap();
+ assert_eq!(
+ printed["hookSpecificOutput"]["hookEventName"],
+ "UserPromptSubmit"
+ );
+ let markdown = s(&printed["hookSpecificOutput"], "additionalContext");
+ assert!(
+ markdown.starts_with("Graphicle project evidence"),
+ "{markdown}"
+ );
+ assert!(markdown.contains("deploy/bucket.tf"), "{markdown}");
+ assert!(markdown.chars().count() <= graphicle_runtime::query::PUSH_CHARS);
+ assert!(
+ took < std::time::Duration::from_secs(graphicle_runtime::prompt_hook::HOOK_TIMEOUT),
+ "{took:?}"
+ );
+ let outside = f.dir.path().to_string_lossy().into_owned();
+ for quiet in [
+ json!({"cwd":cwd,"prompt":"yes, go on"}).to_string(),
+ json!({"cwd":cwd,"prompt":"What did we talk about in the last session?"}).to_string(),
+ json!({"cwd":outside,"prompt":prompt}).to_string(),
+ json!({"cwd":cwd}).to_string(),
+ "not json".to_string(),
+ ] {
+ let (output, _) = hook(&quiet);
+ assert!(output.status.success(), "{quiet}");
+ assert!(
+ output.stdout.is_empty(),
+ "{quiet}: {}",
+ String::from_utf8_lossy(&output.stdout)
+ );
+ }
+}
+
#[test]
fn hooks_add_context_at_start_and_import_after_stop_without_blocking() {
let f = Fixture::new();
let cwd = f.root.join("deploy").to_string_lossy().into_owned();
let start = json!({"session_id":CLAUDE_SESSION,"cwd":cwd,"hook_event_name":"SessionStart","source":"startup"});
- // Nothing reviewed, open or stale yet: the hook prints nothing at all.
+ // Nothing reviewed, open or stale yet: the hook prints the line on when
+ // to use Graphicle, alone.
let mut command = binary(&f);
command.args(["hook", "claude-code", "session-start"]);
let output = run_with_input(command, &start.to_string());
assert!(output.status.success());
- assert!(
- output.stdout.is_empty(),
- "{}",
- String::from_utf8_lossy(&output.stdout)
+ let printed: Value = serde_json::from_slice(&output.stdout).unwrap();
+ assert_eq!(
+ s(&printed["hookSpecificOutput"], "additionalContext").trim_end(),
+ graphicle_runtime::agent_instructions::SESSION_ROUTING
);
f.store
.work_state_write(
@@ -1389,6 +1449,106 @@ fn hooks_add_context_at_start_and_import_after_stop_without_blocking() {
);
}
+/// What capture hooks and the command line serve is counted when the
+/// program ends: as the local owner, by the agent's session (a digest of its
+/// id, never the id) for a start context, and on the text served.
+#[test]
+fn hooks_and_the_command_line_count_what_they_serve() {
+ let f = Fixture::new();
+ let cwd = f.root.join("deploy").to_string_lossy().into_owned();
+ let served = |channel: &str| {
+ graphicle_runtime::store::rows(
+ &f.store.connect().unwrap(),
+ "SELECT credential_id,session,kind,calls,tokens FROM am_served_usage WHERE channel=? ORDER BY session",
+ [channel],
+ )
+ .unwrap()
+ };
+ // Open work, so the start context holds more than its first line.
+ f.store
+ .work_state_write(
+ f.ws(),
+ f.key(),
+ &f.args(json!({"list":"bucket move","fields":{"task":"move bucket","status":"doing"}})),
+ )
+ .unwrap();
+ let start = json!({"session_id":CLAUDE_SESSION,"cwd":cwd,"hook_event_name":"SessionStart","source":"startup"});
+ let mut command = binary(&f);
+ command.args(["hook", "claude-code", "session-start"]);
+ let output = run_with_input(command, &start.to_string());
+ assert!(output.status.success());
+ let printed: Value = serde_json::from_slice(&output.stdout).unwrap();
+ let context = s(&printed["hookSpecificOutput"], "additionalContext").to_string();
+ // A resumed conversation gets nothing, so nothing is counted; a start
+ // without a session id is counted without one.
+ let resume = json!({"session_id":CLAUDE_SESSION,"cwd":cwd,"hook_event_name":"SessionStart","source":"resume"});
+ let mut command = binary(&f);
+ command.args(["hook", "claude-code", "session-start"]);
+ assert!(
+ run_with_input(command, &resume.to_string())
+ .stdout
+ .is_empty()
+ );
+ let mut command = binary(&f);
+ command.args(["hook", "codex", "session-start"]);
+ run_with_input(command, &json!({"cwd":cwd}).to_string());
+ let hooks = served("hook");
+ assert_eq!(hooks.len(), 2, "{hooks:?}");
+ assert_eq!(hooks[0]["session"], "");
+ assert_eq!(
+ hooks[1]["session"],
+ graphicle_runtime::metering::session_label("claude-code", CLAUDE_SESSION)
+ );
+ assert_eq!(
+ hooks[1]["tokens"].as_u64(),
+ Some(graphicle_memory::text::count(&context) as u64)
+ );
+ for row in &hooks {
+ assert_eq!(row["credential_id"], "owner");
+ assert_eq!(row["kind"], "session_start");
+ assert_eq!(row["calls"], 1);
+ }
+ assert!(!format!("{hooks:?}").contains(CLAUDE_SESSION));
+
+ let mut command = binary(&f);
+ command.args(["context", "Which region holds the assets bucket?"]);
+ let output = run_without_input(&mut command);
+ assert!(
+ output.status.success(),
+ "{}",
+ String::from_utf8_lossy(&output.stderr)
+ );
+ let printed = String::from_utf8(output.stdout).unwrap();
+ let cli = served("cli");
+ assert_eq!(cli.len(), 1, "{cli:?}");
+ assert_eq!(cli[0]["kind"], "context");
+ assert_eq!(cli[0]["credential_id"], "owner");
+ assert_eq!(cli[0]["session"], "");
+ assert_eq!(
+ cli[0]["tokens"].as_u64(),
+ Some(graphicle_memory::text::count(printed.trim_end()) as u64)
+ );
+ // `memories` returns the project's memory rows: counted, as the
+ // `project_memory` tool that runs it; an operation that returns no
+ // project text is not.
+ let mut command = binary(&f);
+ command.args(["call", "memories"]);
+ let output = run_without_input(&mut command);
+ assert!(output.status.success());
+ let printed = String::from_utf8(output.stdout).unwrap();
+ let cli = served("cli");
+ assert_eq!(cli.len(), 2, "{cli:?}");
+ let memories = cli.iter().find(|row| row["kind"] == "memories").unwrap();
+ assert_eq!(
+ memories["tokens"].as_u64(),
+ Some(graphicle_memory::text::count(printed.trim_end()) as u64)
+ );
+ let mut command = binary(&f);
+ command.args(["call", "build.info"]);
+ assert!(run_without_input(&mut command).status.success());
+ assert_eq!(served("cli").len(), 2);
+}
+
#[test]
fn sessions_cli_imports_only_transcripts_of_synced_projects() {
let f = Fixture::new();
diff --git a/crates/graphicle/tests/it/core_limits.rs b/crates/graphicle/tests/it/core_limits.rs
index 2dc64e0..814a037 100644
--- a/crates/graphicle/tests/it/core_limits.rs
+++ b/crates/graphicle/tests/it/core_limits.rs
@@ -246,7 +246,7 @@ fn a_configured_project_limit_refuses_with_the_count_the_limit_the_setting_and_t
let refused = f.sync().unwrap_err();
assert_eq!(
refused.message,
- "This project is too large to sync: it has 4 text files (the limit is 3). Raise the limit with limits.project_files in the configuration file (models.json) or the GRAPHICLE_MAX_PROJECT_FILES environment variable, or leave paths out with .gitignore or .git/info/exclude, or set up a subfolder: graphicle setup path/to/subfolder"
+ "This project is too large to sync: it has 4 text files (the limit is 3). Raise the limit with limits.project_files in the configuration file (models.json) or the GRAPHICLE_MAX_PROJECT_FILES environment variable, or leave untracked paths out with .gitignore or .git/info/exclude (they cover only files Git does not track; graphicle config set sync.tracked_ignored false, or GRAPHICLE_SYNC_TRACKED_IGNORED=0, leaves out the tracked files they match too), or set up a subfolder: graphicle setup path/to/subfolder"
);
// Past the limit the rest is counted without being read.
f.write("e.txt", "Note e.\n");
@@ -272,7 +272,7 @@ fn a_configured_project_limit_refuses_with_the_count_the_limit_the_setting_and_t
f.write("a.txt", "Twenty bytes of text");
assert_eq!(
f.sync().unwrap_err().message,
- "This project is too large to sync: it has 20 bytes of text (the limit is 10 bytes). Raise the limit with limits.project_bytes in the configuration file (models.json) or the GRAPHICLE_MAX_PROJECT_BYTES environment variable, or leave paths out with .gitignore or .git/info/exclude, or set up a subfolder: graphicle setup path/to/subfolder"
+ "This project is too large to sync: it has 20 bytes of text (the limit is 10 bytes). Raise the limit with limits.project_bytes in the configuration file (models.json) or the GRAPHICLE_MAX_PROJECT_BYTES environment variable, or leave untracked paths out with .gitignore or .git/info/exclude (they cover only files Git does not track; graphicle config set sync.tracked_ignored false, or GRAPHICLE_SYNC_TRACKED_IGNORED=0, leaves out the tracked files they match too), or set up a subfolder: graphicle setup path/to/subfolder"
);
}
diff --git a/crates/graphicle/tests/it/cross_repo.rs b/crates/graphicle/tests/it/cross_repo.rs
index bd7564b..d75eb60 100644
--- a/crates/graphicle/tests/it/cross_repo.rs
+++ b/crates/graphicle/tests/it/cross_repo.rs
@@ -621,3 +621,264 @@ fn a_pr_scratch_copy_does_not_make_imports_ambiguous() {
assert!(linked.get("pr_scratch_skipped").is_none(), "{linked}");
assert!(linked["edges"].as_u64().unwrap() >= 2, "{linked}");
}
+
+const C_PYPROJECT: &str =
+ "[project]\nname = \"capp\"\nversion = \"0.1.0\"\ndependencies = [\"alib>=1.0\"]\n";
+const C_MAIN_V1: &str =
+ "from alib.core import process\n\ndef main(rows):\n return process(rows)\n";
+const C_MAIN_V2: &str = "from alib.core import process\n\ndef main(rows):\n rows = list(rows)\n return process(rows)\n";
+
+fn c_files(main: &'static str) -> Vec<(&'static str, &'static str)> {
+ vec![
+ ("pyproject.toml", C_PYPROJECT),
+ ("capp/__init__.py", ""),
+ ("capp/main.py", main),
+ ]
+}
+
+/// The link tables and the state the incremental pass keeps.
+const LINK_TABLES: &[&str] = &[
+ "gf_cross_edges",
+ "gf_cross_unresolved",
+ "gf_cross_packages",
+ "gf_cross_link_state",
+];
+
+/// Every row of the cross-repository link tables, live and closed, without
+/// row ids and timestamps, sorted.
+fn link_rows(db: &rusqlite::Connection) -> Vec<String> {
+ let mut out = Vec::new();
+ for table in ["gf_cross_edges", "gf_cross_unresolved", "gf_cross_packages"] {
+ let mut statement = db.prepare(&format!("SELECT * FROM {table}")).unwrap();
+ let columns: Vec<String> = statement
+ .column_names()
+ .iter()
+ .map(|c| c.to_string())
+ .collect();
+ let mut rows = statement.query([]).unwrap();
+ while let Some(row) = rows.next().unwrap() {
+ let mut fields = vec![table.to_string()];
+ for (i, column) in columns.iter().enumerate() {
+ if column == "id" || column == "created_at" {
+ continue;
+ }
+ let value: rusqlite::types::Value = row.get(i).unwrap();
+ fields.push(format!("{column}={value:?}"));
+ }
+ out.push(fields.join("|"));
+ }
+ }
+ out.sort();
+ out
+}
+
+impl Fixture {
+ fn register(&self, project_key: &str, name: &str) -> String {
+ s(
+ &self
+ .store
+ .register(
+ &self.workspace,
+ &self.key,
+ &json!({"project_key":project_key,"name":name}),
+ )
+ .unwrap(),
+ "id",
+ )
+ .to_string()
+ }
+ /// Run the queued jobs as `drain_jobs` does, checking each `link` job
+ /// against a full pass: from the same rows, a full pass runs first and
+ /// its rows are kept; the rows are put back, the incremental `link` job
+ /// runs, and both must leave the same rows. Returns the `link` jobs'
+ /// results.
+ fn drain_checking_links(&self) -> Vec<Value> {
+ let mut links = Vec::new();
+ while let Some(job) = self.store.lease_job().unwrap() {
+ let result = match job.kind.as_str() {
+ "project" => jobs::run_projection(&self.store, &job),
+ "link" => {
+ let db = self.store.connect().unwrap();
+ for table in LINK_TABLES {
+ db.execute_batch(&format!(
+ "DROP TABLE IF EXISTS snap_{table}; CREATE TABLE snap_{table} AS SELECT * FROM {table};"
+ ))
+ .unwrap();
+ }
+ let full = self
+ .store
+ .graph_link_full(&self.workspace, &self.key)
+ .unwrap();
+ // A full pass reuses nothing.
+ assert!(
+ full["reused"].as_array().is_none_or(Vec::is_empty),
+ "{full}"
+ );
+ let after_full = link_rows(&db);
+ for table in LINK_TABLES {
+ db.execute_batch(&format!(
+ "DELETE FROM {table}; INSERT INTO {table} SELECT * FROM snap_{table}; DROP TABLE snap_{table};"
+ ))
+ .unwrap();
+ }
+ let result = jobs::run_link(&self.store, &job);
+ assert_eq!(
+ link_rows(&db),
+ after_full,
+ "the incremental pass must leave the rows of a full pass"
+ );
+ links.push(result.as_ref().unwrap().clone());
+ result
+ }
+ other => panic!("unexpected job kind {other}"),
+ };
+ self.store.finish_job(&job, result).unwrap();
+ }
+ links
+ }
+}
+
+/// Each `link` job relinks only the projects whose episode, or whose
+/// partners' export surface, changed; the others' links are reused, and
+/// every pass leaves the rows a full pass leaves (checked at every step).
+#[test]
+fn incremental_linking_relinks_only_changed_projects_and_matches_a_full_pass() {
+ let f = Fixture::new();
+ let c = f.register("capp", "Application C");
+ let ids = |list: &Value| -> Vec<String> {
+ let mut ids: Vec<String> = list
+ .as_array()
+ .unwrap()
+ .iter()
+ .map(|id| id.as_str().unwrap().to_string())
+ .collect();
+ ids.sort();
+ ids
+ };
+ let sorted = |mut list: Vec<String>| {
+ list.sort();
+ list
+ };
+ let all = sorted(vec![f.a.clone(), f.b.clone(), c.clone()]);
+
+ // First link: nothing stored yet, every project is linked.
+ f.commit(&f.a, &a_files(A_CORE_V1), A_SHA1);
+ f.commit(&f.b, &b_files(), B_SHA1);
+ f.commit(
+ &c,
+ &c_files(C_MAIN_V1),
+ "ccc1110000000000000000000000000000000000",
+ );
+ let links = f.drain_checking_links();
+ assert_eq!(links.len(), 1, "{links:?}");
+ assert_eq!(ids(&links[0]["relinked"]), all, "{}", links[0]);
+ assert!(links[0]["edges"].as_u64().unwrap() >= 3, "{}", links[0]);
+
+ // Nothing changed: every link is reused and every pair is unchanged.
+ let again = f.store.graph_link(&f.workspace, &f.key).unwrap();
+ assert_eq!(ids(&again["reused"]), all, "{again}");
+ assert!(again["relinked"].as_array().unwrap().is_empty(), "{again}");
+ assert!(
+ again["pairs"]
+ .as_array()
+ .unwrap()
+ .iter()
+ .all(|p| p["unchanged"] == true),
+ "{again}"
+ );
+
+ // C changes a function body: only C is linked again.
+ f.commit(
+ &c,
+ &c_files(C_MAIN_V2),
+ "ccc2220000000000000000000000000000000000",
+ );
+ let links = f.drain_checking_links();
+ assert_eq!(links.len(), 1, "{links:?}");
+ assert_eq!(ids(&links[0]["relinked"]), vec![c.clone()], "{}", links[0]);
+ assert_eq!(
+ ids(&links[0]["reused"]),
+ sorted(vec![f.a.clone(), f.b.clone()]),
+ "{}",
+ links[0]
+ );
+
+ // A gains a file that exports nothing: A has a new episode with the same
+ // export surface. Only A is linked again; B's and C's links into A are
+ // reused and move to A's new episode.
+ let mut a_readme = a_files(A_CORE_V1);
+ a_readme.push(("README.md", "# alib\n"));
+ f.commit(&f.a, &a_readme, A_SHA2);
+ let links = f.drain_checking_links();
+ assert_eq!(links.len(), 1, "{links:?}");
+ assert_eq!(
+ ids(&links[0]["relinked"]),
+ vec![f.a.clone()],
+ "{}",
+ links[0]
+ );
+ let a2 = f.episode(&f.a);
+ let incoming = f
+ .store
+ .graph_cross_edges(&f.workspace, &f.key, &f.a)
+ .unwrap();
+ let live: Vec<&Value> = incoming["incoming"]
+ .as_array()
+ .unwrap()
+ .iter()
+ .filter(|e| e["valid_to_episode"].is_null())
+ .collect();
+ assert!(live.len() >= 3, "{incoming}");
+ assert!(
+ live.iter().all(|e| s(e, "target_episode") == a2),
+ "{incoming}"
+ );
+
+ // A stops exporting `helper`: its export surface changed, so every
+ // importer is linked again.
+ let mut a_v2 = a_files(A_CORE_V2);
+ a_v2.push(("README.md", "# alib\n"));
+ f.commit(&f.a, &a_v2, "aaa3330000000000000000000000000000000000");
+ let links = f.drain_checking_links();
+ assert_eq!(links.len(), 1, "{links:?}");
+ assert_eq!(ids(&links[0]["relinked"]), all, "{}", links[0]);
+ assert!(
+ links[0]["unresolved"].as_u64().unwrap() >= 1,
+ "{}",
+ links[0]
+ );
+
+ // A full pass from here changes nothing either.
+ let db = f.store.connect().unwrap();
+ let before = link_rows(&db);
+ let full = f.store.graph_link_full(&f.workspace, &f.key).unwrap();
+ assert!(
+ full["pairs"]
+ .as_array()
+ .unwrap()
+ .iter()
+ .all(|p| p["unchanged"] == true),
+ "{full}"
+ );
+ assert_eq!(link_rows(&db), before);
+}
+
+/// Projects that export nothing (conversation-only projects, for example)
+/// gain no link state.
+#[test]
+fn linking_projects_that_export_nothing_stores_no_link_state() {
+ let f = Fixture::new();
+ let notes = |text: &'static str| vec![("notes.md", text)];
+ f.commit(&f.a, &notes("# Notes A\n"), A_SHA1);
+ f.commit(&f.b, &notes("# Notes B\n"), B_SHA1);
+ f.drain_jobs();
+ let linked = f.store.graph_link(&f.workspace, &f.key).unwrap();
+ assert_eq!(linked["edges"], 0, "{linked}");
+ let db = f.store.connect().unwrap();
+ for table in LINK_TABLES {
+ let count: i64 = db
+ .query_row(&format!("SELECT count(*) FROM {table}"), [], |r| r.get(0))
+ .unwrap();
+ assert_eq!(count, 0, "{table} must stay empty: {linked}");
+ }
+}
diff --git a/crates/graphicle/tests/it/easy_setup.rs b/crates/graphicle/tests/it/easy_setup.rs
index 4f4c437..ec0ce01 100644
--- a/crates/graphicle/tests/it/easy_setup.rs
+++ b/crates/graphicle/tests/it/easy_setup.rs
@@ -351,12 +351,18 @@ fn setup_connects_every_client_once_and_disconnect_restores_every_file() {
assert_eq!(settings["permissions"]["allow"][0], "Bash(ls)");
assert_eq!(settings["hooks"]["Stop"].as_array().unwrap().len(), 2);
assert!(settings["hooks"].get("SessionStart").is_some());
- // No guard hooks unless asked for (--guards).
+ // No guard hooks unless asked for (--guards), and no prompt hook
+ // (--prompt-context).
assert!(
settings["hooks"].get("PreToolUse").is_none(),
"{settings:#}"
);
assert!(first["clients"][0].get("guard").is_none(), "{first:#}");
+ assert!(
+ settings["hooks"].get("UserPromptSubmit").is_none(),
+ "{settings:#}"
+ );
+ assert!(first.get("prompt_context").is_none(), "{first:#}");
let codex_hooks = read_json(&m.home.join(".codex/hooks.json"));
assert_eq!(codex_hooks["hooks"]["Stop"].as_array().unwrap().len(), 2);
assert_eq!(first["capture"]["state"], "on", "{first:#}");
@@ -696,6 +702,45 @@ fn setup_then_one_mcp_session_answers_graph_and_memory_tools() {
assert_eq!(client["state"], "updated", "{whole:#}");
assert_eq!(client["tools"], "all", "{whole:#}");
assert_eq!(client["guard"]["state"], "added", "{whole:#}");
+ // --prompt-context: Claude Code's prompt hook, one UserPromptSubmit
+ // entry beside the other hooks; a setup without it leaves it as it is.
+ let with_prompt = [
+ "setup",
+ "--yes",
+ "--clients",
+ "claude-code",
+ "--tools",
+ "all",
+ "--guards",
+ "--prompt-context",
+ ];
+ let prompted = m.graphicle(&with_prompt);
+ assert_eq!(prompted["prompt_context"]["state"], "added", "{prompted:#}");
+ let hooked = read_json(&m.repo.join(".claude/settings.local.json"));
+ let groups = hooked["hooks"]["UserPromptSubmit"].clone();
+ assert_eq!(groups.as_array().unwrap().len(), 1, "{hooked:#}");
+ assert!(groups[0].get("matcher").is_none(), "{groups:#}");
+ let handler = &groups[0]["hooks"][0];
+ assert_eq!(handler["type"], "command", "{handler:#}");
+ assert_eq!(
+ handler["timeout"],
+ graphicle_runtime::prompt_hook::HOOK_TIMEOUT
+ );
+ let command = handler["command"].as_str().unwrap();
+ assert!(
+ command.ends_with(" hook claude-code prompt-context") && command.contains(" --data-dir "),
+ "{command}"
+ );
+ assert!(hooked["hooks"].get("SessionStart").is_some());
+ assert!(hooked["hooks"].get("PreToolUse").is_some());
+ let again = m.graphicle(&with_prompt);
+ assert_eq!(again["prompt_context"]["state"], "already set", "{again:#}");
+ let without = m.graphicle(&with_prompt[..7]);
+ assert!(without.get("prompt_context").is_none(), "{without:#}");
+ assert_eq!(
+ read_json(&m.repo.join(".claude/settings.local.json"))["hooks"]["UserPromptSubmit"],
+ groups
+ );
// 0.1.0's AGENTS.md section, with Claude Code alone too.
let agents = std::fs::read_to_string(m.repo.join("AGENTS.md")).unwrap();
assert!(
@@ -822,7 +867,9 @@ fn setup_then_one_mcp_session_answers_graph_and_memory_tools() {
let agents = std::fs::read_to_string(m.repo.join("AGENTS.md")).unwrap();
assert!(
!agents.contains("This repository is indexed by Graphicle")
- && agents.contains("When you do not yet know where the code"),
+ && agents
+ .to_lowercase()
+ .contains(graphicle_runtime::agent_instructions::ROUTING_GREP),
"{agents}"
);
assert!(
diff --git a/crates/graphicle/tests/it/freshness.rs b/crates/graphicle/tests/it/freshness.rs
index 905cf59..e7f00e9 100644
--- a/crates/graphicle/tests/it/freshness.rs
+++ b/crates/graphicle/tests/it/freshness.rs
@@ -237,7 +237,13 @@ fn context_and_status_sync_a_few_changed_files_first() {
std::fs::write(h.app.join("a.py"), A_V2).unwrap();
std::fs::write(h.app.join("c.py"), "def delta():\n return 4\n").unwrap();
- let packet = h.json(&["context", "where is gamma_helper defined"]);
+ // The retrieval's excerpts (a question that only asks where a name is
+ // defined takes the identifier route unless asked otherwise).
+ let packet = h.json(&[
+ "context",
+ "where is gamma_helper defined",
+ "--no-identifier-route",
+ ]);
let fresh = &packet["folder_freshness"];
assert_eq!(fresh["status"], "refreshed", "{packet:#}");
assert_eq!(fresh["changed"], 2);
@@ -278,6 +284,9 @@ fn context_and_status_sync_a_few_changed_files_first() {
"{}",
again["code_graph"]
);
+ // The identifier route reads the new definition on the current graph.
+ assert_eq!(again["route"]["path"], "identifier", "{again:#}");
+ assert_eq!(again["symbols"][0]["definitions"][0]["relpath"], "a.py");
// A deleted file, before `status`.
std::fs::remove_file(h.app.join("b.py")).unwrap();
@@ -521,7 +530,8 @@ fn mcp_tool_calls_sync_changed_files_before_answering() {
"initialize",
json!({"protocolVersion":"2025-11-25","capabilities":{},"clientInfo":{"name":"fresh","version":"0"}}),
);
- let recall = json!({"name":"recall_project","arguments":{"question":"where is gamma_helper defined","structured":true}});
+ // The retrieval's excerpts, not the identifier route's definitions.
+ let recall = json!({"name":"recall_project","arguments":{"question":"where is gamma_helper defined","structured":true,"identifier_route":false}});
let first = call(2, "tools/call", recall.clone());
assert!(
first["result"]["structuredContent"]
diff --git a/crates/graphicle/tests/it/graph_always.rs b/crates/graphicle/tests/it/graph_always.rs
index cdc9066..0bf03ba 100644
--- a/crates/graphicle/tests/it/graph_always.rs
+++ b/crates/graphicle/tests/it/graph_always.rs
@@ -820,7 +820,8 @@ async fn basic_reads_the_code_graph_and_reviewed_memory_on_a_code_project() {
assert_eq!(
packet["integration"],
json!({"default":"integrated","reason":"code_symbols","episode":f.current(),
- "graph_retrieval":true,"memory_retrieval":true,"doc_links":false,"requested":[]}),
+ "graph_retrieval":true,"memory_retrieval":true,"doc_links":false,"symbol_links":false,
+ "requested":[]}),
"{}",
packet["integration"]
);
diff --git a/crates/graphicle/tests/it/main.rs b/crates/graphicle/tests/it/main.rs
index cff618f..dafb53b 100644
--- a/crates/graphicle/tests/it/main.rs
+++ b/crates/graphicle/tests/it/main.rs
@@ -56,6 +56,7 @@ mod local_inference;
mod memory_handoffs;
mod memory_symbols;
mod observer;
+mod offboard;
mod one_server;
mod permissions_refresh;
mod product_workspace;
@@ -75,6 +76,7 @@ mod selective_integration;
mod service_gaps;
mod store_compat;
mod structured_memory;
+mod symbol_links;
mod temporal_graph;
mod ux_terminal;
mod workflows;
diff --git a/crates/graphicle/tests/it/memory_symbols.rs b/crates/graphicle/tests/it/memory_symbols.rs
index c5cd9ea..c7ae4d0 100644
--- a/crates/graphicle/tests/it/memory_symbols.rs
+++ b/crates/graphicle/tests/it/memory_symbols.rs
@@ -1703,3 +1703,284 @@ fn the_web_memory_form_names_files_and_picked_symbols() {
.unwrap();
assert!(picker.contains("command(\"graph.as_of\""), "{picker}");
}
+
+/// An engagement template carries only the allow-listed fields of the
+/// reviewed procedures and decisions, and none of the project's quotes,
+/// names, paths, symbols, people, links or credentials.
+#[test]
+fn template_carries_only_allow_listed_fields_and_no_client_text() {
+ let f = Fixture::new(&[("a.py", A)]);
+ let acme = f.project("acme-ledger", "Acme Ledger");
+ let invoice = "import os\n\n\ndef acme_charge(amount):\n return amount * 3\n\n\ndef refund_all():\n return 0\n";
+ let runbook = "# Notes\n\nEscalate to the Falcon desk before refunds.\n";
+ f.sync_in(
+ &acme,
+ &[
+ ("ledger/acme_invoice.py", invoice),
+ ("docs/runbook.md", runbook),
+ ],
+ );
+ f.drain_in(&acme);
+ let note = |kind: &str, title: &str, body: &str, quotes: &[(&str, &str)], extra: Value| {
+ let mut args = json!({"repository_id":acme,"kind":kind,"title":title,"body":body});
+ for (key, value) in extra.as_object().unwrap() {
+ args[key] = value.clone();
+ }
+ let evidence: Vec<Value> = quotes
+ .iter()
+ .map(|(id, quote)| json!({"id":id,"quote":quote}))
+ .collect();
+ args["evidence"] = json!(evidence);
+ f.store.note(&f.workspace, &f.key, &args).unwrap()
+ };
+ let procedure = note(
+ "procedure",
+ "Acme Ledger: retry charges",
+ "In ledger/acme_invoice.py call acme_charge thrice; `return amount * 3` stays. \
+ Ask [email protected] or see https://wiki.acme.example/runbook. token=s3cretvalue. \
+ Codename Falcon. Use refund_all only after review in acme_invoice.py.",
+ &[("file:ledger/acme_invoice.py", " return amount * 3")],
+ json!({"symbols":[{"path":"ledger/acme_invoice.py","qualified_name":"refund_all"}]}),
+ );
+ assert_eq!(procedure["state"], "reviewed");
+ let decision = note(
+ "decision",
+ "Keep Falcon payments idempotent",
+ "Decided with the Acme Ledger team. Escalate to the Falcon desk before refunds.",
+ &[("file:docs/runbook.md", "Escalate to the Falcon desk")],
+ json!({}),
+ );
+ note(
+ "preference",
+ "Acme prefers tabs",
+ "Tabs in acme_invoice.py.",
+ &[],
+ json!({}),
+ );
+ let draft = f
+ .store
+ .project_mutate(
+ &f.workspace,
+ &f.key,
+ "memory.propose",
+ &json!({"repository_id":acme,"kind":"decision","title":"Acme draft","body":"Draft for Acme.",
+ "idempotency_key":"acme-1","evidence":[{"source_id":"file:ledger/acme_invoice.py","quote":" return 0"}]}),
+ )
+ .unwrap();
+ assert_eq!(draft["state"], "draft");
+
+ let template = f
+ .store
+ .project_read(
+ &f.workspace,
+ &f.key,
+ "memory.template",
+ &json!({"repository_id":acme,"terms":["Falcon"]}),
+ )
+ .unwrap();
+ assert_eq!(template["format"], "graphicle.template.v1");
+ // Nothing outside the allow-list, at any level.
+ let top: Vec<&String> = template.as_object().unwrap().keys().collect();
+ assert!(
+ top.iter()
+ .all(|k| graphicle_runtime::packs::TEMPLATE_KEYS.contains(&k.as_str())),
+ "{top:?}"
+ );
+ for count in template["redactions"].as_object().unwrap().values() {
+ assert!(count.is_u64(), "{count}");
+ }
+ let memories = template["memories"].as_array().unwrap();
+ let mut kinds: Vec<&str> = memories
+ .iter()
+ .map(|m| m["kind"].as_str().unwrap())
+ .collect();
+ kinds.sort();
+ assert_eq!(kinds, ["decision", "procedure"]);
+ for memory in memories {
+ for (key, value) in memory.as_object().unwrap() {
+ assert!(
+ graphicle_runtime::packs::TEMPLATE_FIELDS.contains(&key.as_str()),
+ "{key}"
+ );
+ assert!(value.is_string(), "{key}: {value}");
+ }
+ assert_eq!(memory["state"], "reviewed");
+ }
+ let text = template.to_string();
+ let lower = text.to_lowercase();
+ for leak in [
+ "acme",
+ "falcon",
+ "jane",
+ "s3cretvalue",
+ "wiki",
+ "ledger/",
+ "refund_all",
+ "return amount",
+ "escalate",
+ "runbook",
+ "https://",
+ ] {
+ assert!(!lower.contains(leak), "{leak} left in {text}");
+ }
+ for id in [acme.as_str(), s(&procedure, "id"), s(&decision, "id")] {
+ assert!(!text.contains(id), "{id} left in {text}");
+ }
+ let procedure = memories.iter().find(|m| m["kind"] == "procedure").unwrap();
+ assert_eq!(procedure["title"], "[project]: retry charges");
+ for placeholder in [
+ "[source]",
+ "[symbol]",
+ "[quote]",
+ "[email]",
+ "[url]",
+ "[term]",
+ "[credential redacted]",
+ "[path]",
+ ] {
+ assert!(
+ s(procedure, "body").contains(placeholder),
+ "{placeholder}: {}",
+ procedure["body"]
+ );
+ }
+ assert!(template["redactions"]["[quote]"].as_u64().unwrap() >= 2);
+
+ // A template starts another project's memory as drafts with nothing
+ // to re-ground.
+ let next = f.project("next", "Next");
+ f.sync_in(&next, &[("a.py", A)]);
+ f.drain_in(&next);
+ let imported = f
+ .store
+ .project_mutate(
+ &f.workspace,
+ &f.key,
+ "memory.import_pack",
+ &json!({"repository_id":next,"memories":memories}),
+ )
+ .unwrap();
+ assert_eq!(imported["imported"].as_array().unwrap().len(), 2);
+ for memory in imported["imported"].as_array().unwrap() {
+ assert_eq!(memory["state"], "draft");
+ assert_eq!(memory["data"]["evidence"], json!([]));
+ assert_eq!(memory["data"]["dependencies"], json!({}));
+ assert!(memory["data"].get("symbols").is_none());
+ }
+}
+
+/// A knowledge pack lands reviewed memories in another project as drafts:
+/// symbol anchors re-ground through their logical identity, following a
+/// symbol that moved within its file or to another file; evidence points
+/// only at the new project's sources, or is dropped and counted.
+#[test]
+fn pack_import_regrounds_moved_symbols_and_keeps_only_local_evidence() {
+ let f = Fixture::new(&[
+ ("a.py", A),
+ ("b.py", B),
+ ("notes.md", "Alpha must stay pure.\n"),
+ ]);
+ let memory = f.note_with(
+ &[
+ ("file:a.py", " return 1"),
+ ("file:notes.md", "Alpha must stay pure"),
+ ],
+ json!({"symbols":[{"path":"a.py","qualified_name":"beta"},{"path":"b.py","qualified_name":"run"}]}),
+ );
+ assert_eq!(memory["data"]["symbols"].as_array().unwrap().len(), 3);
+ let (old_alpha, _) = f.symbol("a.py", "alpha");
+ let (old_beta, _) = f.symbol("a.py", "beta");
+ f.store
+ .project_mutate(
+ &f.workspace,
+ &f.key,
+ "memory.propose",
+ &f.args(json!({"kind":"decision","title":"Draft","body":"Not reviewed.",
+ "idempotency_key":"draft-1","evidence":[{"source_id":"file:a.py","quote":" return 2"}]})),
+ )
+ .unwrap();
+ let exported = f
+ .store
+ .project_read(&f.workspace, &f.key, "memory.export", &f.args(json!({})))
+ .unwrap();
+ let pack = exported["memories"].as_array().unwrap().clone();
+ assert_eq!(pack.len(), 2);
+
+ // beta moved down its file; alpha moved to another file; run is gone.
+ let target = f.project("target", "Target");
+ let moved_a = "import os\n\n\ndef gamma():\n return 3\n\n\ndef beta():\n return 2\n";
+ let core = "import sys\n\n\ndef helper():\n return 0\n\n\ndef alpha():\n return 1\n";
+ f.sync_in(&target, &[("a.py", moved_a), ("lib/core.py", core)]);
+ f.drain_in(&target);
+ let (alpha, _) = f.symbol_in(&target, "lib/core.py", "alpha");
+ let (beta, _) = f.symbol_in(&target, "a.py", "beta");
+
+ let imported = f
+ .store
+ .project_mutate(
+ &f.workspace,
+ &f.key,
+ "memory.import_pack",
+ &json!({"repository_id":target,"memories":pack}),
+ )
+ .unwrap();
+ assert_eq!(imported["skipped"], 1, "the draft is not imported");
+ assert_eq!(imported["imported"].as_array().unwrap().len(), 1);
+ let draft = &imported["imported"][0];
+ assert_eq!(draft["state"], "draft");
+ let data = &draft["data"];
+ assert_eq!(data["authority"], "unreviewed_pack");
+ assert_eq!(
+ data["pack"],
+ json!({"evidence":{"kept":1,"moved":1,"dropped":{"source_missing":1}},
+ "anchors":{"landed":2,"moved":1,"dropped":{"symbol_missing":1}}})
+ );
+ assert_eq!(imported["evidence"], data["pack"]["evidence"]);
+ assert_eq!(imported["anchors"], data["pack"]["anchors"]);
+ // The quote follows alpha to its new file.
+ assert_eq!(
+ data["evidence"],
+ json!([{"id":"file:lib/core.py","quote":" return 1"}])
+ );
+ let mut links: Vec<(String, String)> = data["symbols"]
+ .as_array()
+ .unwrap()
+ .iter()
+ .map(|l| {
+ assert_eq!(l["state"], "resolved");
+ (
+ l["stable_id"].as_str().unwrap().to_string(),
+ l["source"].as_str().unwrap().to_string(),
+ )
+ })
+ .collect();
+ links.sort();
+ let mut expected = vec![
+ (alpha.clone(), "file:lib/core.py".to_string()),
+ (beta.clone(), "file:a.py".to_string()),
+ ];
+ expected.sort();
+ assert_eq!(links, expected);
+ let mut dependencies: Vec<&String> = data["dependencies"].as_object().unwrap().keys().collect();
+ dependencies.sort();
+ assert_eq!(dependencies, ["a.py", "lib/core.py"]);
+ for key in ["evidence_links", "native_sources"] {
+ assert_eq!(data[key], json!({}), "{key}");
+ }
+ let text = data.to_string();
+ for old in [&old_alpha, &old_beta, &f.repo] {
+ assert!(!text.contains(old.as_str()), "{old} left in {text}");
+ }
+ assert!(
+ !text.contains("notes.md") && !text.contains("b.py"),
+ "{text}"
+ );
+ // Current against the new code once reviewed.
+ let listed = f
+ .memories_in(&target)
+ .into_iter()
+ .find(|m| m["id"] == draft["id"])
+ .unwrap();
+ assert_eq!(listed["stale"], false, "{listed}");
+ assert_eq!(listed["state"], "draft");
+}
diff --git a/crates/graphicle/tests/it/offboard.rs b/crates/graphicle/tests/it/offboard.rs
new file mode 100644
index 0000000..4ecaad8
--- /dev/null
+++ b/crates/graphicle/tests/it/offboard.rs
@@ -0,0 +1,328 @@
+//! `graphicle offboard`: one project's data leaves the store, its graph
+//! cache and the data folder's backups, with a hash-chained receipt that
+//! lists what was removed. A second project stays, in the store and in the
+//! backups; nothing outside the data folder is touched; the plan changes
+//! nothing, and only the plan that was shown is carried out.
+// The symbolic and hard links in the backups folder are Unix fixtures.
+#![cfg(unix)]
+use graphicle_runtime::{
+ deletion, jobs, local, offboard,
+ store::{self, Store, s},
+ terminal::Style,
+};
+use serde_json::{Value, json};
+use std::path::{Path, PathBuf};
+use std::process::{Command, Stdio};
+use tempfile::TempDir;
+
+/// Tables keyed by workspace rather than by project.
+const WORKSPACE_TABLES: &[&str] = &["gf_dependencies", "gf_episode_labels"];
+
+struct Fixture {
+ _dir: TempDir,
+ store: Store,
+ session: local::Session,
+ root: PathBuf,
+}
+
+impl Fixture {
+ fn new() -> Self {
+ let dir = TempDir::new().unwrap();
+ let store = Store::open(dir.path().join("store")).unwrap();
+ let session = local::session(&store, true).unwrap();
+ let root = dir.path().canonicalize().unwrap().join("work");
+ std::fs::create_dir_all(&root).unwrap();
+ Self {
+ _dir: dir,
+ store,
+ session,
+ root,
+ }
+ }
+ /// A synced folder whose handbook carries `marker`.
+ fn project(&mut self, name: &str, marker: &str) -> String {
+ let folder = self.root.join(name);
+ std::fs::create_dir_all(&folder).unwrap();
+ std::fs::write(
+ folder.join("README.md"),
+ format!("# Handbook\n\nThe {marker} handbook for this client.\n"),
+ )
+ .unwrap();
+ std::fs::write(folder.join("app.py"), "def handler():\n return 1\n").unwrap();
+ let synced = local::sync(&self.store, &mut self.session, &folder, None).unwrap();
+ s(&synced, "repository_id").to_string()
+ }
+ /// Run every queued job as a worker would.
+ fn drain(&self) {
+ while let Some(job) = self.store.lease_job().unwrap() {
+ let result = match job.kind.as_str() {
+ "project" => jobs::run_projection(&self.store, &job),
+ "link" => jobs::run_link(&self.store, &job),
+ _ => Ok(json!({"skipped": true})),
+ };
+ self.store.finish_job(&job, result).unwrap();
+ }
+ }
+ /// `project`'s state, without the tables keyed by workspace (their
+ /// digests in a project's state cover every project's rows), and that
+ /// project's own rows of those tables.
+ fn state(&self, project: &str) -> (Value, Vec<String>) {
+ let mut state = self
+ .store
+ .read(|db| deletion::state(db, &self.session.workspace, project))
+ .unwrap();
+ let tables = state["tables"].as_object_mut().unwrap();
+ for table in WORKSPACE_TABLES {
+ tables.remove(*table);
+ }
+ state.as_object_mut().unwrap().remove("digest");
+ let workspace = &self.session.workspace;
+ let own = self
+ .store
+ .read(|db| {
+ let prefix = format!("{project}:");
+ let mut own = Vec::new();
+ for row in store::rows(
+ db,
+ "SELECT * FROM gf_dependencies WHERE workspace=?1 AND (substr(source_id,1,length(?2))=?2 OR substr(dependent_id,1,length(?2))=?2) ORDER BY source_id,dependent_id",
+ rusqlite::params![workspace, prefix],
+ )? {
+ own.push(row.to_string());
+ }
+ for row in store::rows(
+ db,
+ "SELECT * FROM gf_episode_labels WHERE workspace=?1 AND repo=?2",
+ rusqlite::params![workspace, project],
+ )? {
+ own.push(row.to_string());
+ }
+ Ok(own)
+ })
+ .unwrap();
+ assert!(!own.is_empty(), "{project} has dependency entries");
+ (state, own)
+ }
+ fn exists(&self, project: &str) -> bool {
+ self.store
+ .read(|db| {
+ Ok(db
+ .query_row(
+ "SELECT count(*) FROM repo_projects WHERE id=?",
+ [project],
+ |r| r.get::<_, i64>(0),
+ )
+ .unwrap()
+ == 1)
+ })
+ .unwrap()
+ }
+}
+
+fn sha(path: &Path) -> String {
+ graphicle_memory::text::sha256(&std::fs::read(path).unwrap())
+}
+
+fn holds(path: &Path, text: &str) -> bool {
+ let bytes = std::fs::read(path).unwrap();
+ bytes
+ .windows(text.len())
+ .any(|window| window == text.as_bytes())
+}
+
+/// The projects a store file holds.
+fn projects(path: &Path) -> Vec<String> {
+ let db = rusqlite::Connection::open(path).unwrap();
+ let mut statement = db
+ .prepare("SELECT id FROM repo_projects ORDER BY id")
+ .unwrap();
+ statement
+ .query_map([], |r| r.get::<_, String>(0))
+ .unwrap()
+ .map(Result::unwrap)
+ .collect()
+}
+
+fn paths(value: &Value) -> Vec<String> {
+ value
+ .as_array()
+ .into_iter()
+ .flatten()
+ .map(|entry| s(entry, "path").to_string())
+ .collect()
+}
+
+#[test]
+fn offboarding_removes_one_project_with_its_backups_and_keeps_the_other() {
+ crate::edition_setup();
+ let mut f = Fixture::new();
+ let a = f.project("client-a", "zebracorn-alpha-7731");
+ let b = f.project("client-b", "quokka-beta-5512");
+ f.drain();
+ let data = f.store.directory.canonicalize().unwrap();
+ for id in [&a, &b] {
+ let cache = data.join("gf-cache").join(id);
+ std::fs::create_dir_all(&cache).unwrap();
+ std::fs::write(cache.join("marker"), id.as_bytes()).unwrap();
+ }
+ // A backup in the data folder (`graphicle backup` without a path), and
+ // one written elsewhere and linked into the backups folder.
+ let backup = f
+ .store
+ .backup(&offboard::backup_path(&f.store).unwrap())
+ .unwrap();
+ let kept = PathBuf::from(s(&backup, "path"));
+ assert!(kept.starts_with(data.join(offboard::BACKUPS)), "{kept:?}");
+ let outside = f.root.join("elsewhere.sqlite3");
+ f.store.backup(&outside).unwrap();
+ let backups = data.join(offboard::BACKUPS);
+ std::os::unix::fs::symlink(&outside, backups.join("linked.sqlite3")).unwrap();
+ // One written elsewhere with a second name in the backups folder (a hard
+ // link): changing it would change the file outside too.
+ let hard = f.root.join("hard.sqlite3");
+ f.store.backup(&hard).unwrap();
+ std::fs::hard_link(&hard, backups.join("hard.sqlite3")).unwrap();
+ std::fs::write(backups.join("notes.txt"), "not a store").unwrap();
+ let name = format!(
+ "{}/{}",
+ offboard::BACKUPS,
+ kept.file_name().unwrap().to_str().unwrap()
+ );
+ let (kept_sha, outside_sha, hard_sha) = (sha(&kept), sha(&outside), sha(&hard));
+ assert!(holds(&kept, "zebracorn-alpha-7731") && holds(&kept, "quokka-beta-5512"));
+ let b_state = f.state(&b);
+
+ // The plan changes nothing and lists what would go.
+ let plan = offboard::plan(&f.store, &f.session, &a).unwrap();
+ assert_eq!(plan["dry_run"], true);
+ assert_eq!(plan["blocked"], false, "{plan:#}");
+ assert_eq!(plan["project"]["id"], json!(a));
+ assert!(
+ plan["store_rows"]["repo_objects"].as_i64().unwrap() > 0,
+ "{plan:#}"
+ );
+ assert_eq!(paths(&plan["backups"]), vec![name.clone()], "{plan:#}");
+ assert_eq!(plan["backups"][0]["other_projects"], 1);
+ assert_eq!(plan["backups"][0]["sha256"], json!(kept_sha));
+ assert!(paths(&plan["graph_cache"]).contains(&format!("gf-cache/{a}")));
+ assert_eq!(
+ paths(&plan["refused"]),
+ vec![
+ format!("{}/hard.sqlite3", offboard::BACKUPS),
+ format!("{}/linked.sqlite3", offboard::BACKUPS),
+ ],
+ "{plan:#}"
+ );
+ assert!(s(&plan["refused"][0], "reason").contains("hard link"));
+ assert_eq!(
+ paths(&plan["skipped"]),
+ vec![format!("{}/notes.txt", offboard::BACKUPS)]
+ );
+ let hash = s(&plan, "plan_hash").to_string();
+ assert_eq!(
+ s(&plan, "next"),
+ format!("graphicle offboard --project {a} --apply {hash}")
+ );
+ assert_eq!(sha(&kept), kept_sha);
+ assert!(f.exists(&a) && data.join("gf-cache").join(&a).exists());
+
+ // The command line shows the same plan, and changes nothing either.
+ let mut command = Command::new(env!("CARGO_BIN_EXE_graphicle"));
+ command
+ .current_dir(&f.root)
+ .arg("--data-dir")
+ .arg(f.store.directory.as_path())
+ .args(["offboard", "--project", &a, "--json"])
+ .stdin(Stdio::null())
+ .stdout(Stdio::piped())
+ .stderr(Stdio::piped());
+ let output = crate::fork_guard::spawn(&mut command)
+ .unwrap()
+ .wait_with_output()
+ .unwrap();
+ assert!(
+ output.status.success(),
+ "{}",
+ String::from_utf8_lossy(&output.stderr)
+ );
+ let shown: Value = serde_json::from_slice(&output.stdout).unwrap();
+ assert_eq!(shown["plan_hash"], json!(hash));
+ assert_eq!(sha(&kept), kept_sha);
+ assert!(f.exists(&a));
+
+ // A hash that is not the plan's changes nothing.
+ let refused = offboard::apply(&f.store, &f.session, &a, "not-the-plan").unwrap_err();
+ assert!(
+ refused.message.contains("plan changed"),
+ "{}",
+ refused.message
+ );
+ assert_eq!(sha(&kept), kept_sha);
+ assert!(f.exists(&a));
+
+ // Applied: the project leaves the store, its cache and the backup. The
+ // two links in the backups folder were refused and never changed, so
+ // they may still hold it: the offboarding is not verified, and says why.
+ let done = offboard::apply(&f.store, &f.session, &a, &hash).unwrap();
+ assert_eq!(done["offboarded"], true);
+ assert_eq!(done["verified"], false, "{done:#}");
+ assert_eq!(paths(&done["refused"]).len(), 2, "{done:#}");
+ let shown = offboard::text(&done, Style::plain());
+ assert!(shown.contains("NOT fully verified"), "{shown}");
+ assert!(
+ shown.contains("2 refused paths were not changed and may still hold the project"),
+ "{shown}"
+ );
+ let receipt = &done["receipt"];
+ assert_eq!(receipt["operation"], "project.delete");
+ assert_eq!(receipt["verified_local"], true, "{receipt:#}");
+ let listed = &receipt["removed"]["offboarding"];
+ assert_eq!(listed["plan_hash"], json!(hash));
+ assert_eq!(paths(&listed["backups"]), vec![name.clone()]);
+ assert_eq!(listed["backups"][0]["sha256_before"], json!(kept_sha));
+ assert_eq!(listed["backups"][0]["sha256_after"], json!(sha(&kept)));
+ assert_eq!(listed["backups"][0]["other_projects_kept"], 1);
+ assert_eq!(listed["backups"][0]["verified"], true);
+ assert!(paths(&listed["graph_cache"]).contains(&format!("gf-cache/{a}")));
+ let chain = deletion::list(&f.store, &f.session.workspace, &f.session.capability).unwrap();
+ assert_eq!(chain["chain"]["intact"], true, "{chain:#}");
+ assert_eq!(chain["chain"]["head"], receipt["digest"]);
+ assert!(!f.exists(&a));
+ assert!(!data.join("gf-cache").join(&a).exists());
+ assert_eq!(projects(&kept), vec![b.clone()]);
+ assert!(!holds(&kept, "zebracorn-alpha-7731"));
+
+ // The other project stays: in the store, its cache and the backup.
+ assert!(f.exists(&b));
+ assert_eq!(f.state(&b), b_state);
+ assert!(data.join("gf-cache").join(&b).join("marker").exists());
+ assert!(holds(&kept, "quokka-beta-5512"));
+
+ // Nothing outside the data folder was touched.
+ assert_eq!(sha(&outside), outside_sha);
+ assert!(projects(&outside).contains(&a));
+ assert_eq!(sha(&hard), hard_sha);
+ assert!(projects(&hard).contains(&a));
+ assert!(std::fs::symlink_metadata(backups.join("linked.sqlite3")).is_ok());
+
+ // The project is gone: there is nothing left to plan.
+ assert!(offboard::plan(&f.store, &f.session, &a).is_err());
+
+ // Without the links, nothing is refused: offboarding the other project
+ // removes it from the store and the backup, verified.
+ std::fs::remove_file(backups.join("linked.sqlite3")).unwrap();
+ std::fs::remove_file(backups.join("hard.sqlite3")).unwrap();
+ let plan = offboard::plan(&f.store, &f.session, &b).unwrap();
+ assert_eq!(plan["refused"], json!([]), "{plan:#}");
+ assert_eq!(paths(&plan["backups"]), vec![name.clone()], "{plan:#}");
+ let done = offboard::apply(&f.store, &f.session, &b, s(&plan, "plan_hash")).unwrap();
+ assert_eq!(done["verified"], true, "{done:#}");
+ let shown = offboard::text(&done, Style::plain());
+ assert!(shown.contains(", verified."), "{shown}");
+ assert!(!shown.contains("may still hold"), "{shown}");
+ assert!(!f.exists(&b));
+ assert_eq!(projects(&kept), Vec::<String>::new());
+ assert!(!holds(&kept, "quokka-beta-5512"));
+ // Outside the data folder, still nothing changed.
+ assert_eq!(sha(&outside), outside_sha);
+ assert_eq!(sha(&hard), hard_sha);
+}
diff --git a/crates/graphicle/tests/it/one_server.rs b/crates/graphicle/tests/it/one_server.rs
index f1f9924..093a876 100644
--- a/crates/graphicle/tests/it/one_server.rs
+++ b/crates/graphicle/tests/it/one_server.rs
@@ -21,7 +21,7 @@ use graphicle_runtime::platform::CanonicalExt;
use graphicle_runtime::{
api::{self, App, McpOptions, ToolSet},
extension::McpTool,
- graph_projection, graph_tools, jobs, model,
+ graph_projection, graph_tools, jobs, model, query,
store::{Store, s},
};
use serde_json::{Value, json};
@@ -878,9 +878,9 @@ fn server_fixed_switches_apply_are_reported_and_cannot_be_overridden() {
assert!(refused.contains("doc_links is fixed to false"), "{refused}");
let refused = api::fixed_switches(&["code_graph=false".into()]).unwrap_err();
assert!(
- refused
- .message
- .contains("the server fixes graph_retrieval, memory_retrieval and doc_links"),
+ refused.message.contains(
+ "the server fixes graph_retrieval, memory_retrieval, doc_links, symbol_links, cross_repo, notes_first, identifier_route, code_first, query_focus, identifier_arm, more_files and scope"
+ ),
"{}",
refused.message
);
@@ -980,20 +980,24 @@ fn a_tool_set_serves_one_half_of_the_server() {
assert!(refused.contains("Tool unavailable"), "{refused}");
}
-/// The 0.1.0 server, frozen: `graphicle mcp --project . --allow-learning`
-/// (what setup writes for every client but Claude Code, and for Claude Code
-/// with `--tools all`) initializes and lists exactly this (an edition adds
-/// its tools after these).
+/// The 0.1.0 server, frozen but for 0.1.4's routing (a sentence on when to
+/// call recall and the code graph and when grep is enough first in the
+/// instructions, and one on when to use it instead of grep at the end of
+/// each search tool's description): `graphicle mcp --project .
+/// --allow-learning` (what setup writes for every client but Claude Code,
+/// and for Claude Code with `--tools all`) initializes and lists exactly
+/// this (an edition adds its tools after these).
const FROZEN_ALL: &str = include_str!("../fixtures/one_server_tools.json");
-/// What setup gives Claude Code (`--tools essentials`): five tools and one
-/// sentence of instructions.
+/// What setup gives Claude Code (`--tools essentials`): five tools and short
+/// instructions on when to call them and when grep is enough.
const FROZEN_ESSENTIALS: &str = include_str!("../fixtures/one_server_essentials_tools.json");
-/// The whole server (`--tools all`) is 0.1.0's, byte for byte. The
-/// essentials are the five tools setup gives Claude Code: the whole server's
-/// schemas, descriptions that start with what an agent searches for and
-/// carry the citation details, and one sentence of instructions; they
-/// answer, the other tools do not, and the server's opt-ins add their tools.
+/// The whole server (`--tools all`) is 0.1.0's but for the routing
+/// sentences. The essentials are the five tools setup gives Claude Code:
+/// the whole server's schemas, descriptions that start with what an agent
+/// searches for and carry the citation details, and short instructions;
+/// they answer, the other tools do not, and the server's opt-ins add their
+/// tools.
#[test]
fn all_is_the_0_1_0_server_and_the_essentials_are_five_tools() {
let f = Fixture::new(&[("a.py", A), ("b.py", B)]);
@@ -2095,3 +2099,437 @@ fn serve_publishes_its_tool_set_and_fixed_switches_over_http() {
assert_eq!(unpublished["error"]["message"], "Tool unavailable");
drop(server);
}
+
+/// Conformance (the integration switches): every recall packet echoes the
+/// switches in force (`mechanisms.switches`), whether a request set them,
+/// the server fixed them or they kept their defaults; `cross_repo` and
+/// `scope` are fixed like the others; an unknown switch is refused, never
+/// ignored, by `--set` and in a request.
+#[test]
+fn conformance_switches_are_echoed_fixed_and_never_ignored() {
+ let f = Fixture::new(&[("a.py", A), ("b.py", B)]);
+ let app = f.app();
+ let recall = |app: &App, arguments: Value| {
+ call(&f, app, "recall_project", arguments).map(|r| r["structuredContent"].clone())
+ };
+ let packet = recall(&app, json!({"question":"who calls beta"})).unwrap();
+ assert_eq!(
+ packet["mechanisms"]["switches"],
+ json!({"graph_retrieval":true,"memory_retrieval":true,"doc_links":"counted",
+ "symbol_links":"counted","cross_repo":true,"notes_first":false,
+ "identifier_route":false,"code_first":"auto","query_focus":"auto",
+ "identifier_arm":"auto","more_files":"auto","scope":"project"})
+ );
+ let packet = recall(
+ &app,
+ json!({"question":"who calls beta","graph_retrieval":false,"doc_links":true,
+ "symbol_links":false,"cross_repo":false,"notes_first":true}),
+ )
+ .unwrap();
+ assert_eq!(
+ packet["mechanisms"]["switches"],
+ json!({"graph_retrieval":false,"memory_retrieval":true,"doc_links":true,
+ "symbol_links":false,"cross_repo":false,"notes_first":true,
+ "identifier_route":false,"code_first":"auto","query_focus":"auto",
+ "identifier_arm":"auto","more_files":"auto","scope":"project"})
+ );
+ // `cross_repo` follows `graph_retrieval` when left out.
+ let packet = recall(
+ &app,
+ json!({"question":"who calls beta","graph_retrieval":false}),
+ )
+ .unwrap();
+ assert_eq!(packet["mechanisms"]["switches"]["cross_repo"], false);
+ // The essentials set builds 0.1.2's packet unless a call turns
+ // `notes_first` on; `--tools all` keeps 0.1.0's windows whatever it says.
+ let mut essentials = f.app();
+ essentials.mcp.tools = ToolSet::Essentials;
+ let plain = recall(&essentials, json!({"question":"who calls beta"})).unwrap();
+ assert_eq!(
+ plain["notes_first"],
+ json!({"status":"off","defaulted":true}),
+ "{}",
+ plain["notes_first"]
+ );
+ assert_eq!(plain["source_age"]["status"], "disabled");
+ let first = recall(
+ &essentials,
+ json!({"question":"who calls beta","notes_first":true}),
+ )
+ .unwrap();
+ assert_eq!(
+ first["notes_first"]["status"], "reranked",
+ "{}",
+ first["notes_first"]
+ );
+ assert_eq!(first["notes_first"]["defaulted"], false);
+ assert_eq!(first["mechanisms"]["switches"]["notes_first"], true);
+ let all = recall(
+ &app,
+ json!({"question":"who calls beta","notes_first":true}),
+ )
+ .unwrap();
+ assert_eq!(all["notes_first"]["status"], "windows_as_ranked");
+ // Fixed by the server: echoed, listed under `server_fixed`, and a request
+ // for another value is refused.
+ let mut fixed = f.app();
+ fixed.mcp.fixed = api::fixed_switches(&[
+ "graph_retrieval=false".into(),
+ "memory_retrieval=false".into(),
+ "doc_links=false".into(),
+ "symbol_links=false".into(),
+ "cross_repo=false".into(),
+ "notes_first=true".into(),
+ "scope=project".into(),
+ ])
+ .unwrap();
+ let packet = recall(&fixed, json!({"question":"who calls beta"})).unwrap();
+ assert_eq!(
+ packet["mechanisms"]["switches"],
+ json!({"graph_retrieval":false,"memory_retrieval":false,"doc_links":false,
+ "symbol_links":false,"cross_repo":false,"notes_first":true,
+ "identifier_route":false,"code_first":"auto","query_focus":"auto",
+ "identifier_arm":"auto","more_files":"auto","scope":"project"})
+ );
+ assert_eq!(packet["mechanisms"]["server_fixed"]["cross_repo"], false);
+ assert_eq!(packet["mechanisms"]["server_fixed"]["notes_first"], true);
+ assert_eq!(packet["mechanisms"]["server_fixed"]["scope"], "project");
+ for (switch, other) in [
+ ("cross_repo", json!(true)),
+ ("symbol_links", json!(true)),
+ ("notes_first", json!(false)),
+ ("scope", json!("workspace")),
+ ] {
+ let refused =
+ recall(&fixed, json!({"question":"who calls beta", switch: other})).unwrap_err();
+ assert!(refused.contains("fixed to"), "{switch}: {refused}");
+ }
+ // Unknown names and values are refused, by `--set` and in a request.
+ for bad in [
+ "code_graph=false",
+ "cross_repo=maybe",
+ "notes_first=yes",
+ "scope=everything",
+ "scope=true",
+ "links=true",
+ ] {
+ assert!(api::fixed_switches(&[bad.into()]).is_err(), "{bad}");
+ }
+ let refused = api::fixed_switches(&["links=true".into()]).unwrap_err();
+ assert!(
+ refused.message.contains(
+ "the server fixes graph_retrieval, memory_retrieval, doc_links, symbol_links, cross_repo, notes_first, identifier_route, code_first, query_focus, identifier_arm, more_files and scope"
+ ),
+ "{}",
+ refused.message
+ );
+ let refused = recall(
+ &app,
+ json!({"question":"who calls beta","code_graph":false}),
+ )
+ .unwrap_err();
+ assert!(refused.contains("published contract"), "{refused}");
+ let refused = recall(&app, json!({"question":"who calls beta","cross_repo":"no"})).unwrap_err();
+ assert!(
+ refused.contains("cross_repo must be true or false"),
+ "{refused}"
+ );
+ // The code-question switches: taken beside the published arguments,
+ // fixed by `--set`, and refused outside their values.
+ let packet = recall(
+ &app,
+ json!({"question":"who calls beta","code_first":false,"query_focus":"auto",
+ "identifier_arm":true,"more_files":3}),
+ )
+ .unwrap();
+ let switches = &packet["mechanisms"]["switches"];
+ assert_eq!(switches["code_first"], false, "{switches}");
+ assert_eq!(switches["query_focus"], "auto");
+ assert_eq!(switches["identifier_arm"], true);
+ assert_eq!(switches["more_files"], 3);
+ assert_eq!(packet["code_first"]["applied"], false);
+ for (switch, bad, takes) in [
+ ("code_first", json!("maybe"), "true, false or auto"),
+ ("query_focus", json!(1), "true, false or auto"),
+ ("more_files", json!(41), "a number from 0 to 40"),
+ ] {
+ let refused = recall(&app, json!({"question":"who calls beta", switch: bad})).unwrap_err();
+ assert!(
+ refused.contains(&format!("{switch} must be {takes}")),
+ "{refused}"
+ );
+ }
+ let mut chosen = f.app();
+ chosen.mcp.fixed = api::fixed_switches(&[
+ "code_first=false".into(),
+ "identifier_arm=auto".into(),
+ "more_files=0".into(),
+ ])
+ .unwrap();
+ let packet = recall(&chosen, json!({"question":"who calls beta"})).unwrap();
+ assert_eq!(packet["mechanisms"]["switches"]["code_first"], false);
+ assert_eq!(packet["mechanisms"]["switches"]["identifier_arm"], "auto");
+ assert_eq!(packet["mechanisms"]["switches"]["more_files"], 0);
+ for bad in [
+ "code_first=maybe",
+ "more_files=41",
+ "more_files=-1",
+ "query_focus=yes",
+ ] {
+ assert!(api::fixed_switches(&[bad.into()]).is_err(), "{bad}");
+ }
+ // A server that fixes the scope to the workspace serves no project
+ // connection.
+ let mut whole = f.app();
+ whole.mcp.fixed = api::fixed_switches(&["scope=workspace".into()]).unwrap();
+ let refused = recall(&whole, json!({"question":"who calls beta"})).unwrap_err();
+ assert!(refused.contains("fixes scope to workspace"), "{refused}");
+}
+
+/// Conformance (the manifest): `graphicle mcp --manifest` records the
+/// program (version, edition, sha256), the tools a connection lists with
+/// their hash, the switches the server fixes and those a request may set,
+/// and the schema and format versions. Fixing a switch changes the
+/// switches, not the tools.
+#[test]
+fn conformance_the_manifest_records_program_tools_switches_and_schemas() {
+ let f = Fixture::new(&[("a.py", A)]);
+ let mut app = f.app();
+ app.mcp.fixed =
+ api::fixed_switches(&["doc_links=false".into(), "scope=project".into()]).unwrap();
+ let manifest = api::manifest(&app, &f.workspace, &f.key, Some(&f.repo)).unwrap();
+ assert_eq!(manifest["format"], api::MANIFEST_FORMAT);
+ // The runtime's version, as `initialize` reports it (a test built in
+ // another crate has that crate's version).
+ let initialized = rpc(&f, &app, &f.key, "initialize", json!({}));
+ assert_eq!(
+ manifest["program"]["version"],
+ initialized["result"]["serverInfo"]["version"]
+ );
+ assert_eq!(
+ manifest["program"]["sha256"].as_str().map(str::len),
+ Some(64),
+ "{manifest}"
+ );
+ assert_eq!(manifest["connection"], "project");
+ let listed = rpc(&f, &app, &f.key, "tools/list", json!({}));
+ let listed: BTreeSet<String> = names(&listed["result"]).into_iter().collect();
+ let recorded: BTreeSet<String> = manifest["tools"]["names"]
+ .as_array()
+ .unwrap()
+ .iter()
+ .map(|name| name.as_str().unwrap().to_string())
+ .collect();
+ assert_eq!(recorded, listed);
+ assert_eq!(
+ manifest["switches"]["server_fixed"],
+ json!({"doc_links":false,"scope":"project"})
+ );
+ assert_eq!(
+ manifest["switches"]["request"],
+ json!([
+ "graph_retrieval",
+ "memory_retrieval",
+ "doc_links",
+ "symbol_links",
+ "cross_repo",
+ "notes_first",
+ "identifier_route",
+ "code_first",
+ "query_focus",
+ "identifier_arm",
+ "more_files",
+ "scope"
+ ])
+ );
+ assert_eq!(
+ manifest["switches"]["notes_first_default"],
+ query::NOTES_FIRST_DEFAULT
+ );
+ for field in [
+ "compiled_sha256",
+ "deletion",
+ "state",
+ "export",
+ "template",
+ "cross_link_state",
+ ] {
+ assert!(
+ manifest["schemas"][field].is_string(),
+ "{field}: {manifest}"
+ );
+ }
+ assert!(manifest["schemas"]["store"]["tables"].as_u64().unwrap() > 10);
+ assert!(manifest["retrieval_defaults"].is_object(), "{manifest}");
+ let plain = api::manifest(&f.app(), &f.workspace, &f.key, Some(&f.repo)).unwrap();
+ assert_eq!(plain["tools"]["sha256"], manifest["tools"]["sha256"]);
+ assert_eq!(plain["schemas"], manifest["schemas"]);
+ assert_ne!(plain["switches"], manifest["switches"]);
+}
+
+/// The identifier route: a question that is an identifier, or only asks
+/// where named identifiers are defined or used, gets their definitions and
+/// references from the code graph as path:line lines, in the essentials set
+/// and through `context`, within the budget. A question in plain words, one
+/// that asks more about a name, and a name the code graph does not define
+/// in the caller's view keep the retrieval; so do `identifier_route: false`
+/// and the whole server unless a call asks for the route. The packet's
+/// `route` says which path ran.
+#[test]
+fn identifier_questions_take_the_code_graph_route() {
+ let f = Fixture::new(&[("a.py", A), ("b.py", B)]);
+ let mut essentials = f.app();
+ essentials.mcp.tools = ToolSet::Essentials;
+ let recall = |app: &App, arguments: Value| {
+ call(&f, app, "recall_project", arguments)
+ .map(|r| r["structuredContent"].clone())
+ .unwrap()
+ };
+ // An identifier alone: its definition in a.py and its uses in b.py.
+ let packet = recall(&essentials, json!({"question":"`beta`"}));
+ assert_eq!(packet["route"]["path"], "identifier", "{packet:#}");
+ assert_eq!(packet["route"]["defaulted"], true);
+ assert_eq!(packet["mechanisms"]["switches"]["identifier_route"], true);
+ let symbol = &packet["symbols"][0];
+ assert_eq!(symbol["name"], "beta");
+ assert_eq!(symbol["definitions"][0]["relpath"], "a.py", "{symbol:#}");
+ assert_eq!(symbol["definitions"][0]["line"], 4, "{symbol:#}");
+ assert!(
+ symbol["references"]
+ .as_array()
+ .unwrap()
+ .iter()
+ .any(|reference| reference["relpath"] == "b.py"),
+ "{symbol:#}"
+ );
+ let markdown = s(&packet, "markdown");
+ assert!(markdown.contains("a.py:4"), "{markdown}");
+ assert!(markdown.contains("- reference b.py:"), "{markdown}");
+ assert!(packet["sources"].as_array().unwrap().is_empty());
+ assert!(packet["tokens"].as_u64() <= packet["max_tokens"].as_u64());
+ // The default reply is that text and nothing else.
+ let reply = rpc(
+ &f,
+ &essentials,
+ &f.key,
+ "tools/call",
+ json!({"name":"recall_project","arguments":{"question":"`beta`"}}),
+ );
+ assert!(
+ reply["result"].get("structuredContent").is_none(),
+ "{reply}"
+ );
+ assert_eq!(reply["result"]["content"][0]["text"], packet["markdown"]);
+ // Mixed: names with words that only ask where they are and who uses
+ // them take the route; words that ask more keep the retrieval.
+ for question in [
+ "Where is `alpha` defined, and who calls it?",
+ "who calls alpha() and beta()",
+ "find the callers of run()",
+ ] {
+ let packet = recall(&essentials, json!({"question":question}));
+ assert_eq!(
+ packet["route"]["path"], "identifier",
+ "{question}: {packet:#}"
+ );
+ }
+ let both = recall(
+ &essentials,
+ json!({"question":"who calls alpha() and beta()"}),
+ );
+ assert_eq!(both["route"]["names"], json!(["alpha", "beta"]));
+ let more = recall(
+ &essentials,
+ json!({"question":"how does `run` add alpha and beta together"}),
+ );
+ assert_eq!(more["route"]["path"], "retrieval");
+ assert_eq!(more["route"]["reason"], "asks_more");
+ assert_eq!(more["route"]["names"], json!(["run"]));
+ assert!(!more["sources"].as_array().unwrap().is_empty(), "{more:#}");
+ // Content, outgoing calls and mentions keep it too.
+ for question in [
+ "what is `beta` used for",
+ "callees of run()",
+ "show me the code of run()",
+ ] {
+ let packet = recall(&essentials, json!({"question":question}));
+ assert_eq!(packet["route"]["reason"], "asks_more", "{question}");
+ }
+ // Plain words, a name the code graph does not define, the switch, and
+ // a call that names needs.
+ for (arguments, reason) in [
+ (json!({"question":"who calls beta"}), "plain_words"),
+ (json!({"question":"`gamma_delta`"}), "not_in_code_graph"),
+ (json!({"question":"`beta`","identifier_route":false}), "off"),
+ (
+ json!({"question":"`beta`","needs":["the return value"]}),
+ "needs",
+ ),
+ ] {
+ let packet = recall(&essentials, arguments.clone());
+ assert_eq!(packet["route"]["path"], "retrieval", "{arguments}");
+ assert_eq!(packet["route"]["reason"], reason, "{arguments}");
+ }
+ // The whole server keeps 0.1.0's recall unless a call asks for the route.
+ let all = f.app();
+ let packet = recall(&all, json!({"question":"`beta`"}));
+ assert_eq!(packet["route"]["reason"], "off");
+ assert_eq!(packet["route"]["defaulted"], true);
+ let packet = recall(&all, json!({"question":"`beta`","identifier_route":true}));
+ assert_eq!(packet["route"]["path"], "identifier");
+ // `context` (the HTTP API, the SDKs, the app's evidence button): the
+ // retrieval unless a call asks for the route; the route's packet has no
+ // evidence, and cites only within the caller's view (`include`).
+ let context = |arguments: Value| {
+ let mut arguments = arguments;
+ arguments["repository_id"] = json!(f.repo);
+ f.store
+ .project_context(&f.workspace, &f.key, &arguments)
+ .unwrap()
+ };
+ let packet = context(json!({"question":"beta()"}));
+ assert_eq!(packet["route"]["reason"], "off", "{packet:#}");
+ assert_eq!(packet["route"]["defaulted"], true);
+ assert!(!packet["evidence"].as_array().unwrap().is_empty());
+ let packet = context(json!({"question":"beta()","identifier_route":true}));
+ assert_eq!(packet["route"]["path"], "identifier", "{packet:#}");
+ assert_eq!(packet["evidence"], json!([]));
+ let packet = context(json!({"question":"beta()","identifier_route":true,
+ "include":["file:b.py"]}));
+ assert_eq!(packet["route"]["reason"], "not_in_code_graph", "{packet:#}");
+ let packet = context(json!({"question":"how is the sum returned","identifier_route":true}));
+ assert_eq!(packet["route"]["reason"], "plain_words");
+}
+
+/// Within the budget: past it, the route lists what fits and counts the
+/// rest.
+#[test]
+fn the_identifier_route_keeps_to_the_budget() {
+ let many: String = std::iter::once("from a import beta\n\n".to_string())
+ .chain((0..300).map(|i| format!("def caller_{i}():\n return beta()\n\n")))
+ .collect();
+ let f = Fixture::new(&[("a.py", A), ("c.py", &many)]);
+ let packet = f
+ .store
+ .project_context(
+ &f.workspace,
+ &f.key,
+ &json!({"repository_id":f.repo,"question":"`beta`","max_tokens":256,"max_chars":2000,
+ "identifier_route":true}),
+ )
+ .unwrap();
+ assert_eq!(packet["route"]["path"], "identifier", "{packet:#}");
+ assert!(packet["characters"].as_u64().unwrap() <= 2000, "{packet:#}");
+ assert!(packet["tokens"].as_u64().unwrap() <= 256, "{packet:#}");
+ assert!(
+ packet["symbols"][0]["reference_count"].as_u64().unwrap() > 100,
+ "{packet:#}"
+ );
+ assert!(
+ packet["omitted"]["definitions_and_references"]
+ .as_u64()
+ .unwrap()
+ > 0
+ );
+ assert!(s(&packet, "markdown").contains("Budget: 256"));
+}
diff --git a/crates/graphicle/tests/it/permissions_refresh.rs b/crates/graphicle/tests/it/permissions_refresh.rs
index d36eca7..f475e78 100644
--- a/crates/graphicle/tests/it/permissions_refresh.rs
+++ b/crates/graphicle/tests/it/permissions_refresh.rs
@@ -143,6 +143,54 @@ async fn provider_permission_work_waits_for_graphicle_pro() {
assert_eq!(info(&store)["provider_permission_sync"], false);
}
+/// Jira and Confluence provider sharing, and connector kinds the core does
+/// not have, need an installed extension that provides them: without one,
+/// they are refused with the errors Core always gave. Jira and Confluence
+/// identities are Atlassian accounts in every edition.
+#[test]
+fn provider_sharing_and_added_connector_kinds_need_an_extension() {
+ let (_dir, store, w, key, r, _connector) = provider_store();
+ let credential = store
+ .put_credential(
+ &w,
+ &key,
+ &json!({"name":"Provider token","value":"fixture-only-access"}),
+ )
+ .unwrap();
+ let acl = json!({"workspace_readers":true,"credentials":[]});
+ let jira = store.connector_add(&w,&key,&json!({"repository_id":r,"name":"Jira","kind":"jira","credential_ref":credential["credential_ref"],
+ "config":{"base_url":"https://example.atlassian.net","site_url":"https://example.atlassian.net","auth_type":"bearer",
+ "jql":"project = OPS","permission_mode":"provider","acl":acl}}));
+ let added = store.connector_add(&w,&key,&json!({"repository_id":r,"name":"Added","kind":"no_such_kind","credential_ref":credential["credential_ref"],
+ "config":{"acl":acl}}));
+ let mut config = model::Config::default();
+ config
+ .connector_endpoints
+ .insert("no_such_kind".into(), "http://127.0.0.1:9/v1".into());
+ let synced = graphicle_runtime::connectors::provider_permission_kinds();
+ if synced.iter().any(|kind| kind == "jira") {
+ jira.unwrap();
+ } else {
+ assert_eq!(
+ jira.unwrap_err().message,
+ "This provider does not expose the required source ACL API; use explicit sharing"
+ );
+ }
+ if graphicle_runtime::extension::installed().is_empty() {
+ assert!(synced.is_empty());
+ }
+ assert_eq!(added.unwrap_err().message, "Unsupported source connector");
+ assert_eq!(
+ config.validate().unwrap_err().message,
+ "Unknown connector endpoint"
+ );
+ let provider = graphicle_runtime::connectors::identity_provider;
+ assert_eq!(provider("jira"), "atlassian");
+ assert_eq!(provider("confluence"), "atlassian");
+ assert_eq!(provider("gdrive"), "gdrive");
+ assert_eq!(provider("no_such_kind"), "no_such_kind");
+}
+
#[test]
fn portable_backup_excludes_encrypted_credentials_and_pauses_their_connections() {
crate::edition_setup();
diff --git a/crates/graphicle/tests/it/product_workspace.rs b/crates/graphicle/tests/it/product_workspace.rs
index 47b06e9..4dbc196 100644
--- a/crates/graphicle/tests/it/product_workspace.rs
+++ b/crates/graphicle/tests/it/product_workspace.rs
@@ -193,6 +193,255 @@ async fn v1_binds_authority_and_usage_is_owner_only() {
);
}
+/// One request with optional extra headers: status, headers and the raw body
+/// (the exact text the server served).
+async fn raw(
+ app: &Router,
+ path: &str,
+ cap: &str,
+ body: Value,
+ extra: &[(&str, &str)],
+) -> (StatusCode, axum::http::HeaderMap, String) {
+ let mut req = Request::builder()
+ .method("POST")
+ .uri(path)
+ .header("host", "localhost")
+ .header("content-type", "application/json")
+ .header("x-workspace-capability", cap);
+ for (name, value) in extra {
+ req = req.header(*name, *value);
+ }
+ let response = app
+ .clone()
+ .oneshot(req.body(Body::from(body.to_string())).unwrap())
+ .await
+ .unwrap();
+ let (status, headers) = (response.status(), response.headers().clone());
+ let bytes = axum::body::to_bytes(response.into_body(), 8 * 1024 * 1024)
+ .await
+ .unwrap();
+ (status, headers, String::from_utf8(bytes.to_vec()).unwrap())
+}
+
+/// What Graphicle serves is metered (`graphicle_runtime::metering`): the
+/// tokens of the text served, counted with cl100k_base, per credential, agent
+/// session, channel and tool or operation. The owner's usage report lists
+/// them beside the recorded model tokens, with no cost. An MCP HTTP client's
+/// agent session is the `Mcp-Session-Id` issued and signed at `initialize`;
+/// an id the server did not sign shares one label. Requests and results
+/// themselves are never stored.
+#[tokio::test]
+async fn served_tokens_are_reported_per_credential_and_agent_session() {
+ let f = Fixture::new();
+ let app = f.app();
+ f.sync("def authenticate():\n return 'rotate keys every Friday'\n");
+ let agent = f
+ .store
+ .grant(
+ &f.workspace,
+ &f.owner,
+ &json!({"role":"agent","label":"Build agent"}),
+ )
+ .unwrap();
+ let key = s(&agent, "capability");
+ let question = "How does authenticate rotate keys?";
+ let (status, _, body) = raw(
+ &app,
+ &f.command_url(),
+ key,
+ json!({"operation":"context","arguments":{"question":question}}),
+ &[],
+ )
+ .await;
+ assert_eq!(status, StatusCode::OK, "{body}");
+ let http_tokens = graphicle_memory::text::count(&body) as u64;
+ // `memories` returns the project's memory rows: metered, as the
+ // `project_memory` tool that runs it.
+ let (status, _, body) = raw(
+ &app,
+ &f.command_url(),
+ key,
+ json!({"operation":"memories"}),
+ &[],
+ )
+ .await;
+ assert_eq!(status, StatusCode::OK);
+ let memories_tokens = graphicle_memory::text::count(&body) as u64;
+ // An operation that returns only counts is not metered.
+ let (status, _, _) = raw(
+ &app,
+ &f.command_url(),
+ key,
+ json!({"operation":"observer.status","arguments":{"include":["file:"]}}),
+ &[],
+ )
+ .await;
+ assert_eq!(status, StatusCode::OK);
+ let mcp = format!("/mcp/{}/{}", f.workspace, f.repo);
+ let (status, headers, body) = raw(
+ &app,
+ &mcp,
+ key,
+ json!({"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-06-18","capabilities":{},"clientInfo":{"name":"Test Agent","version":"1.0"}}}),
+ &[],
+ )
+ .await;
+ assert_eq!(status, StatusCode::OK, "{body}");
+ let session = headers["mcp-session-id"].to_str().unwrap().to_string();
+ let (signed, signature) = session.rsplit_once('.').unwrap();
+ let random = signed.strip_prefix("testagent.").unwrap();
+ assert_eq!((random.len(), signature.len()), (32, 64), "{session}");
+ let (status, _, body) = raw(
+ &app,
+ &mcp,
+ key,
+ json!({"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"recall_project","arguments":{"question":question}}}),
+ &[("mcp-session-id", &session)],
+ )
+ .await;
+ assert_eq!(status, StatusCode::OK, "{body}");
+ let reply: Value = serde_json::from_str(&body).unwrap();
+ assert_eq!(reply["result"]["isError"], false, "{reply}");
+ let mcp_tokens =
+ graphicle_memory::text::count(s(&reply["result"]["content"][0], "text")) as u64;
+ assert!(http_tokens > 0 && mcp_tokens > 0 && memories_tokens > 0);
+ // A session id the server did not sign: one shared label, whatever the
+ // client sends, so it cannot add a counter row per call.
+ for forged in [
+ "testagent.0123456789abcdef0123456789abcdef",
+ "my-own-session",
+ ] {
+ let (status, _, body) = raw(
+ &app,
+ &mcp,
+ key,
+ json!({"jsonrpc":"2.0","id":3,"method":"tools/call","params":{"name":"repository_status","arguments":{}}}),
+ &[("mcp-session-id", forged)],
+ )
+ .await;
+ assert_eq!(status, StatusCode::OK, "{body}");
+ }
+
+ // Results are counted on threads of their own, and a usage report does
+ // not wait for them: record them first.
+ graphicle_runtime::metering::flush(&f.store).unwrap();
+ let (status, usage, _) = call(&app, &format!("{}/usage", f.base()), &f.owner, None).await;
+ assert_eq!(status, StatusCode::OK, "{usage}");
+ assert_eq!(usage["cost"], Value::Null, "no price table: no cost");
+ let served = &usage["served"];
+ assert_eq!(served["counted_with"], "cl100k_base");
+ assert_eq!(served["calls"], 5, "{served:#}");
+ assert_eq!(served["unrecorded_tokens"], 0);
+ let mut kinds: Vec<(String, String, u64)> = served["by_kind"]
+ .as_array()
+ .unwrap()
+ .iter()
+ .map(|row| {
+ (
+ s(row, "channel").to_string(),
+ s(row, "kind").to_string(),
+ row["tokens"].as_u64().unwrap(),
+ )
+ })
+ .collect();
+ kinds.sort();
+ let status_tokens = kinds
+ .iter()
+ .find(|(_, kind, _)| kind == "repository_status")
+ .map(|row| row.2)
+ .unwrap_or_default();
+ assert!(status_tokens > 0, "{kinds:?}");
+ assert_eq!(
+ served["tokens"].as_u64(),
+ Some(http_tokens + memories_tokens + mcp_tokens + status_tokens)
+ );
+ assert_eq!(
+ kinds,
+ [
+ ("http".to_string(), "context".to_string(), http_tokens),
+ ("http".to_string(), "memories".to_string(), memories_tokens),
+ ("mcp".to_string(), "recall_project".to_string(), mcp_tokens),
+ (
+ "mcp".to_string(),
+ "repository_status".to_string(),
+ status_tokens
+ ),
+ ]
+ );
+ let credentials = served["by_credential"].as_array().unwrap();
+ assert_eq!(credentials.len(), 1, "{credentials:?}");
+ assert_eq!(credentials[0]["credential_id"], agent["id"]);
+ assert_eq!(credentials[0]["label"], "Build agent");
+ assert_eq!(credentials[0]["role"], "agent");
+ let mut sessions: Vec<(String, u64, u64)> = served["by_session"]
+ .as_array()
+ .unwrap()
+ .iter()
+ .map(|row| {
+ assert_eq!(row["credential_id"], agent["id"]);
+ (
+ s(row, "session").to_string(),
+ row["calls"].as_u64().unwrap(),
+ row["tokens"].as_u64().unwrap(),
+ )
+ })
+ .collect();
+ sessions.sort();
+ assert_eq!(
+ sessions,
+ [
+ ("mcp:unverified".to_string(), 2, status_tokens),
+ (format!("testagent:{}", &random[..12]), 1, mcp_tokens),
+ ]
+ );
+ assert_eq!(served["by_project"][0]["repository_id"], json!(f.repo));
+ assert!(usage["model_usage_by_credential"].is_array());
+ assert!(usage["model_usage_by_model"].is_array());
+ // Counters only: never the question, a result or the client's session id.
+ let stored = graphicle_runtime::store::rows(
+ &f.store.connect().unwrap(),
+ "SELECT * FROM am_served_usage",
+ [],
+ )
+ .unwrap();
+ let stored = json!(stored).to_string();
+ assert!(
+ !stored.contains("authenticate") && !stored.contains(&session),
+ "{stored}"
+ );
+ // Graphicle's own model calls, by the credential that queued the job and
+ // by model: tokens, and still no cost.
+ let db = f.store.connect().unwrap();
+ let stamp = graphicle_runtime::now();
+ db.execute(
+ "INSERT INTO am_jobs(id,repository_id,kind,input_hash,payload,principal_hash,state,not_before,created_at,updated_at)
+ VALUES('job-1',?,'answer','job-1','{}',?,'complete',?,?,?)",
+ rusqlite::params![
+ f.repo,
+ graphicle_memory::text::sha256(key.as_bytes()),
+ stamp,
+ stamp,
+ stamp
+ ],
+ )
+ .unwrap();
+ db.execute(
+ "INSERT INTO am_model_calls VALUES('call-1',?,'job-1','openai','gpt-test','h',1200,300,0,0,?)",
+ rusqlite::params![f.repo, stamp],
+ )
+ .unwrap();
+ let (_, usage, _) = call(&app, &format!("{}/usage", f.base()), &f.owner, None).await;
+ assert_eq!(
+ usage["model_usage_by_credential"],
+ json!([{"credential_id":agent["id"],"calls":1,"input_tokens":1200,"output_tokens":300}])
+ );
+ assert_eq!(
+ usage["model_usage_by_model"],
+ json!([{"provider":"openai","model":"gpt-test","calls":1,"input_tokens":1200,"output_tokens":300}])
+ );
+ assert_eq!(usage["cost"], Value::Null);
+}
+
#[tokio::test]
async fn quota_covers_v1_legacy_and_mcp_but_preserves_recovery() {
let f = Fixture::new();
diff --git a/crates/graphicle/tests/it/retrieval_defaults.rs b/crates/graphicle/tests/it/retrieval_defaults.rs
index db1c137..b0884b4 100644
--- a/crates/graphicle/tests/it/retrieval_defaults.rs
+++ b/crates/graphicle/tests/it/retrieval_defaults.rs
@@ -176,10 +176,16 @@ fn origin_quota_is_opt_in_and_false_keeps_the_flat_cap() {
let on = f
.context(json!({"pack_focus":false,"origin_quota":true}))
.unwrap();
- // Unset and false keep the flat cap of two excerpts per origin.
+ let one_per_file = f
+ .context(json!({"pack_focus":false,"notes_first":true}))
+ .unwrap();
+ // Unset and false keep the flat cap of two excerpts per origin;
+ // `notes_first: true` quotes one excerpt per file
+ // (crate::notes_first::one_per_file).
assert!(unset.get("origin_quota").is_none());
assert_eq!(gates(&unset), 2);
assert_eq!(gates(&off), 2);
+ assert_eq!(gates(&one_per_file), 1);
// One origin: the quota's maximum of three, then leftover slots from the
// same origin.
assert_eq!(on["origin_quota"]["origins"], 1);
diff --git a/crates/graphicle/tests/it/selective_integration.rs b/crates/graphicle/tests/it/selective_integration.rs
index 9d3c5f2..c7321b0 100644
--- a/crates/graphicle/tests/it/selective_integration.rs
+++ b/crates/graphicle/tests/it/selective_integration.rs
@@ -152,9 +152,11 @@ fn test_files_follow_the_code_unless_the_question_names_tests() {
graph: json!({"edges":[]}),
state: "fixture-v1".into(),
};
+ // The presentation alone: `code_first: false` keeps the ranking's
+ // order (the default ranks the source file first, below).
let files = |question: &str, include_tests: Option<Value>| {
- let mut args =
- json!({"question":question,"max_tokens":2000,"limit":4,"expand_context":false});
+ let mut args = json!({"question":question,"max_tokens":2000,"limit":4,
+ "expand_context":false,"code_first":false});
if let Some(value) = include_tests {
args["include_tests"] = value;
}
@@ -229,4 +231,113 @@ fn test_files_follow_the_code_unless_the_question_names_tests() {
)
.is_err()
);
+ // Left out, `code_first` ranks the source file before the test for
+ // this code question, in the ranking itself: nothing is left to move.
+ let packet = query::context(
+ &snap,
+ &json!({"question":question,"max_tokens":2000,"limit":4,"expand_context":false}),
+ json!({}),
+ )
+ .unwrap();
+ let ranked: Vec<&str> = packet["evidence"]
+ .as_array()
+ .unwrap()
+ .iter()
+ .map(|window| window["id"].as_str().unwrap())
+ .collect();
+ assert_eq!(ranked, ["file:parser.py", "file:tests/test_parser.py"]);
+ assert_eq!(
+ packet["code_first"]["applied"], true,
+ "{}",
+ packet["code_first"]
+ );
+ assert_eq!(packet["code_first"]["files_lowered"], json!({"test": 1}));
+ assert_eq!(packet["test_files"]["moved"], 0, "{}", packet["test_files"]);
+ // `include_tests: true` keeps the tests' weight.
+ let kept = query::context(
+ &snap,
+ &json!({"question":question,"max_tokens":2000,"limit":4,"expand_context":false,
+ "include_tests":true}),
+ json!({}),
+ )
+ .unwrap();
+ assert_eq!(kept["code_first"]["tests"], false);
+ assert_eq!(kept["evidence"][0]["id"], "file:tests/test_parser.py");
+}
+
+/// With `notes_first: true`, a question in prose takes the named note first
+/// and one window per file; left out, the packet is 0.1.2's.
+#[test]
+fn a_question_in_prose_ranks_named_notes_first_one_window_per_file() {
+ let document = |path: &str, content: &str| {
+ json!({"id":format!("file:{path}"),"path":path,"title":path,
+ "content":content,"sha256":text::sha256(content.as_bytes()),
+ "source_kind":"repository_file","recorded_at":null})
+ };
+ let long_log: String = (0..40)
+ .map(|i| format!("Entry {i}: heron counts went up again.\n\n"))
+ .collect();
+ let snap = Snapshot {
+ repository: json!({"id":"notes-first","name":"Notes first"}),
+ documents: vec![
+ document(
+ "src/counts.rs",
+ "// heron heron heron counts\nfn tally() {}\n",
+ ),
+ document("notes/log.md", &format!("# Log\n\n{long_log}")),
+ document("notes/copy-of-log.md", &format!("# Log\n\n{long_log}")),
+ document(
+ "notes/heron-survey.md",
+ "# Heron survey\n\nThe survey moved to the north marsh on 2026-10-14.\n",
+ ),
+ ],
+ memories: vec![],
+ graph: json!({"edges":[]}),
+ state: "fixture-v1".into(),
+ };
+ let ask_with = |question: &str, notes_first: Value| {
+ query::context(
+ &snap,
+ &json!({"question":question,"max_tokens":3000,"limit":4,"expand_context":false,
+ "notes_first":notes_first}),
+ json!({}),
+ )
+ .unwrap()
+ };
+ let ask = |question: &str| ask_with(question, json!(true));
+ // Left out: off, as query::NOTES_FIRST_DEFAULT says.
+ let plain = ask_with("Where did the heron survey move?", Value::Null);
+ assert_eq!(
+ plain["notes_first"],
+ json!({"status":"off","defaulted":true}),
+ "{}",
+ plain["notes_first"]
+ );
+ let packet = ask("Where did the heron survey move?");
+ assert_eq!(packet["notes_first"]["defaulted"], false);
+ assert_eq!(packet["notes_first"]["status"], "reranked", "{packet}");
+ let files: Vec<&str> = packet["evidence"]
+ .as_array()
+ .unwrap()
+ .iter()
+ .map(|e| e["id"].as_str().unwrap())
+ .collect();
+ assert_eq!(
+ files.first(),
+ Some(&"file:notes/heron-survey.md"),
+ "{files:?}"
+ );
+ // One window of the long log, and none of its identical copy.
+ assert_eq!(
+ files.iter().filter(|f| f.contains("log.md")).count(),
+ 1,
+ "{files:?}"
+ );
+ let mut unique = files.clone();
+ unique.sort_unstable();
+ unique.dedup();
+ assert_eq!(unique.len(), files.len(), "{files:?}");
+ // A question that names code keeps the fused ranking.
+ let code = ask("Where is `tally` defined?");
+ assert_eq!(code["notes_first"]["status"], "code_question");
}
diff --git a/crates/graphicle/tests/it/symbol_links.rs b/crates/graphicle/tests/it/symbol_links.rs
new file mode 100644
index 0000000..f00df52
--- /dev/null
+++ b/crates/graphicle/tests/it/symbol_links.rs
@@ -0,0 +1,531 @@
+//! Reviewed memory read from the code symbols it is linked to, and code
+//! read from the memory.
+//!
+//! A code window selected for a question lifts the reviewed memory linked to
+//! a symbol inside it, and a selected memory lifts its symbols' current
+//! windows, only with `symbol_links: true`; left out, the links are counted;
+//! `false` reads none. The memory's text shares no word with the question,
+//! so only the link can bring it. A stale memory is never lifted or listed.
+//! `get_node` lists a symbol's linked memories and documents. Answers take
+//! these switches, and `notes_first`, as recall does.
+use axum::Json;
+use graphicle_runtime::{
+ graph_tools,
+ jobs::{self, Worker},
+ model,
+ store::{Store, s},
+};
+use serde_json::{Value, json};
+use tempfile::TempDir;
+
+const A: &str = "import os\n\n\ndef alpha():\n return 1\n\n\ndef beta():\n return 2\n";
+const B: &str = "from a import alpha, beta\n\n\ndef run():\n return alpha() + beta()\n";
+
+struct Fixture {
+ _dir: TempDir,
+ store: Store,
+ workspace: String,
+ key: String,
+ repo: String,
+}
+
+impl Fixture {
+ /// A project holding `files`, synced and projected.
+ fn new(files: &[(&str, &str)]) -> Self {
+ crate::edition_setup();
+ let dir = TempDir::new().unwrap();
+ let store = Store::open(dir.path()).unwrap();
+ let ws = store.create_workspace("Links").unwrap();
+ let workspace = s(&ws, "id").to_string();
+ let key = s(&ws, "capability").to_string();
+ let registered = store
+ .register(
+ &workspace,
+ &key,
+ &json!({"project_key":"links","name":"Links"}),
+ )
+ .unwrap();
+ let repo = s(&registered, "id").to_string();
+ let f = Self {
+ _dir: dir,
+ store,
+ workspace,
+ key,
+ repo,
+ };
+ f.sync(files);
+ f
+ }
+ fn args(&self, mut args: Value) -> Value {
+ args["repository_id"] = json!(self.repo);
+ args
+ }
+ /// Sync `files` and run the projection and link jobs.
+ fn sync(&self, files: &[(&str, &str)]) {
+ let status = self
+ .store
+ .project_status(&self.workspace, &self.key, &self.args(json!({})))
+ .unwrap();
+ let manifest: Vec<Value> = files
+ .iter()
+ .map(|(name, text)| json!({"path":name,"sha256":graphicle_memory::text::sha256(text.as_bytes()),"bytes":text.len()}))
+ .collect();
+ let begin = self
+ .store
+ .sync_prepare(
+ &self.workspace,
+ &self.key,
+ &self.args(json!({"expected_snapshot":status["repository"]["snapshot"],"manifest":manifest})),
+ )
+ .unwrap();
+ if begin["replayed"] != true {
+ let upload: Vec<Value> = files
+ .iter()
+ .map(|(name, text)| json!({"path":name,"content":text}))
+ .collect();
+ self.store
+ .sync_upload(
+ &self.workspace,
+ &self.key,
+ &self.args(json!({"sync_id":begin["sync_id"],"files":upload})),
+ )
+ .unwrap();
+ self.store
+ .sync_commit(
+ &self.workspace,
+ &self.key,
+ &self.args(json!({"sync_id":begin["sync_id"]})),
+ )
+ .unwrap();
+ }
+ jobs::drain_projection(&self.store, &self.repo).unwrap();
+ }
+ /// A reviewed memory named for `symbols`, quoting nothing.
+ fn note(&self, title: &str, body: &str, symbols: Value) -> Value {
+ self.store
+ .note(
+ &self.workspace,
+ &self.key,
+ &self.args(json!({"title":title,"body":body,"kind":"decision","symbols":symbols})),
+ )
+ .unwrap()
+ }
+ fn context(&self, question: &str, switches: Value) -> Value {
+ let mut args = self.args(json!({"question":question}));
+ for (key, value) in switches.as_object().unwrap() {
+ args[key] = value.clone();
+ }
+ self.store
+ .project_context(&self.workspace, &self.key, &args)
+ .unwrap()
+ }
+ fn node(&self, label: &str) -> Value {
+ graph_tools::call(
+ &self.store,
+ &self.workspace,
+ &self.key,
+ &self.args(json!({"tool":"get_node","label":label})),
+ )
+ .unwrap()
+ }
+}
+
+fn includes(packet: &Value, memory: &Value) -> bool {
+ packet["memories"]
+ .as_array()
+ .unwrap()
+ .iter()
+ .any(|m| m["id"] == memory["id"])
+}
+
+#[test]
+fn a_code_window_lifts_its_linked_memory_only_when_asked() {
+ let f = Fixture::new(&[("a.py", A), ("b.py", B)]);
+ let memory = f.note(
+ "Quokka ledger",
+ "Keep the quokka ledger frozen.",
+ json!([{"path":"a.py","qualified_name":"alpha"}]),
+ );
+ let question = "What does alpha return?";
+ // Left out: the link is counted and nothing is lifted.
+ let counted = f.context(question, json!({}));
+ assert!(!includes(&counted, &memory), "{:#}", counted["memories"]);
+ let report = &counted["symbol_links"];
+ assert_eq!(report["status"], "counted", "{report:#}");
+ assert_eq!(report["withheld"], 1, "{report:#}");
+ assert_eq!(report["lifted_memories"], 0);
+ assert_eq!(counted["mechanisms"]["symbol_links_enabled"], false);
+ assert_eq!(counted["mechanisms"]["links_used"]["memory"], 0);
+ // false: no link is read.
+ let off = f.context(question, json!({"symbol_links":false}));
+ assert!(!includes(&off, &memory));
+ assert_eq!(off["symbol_links"], json!({"status":"disabled"}));
+ // true: the code window lifts the memory, one hop.
+ let on = f.context(question, json!({"symbol_links":true}));
+ let lifted = on["memories"]
+ .as_array()
+ .unwrap()
+ .iter()
+ .find(|m| m["id"] == memory["id"])
+ .cloned()
+ .unwrap_or_else(|| panic!("{:#}", on["symbol_links"]));
+ assert_eq!(lifted["via"], "link");
+ let link = &lifted["link"];
+ assert_eq!(link["direction"], "code_to_memory");
+ assert_eq!(link["qualified_name"], "alpha");
+ assert_eq!(link["rung"], "named");
+ assert!(
+ link["from"].as_str().unwrap().starts_with("file:a.py"),
+ "{link}"
+ );
+ assert!(s(&on, "markdown").contains("Quokka ledger"));
+ let report = &on["symbol_links"];
+ assert_eq!(report["status"], "followed", "{report:#}");
+ assert_eq!(
+ (&report["lifted_memories"], &report["memories_included"]),
+ (&json!(1), &json!(1)),
+ "{report:#}"
+ );
+ let mechanisms = &on["mechanisms"];
+ assert_eq!(mechanisms["symbol_links_enabled"], true);
+ assert_eq!(mechanisms["links_used"]["memory"], 1);
+ assert_eq!(mechanisms["links_used"]["by_rung"]["named"], 1);
+ // The same packet otherwise: the code evidence is unchanged.
+ let ids = |packet: &Value| -> Vec<Value> {
+ packet["evidence"]
+ .as_array()
+ .unwrap()
+ .iter()
+ .map(|e| json!([e["id"], e["byte_start"], e["byte_end"]]))
+ .collect()
+ };
+ assert_eq!(ids(&on), ids(&counted));
+ assert_eq!(ids(&off), ids(&counted));
+
+ // An edit elsewhere in the file keeps the memory current and linked.
+ let elsewhere = A.replace("return 2", "return 20");
+ f.sync(&[("a.py", &elsewhere), ("b.py", B)]);
+ assert!(includes(
+ &f.context(question, json!({"symbol_links":true})),
+ &memory
+ ));
+ // An edit inside alpha withholds it: never lifted.
+ f.sync(&[
+ ("a.py", &elsewhere.replace("return 1", "return 10")),
+ ("b.py", B),
+ ]);
+ let stale = f.context(question, json!({"symbol_links":true}));
+ assert!(!includes(&stale, &memory), "{:#}", stale["memories"]);
+ assert_eq!(stale["mechanisms"]["memories_withheld"]["by_symbol"], 1);
+ assert_eq!(stale["mechanisms"]["links_used"]["memory"], 0);
+}
+
+/// The identifier route names, in one line, the current reviewed memories
+/// linked to the symbols it cites; a call that leaves memory out gets no
+/// such line.
+#[test]
+fn the_identifier_route_names_linked_reviewed_memory() {
+ let f = Fixture::new(&[("a.py", A), ("b.py", B)]);
+ let memory = f.note(
+ "Quokka ledger",
+ "Keep the quokka ledger frozen.",
+ json!([{"path":"a.py","qualified_name":"alpha"}]),
+ );
+ let packet = f.context("where is `alpha` defined", json!({"identifier_route":true}));
+ assert_eq!(packet["route"]["path"], "identifier", "{packet:#}");
+ assert_eq!(
+ packet["linked_memories"][0]["id"], memory["id"],
+ "{packet:#}"
+ );
+ let markdown = s(&packet, "markdown");
+ assert!(
+ markdown.contains("Reviewed memory linked to these symbols: Quokka ledger (memory "),
+ "{markdown}"
+ );
+ let off = f.context(
+ "where is `alpha` defined",
+ json!({"identifier_route":true,"memory_retrieval":false}),
+ );
+ assert_eq!(off["route"]["path"], "identifier");
+ assert!(!s(&off, "markdown").contains("Quokka ledger"), "{off:#}");
+ // A symbol no memory links: no line.
+ let beta = f.context("who calls `beta`", json!({"identifier_route":true}));
+ assert!(
+ !s(&beta, "markdown").contains("Reviewed memory"),
+ "{beta:#}"
+ );
+}
+
+#[test]
+fn a_selected_memory_lifts_the_window_of_its_symbol() {
+ let f = Fixture::new(&[("a.py", A), ("b.py", B)]);
+ let memory = f.note(
+ "Quokka ledger",
+ "Keep the quokka ledger frozen.",
+ json!([{"path":"a.py","qualified_name":"beta"}]),
+ );
+ let lifted = |packet: &Value| {
+ packet["evidence"]
+ .as_array()
+ .unwrap()
+ .iter()
+ .find(|e| e.get("symbol_links").is_some())
+ .cloned()
+ };
+ // With the graph on, the property graph of sources and reviewed knowledge
+ // already brings a.py (the memory's file) whole: its link is covered and
+ // nothing is lifted twice.
+ let covered = f.context("quokka ledger", json!({"symbol_links":true}));
+ assert!(includes(&covered, &memory));
+ assert!(lifted(&covered).is_none());
+ let report = &covered["symbol_links"];
+ assert_eq!(
+ (&report["covered"], &report["lifted_windows"]),
+ (&json!(2), &json!(0)),
+ "{report:#}"
+ );
+ // With the graph off, only the link can bring the code.
+ let counted = f.context("quokka ledger", json!({"graph_retrieval":false}));
+ assert!(includes(&counted, &memory), "{:#}", counted["memories"]);
+ assert!(lifted(&counted).is_none());
+ assert_eq!(counted["evidence"], json!([]), "{:#}", counted["evidence"]);
+ assert_eq!(
+ counted["symbol_links"]["withheld"], 1,
+ "{:#}",
+ counted["symbol_links"]
+ );
+ let on = f.context(
+ "quokka ledger",
+ json!({"graph_retrieval":false,"symbol_links":true}),
+ );
+ let window = lifted(&on).unwrap_or_else(|| panic!("{:#}", on["symbol_links"]));
+ assert_eq!(window["id"], "file:a.py");
+ let facts = &window["symbol_links"];
+ assert_eq!(facts["direction"], "memory_to_code");
+ assert_eq!(facts["from"], format!("memory:{}", s(&memory, "id")));
+ assert_eq!(facts["qualified_name"], "beta");
+ let (a, b) = (
+ window["byte_start"].as_u64().unwrap() as usize,
+ window["byte_end"].as_u64().unwrap() as usize,
+ );
+ // The cited window holds beta (the packet may widen a short window).
+ assert!(
+ A[a..b].contains("def beta():\n return 2\n"),
+ "{window:#}"
+ );
+ assert_eq!(on["symbol_links"]["lifted_windows"], 1);
+ assert_eq!(on["symbol_links"]["cited"], 1);
+ assert_eq!(on["mechanisms"]["links_used"]["memory"], 1);
+ // A memory without code links lifts nothing and reads no link.
+ let g = Fixture::new(&[("a.py", A)]);
+ g.store
+ .note(
+ &g.workspace,
+ &g.key,
+ &g.args(json!({"title":"Quokka ledger","body":"Keep the quokka ledger frozen."})),
+ )
+ .unwrap();
+ let plain = g.context("quokka ledger", json!({"symbol_links":true}));
+ assert_eq!(plain["symbol_links"], json!({"status":"no_links"}));
+ // Its packet keeps its evidence and memories whatever the switch says.
+ let default = g.context("quokka ledger", json!({}));
+ assert_eq!(default["symbol_links"], json!({"status":"no_links"}));
+ assert_eq!(plain["evidence"], default["evidence"]);
+ assert_eq!(plain["memories"], default["memories"]);
+ assert_eq!(plain["markdown"], default["markdown"]);
+}
+
+#[test]
+fn get_node_lists_the_linked_memory_and_documents() {
+ let readme = "# Notes\n\nCall `alpha` before anything else.\n";
+ let files = [("a.py", A), ("b.py", B), ("README.md", readme)];
+ let f = Fixture::new(&files);
+ let memory = f.note(
+ "Quokka ledger",
+ "Keep the quokka ledger frozen.",
+ json!([{"path":"a.py","qualified_name":"alpha"}]),
+ );
+ let reply = f.node("alpha");
+ let node = &reply["nodes"][0];
+ assert_eq!(node["label"], "alpha()", "{reply:#}");
+ let linked = &node["linked"];
+ let memories = linked["memories"].as_array().unwrap();
+ assert_eq!(memories.len(), 1, "{linked:#}");
+ assert_eq!(memories[0]["id"], memory["id"]);
+ assert_eq!(memories[0]["title"], "Quokka ledger");
+ assert_eq!(memories[0]["rung"], "named");
+ let documents = linked["documents"].as_array().unwrap();
+ assert_eq!(documents.len(), 1, "{linked:#}");
+ assert_eq!(documents[0]["document_id"], "file:README.md");
+ let text = graph_tools::citations_text(&reply);
+ assert!(
+ text.contains(&format!(
+ "reviewed memory linked: Quokka ledger ({})",
+ s(&memory, "id")
+ )),
+ "{text}"
+ );
+ assert!(
+ text.contains("documents mentioning it: file:README.md"),
+ "{text}"
+ );
+ // Nothing links to beta.
+ assert_eq!(
+ f.node("beta")["nodes"][0]["linked"],
+ json!({"memories":[],"documents":[]})
+ );
+ // A stale memory is not listed.
+ f.sync(&[
+ ("a.py", &A.replace("return 1", "return 10")),
+ ("b.py", B),
+ ("README.md", readme),
+ ]);
+ assert_eq!(f.node("alpha")["nodes"][0]["linked"]["memories"], json!([]));
+}
+
+/// The answer model quotes the first source it was given.
+async fn inference(Json(request): Json<Value>) -> Json<Value> {
+ let input: Value = serde_json::from_str(request["input"].as_str().unwrap()).unwrap();
+ let source = &input["sources"][0];
+ let answer = json!({"answer":"from the first source","abstain":false,
+ "evidence":[{"id":source["id"],"quote":source["text"]}],"unresolved":[]});
+ Json(
+ json!({"status":"completed","model":"fixture","usage":{"input_tokens":150,"output_tokens":80},"output":[{"type":"message","content":[{"type":"output_text","text":answer.to_string()}]}]}),
+ )
+}
+
+impl Fixture {
+ /// Queue a `basic` answer and run it as a worker would: its retrieval
+ /// packet.
+ async fn basic(&self, config: &model::Config, mut args: Value) -> Value {
+ args["kind"] = json!("basic");
+ args["repository_id"] = json!(self.repo);
+ let queued = self
+ .store
+ .enqueue(&self.workspace, &self.key, &args, config)
+ .unwrap();
+ Worker::new(self.store.clone(), config.clone())
+ .unwrap()
+ .once()
+ .await
+ .unwrap();
+ let done = self
+ .store
+ .job_status(
+ &self.workspace,
+ &self.key,
+ &json!({"repository_id":self.repo,"job_id":queued["id"]}),
+ )
+ .unwrap();
+ assert_eq!(done["state"], "complete", "{done}");
+ done["result"]["context"].clone()
+ }
+}
+
+/// The answer model of [`inference`], served on a loopback address, and
+/// the configuration that names it.
+async fn answer_model() -> (model::Config, tokio::task::JoinHandle<()>) {
+ // IPv6 loopback first: some build machines refuse IPv4 loopback.
+ let mut bound = None;
+ for address in ["[::1]:0", "127.0.0.1:0"] {
+ if let Ok(listener) = tokio::net::TcpListener::bind(address).await {
+ bound = Some(listener);
+ break;
+ }
+ }
+ let listener = bound.expect("a loopback address to serve the answer model on");
+ let address = listener.local_addr().unwrap();
+ let server = tokio::spawn(async move {
+ let app = axum::Router::new().route("/v1/responses", axum::routing::post(inference));
+ axum::serve(listener, app).await.unwrap();
+ });
+ let config: model::Config = serde_json::from_value(json!({"default_model":"fast","models":{
+ "fast":{"protocol":"responses","base_url":format!("http://{address}/v1"),"model":"fixture","input_limit":16000,"output_limit":4096}
+ }}))
+ .unwrap();
+ (config, server)
+}
+
+/// Answers take `notes_first` like `context`: left out, the answer's
+/// packet is 0.1.2's; `true` orders a question in prose notes first.
+#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
+async fn answers_take_the_notes_first_switch() {
+ let f = Fixture::new(&[
+ ("a.py", A),
+ ("b.py", B),
+ ("README.md", "# Notes\n\nalpha returns one.\n"),
+ ]);
+ let (config, server) = answer_model().await;
+ let question = "What does alpha return?";
+ let plain = f.basic(&config, json!({"question":question})).await;
+ assert_eq!(
+ plain["notes_first"],
+ json!({"status":"off","defaulted":true}),
+ "{}",
+ plain["notes_first"]
+ );
+ let first = f
+ .basic(&config, json!({"question":question,"notes_first":true}))
+ .await;
+ assert_eq!(
+ first["notes_first"]["status"], "reranked",
+ "{}",
+ first["notes_first"]
+ );
+ assert_eq!(first["notes_first"]["defaulted"], false);
+ assert_eq!(first["mechanisms"]["switches"]["notes_first"], true);
+ server.abort();
+}
+
+/// Answers take `symbol_links` whatever `doc_links` says: with documents'
+/// links off, `symbol_links: true` still lifts the reviewed memory linked to
+/// the code window, reports `followed`, and the echo shows the values in
+/// force. Left out, the link is counted.
+#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
+async fn answers_follow_memory_links_with_document_links_off() {
+ let f = Fixture::new(&[("a.py", A), ("b.py", B)]);
+ let memory = f.note(
+ "Quokka ledger",
+ "Keep the quokka ledger frozen.",
+ json!([{"path":"a.py","qualified_name":"alpha"}]),
+ );
+ let (config, server) = answer_model().await;
+ let question = "What does alpha return?";
+ let counted = f
+ .basic(&config, json!({"question":question,"doc_links":false}))
+ .await;
+ assert!(!includes(&counted, &memory), "{:#}", counted["memories"]);
+ assert_eq!(
+ counted["symbol_links"]["status"], "counted",
+ "{:#}",
+ counted["symbol_links"]
+ );
+ assert_eq!(counted["symbol_links"]["withheld"], 1);
+ assert_eq!(counted["mechanisms"]["switches"]["symbol_links"], "counted");
+ let on = f
+ .basic(
+ &config,
+ json!({"question":question,"doc_links":false,"symbol_links":true}),
+ )
+ .await;
+ let lifted = on["memories"]
+ .as_array()
+ .unwrap()
+ .iter()
+ .find(|m| m["id"] == memory["id"])
+ .cloned()
+ .unwrap_or_else(|| panic!("{:#}", on["symbol_links"]));
+ assert_eq!(lifted["via"], "link");
+ assert_eq!(lifted["link"]["direction"], "code_to_memory");
+ let report = &on["symbol_links"];
+ assert_eq!(report["status"], "followed", "{report:#}");
+ assert_eq!(report["lifted_memories"], 1, "{report:#}");
+ let mechanisms = &on["mechanisms"];
+ assert_eq!(mechanisms["symbol_links_enabled"], true);
+ assert_eq!(mechanisms["links_used"]["memory"], 1);
+ assert_eq!(mechanisms["switches"]["symbol_links"], true);
+ assert_eq!(mechanisms["switches"]["doc_links"], false);
+ assert_eq!(on["doc_links"]["status"], "disabled");
+ assert_eq!(on["integration"]["symbol_links"], true);
+ server.abort();
+}
diff --git a/crates/graphicle/tests/it/ux_terminal.rs b/crates/graphicle/tests/it/ux_terminal.rs
index 3646425..94851e9 100644
--- a/crates/graphicle/tests/it/ux_terminal.rs
+++ b/crates/graphicle/tests/it/ux_terminal.rs
@@ -554,6 +554,69 @@ fn ask_without_a_model_prints_the_evidence_and_the_command_that_adds_one() {
assert_eq!(packet["question"], "how does login work");
}
+/// `context` builds 0.1.2's packet unless asked: no excerpt dates and no
+/// notes-first order. `--notes-first` dates each excerpt from Git, in the
+/// packet and on a terminal, and reports the order it used. The packet holds
+/// 8,400 characters at most, or 4 per token of `--max-tokens` when only that
+/// is given, or `--max-chars`.
+#[test]
+fn context_dates_excerpts_with_notes_first_and_sizes_itself_by_its_flags() {
+ let sandbox = Sandbox::new();
+ sandbox.sync();
+ let question = "how does login work";
+ let context = |extra: &[&str]| {
+ let mut args = vec!["context", question];
+ args.extend_from_slice(extra);
+ json_of(&sandbox.run(&sandbox.repo(), &args, &[]))
+ };
+ let dated = |packet: &Value| {
+ packet["sources"]
+ .as_array()
+ .unwrap()
+ .iter()
+ .filter(|source| source.get("changed").is_some())
+ .count()
+ };
+ let plain = context(&[]);
+ assert_eq!(
+ plain["notes_first"],
+ json!({"status":"off","defaulted":true}),
+ "{plain:#}"
+ );
+ assert_eq!(plain["source_age"]["status"], "disabled");
+ assert_eq!(dated(&plain), 0, "{}", plain["sources"]);
+ assert!(!plain["markdown"].as_str().unwrap().contains("(changed "));
+ assert_eq!(plain["max_chars"], 8400);
+ let first = context(&["--notes-first"]);
+ assert_eq!(first["notes_first"]["defaulted"], false, "{first:#}");
+ assert_eq!(first["notes_first"]["status"], "reranked", "{first:#}");
+ assert_eq!(
+ first["source_age"]["status"], "dated",
+ "{}",
+ first["source_age"]
+ );
+ assert!(dated(&first) >= 1, "{}", first["sources"]);
+ assert!(
+ first["sources"]
+ .as_array()
+ .unwrap()
+ .iter()
+ .filter(|source| source.get("changed").is_some())
+ .all(|source| source["changed_basis"] == "git"),
+ "{}",
+ first["sources"]
+ );
+ assert!(first["markdown"].as_str().unwrap().contains(" (changed "));
+ let text = ok(&sandbox.text(&sandbox.repo(), &["context", question, "--notes-first"]));
+ assert!(text.contains("(changed "), "{text}");
+ assert_eq!(context(&["--max-tokens", "1000"])["max_chars"], 4000);
+ assert_eq!(
+ context(&["--max-tokens", "1000", "--max-chars", "3000"])["max_chars"],
+ 3000
+ );
+ assert_eq!(context(&["--max-chars", "5000"])["max_chars"], 5000);
+}
+
/// A stand-in Responses provider: a `basic` reader quotes its first two
/// sources.
async fn respond(Json(request): Json<Value>) -> Json<Value> {
diff --git a/crates/graphicle/tests/it/workspace_scope.rs b/crates/graphicle/tests/it/workspace_scope.rs
index 686023d..912d8cd 100644
--- a/crates/graphicle/tests/it/workspace_scope.rs
+++ b/crates/graphicle/tests/it/workspace_scope.rs
@@ -968,6 +968,7 @@ async fn one_workspace_connection_answers_repo_and_workspace_recall() {
"graph_episodes",
"graph_as_of",
"graph_link",
+ "workspace_map",
"graph_history_stats",
"query_graph",
"get_node",
@@ -1421,6 +1422,158 @@ fn a_project_connections_graph_tools_read_another_project_until_access_is_revoke
assert!(own.to_string().contains("invoice.py"), "{own}");
}
+/// A note of another project that names the money library's function.
+const CLIENT_NOTE: &str =
+ "# Client X ledger\n\nThe Client X ledger rounds with `quantize_cents` before posting.\n";
+/// The money library's own page about the same function.
+const ROUNDING_PAGE: &str = "# Rounding\n\n`quantize_cents` rounds half up to whole cents.\n";
+
+/// `get_node` on a connection: to one project (`Some`), or to the workspace.
+fn get_node(f: &Fixture, app: &App, connection: Option<&str>, arguments: Value) -> Value {
+ let request = json!({"jsonrpc":"2.0","id":1,"method":"tools/call",
+ "params":{"name":"get_node","arguments":structured("get_node", arguments)}});
+ match connection {
+ Some(project) => api::mcp(app, &f.workspace, &f.key, project, &request),
+ None => api::mcp_workspace(app, &f.workspace, &f.key, &request),
+ }
+ .unwrap()
+}
+
+/// The back-links of a `get_node` reply's nodes under `key` (`memories` or
+/// `documents`).
+fn back_links(reply: &Value, key: &str) -> Vec<Value> {
+ reply["result"]["structuredContent"]["nodes"]
+ .as_array()
+ .into_iter()
+ .flatten()
+ .flat_map(|node| node["linked"][key].as_array().cloned().unwrap_or_default())
+ .collect()
+}
+
+/// A project connection keeps documents on its project: `get_node` lists
+/// the project's own page about its function, never another project's note
+/// that names it, in its structured answer or its citations text. A
+/// workspace connection lists both.
+#[test]
+fn a_project_connections_get_node_lists_no_other_projects_documents() {
+ let f = Fixture::new();
+ let mut files = money_files();
+ files.push(("docs/rounding.md", ROUNDING_PAGE));
+ let money = f.project("moneylib", "Money", &files);
+ let notes = f.project(
+ "clientx-notes",
+ "Client X notes",
+ &[("docs/ledger.md", CLIENT_NOTE)],
+ );
+ f.store.graph_link(&f.workspace, &f.key).unwrap();
+ let app = f.app();
+ let in_workspace = get_node(
+ &f,
+ &app,
+ None,
+ json!({"label":"quantize_cents","repo":money}),
+ );
+ let all: Vec<Value> = back_links(&in_workspace, "documents")
+ .iter()
+ .map(|d| d["repository_id"].clone())
+ .collect();
+ assert!(all.contains(&json!(notes)), "{in_workspace}");
+ assert!(all.contains(&json!(money)), "{in_workspace}");
+ let reply = get_node(
+ &f,
+ &app,
+ Some(money.as_str()),
+ json!({"label":"quantize_cents"}),
+ );
+ let documents = back_links(&reply, "documents");
+ assert!(
+ documents.iter().all(|d| d["repository_id"] == json!(money)),
+ "a connection to {money} lists documents of {notes}: {documents:?}"
+ );
+ assert!(
+ documents
+ .iter()
+ .any(|d| d["document_id"] == "file:docs/rounding.md"),
+ "{documents:?}"
+ );
+ let text = reply["result"]["content"].to_string();
+ assert!(!text.contains("docs/ledger.md"), "{text}");
+}
+
+/// A project connection keeps memory on its project: through `repo`,
+/// `get_node` reads another project's code graph but lists none of that
+/// project's reviewed memories; it lists its own project's. A workspace
+/// connection lists the other project's memory.
+#[test]
+fn a_project_connections_get_node_with_repo_lists_no_other_projects_memories() {
+ let (f, shop, money) = Fixture::shop_and_money();
+ let note = |project: &str, title: &str, path: &str, name: &str| {
+ f.store
+ .note(
+ &f.workspace,
+ &f.key,
+ &json!({"repository_id":project,"title":title,"body":"Ask the desk first.",
+ "kind":"decision","symbols":[{"path":path,"qualified_name":name}]}),
+ )
+ .unwrap()
+ };
+ let refunds = note(
+ &shop,
+ "Client X refund rule",
+ "shopapp/invoice.py",
+ "settle_invoice",
+ );
+ let rounding = note(
+ &money,
+ "Rounding stays half up",
+ "moneylib/rounding.py",
+ "quantize_cents",
+ );
+ let app = f.app();
+ let ids = |reply: &Value| -> Vec<Value> {
+ back_links(reply, "memories")
+ .iter()
+ .map(|m| m["id"].clone())
+ .collect()
+ };
+ let in_workspace = get_node(
+ &f,
+ &app,
+ None,
+ json!({"label":"settle_invoice","repo":shop}),
+ );
+ assert_eq!(
+ ids(&in_workspace),
+ vec![refunds["id"].clone()],
+ "{in_workspace}"
+ );
+ let through_repo = get_node(
+ &f,
+ &app,
+ Some(money.as_str()),
+ json!({"label":"settle_invoice","repo":shop}),
+ );
+ assert!(
+ through_repo.to_string().contains("invoice.py"),
+ "{through_repo}"
+ );
+ assert!(
+ ids(&through_repo).is_empty(),
+ "a connection to {money} lists reviewed memories of {shop}: {through_repo}"
+ );
+ assert!(
+ !through_repo.to_string().contains("Client X refund rule"),
+ "{through_repo}"
+ );
+ let own = get_node(
+ &f,
+ &app,
+ Some(money.as_str()),
+ json!({"label":"quantize_cents"}),
+ );
+ assert_eq!(ids(&own), vec![rounding["id"].clone()], "{own}");
+}
+
/// A workspace connection remembers what it showed per project (`shown` and
/// `skip_shown`; source ids repeat across projects): the second recall
/// answers each project's windows with references naming that project.
@@ -1614,3 +1767,339 @@ fn graphicle_mcp_workspace_serves_every_project_over_stdio() {
);
}
}
+
+/// A page of the shop's documentation that names the function it documents.
+const INVOICES: &str = "# Invoices\n\nInvoices are settled by `settle_invoice`.\n";
+
+/// The money library with a memory anchored to its rounding, and the shop
+/// with a documentation page, linked; a PR scratch project beside them.
+fn mapped() -> (Fixture, String, String, String) {
+ let f = Fixture::new();
+ let money = f.project("moneylib", "Money", &money_files());
+ let mut shop_files = shop_files();
+ shop_files.push(("docs/invoices.md", INVOICES));
+ let shop = f.project("shopapp", "Shop", &shop_files);
+ let linked = f.store.graph_link(&f.workspace, &f.key).unwrap();
+ assert!(linked["edges"].as_u64().unwrap() >= 1, "{linked}");
+ f.store
+ .note(
+ &f.workspace,
+ &f.key,
+ &json!({"repository_id":money,"kind":"decision","title":"Cents round half up",
+ "body":"quantize_cents rounds half up to whole cents.",
+ "evidence":[{"id":"file:moneylib/rounding.py","quote":"scaled = int(value * 100 + 0.5)"}]}),
+ )
+ .unwrap();
+ let scratch = f.project("git:scratch", "Scratch", &[("notes.txt", "scratch copy\n")]);
+ f.store
+ .mark_pr_scratch(&f.workspace, &f.key, &scratch)
+ .unwrap();
+ (f, shop, money, scratch)
+}
+
+/// The workspace map lists the projects the caller may read (creation
+/// order, no PR scratch project unless asked), the imports `graph.link`
+/// recorded between them by pair, and per project what the caller's own
+/// single-project reads count: files, documents, code symbols, memories and
+/// links. It writes nothing, and paging lists each pair once.
+#[test]
+fn the_workspace_map_lists_projects_imports_and_counts() {
+ let (f, shop, money, scratch) = mapped();
+ let watcher = f.db();
+ let version = |db: &rusqlite::Connection| {
+ db.query_row("PRAGMA data_version", [], |r| r.get::<_, i64>(0))
+ .unwrap()
+ };
+ let before = version(&watcher);
+ let map = f
+ .store
+ .workspace_map(&f.workspace, &f.key, &json!({}))
+ .unwrap();
+ assert_eq!(version(&watcher), before, "the map wrote to the store");
+ let projects = map["projects"].as_array().unwrap();
+ let ids: Vec<&str> = projects.iter().map(|p| s(p, "id")).collect();
+ assert_eq!(ids, [money.as_str(), shop.as_str()], "{map:#}");
+ assert_eq!(map["total"], 2);
+ assert!(map["next_offset"].is_null());
+ assert!(!map.to_string().contains(&scratch));
+ for project in projects {
+ // Ids, names and times: a project's key can carry a path or a user id.
+ assert!(project.get("project_key").is_none(), "{project}");
+ assert_eq!(project["status"], "ok", "{project}");
+ assert_eq!(project["graph"]["current"], true, "{project}");
+ }
+ // One pair: the shop imports from the money library.
+ let imports = map["imports"].as_array().unwrap();
+ assert_eq!(imports.len(), 1, "{map:#}");
+ let pair = &imports[0];
+ assert_eq!(pair["source_repository_id"], shop.as_str());
+ assert_eq!(pair["target_repository_id"], money.as_str());
+ let edges = pair["edges"].as_u64().unwrap();
+ assert!(edges >= 1);
+ assert_eq!(map["import_edges"], edges);
+ assert!(
+ pair["modules"]
+ .as_array()
+ .unwrap()
+ .iter()
+ .any(|m| m.as_str().unwrap().contains("moneylib")),
+ "{pair}"
+ );
+ assert_eq!(
+ pair["modules_total"],
+ pair["modules"].as_array().unwrap().len()
+ );
+ let (money_entry, shop_entry) = (&projects[0], &projects[1]);
+ assert_eq!(shop_entry["counts"]["links"]["imports_out"], edges);
+ assert_eq!(shop_entry["counts"]["links"]["imports_in"], 0);
+ assert_eq!(money_entry["counts"]["links"]["imports_in"], edges);
+ assert_eq!(money_entry["counts"]["links"]["imports_out"], 0);
+ // Each count is what the caller's reads of that project show.
+ for (entry, id) in [(money_entry, &money), (shop_entry, &shop)] {
+ let counts = &entry["counts"];
+ let args = json!({"repository_id":id});
+ let files = f
+ .store
+ .project_read(&f.workspace, &f.key, "files", &args)
+ .unwrap();
+ assert_eq!(counts["files"], files["total"], "{entry}");
+ assert_eq!(counts["documents"], 0);
+ let symbols: i64 = watcher
+ .query_row(
+ "SELECT COUNT(*) FROM gf_symbol_heads WHERE repository_id=?",
+ [id],
+ |r| r.get(0),
+ )
+ .unwrap();
+ assert!(symbols >= 1);
+ assert_eq!(counts["symbols"], symbols);
+ let memories = f
+ .store
+ .project_read(&f.workspace, &f.key, "memories", &args)
+ .unwrap();
+ let memories = memories.as_array().unwrap();
+ assert_eq!(counts["memories"], memories.len());
+ let anchored: u64 = memories
+ .iter()
+ .map(|m| m["symbol_links"]["links"].as_u64().unwrap_or(0))
+ .sum();
+ assert_eq!(counts["links"]["memory_symbols"], anchored);
+ let coverage =
+ graphicle_runtime::doc_links::read(&f.store, &f.workspace, &f.key, &args).unwrap();
+ assert_eq!(
+ counts["links"]["document_mentions"],
+ coverage["coverage"]["total"]["linked"]
+ .as_u64()
+ .unwrap_or(0),
+ "{coverage}"
+ );
+ }
+ assert_eq!(money_entry["counts"]["memories"], 1);
+ assert_eq!(money_entry["counts"]["links"]["memory_symbols"], 1);
+ assert_eq!(shop_entry["counts"]["memories"], 0);
+ assert!(
+ shop_entry["counts"]["links"]["document_mentions"]
+ .as_u64()
+ .unwrap()
+ >= 1,
+ "{shop_entry}"
+ );
+ // A page at a time: each pair on its source's page.
+ let first = f
+ .store
+ .workspace_map(&f.workspace, &f.key, &json!({"limit":1}))
+ .unwrap();
+ assert_eq!(first["projects"][0]["id"], money.as_str());
+ assert_eq!(first["next_offset"], 1);
+ assert_eq!(first["imports"], json!([]));
+ assert_eq!(first["import_edges"], edges);
+ let second = f
+ .store
+ .workspace_map(&f.workspace, &f.key, &json!({"offset":1,"limit":1}))
+ .unwrap();
+ assert_eq!(second["projects"][0]["id"], shop.as_str());
+ assert!(second["next_offset"].is_null());
+ assert_eq!(second["imports"], map["imports"]);
+ // Scratch projects on request, marked.
+ let all = f
+ .store
+ .workspace_map(&f.workspace, &f.key, &json!({"include_scratch":true}))
+ .unwrap();
+ assert_eq!(all["total"], 3);
+ assert_eq!(all["projects"][2]["id"], scratch.as_str());
+ assert_eq!(all["projects"][2]["role"], "pr_scratch");
+ for bad in [
+ json!({"include_scratch":"yes"}),
+ json!({"limit":201}),
+ json!({"offset":-1}),
+ ] {
+ assert!(
+ f.store.workspace_map(&f.workspace, &f.key, &bad).is_err(),
+ "{bad}"
+ );
+ }
+}
+
+/// A project the caller may not read is not on the map: no entry, no
+/// import edge to or from it, no count that includes it, over the API and
+/// over a workspace MCP connection; a project connection has no map.
+#[test]
+fn an_unreadable_project_is_not_on_the_workspace_map() {
+ let (f, shop, money, _) = mapped();
+ let (reader_id, reader) = f.reader("reader");
+ let full = f
+ .store
+ .workspace_map(&f.workspace, &reader, &json!({}))
+ .unwrap();
+ assert_eq!(full["total"], 2, "{full:#}");
+ f.revoke(&money, &reader_id);
+ let app = f.app();
+ let call = |connection: Option<&str>, arguments: Value| {
+ let request = json!({"jsonrpc":"2.0","id":1,"method":"tools/call",
+ "params":{"name":"workspace_map","arguments":arguments}});
+ match connection {
+ None => api::mcp_workspace(&app, &f.workspace, &reader, &request),
+ Some(project) => api::mcp(&app, &f.workspace, &reader, project, &request),
+ }
+ .unwrap()
+ };
+ let map = f
+ .store
+ .workspace_map(&f.workspace, &reader, &json!({}))
+ .unwrap();
+ let over_mcp = call(None, json!({}));
+ assert_eq!(over_mcp["result"]["isError"], false, "{over_mcp}");
+ assert_eq!(over_mcp["result"]["structuredContent"], map);
+ let over_http = api::command(&app, &f.workspace, &reader, "graph.map", &json!({})).unwrap();
+ assert_eq!(over_http, map);
+ assert_eq!(map["total"], 1, "{map:#}");
+ assert_eq!(map["projects"][0]["id"], shop.as_str());
+ assert_eq!(map["imports"], json!([]));
+ assert_eq!(map["import_edges"], 0);
+ assert_eq!(map["projects"][0]["counts"]["links"]["imports_out"], 0);
+ assert!(!map.to_string().contains(&money), "{map:#}");
+ // The owner still maps both.
+ let owner = f
+ .store
+ .workspace_map(&f.workspace, &f.key, &json!({}))
+ .unwrap();
+ assert_eq!(owner["total"], 2);
+ // A project connection reads its own project only: no map.
+ let refused = call(Some(&shop), json!({}));
+ assert!(
+ s(&refused["error"], "message").contains("Tool unavailable"),
+ "{refused}"
+ );
+ let listed = api::mcp(
+ &app,
+ &f.workspace,
+ &reader,
+ &shop,
+ &json!({"jsonrpc":"2.0","id":2,"method":"tools/list","params":{}}),
+ )
+ .unwrap();
+ assert!(!listed.to_string().contains("workspace_map"), "{listed}");
+}
+
+/// The packet fields a measurement of the integrated build reads, as JSON
+/// pointers: present in every recall packet, of a project or a workspace.
+const MEASURED_FIELDS: &[&str] = &[
+ "/graph_source",
+ "/code_graph/status",
+ "/code_graph/cited",
+ "/code_graph/episode_lag",
+ "/doc_links/status",
+ "/symbol_links/status",
+ "/mechanisms/switches/graph_retrieval",
+ "/mechanisms/switches/memory_retrieval",
+ "/mechanisms/switches/doc_links",
+ "/mechanisms/switches/symbol_links",
+ "/mechanisms/switches/cross_repo",
+ "/mechanisms/switches/notes_first",
+ "/mechanisms/switches/scope",
+ "/mechanisms/memories_withheld/by_file",
+ "/mechanisms/memories_withheld/by_symbol",
+ "/mechanisms/links_used/memory",
+ "/mechanisms/links_used/document",
+ "/mechanisms/links_used/by_rung",
+ "/mechanisms/links_followed_through_move",
+ "/mechanisms/links_pending_projection",
+ "/mechanisms/workspace/projects_searched",
+ "/mechanisms/workspace/cross_edges_used",
+ "/coverage/passage_limit_reached",
+ "/coverage/omitted_documents",
+];
+
+/// Conformance (the cross-repository step's own switch): `cross_repo: false`
+/// turns off only the step (the code arm still reads each project's graph),
+/// `cross_repo: true` turns it on with `graph_retrieval: false`, left out it
+/// follows `graph_retrieval`; every packet echoes the switches in force and
+/// carries the fields a measurement reads.
+#[test]
+fn conformance_cross_repo_switches_the_import_step_alone() {
+ let (f, shop, money) = Fixture::shop_and_money();
+ let args = |extra: Value| {
+ let mut args = json!({"question":ABOUT_THE_SHOP,"scope":"workspace","repository_id":shop});
+ for (key, value) in extra.as_object().unwrap() {
+ args[key] = value.clone();
+ }
+ args
+ };
+ let off = f.context(&f.key, args(json!({"cross_repo":false})));
+ assert_eq!(off["workspace"]["cross_repo"]["enabled"], false);
+ assert!(
+ window(&off, &money, "moneylib/rounding.py").is_none(),
+ "{}",
+ off["evidence"]
+ );
+ assert_eq!(off["mechanisms"]["switches"]["cross_repo"], false);
+ assert_eq!(off["mechanisms"]["switches"]["graph_retrieval"], true);
+ assert_eq!(off["mechanisms"]["code_graph_enabled"], true);
+ assert_eq!(off["mechanisms"]["workspace"]["cross_edges_used"], 0);
+
+ let on = f.context(
+ &f.key,
+ args(json!({"cross_repo":true,"graph_retrieval":false})),
+ );
+ assert!(
+ window(&on, &money, "moneylib/rounding.py").is_some(),
+ "{}",
+ on["evidence"]
+ );
+ assert!(on["workspace"]["cross_repo"]["lifted"].as_u64().unwrap() >= 1);
+ assert_eq!(
+ on["mechanisms"]["switches"],
+ json!({"graph_retrieval":false,"memory_retrieval":true,"doc_links":"counted",
+ "symbol_links":"counted","cross_repo":true,"notes_first":false,
+ "identifier_route":false,"code_first":"auto","query_focus":"auto",
+ "identifier_arm":"auto","more_files":"auto","scope":"workspace"})
+ );
+
+ let default = f.context(&f.key, args(json!({})));
+ assert_eq!(default["mechanisms"]["switches"]["cross_repo"], true);
+ assert!(window(&default, &money, "moneylib/rounding.py").is_some());
+
+ let project = f.context(
+ &f.key,
+ json!({"question":ABOUT_THE_SHOP,"repository_id":shop}),
+ );
+ assert_eq!(project["mechanisms"]["switches"]["scope"], "project");
+ for packet in [&off, &on, &default, &project] {
+ for pointer in MEASURED_FIELDS {
+ assert!(
+ packet.pointer(pointer).is_some(),
+ "{pointer} is missing: {}",
+ packet["mechanisms"]
+ );
+ }
+ }
+ let refused = f
+ .store
+ .project_context(&f.workspace, &f.key, &args(json!({"cross_repo":"no"})))
+ .unwrap_err();
+ assert!(
+ refused.message.contains("cross_repo must be true or false"),
+ "{}",
+ refused.message
+ );
+}
diff --git a/crates/graphicle/web/docs.html b/crates/graphicle/web/docs.html
index 0ef367c..ad19ada 100644
--- a/crates/graphicle/web/docs.html
+++ b/crates/graphicle/web/docs.html
@@ -125,6 +125,7 @@ npm install ./sdk/typescript</pre>
<h2 id="usage-title">Usage, limits and data ownership</h2>
<p>Owner-only <code>GET /v1/workspaces/WORKSPACE_ID/usage</code> returns UTC counters and recorded provider token usage. Set a monthly HTTP request budget with <code>POST /v1/workspaces/WORKSPACE_ID/budget</code> and <code>{"monthly_requests":10000}</code>. Null removes your cap.</p>
<p>Limits are enforced atomically across authenticated HTTP routes and MCP tool calls. Failed requests consume the request budget. Sign-in, navigation, usage, export, cancellation and deletion remain available. A 429 includes Retry-After until the next UTC month. Local CLI calls and background work are separate; workflows have their own model budgets. These counters are not a provider invoice or a global token spending cap.</p>
+ <p>The usage report also counts the tokens Graphicle served this month (<code>served</code>): every MCP tool result and MCP resource read; over HTTP and through <code>graphicle call</code> and <code>graphicle context</code>, every operation an MCP tool runs and the other reads of a project's sources, memory, evidence or graph (for example <code>memory.export</code> and <code>document.original</code>); and the session-start context of capture hooks. They are counted with cl100k_base on the text served, by credential, agent session, channel, tool or operation, project and day. A result that names no project but serves several, such as a recall over every project of a workspace, is counted on those projects, split by the bytes served from each. The other operations and routes, which return settings, counts or listings and no project text (for example <code>observer.status</code>, <code>list_projects</code> and the project overview), are not counted. These counts never leave your machine: Graphicle keeps counters only, in the local store, for 25 months, and an agent session's rows are folded into rows without a session after 90 days. Beside them the report lists Graphicle's own recorded model tokens by credential and by model (<code>model_usage_by_credential</code>, <code>model_usage_by_model</code>). These are what Graphicle served and spent, not your agents' bill: Graphicle does not see or count your agents' own model calls, and their prompts, other tools and output are not counted here. They are counts, not charges: <code>cost</code> stays null.</p>
</section>
<section id="limits" aria-labelledby="limits-title">
diff --git a/crates/graphicle/web/settings.js b/crates/graphicle/web/settings.js
index 68669cf..ddec840 100644
--- a/crates/graphicle/web/settings.js
+++ b/crates/graphicle/web/settings.js
@@ -6,6 +6,12 @@ const sourceServices = [...oauthServices.filter(([id]) => id !== "atlassian"), [
// An installed edition can add choices and notes (/extensions.js).
const connectionSharing = [["owner", "Only me"], ["explicit", "All workspace readers — I authorize this copy"]];
const connectionNotes = ["Drive folders include subfolders."];
+// Connection kinds an installed edition adds (/extensions.js), by kind: the
+// scope field's label and placeholder, the OAuth provider of its accounts
+// and the configuration built from the dialog's values.
+const sourceForms = {};
+// The kinds whose provider sharing the installed edition syncs.
+const providerSharingKinds = ["github", "slack", "gdrive"];
const workspaceCommand = (operation, args = {}) => api(`${base()}/repositories/command`, {operation, arguments: args});
function can(permission) {
return state.role === "owner" || ({reviewer: ["collect", "propose", "approve"], collector: ["collect", "propose"], runner: ["propose", "run"], agent: ["propose", "run"], reader: []}[state.role] || []).includes(permission);
@@ -64,17 +70,17 @@ async function openConnectionDialog() {
field(form, "Update frequency", "interval", {choices: [["900", "Every 15 minutes"], ["3600", "Every hour"], ["0", "Sync manually"]]});
const sharing = field(form, "Who can read these sources?", "sharing", {choices: connectionSharing});
const labels = () => {
- const atlassian = ["jira", "confluence"].includes(service.value), oauth = credential.value.startsWith("oauth:");
+ const atlassian = ["jira", "confluence"].includes(service.value), oauth = credential.value.startsWith("oauth:"), added = sourceForms[service.value];
driveMode.parentElement.hidden = service.value !== "gdrive";
- scope.previousSibling.textContent = ({github: "Repository", slack: "Channel IDs", notion: "Page IDs", gdrive: driveMode.value === "folder" ? "Folder ID" : "File IDs", jira: "Issue selection (JQL)", confluence: "Space key"})[service.value];
- scope.placeholder = ({github: "owner/repository", slack: "C0123456789, C9876543210", notion: "Page IDs, separated by commas", gdrive: driveMode.value === "folder" ? "The ID after /folders/ in the Drive URL" : "File IDs, separated by commas", jira: 'project = "PRODUCT" ORDER BY updated ASC', confluence: "PRODUCT"})[service.value];
+ scope.previousSibling.textContent = added ? added.label : ({github: "Repository", slack: "Channel IDs", notion: "Page IDs", gdrive: driveMode.value === "folder" ? "Folder ID" : "File IDs", jira: "Issue selection (JQL)", confluence: "Space key"})[service.value];
+ scope.placeholder = added ? added.placeholder : ({github: "owner/repository", slack: "C0123456789, C9876543210", notion: "Page IDs, separated by commas", gdrive: driveMode.value === "folder" ? "The ID after /folders/ in the Drive URL" : "File IDs, separated by commas", jira: 'project = "PRODUCT" ORDER BY updated ASC', confluence: "PRODUCT"})[service.value];
site.parentElement.hidden = !atlassian || !oauth; site.required = atlassian && oauth;
siteURL.parentElement.hidden = !atlassian || oauth; siteURL.required = atlassian && !oauth;
email.parentElement.hidden = !atlassian || oauth;
token.parentElement.hidden = oauth;
const provider = sharing.querySelector('option[value="provider"]');
if (provider) {
- provider.disabled = !["github", "slack", "gdrive"].includes(service.value);
+ provider.disabled = !providerSharingKinds.includes(service.value);
if (provider.disabled && sharing.value === "provider") sharing.value = "owner";
}
};
@@ -90,7 +96,7 @@ async function openConnectionDialog() {
};
const refill = () => {
credential.replaceChildren();
- const provider = ["jira", "confluence"].includes(service.value) ? "atlassian" : service.value;
+ const provider = sourceForms[service.value]?.account || (["jira", "confluence"].includes(service.value) ? "atlassian" : service.value);
const choices = [["", "Choose an account, or enter a token below"], ...accounts.accounts.filter(a => a.provider === provider && a.state === "active").map(a => [`oauth:${a.id}`, a.display_name]), ...secrets.map(s => [`secret:${s.id}`, s.name])];
for (const [value, label] of choices) { const option = el("option", label); option.value = value; credential.append(option); }
labels();
@@ -115,7 +121,8 @@ async function openConnectionDialog() {
config.base_url = `https://api.atlassian.com/ex/${values.kind}/${encodeURIComponent(site.id)}`; config.site_url = site.url; config.auth_type = "bearer";
} else { config.base_url = values.site_url.replace(/\/$/, ""); config.site_url = config.base_url; config.auth_type = "basic"; }
config[values.kind === "jira" ? "jql" : "space_key"] = values.scope.trim();
- } else if (values.kind === "github") config.repository = values.scope.trim();
+ } else if (sourceForms[values.kind]) Object.assign(config, sourceForms[values.kind].config(values));
+ else if (values.kind === "github") config.repository = values.scope.trim();
else if (values.kind === "gdrive" && values.drive_mode === "folder") config.folder_id = values.scope.trim();
else config[({slack: "channels", notion: "page_ids", gdrive: "file_ids"})[values.kind]] = values.scope.split(",").map(v => v.trim()).filter(Boolean);
if (values.kind === "gdrive") config.recursive = true;
diff --git a/crates/graphicle/web/workspace.js b/crates/graphicle/web/workspace.js
index 09cdbe4..9961ac6 100644
--- a/crates/graphicle/web/workspace.js
+++ b/crates/graphicle/web/workspace.js
@@ -399,6 +399,19 @@ async function workspaceUsage(root, scope, current) {
const usage = panel("Provider usage", data.cost_note);
usage.append(facts([["Recorded input tokens", (data.model_usage?.input_tokens || 0).toLocaleString()], ["Recorded output tokens", (data.model_usage?.output_tokens || 0).toLocaleString()], ["Unreported reservations", data.unreported_reservations || 0], ["HTTP errors", data.http_errors]]));
columns.append(budget, usage); root.append(columns);
+ // What Graphicle returned to agents and keys this month: tokens, not cost.
+ const served = data.served || {}, channels = {mcp: "MCP tool results", http: "API", web: "Web app", cli: "Command line", hook: "Session-start context"};
+ const servedPanel = panel("What Graphicle served", served.scope);
+ servedPanel.append(facts([["Tokens served", Number(served.tokens || 0).toLocaleString()], ["Results served", Number(served.calls || 0).toLocaleString()],
+ ...(served.unrecorded_tokens ? [["Counted, not yet recorded", Number(served.unrecorded_tokens).toLocaleString() + " tokens"]] : []),
+ ...(served.by_channel || []).map(row => [channels[row.channel] || row.channel, Number(row.tokens).toLocaleString() + " tokens"]),
+ ...(served.by_credential || []).slice(0, 5).map(row => [row.label || row.credential_id, Number(row.tokens).toLocaleString() + " tokens"])]));
+ root.append(servedPanel);
+ // An installed extension can add to this view (/extensions.js).
+ if (typeof loadUsageDetails === "function") {
+ await loadUsageDetails(root, scope, current, data);
+ if (!current()) return;
+ }
// An installed edition can add its own panels here (/extensions.js).
if (typeof loadPlan === "function") {
await loadPlan(root, scope, current, data);
diff --git a/docs/agents.md b/docs/agents.md
index 4c26e85..7c46348 100644
--- a/docs/agents.md
+++ b/docs/agents.md
@@ -35,9 +35,10 @@ as `connect <agent> --graph` does:
MCP server's tools and the server's instructions in every request, and
loads a tool only when the agent searches for it. Its entry runs
`graphicle mcp --tools essentials`: `query_graph`, `get_node`,
- `get_neighbors`, `recall_project` and `read_project_source`, with one
- sentence of instructions on when to call them; each tool's description
- says how its answers cite code. `--tools all` gives it every tool, as
+ `get_neighbors`, `recall_project` and `read_project_source`, with short
+ instructions on when to call them and when grep is enough; each tool's
+ description says how its answers cite code and, for the search tools,
+ when to use it instead of grep. `--tools all` gives it every tool, as
0.1.0 did.
- **Memory drafts.** The other agents' entries run the whole server with
`--allow-learning`, so the agent can propose a memory: a decision, a
@@ -52,15 +53,34 @@ The graph guard is off unless you ask for it with `--guards` (setup or
`.claude/settings.local.json` run before Claude Code searches (Grep, or a
shell command such as `grep`, `rg` or `find`) or reads a source file in a
project whose code graph holds code. They point it to `query_graph`,
- `get_node`, `get_neighbors` and `recall_project` first; reading a file to
- change it stays the agent's choice. In other folders they pass the request
- to the graph engine's own guard. Each agent gets at most five of these
- nudges a session (a subagent counts on its own, and the first nudge always
- comes); the environment variable `GRAPHICLE_HOOK_NUDGE_CAP` sets another
- limit, and `0` lifts it. The other agents' hooks cannot add context before
- a tool call, so they get the entry only. Setup or `connect` without an
- agent, run without `--guards`, removes the guard hooks an earlier setup
- installed.
+ `get_node`, `get_neighbors` and `recall_project` first (the search hook
+ adds that grep is enough for an exact identifier the agent already
+ knows); reading a file to change it stays the agent's choice. `get_node` also lists the reviewed
+ memories anchored to the symbol and the documents that name it. In other
+ folders they pass the request to the graph engine's own guard. Each agent
+ gets at most five of these nudges a session (a subagent counts on its own,
+ and the first nudge always comes); the environment variable
+ `GRAPHICLE_HOOK_NUDGE_CAP` sets another limit, and `0` lifts it. The other
+ agents' hooks cannot add context before a tool call, so they get the entry
+ only. Setup or `connect` without an agent, run without `--guards`, removes
+ the guard hooks an earlier setup installed.
+
+The prompt hook is off unless you ask for it with `graphicle setup
+--prompt-context`:
+
+- **The prompt hook (Claude Code).** One UserPromptSubmit hook in
+ `.claude/settings.local.json` runs `graphicle context` on each prompt that
+ is a code question (it names code, such as an identifier, a call or a
+ code file, or reads like an issue or bug report) and gives Claude Code
+ the packet's Markdown, at most 8,400 characters (Claude Code shows hook
+ output over 10,000 characters only as a 2 KB preview), as the prompt's
+ additional context. It adds nothing for a prompt with fewer than 16
+ characters besides spaces, for a question in plain words, in a folder of
+ no Graphicle project, when `graphicle context` fails, and when it has not
+ answered within 10 seconds (it is stopped; the hook's own timeout is 15
+ seconds). Setup without `--prompt-context` leaves the hook as an earlier
+ setup left it; `graphicle disconnect claude-code` removes it with the
+ other hooks.
A plain `graphicle connect <agent>` writes the entry without `--allow-learning`
and adds no guard hooks; run after setup (0.1.0's too, or `setup --tools
@@ -69,12 +89,21 @@ all`), it keeps setup's entry as it is.
`graphicle setup --tools all --guards` brings back 0.1.0's setup for Claude
Code: every tool, with 0.1.0's server instructions and replies (recall at
the budget asked for and in 0.1.0's order), the guard hooks, and 0.1.0's
-`AGENTS.md` section. Two things stay as in 0.1.1: the session-start hook
-prints nothing when the project has no reviewed memory, no open work and no
-stale memory (0.1.0 printed the last captured turns), and `graphicle
+`AGENTS.md` section. The instructions and the search tools' descriptions
+also say when to use Graphicle and when grep is enough, as every set's do.
+Two things are as in the default setup: the session-start hook prints only its
+line on when to use Graphicle when the project has no reviewed memory, no
+open work and no stale memory (0.1.0 printed the last captured turns), and
+`graphicle
context` in a terminal puts test files last unless a call asks otherwise
(`include_tests: true` through `graphicle call context`).
+An entry that runs `graphicle mcp --workspace` instead gives the agent a
+workspace connection to every project its key can read: `list_projects`
+names them, `workspace_map` shows what each holds and the imports between
+them, and `recall_project` searches them, up to 8 at a time, unless `repo`
+names one ([mcp.md](mcp.md#several-projects-in-one-connection)).
+
## How Graphicle edits your files
- **Only its own entries.** Graphicle adds an MCP entry named `graphicle` or
@@ -110,6 +139,7 @@ the folder they start in. Agents with one settings file for your user account
| MCP server `graphicle` | `.mcp.json` in the project folder | setup, `connect claude-code` |
| Session capture hooks | `.claude/settings.local.json` in the project folder | setup (unless `--no-capture`), `connect claude-code --hooks` |
| Graph guard hooks | `.claude/settings.local.json` in the project folder | `setup --guards`, `connect claude-code --guards` |
+| Prompt hook | `.claude/settings.local.json` in the project folder | `setup --prompt-context` |
| Graphicle section | `CLAUDE.md`, if the project has one and another agent is connected too | setup (unless `--no-instructions`) |
- Claude Code asks you to approve the servers in a project's `.mcp.json`
@@ -187,8 +217,8 @@ Graphicle. [mcp.md](mcp.md#other-clients) shows the entry to add by hand.
Setup adds a two-line Graphicle section to `AGENTS.md` in the project folder,
and to `CLAUDE.md` if it exists. Many agents read these files with every
-request. The section tells them when to call Graphicle's tools, and what to
-run in a terminal without them.
+request. The section tells them when to call Graphicle's tools and when grep
+is enough, and what to run in a terminal without them.
- The section sits between the lines
`<!-- graphicle:start (added by graphicle setup; graphicle disconnect removes it) -->`
diff --git a/docs/assets/retrieval-dark.png b/docs/assets/retrieval-dark.png
new file mode 100644
index 0000000..7091898
Binary files /dev/null and b/docs/assets/retrieval-dark.png differ
diff --git a/docs/assets/retrieval-dark.svg b/docs/assets/retrieval-dark.svg
new file mode 100644
index 0000000..912ce97
--- /dev/null
+++ b/docs/assets/retrieval-dark.svg
@@ -0,0 +1,6372 @@
+<?xml version="1.0" encoding="utf-8" standalone="no"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
+ "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
+<svg xmlns:xlink="http://www.w3.org/1999/xlink" width="1600" height="900" viewBox="0 0 1600 900" xmlns="http://www.w3.org/2000/svg" version="1.1">
+ <title>Finding the files a fix changes: 100 SWE-bench Verified issues, held out from tuning. Top 1: Graphicle 0.1.3 43, Graphicle 0.1.2 13, BM25 (SWE-bench style) 35, grep for the issue&#x27;s names 20; Top 5: Graphicle 0.1.3 75, Graphicle 0.1.2 30, BM25 (SWE-bench style) 61, grep for the issue&#x27;s names 54; Top 10: Graphicle 0.1.3 82, Graphicle 0.1.2 30, BM25 (SWE-bench style) 77, grep for the issue&#x27;s names 71; MRR: Graphicle 0.1.3 0.562, Graphicle 0.1.2 0.191, BM25 (SWE-bench style) 0.478, grep for the issue&#x27;s names 0.365.</title>
+ <desc>Finding the files a fix changes: 100 SWE-bench Verified issues, held out from tuning. For each issue: is a file the fix changed among the first k files? Graphicle: the files its context packet cites, then lists. No model calls. Higher is better. Top 1 (Issues of 100 with a changed file first): Graphicle 0.1.3 43, Graphicle 0.1.2 13, BM25 (SWE-bench style) 35, grep for the issue&#x27;s names 20; 0.1.3 vs BM25, McNemar exact: +8 issues, p = 0.200, not significant. Top 5 (Issues of 100 with a changed file in the first 5): Graphicle 0.1.3 75, Graphicle 0.1.2 30, BM25 (SWE-bench style) 61, grep for the issue&#x27;s names 54; 0.1.3 vs BM25, McNemar exact: +14 issues, p = 0.013. Top 10 (Issues of 100 with a changed file in the first 10): Graphicle 0.1.3 82, Graphicle 0.1.2 30, BM25 (SWE-bench style) 77, grep for the issue&#x27;s names 71; 0.1.3 vs BM25, McNemar exact: +5 issues, p = 0.383, not significant. MRR (Mean reciprocal rank of the first changed file): Graphicle 0.1.3 0.562, Graphicle 0.1.2 0.191, BM25 (SWE-bench style) 0.478, grep for the issue&#x27;s names 0.365. Graphicle 0.1.3 and the 0.1.2 release binary run graphicle context on the issue&#x27;s prompt, with their defaults. BM25: SWE-bench style, one document per source file. grep: rg 14.1.1 for the identifiers and paths the issue names, files ranked by names matched. This measures ranking, not whether a coding agent fixes more issues. The agent test of 0.1.3 is pending. Method, task list and limits: github.com/graphicle-ai/graphicle/blob/main/docs/benchmarks/retrieval.md</desc>
+ <metadata>
+ <rdf:RDF xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://creativecommons.org/ns#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
+ <cc:Work>
+ <dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage"/>
+ <dc:format>image/svg+xml</dc:format>
+ <dc:creator>
+ <cc:Agent>
+ <dc:title>Matplotlib v3.11.2, https://matplotlib.org/</dc:title>
+ </cc:Agent>
+ </dc:creator>
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <defs>
+ <style type="text/css">*{stroke-linejoin: round; stroke-linecap: butt}</style>
+ </defs>
+ <g id="figure_1">
+ <g id="patch_1">
+ <path d="M 0 900
+L 1600 900
+L 1600 0
+L 0 0
+z
+" style="fill: #0d1117"/>
+ </g>
+ <g id="axes_1">
+ <g id="patch_2">
+ <path d="M 48 764
+L 1552 764
+L 1552 765
+L 48 765
+z
+" clip-path="url(#pd3e7befa96)" style="fill: #2a2f3b"/>
+ </g>
+ <g id="patch_3">
+ <path d="M 678.296875 46
+L 686.296875 46
+Q 690.296875 46 690.296875 50
+L 690.296875 58
+Q 690.296875 62 686.296875 62
+L 678.296875 62
+Q 674.296875 62 674.296875 58
+L 674.296875 50
+Q 674.296875 46 678.296875 46
+z
+" clip-path="url(#pd3e7befa96)" style="fill: #5b7cff"/>
+ </g>
+ <g id="patch_4">
+ <path d="M 856.40625 46
+L 864.40625 46
+Q 868.40625 46 868.40625 50
+L 868.40625 58
+Q 868.40625 62 864.40625 62
+L 856.40625 62
+Q 852.40625 62 852.40625 58
+L 852.40625 50
+Q 852.40625 46 856.40625 46
+z
+" clip-path="url(#pd3e7befa96)" style="fill: #2e3d85"/>
+ </g>
+ <g id="patch_5">
+ <path d="M 1034.78125 46
+L 1042.78125 46
+Q 1046.78125 46 1046.78125 50
+L 1046.78125 58
+Q 1046.78125 62 1042.78125 62
+L 1034.78125 62
+Q 1030.78125 62 1030.78125 58
+L 1030.78125 50
+Q 1030.78125 46 1034.78125 46
+z
+" clip-path="url(#pd3e7befa96)" style="fill: #6b7385"/>
+ </g>
+ <g id="patch_6">
+ <path d="M 1304 46
+L 1312 46
+Q 1316 46 1316 50
+L 1316 58
+Q 1316 62 1312 62
+L 1304 62
+Q 1300 62 1300 58
+L 1300 50
+Q 1300 46 1304 46
+z
+" clip-path="url(#pd3e7befa96)" style="fill: #3a3f4b"/>
+ </g>
+ <g id="patch_7">
+ <path d="M 65.3 624
+L 65.3 493.84
+Q 65.3 489.84 69.3 489.84
+L 113.2 489.84
+Q 117.2 489.84 117.2 493.84
+L 117.2 624
+z
+" clip-path="url(#pd3e7befa96)" style="fill: #5b7cff"/>
+ </g>
+ <g id="patch_8">
+ <path d="M 151.8 624
+L 151.8 587.44
+Q 151.8 583.44 155.8 583.44
+L 199.7 583.44
+Q 203.7 583.44 203.7 587.44
+L 203.7 624
+z
+" clip-path="url(#pd3e7befa96)" style="fill: #2e3d85"/>
+ </g>
+ <g id="patch_9">
+ <path d="M 238.3 624
+L 238.3 518.8
+Q 238.3 514.8 242.3 514.8
+L 286.2 514.8
+Q 290.2 514.8 290.2 518.8
+L 290.2 624
+z
+" clip-path="url(#pd3e7befa96)" style="fill: #6b7385"/>
+ </g>
+ <g id="patch_10">
+ <path d="M 324.8 624
+L 324.8 565.6
+Q 324.8 561.6 328.8 561.6
+L 372.7 561.6
+Q 376.7 561.6 376.7 565.6
+L 376.7 624
+z
+" clip-path="url(#pd3e7befa96)" style="fill: #3a3f4b"/>
+ </g>
+ <g id="patch_11">
+ <path d="M 451.3 624
+L 451.3 394
+Q 451.3 390 455.3 390
+L 499.2 390
+Q 503.2 390 503.2 394
+L 503.2 624
+z
+" clip-path="url(#pd3e7befa96)" style="fill: #5b7cff"/>
+ </g>
+ <g id="patch_12">
+ <path d="M 537.8 624
+L 537.8 534.4
+Q 537.8 530.4 541.8 530.4
+L 585.7 530.4
+Q 589.7 530.4 589.7 534.4
+L 589.7 624
+z
+" clip-path="url(#pd3e7befa96)" style="fill: #2e3d85"/>
+ </g>
+ <g id="patch_13">
+ <path d="M 624.3 624
+L 624.3 437.68
+Q 624.3 433.68 628.3 433.68
+L 672.2 433.68
+Q 676.2 433.68 676.2 437.68
+L 676.2 624
+z
+" clip-path="url(#pd3e7befa96)" style="fill: #6b7385"/>
+ </g>
+ <g id="patch_14">
+ <path d="M 710.8 624
+L 710.8 459.52
+Q 710.8 455.52 714.8 455.52
+L 758.7 455.52
+Q 762.7 455.52 762.7 459.52
+L 762.7 624
+z
+" clip-path="url(#pd3e7befa96)" style="fill: #3a3f4b"/>
+ </g>
+ <g id="patch_15">
+ <path d="M 837.3 624
+L 837.3 372.16
+Q 837.3 368.16 841.3 368.16
+L 885.2 368.16
+Q 889.2 368.16 889.2 372.16
+L 889.2 624
+z
+" clip-path="url(#pd3e7befa96)" style="fill: #5b7cff"/>
+ </g>
+ <g id="patch_16">
+ <path d="M 923.8 624
+L 923.8 534.4
+Q 923.8 530.4 927.8 530.4
+L 971.7 530.4
+Q 975.7 530.4 975.7 534.4
+L 975.7 624
+z
+" clip-path="url(#pd3e7befa96)" style="fill: #2e3d85"/>
+ </g>
+ <g id="patch_17">
+ <path d="M 1010.3 624
+L 1010.3 387.76
+Q 1010.3 383.76 1014.3 383.76
+L 1058.2 383.76
+Q 1062.2 383.76 1062.2 387.76
+L 1062.2 624
+z
+" clip-path="url(#pd3e7befa96)" style="fill: #6b7385"/>
+ </g>
+ <g id="patch_18">
+ <path d="M 1096.8 624
+L 1096.8 406.48
+Q 1096.8 402.48 1100.8 402.48
+L 1144.7 402.48
+Q 1148.7 402.48 1148.7 406.48
+L 1148.7 624
+z
+" clip-path="url(#pd3e7befa96)" style="fill: #3a3f4b"/>
+ </g>
+ <g id="patch_19">
+ <path d="M 1223.3 624
+L 1223.3 452.7496
+Q 1223.3 448.7496 1227.3 448.7496
+L 1271.2 448.7496
+Q 1275.2 448.7496 1275.2 452.7496
+L 1275.2 624
+z
+" clip-path="url(#pd3e7befa96)" style="fill: #5b7cff"/>
+ </g>
+ <g id="patch_20">
+ <path d="M 1309.8 624
+L 1309.8 568.3456
+Q 1309.8 564.3456 1313.8 564.3456
+L 1357.7 564.3456
+Q 1361.7 564.3456 1361.7 568.3456
+L 1361.7 624
+z
+" clip-path="url(#pd3e7befa96)" style="fill: #2e3d85"/>
+ </g>
+ <g id="patch_21">
+ <path d="M 1396.3 624
+L 1396.3 478.9888
+Q 1396.3 474.9888 1400.3 474.9888
+L 1444.2 474.9888
+Q 1448.2 474.9888 1448.2 478.9888
+L 1448.2 624
+z
+" clip-path="url(#pd3e7befa96)" style="fill: #6b7385"/>
+ </g>
+ <g id="patch_22">
+ <path d="M 1482.8 624
+L 1482.8 514.0264
+Q 1482.8 510.0264 1486.8 510.0264
+L 1530.7 510.0264
+Q 1534.7 510.0264 1534.7 514.0264
+L 1534.7 624
+z
+" clip-path="url(#pd3e7befa96)" style="fill: #3a3f4b"/>
+ </g>
+ <g id="patch_23">
+ <path d="M 48 623.25
+L 394 623.25
+L 394 624.75
+L 48 624.75
+z
+" clip-path="url(#pd3e7befa96)" style="fill: #2a2f3b"/>
+ </g>
+ <g id="patch_24">
+ <path d="M 434 623.25
+L 780 623.25
+L 780 624.75
+L 434 624.75
+z
+" clip-path="url(#pd3e7befa96)" style="fill: #2a2f3b"/>
+ </g>
+ <g id="patch_25">
+ <path d="M 820 623.25
+L 1166 623.25
+L 1166 624.75
+L 820 624.75
+z
+" clip-path="url(#pd3e7befa96)" style="fill: #2a2f3b"/>
+ </g>
+ <g id="patch_26">
+ <path d="M 1206 623.25
+L 1552 623.25
+L 1552 624.75
+L 1206 624.75
+z
+" clip-path="url(#pd3e7befa96)" style="fill: #2a2f3b"/>
+ </g>
+ <g id="patch_27">
+ <path d="M 63 712.457
+L 369.640625 712.457
+Q 384.640625 712.457 384.640625 727.457
+L 384.640625 727.457
+Q 384.640625 742.457 369.640625 742.457
+L 63 742.457
+Q 48 742.457 48 727.457
+L 48 727.457
+Q 48 712.457 63 712.457
+z
+" clip-path="url(#pd3e7befa96)" style="fill: #262c36"/>
+ </g>
+ <g id="patch_28">
+ <path d="M 449 712.457
+L 625.125 712.457
+Q 640.125 712.457 640.125 727.457
+L 640.125 727.457
+Q 640.125 742.457 625.125 742.457
+L 449 742.457
+Q 434 742.457 434 727.457
+L 434 727.457
+Q 434 712.457 449 712.457
+z
+" clip-path="url(#pd3e7befa96)" style="fill: #3f5efb"/>
+ </g>
+ <g id="patch_29">
+ <path d="M 835 712.457
+L 1140.265625 712.457
+Q 1155.265625 712.457 1155.265625 727.457
+L 1155.265625 727.457
+Q 1155.265625 742.457 1140.265625 742.457
+L 835 742.457
+Q 820 742.457 820 727.457
+L 820 727.457
+Q 820 712.457 835 712.457
+z
+" clip-path="url(#pd3e7befa96)" style="fill: #262c36"/>
+ </g>
+ <g id="text_1">
+ <!-- Graphicle -->
+ <g style="fill: #f4f6fa" transform="translate(48 60) scale(0.28 -0.28)">
+ <defs>
+ <path id="Inter-Bold-8d" d="M 2484 -63
+Q 1831 -63 1337 226
+Q 844 516 569 1050
+Q 294 1584 294 2322
+Q 294 3075 580 3612
+Q 866 4150 1358 4434
+Q 1850 4719 2463 4719
+Q 2988 4719 3413 4519
+Q 3838 4319 4109 3967
+Q 4381 3616 4447 3156
+L 3478 3156
+Q 3378 3491 3122 3681
+Q 2866 3872 2478 3872
+Q 1941 3872 1602 3472
+Q 1263 3072 1263 2331
+Q 1263 1591 1597 1187
+Q 1931 784 2491 784
+Q 2988 784 3272 1046
+Q 3556 1309 3569 1756
+L 2556 1756
+L 2556 2481
+L 4494 2481
+L 4494 1900
+Q 4494 1288 4234 848
+Q 3975 409 3522 173
+Q 3069 -63 2484 -63
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Bold-354" d="M 400 0
+L 400 3494
+L 1306 3494
+L 1306 2884
+L 1344 2884
+Q 1441 3206 1667 3373
+Q 1894 3541 2188 3541
+Q 2347 3541 2491 3509
+L 2491 2672
+Q 2428 2691 2308 2705
+Q 2188 2719 2084 2719
+Q 1759 2719 1548 2516
+Q 1338 2313 1338 1988
+L 1338 0
+L 400 0
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Bold-1fb" d="M 1375 -69
+Q 875 -69 544 195
+Q 213 459 213 978
+Q 213 1369 400 1591
+Q 588 1813 888 1916
+Q 1188 2019 1531 2050
+Q 1981 2094 2179 2142
+Q 2378 2191 2378 2363
+L 2378 2378
+Q 2378 2600 2236 2722
+Q 2094 2844 1831 2844
+Q 1559 2844 1393 2726
+Q 1228 2609 1172 2441
+L 313 2584
+Q 447 3038 848 3288
+Q 1250 3538 1834 3538
+Q 2209 3538 2548 3419
+Q 2888 3300 3102 3039
+Q 3316 2778 3316 2353
+L 3316 0
+L 2428 0
+L 2428 484
+L 2397 484
+Q 2269 241 2016 86
+Q 1763 -69 1375 -69
+z
+M 1641 591
+Q 1969 591 2176 781
+Q 2384 972 2384 1250
+L 2384 1628
+Q 2328 1588 2201 1558
+Q 2075 1528 1934 1504
+Q 1794 1481 1691 1469
+Q 1431 1431 1272 1322
+Q 1113 1213 1113 1003
+Q 1113 800 1261 695
+Q 1409 591 1641 591
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Bold-34b" d="M 400 -1306
+L 400 3494
+L 1322 3494
+L 1322 2906
+L 1366 2906
+Q 1428 3044 1548 3191
+Q 1669 3338 1867 3438
+Q 2066 3538 2363 3538
+Q 2750 3538 3072 3338
+Q 3394 3138 3586 2738
+Q 3778 2338 3778 1741
+Q 3778 1159 3590 757
+Q 3403 356 3081 148
+Q 2759 -59 2356 -59
+Q 2072 -59 1875 37
+Q 1678 134 1554 276
+Q 1431 419 1366 559
+L 1338 559
+L 1338 -1306
+L 400 -1306
+z
+M 2069 694
+Q 2434 694 2626 987
+Q 2819 1281 2819 1744
+Q 2819 2203 2628 2495
+Q 2438 2788 2069 2788
+Q 1706 2788 1511 2503
+Q 1316 2219 1316 1744
+Q 1316 1269 1512 981
+Q 1709 694 2069 694
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Bold-29e" d="M 1338 2022
+L 1338 0
+L 400 0
+L 400 4656
+L 1319 4656
+L 1319 2825
+Q 1472 3166 1734 3352
+Q 1997 3538 2384 3538
+Q 2928 3538 3258 3188
+Q 3588 2838 3588 2222
+L 3588 0
+L 2647 0
+L 2647 2059
+Q 2647 2384 2480 2568
+Q 2313 2753 2016 2753
+Q 1716 2753 1527 2561
+Q 1338 2369 1338 2022
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Bold-2b1" d="M 400 0
+L 400 3494
+L 1338 3494
+L 1338 0
+L 400 0
+z
+M 869 3950
+Q 656 3950 506 4090
+Q 356 4231 356 4431
+Q 356 4631 506 4772
+Q 656 4913 869 4913
+Q 1081 4913 1232 4772
+Q 1384 4631 1384 4431
+Q 1384 4231 1232 4090
+Q 1081 3950 869 3950
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Bold-24a" d="M 1963 -69
+Q 1434 -69 1051 157
+Q 669 384 461 789
+Q 253 1194 253 1731
+Q 253 2272 461 2678
+Q 669 3084 1051 3311
+Q 1434 3538 1963 3538
+Q 2584 3538 3000 3227
+Q 3416 2916 3516 2375
+L 2644 2213
+Q 2584 2484 2414 2642
+Q 2244 2800 1972 2800
+Q 1597 2800 1403 2504
+Q 1209 2209 1209 1734
+Q 1209 1266 1403 967
+Q 1597 669 1972 669
+Q 2244 669 2419 833
+Q 2594 997 2650 1278
+L 3522 1119
+Q 3422 566 3006 248
+Q 2591 -69 1963 -69
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Bold-2e0" d="M 1338 4656
+L 1338 0
+L 400 0
+L 400 4656
+L 1338 4656
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Bold-266" d="M 1978 -69
+Q 1444 -69 1056 150
+Q 669 369 461 772
+Q 253 1175 253 1728
+Q 253 2269 461 2675
+Q 669 3081 1045 3309
+Q 1422 3538 1931 3538
+Q 2388 3538 2759 3344
+Q 3131 3150 3351 2756
+Q 3572 2363 3572 1766
+L 3572 1503
+L 1181 1503
+Q 1197 1075 1419 856
+Q 1641 638 1994 638
+Q 2241 638 2417 742
+Q 2594 847 2669 1050
+L 3519 891
+Q 3391 456 2989 193
+Q 2588 -69 1978 -69
+z
+M 1188 2091
+L 2669 2091
+Q 2634 2431 2450 2631
+Q 2266 2831 1941 2831
+Q 1603 2831 1409 2623
+Q 1216 2416 1188 2091
+z
+" transform="scale(0.015625)"/>
+ </defs>
+ <use xlink:href="#Inter-Bold-8d"/>
+ <use xlink:href="#Inter-Bold-354" transform="translate(75.046875 0)"/>
+ <use xlink:href="#Inter-Bold-1fb" transform="translate(114.40625 0)"/>
+ <use xlink:href="#Inter-Bold-34b" transform="translate(172.46875 0)"/>
+ <use xlink:href="#Inter-Bold-29e" transform="translate(235.5 0)"/>
+ <use xlink:href="#Inter-Bold-2b1" transform="translate(297.75 0)"/>
+ <use xlink:href="#Inter-Bold-24a" transform="translate(324.84375 0)"/>
+ <use xlink:href="#Inter-Bold-2e0" transform="translate(383.6875 0)"/>
+ <use xlink:href="#Inter-Bold-266" transform="translate(410.78125 0)"/>
+ </g>
+ </g>
+ <g id="text_2">
+ <!-- Offline retrieval benchmark, 21 October 2026 -->
+ <g style="fill: #8a93a6" transform="translate(195.734375 60) scale(0.2 -0.2)">
+ <defs>
+ <path id="Inter-Regular-141" d="M 2450 -63
+Q 1853 -63 1386 226
+Q 919 516 650 1052
+Q 381 1588 381 2325
+Q 381 3066 650 3602
+Q 919 4138 1386 4428
+Q 1853 4719 2450 4719
+Q 3047 4719 3512 4428
+Q 3978 4138 4245 3602
+Q 4513 3066 4513 2325
+Q 4513 1588 4245 1052
+Q 3978 516 3512 226
+Q 3047 -63 2450 -63
+z
+M 2450 488
+Q 2866 488 3202 698
+Q 3538 909 3736 1320
+Q 3934 1731 3934 2325
+Q 3934 2925 3736 3336
+Q 3538 3747 3202 3958
+Q 2866 4169 2450 4169
+Q 2031 4169 1693 3956
+Q 1356 3744 1157 3333
+Q 959 2922 959 2325
+Q 959 1731 1157 1322
+Q 1356 913 1693 700
+Q 2031 488 2450 488
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Regular-287" d="M 2119 3494
+L 2119 3013
+L 1313 3013
+L 1313 0
+L 750 0
+L 750 3013
+L 63 3013
+L 63 3494
+L 750 3494
+L 750 3959
+Q 750 4263 892 4466
+Q 1034 4669 1262 4772
+Q 1491 4875 1744 4875
+Q 1944 4875 2075 4842
+Q 2206 4809 2269 4781
+L 2113 4300
+Q 2069 4316 1998 4334
+Q 1928 4353 1809 4353
+Q 1550 4353 1431 4220
+Q 1313 4088 1313 3834
+L 1313 3494
+L 2119 3494
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Regular-2e0" d="M 1056 4656
+L 1056 0
+L 494 0
+L 494 4656
+L 1056 4656
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Regular-2b1" d="M 494 0
+L 494 3494
+L 1056 3494
+L 1056 0
+L 494 0
+z
+M 778 4066
+Q 619 4066 503 4175
+Q 387 4284 387 4438
+Q 387 4594 503 4701
+Q 619 4809 778 4809
+Q 940 4809 1056 4701
+Q 1172 4594 1172 4438
+Q 1172 4284 1056 4175
+Q 940 4066 778 4066
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Regular-305" d="M 1056 2094
+L 1056 0
+L 494 0
+L 494 3494
+L 1034 3494
+L 1038 2847
+Q 1206 3219 1479 3378
+Q 1753 3538 2106 3538
+Q 2638 3538 2963 3209
+Q 3288 2881 3288 2219
+L 3288 0
+L 2725 0
+L 2725 2172
+Q 2725 2575 2514 2803
+Q 2303 3031 1938 3031
+Q 1559 3031 1307 2786
+Q 1056 2541 1056 2094
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Regular-266" d="M 1963 -75
+Q 1456 -75 1089 150
+Q 722 375 523 778
+Q 325 1181 325 1719
+Q 325 2256 519 2665
+Q 713 3075 1067 3306
+Q 1422 3538 1897 3538
+Q 2175 3538 2445 3445
+Q 2716 3353 2936 3148
+Q 3156 2944 3287 2609
+Q 3419 2275 3419 1791
+L 3419 1556
+L 894 1556
+Q 916 1009 1208 717
+Q 1500 425 1966 425
+Q 2275 425 2498 561
+Q 2722 697 2819 963
+L 3363 813
+Q 3241 416 2870 170
+Q 2500 -75 1963 -75
+z
+M 897 2031
+L 2847 2031
+Q 2806 2478 2567 2758
+Q 2328 3038 1897 3038
+Q 1597 3038 1380 2897
+Q 1163 2756 1038 2528
+Q 913 2300 897 2031
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Regular-6f1" transform="scale(0.015625)"/>
+ <path id="Inter-Regular-354" d="M 494 0
+L 494 3494
+L 1038 3494
+L 1038 2956
+L 1075 2956
+Q 1172 3222 1420 3383
+Q 1669 3544 1981 3544
+Q 2044 3544 2130 3541
+Q 2216 3538 2266 3534
+L 2266 2969
+Q 2241 2975 2141 2987
+Q 2041 3000 1928 3000
+Q 1550 3000 1303 2770
+Q 1056 2541 1056 2188
+L 1056 0
+L 494 0
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Regular-379" d="M 1869 3494
+L 1869 3013
+L 1150 3013
+L 1150 906
+Q 1150 672 1245 564
+Q 1341 456 1563 456
+Q 1616 456 1698 468
+Q 1781 481 1850 494
+L 1966 19
+Q 1878 -13 1767 -28
+Q 1656 -44 1547 -44
+Q 1094 -44 841 195
+Q 588 434 588 863
+L 588 3013
+L 63 3013
+L 63 3494
+L 588 3494
+L 588 4325
+L 1150 4325
+L 1150 3494
+L 1869 3494
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Regular-3d4" d="M 1503 0
+L 169 3494
+L 784 3494
+L 1528 1422
+Q 1609 1194 1675 967
+Q 1741 741 1800 522
+Q 1859 741 1923 967
+Q 1988 1194 2069 1422
+L 2813 3494
+L 3428 3494
+L 2094 0
+L 1503 0
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Regular-1fb" d="M 1472 -81
+Q 1141 -81 870 44
+Q 600 169 440 409
+Q 281 650 281 994
+Q 281 1294 400 1481
+Q 519 1669 717 1776
+Q 916 1884 1156 1937
+Q 1397 1991 1641 2022
+Q 1953 2063 2150 2084
+Q 2347 2106 2442 2159
+Q 2538 2213 2538 2341
+L 2538 2359
+Q 2538 2684 2353 2864
+Q 2169 3044 1806 3044
+Q 1428 3044 1215 2880
+Q 1003 2716 922 2531
+L 381 2709
+Q 516 3028 744 3208
+Q 972 3388 1247 3463
+Q 1522 3538 1791 3538
+Q 1966 3538 2189 3495
+Q 2413 3453 2620 3328
+Q 2828 3203 2964 2958
+Q 3100 2713 3100 2303
+L 3100 0
+L 2547 0
+L 2547 475
+L 2509 475
+Q 2450 353 2319 223
+Q 2188 94 1978 6
+Q 1769 -81 1472 -81
+z
+M 1569 416
+Q 1881 416 2097 537
+Q 2313 659 2425 854
+Q 2538 1050 2538 1263
+L 2538 1747
+Q 2503 1706 2387 1673
+Q 2272 1641 2123 1616
+Q 1975 1591 1836 1573
+Q 1697 1556 1616 1547
+Q 1413 1522 1236 1461
+Q 1059 1400 953 1283
+Q 847 1166 847 966
+Q 847 694 1051 555
+Q 1256 416 1569 416
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Regular-242" d="M 2116 -75
+Q 1784 -75 1581 39
+Q 1378 153 1268 298
+Q 1159 444 1100 541
+L 1038 541
+L 1038 0
+L 494 0
+L 494 4656
+L 1056 4656
+L 1056 2934
+L 1100 2934
+Q 1159 3028 1265 3170
+Q 1372 3313 1572 3425
+Q 1772 3538 2113 3538
+Q 2550 3538 2883 3319
+Q 3216 3100 3405 2695
+Q 3594 2291 3594 1738
+Q 3594 1181 3406 775
+Q 3219 369 2886 147
+Q 2553 -75 2116 -75
+z
+M 2031 428
+Q 2359 428 2579 604
+Q 2800 781 2911 1079
+Q 3022 1378 3022 1744
+Q 3022 2106 2912 2398
+Q 2803 2691 2583 2862
+Q 2363 3034 2031 3034
+Q 1550 3034 1300 2678
+Q 1050 2322 1050 1744
+Q 1050 1159 1303 793
+Q 1556 428 2031 428
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Regular-24a" d="M 1916 -75
+Q 1441 -75 1083 150
+Q 725 375 525 781
+Q 325 1188 325 1725
+Q 325 2272 525 2680
+Q 725 3088 1083 3313
+Q 1441 3538 1916 3538
+Q 2422 3538 2805 3283
+Q 3188 3028 3331 2572
+L 2791 2419
+Q 2713 2688 2486 2861
+Q 2259 3034 1916 3034
+Q 1566 3034 1341 2851
+Q 1116 2669 1006 2372
+Q 897 2075 897 1725
+Q 897 1381 1006 1086
+Q 1116 791 1341 609
+Q 1566 428 1916 428
+Q 2269 428 2498 608
+Q 2728 788 2806 1072
+L 3344 919
+Q 3203 453 2815 189
+Q 2428 -75 1916 -75
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Regular-29e" d="M 1056 2094
+L 1056 0
+L 494 0
+L 494 4656
+L 1056 4656
+L 1056 2888
+Q 1228 3238 1495 3388
+Q 1763 3538 2106 3538
+Q 2638 3538 2964 3209
+Q 3291 2881 3291 2219
+L 3291 0
+L 2725 0
+L 2725 2172
+Q 2725 2575 2514 2803
+Q 2303 3031 1938 3031
+Q 1559 3031 1307 2786
+Q 1056 2541 1056 2094
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Regular-2fe" d="M 494 0
+L 494 3494
+L 1041 3494
+L 1044 2853
+Q 1172 3206 1442 3381
+Q 1713 3556 2022 3556
+Q 2366 3556 2592 3361
+Q 2819 3166 2913 2844
+Q 3038 3175 3336 3365
+Q 3634 3556 4013 3556
+Q 4316 3556 4566 3425
+Q 4816 3294 4964 3028
+Q 5113 2763 5113 2356
+L 5113 0
+L 4550 0
+L 4550 2341
+Q 4550 2719 4337 2881
+Q 4125 3044 3844 3044
+Q 3491 3044 3287 2828
+Q 3084 2613 3084 2281
+L 3084 0
+L 2522 0
+L 2522 2397
+Q 2522 2688 2328 2866
+Q 2134 3044 1838 3044
+Q 1531 3044 1293 2831
+Q 1056 2619 1056 2200
+L 1056 0
+L 494 0
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Regular-2d7" d="M 494 0
+L 494 4656
+L 1056 4656
+L 1056 1953
+L 1125 1953
+L 2619 3494
+L 3316 3494
+L 1853 1994
+L 3425 0
+L 2703 0
+L 1425 1634
+L 1056 1288
+L 1056 0
+L 494 0
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Regular-5dd" d="M 400 -1122
+L 675 650
+L 1319 650
+L 831 -1122
+L 400 -1122
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Regular-53f" d="M 481 0
+L 481 428
+L 2028 2106
+Q 2288 2388 2459 2600
+Q 2631 2813 2718 3005
+Q 2806 3197 2806 3413
+Q 2806 3778 2554 3990
+Q 2303 4203 1931 4203
+Q 1534 4203 1298 3965
+Q 1063 3728 1063 3334
+L 494 3334
+Q 494 3747 684 4059
+Q 875 4372 1203 4545
+Q 1531 4719 1947 4719
+Q 2363 4719 2683 4545
+Q 3003 4372 3186 4078
+Q 3369 3784 3369 3419
+Q 3369 3166 3278 2927
+Q 3188 2688 2959 2384
+Q 2731 2081 2319 1644
+L 1300 559
+L 1300 522
+L 3447 522
+L 3447 0
+L 481 0
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Regular-53e" d="M 2041 4656
+L 2041 0
+L 1456 0
+L 1456 4106
+L 1425 4106
+L 300 3272
+L 300 3909
+L 1313 4656
+L 2041 4656
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Regular-316" d="M 1916 -75
+Q 1441 -75 1083 150
+Q 725 375 525 781
+Q 325 1188 325 1725
+Q 325 2272 525 2680
+Q 725 3088 1083 3313
+Q 1441 3538 1916 3538
+Q 2394 3538 2753 3313
+Q 3113 3088 3313 2680
+Q 3513 2272 3513 1725
+Q 3513 1188 3313 781
+Q 3113 375 2753 150
+Q 2394 -75 1916 -75
+z
+M 1916 428
+Q 2269 428 2497 609
+Q 2725 791 2834 1086
+Q 2944 1381 2944 1725
+Q 2944 2072 2834 2370
+Q 2725 2669 2497 2851
+Q 2269 3034 1916 3034
+Q 1566 3034 1341 2851
+Q 1116 2669 1006 2372
+Q 897 2075 897 1725
+Q 897 1381 1006 1086
+Q 1116 791 1341 609
+Q 1566 428 1916 428
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Regular-53d" d="M 2019 -63
+Q 1241 -63 811 562
+Q 381 1188 381 2325
+Q 381 3456 814 4087
+Q 1247 4719 2019 4719
+Q 2794 4719 3225 4087
+Q 3656 3456 3656 2325
+Q 3656 1188 3228 562
+Q 2800 -63 2019 -63
+z
+M 2019 456
+Q 2531 456 2807 948
+Q 3084 1441 3084 2325
+Q 3084 3216 2807 3709
+Q 2531 4203 2019 4203
+Q 1509 4203 1231 3708
+Q 953 3213 953 2325
+Q 953 1441 1231 948
+Q 1509 456 2019 456
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Regular-545" d="M 2019 -63
+Q 1728 -63 1437 43
+Q 1147 150 908 400
+Q 669 650 525 1078
+Q 381 1506 381 2150
+Q 381 3378 840 4048
+Q 1300 4719 2091 4719
+Q 2481 4719 2790 4562
+Q 3100 4406 3297 4128
+Q 3494 3850 3550 3484
+L 2969 3484
+Q 2891 3788 2672 3991
+Q 2453 4194 2091 4194
+Q 1553 4194 1248 3730
+Q 944 3266 944 2425
+L 981 2425
+Q 1169 2716 1467 2880
+Q 1766 3044 2128 3044
+Q 2528 3044 2859 2847
+Q 3191 2650 3389 2301
+Q 3588 1953 3588 1503
+Q 3588 1069 3394 714
+Q 3200 359 2847 148
+Q 2494 -63 2019 -63
+z
+M 2019 459
+Q 2300 459 2525 600
+Q 2750 741 2881 977
+Q 3013 1213 3013 1503
+Q 3013 1788 2886 2020
+Q 2759 2253 2537 2390
+Q 2316 2528 2034 2528
+Q 1753 2528 1525 2384
+Q 1297 2241 1162 2005
+Q 1028 1769 1028 1497
+Q 1028 1222 1156 986
+Q 1284 750 1509 604
+Q 1734 459 2019 459
+z
+" transform="scale(0.015625)"/>
+ </defs>
+ <use xlink:href="#Inter-Regular-141"/>
+ <use xlink:href="#Inter-Regular-287" transform="translate(76.46875 0)"/>
+ <use xlink:href="#Inter-Regular-287" transform="translate(109.578125 0)"/>
+ <use xlink:href="#Inter-Regular-2e0" transform="translate(146.59375 0)"/>
+ <use xlink:href="#Inter-Regular-2b1" transform="translate(170.8125 0)"/>
+ <use xlink:href="#Inter-Regular-305" transform="translate(195.03125 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(254.109375 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(312.40625 0)"/>
+ <use xlink:href="#Inter-Regular-354" transform="translate(340.53125 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(376.515625 0)"/>
+ <use xlink:href="#Inter-Regular-379" transform="translate(434.8125 0)"/>
+ <use xlink:href="#Inter-Regular-354" transform="translate(467.53125 0)"/>
+ <use xlink:href="#Inter-Regular-2b1" transform="translate(506.15625 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(530.375 0)"/>
+ <use xlink:href="#Inter-Regular-3d4" transform="translate(586.71875 0)"/>
+ <use xlink:href="#Inter-Regular-1fb" transform="translate(642.4375 0)"/>
+ <use xlink:href="#Inter-Regular-2e0" transform="translate(698.59375 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(722.8125 0)"/>
+ <use xlink:href="#Inter-Regular-242" transform="translate(750.9375 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(812.171875 0)"/>
+ <use xlink:href="#Inter-Regular-305" transform="translate(870.46875 0)"/>
+ <use xlink:href="#Inter-Regular-24a" transform="translate(929.546875 0)"/>
+ <use xlink:href="#Inter-Regular-29e" transform="translate(986.671875 0)"/>
+ <use xlink:href="#Inter-Regular-2fe" transform="translate(1045.796875 0)"/>
+ <use xlink:href="#Inter-Regular-1fb" transform="translate(1133.390625 0)"/>
+ <use xlink:href="#Inter-Regular-354" transform="translate(1189.546875 0)"/>
+ <use xlink:href="#Inter-Regular-2d7" transform="translate(1228.75 0)"/>
+ <use xlink:href="#Inter-Regular-5dd" transform="translate(1283.640625 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(1312.453125 0)"/>
+ <use xlink:href="#Inter-Regular-53f" transform="translate(1340.578125 0)"/>
+ <use xlink:href="#Inter-Regular-53e" transform="translate(1401.5625 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(1442.234375 0)"/>
+ <use xlink:href="#Inter-Regular-141" transform="translate(1470.359375 0)"/>
+ <use xlink:href="#Inter-Regular-24a" transform="translate(1546.828125 0)"/>
+ <use xlink:href="#Inter-Regular-379" transform="translate(1603.953125 0)"/>
+ <use xlink:href="#Inter-Regular-316" transform="translate(1635.703125 0)"/>
+ <use xlink:href="#Inter-Regular-242" transform="translate(1695.671875 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(1756.90625 0)"/>
+ <use xlink:href="#Inter-Regular-354" transform="translate(1815.203125 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(1852.84375 0)"/>
+ <use xlink:href="#Inter-Regular-53f" transform="translate(1880.96875 0)"/>
+ <use xlink:href="#Inter-Regular-53d" transform="translate(1941.953125 0)"/>
+ <use xlink:href="#Inter-Regular-53f" transform="translate(2005.046875 0)"/>
+ <use xlink:href="#Inter-Regular-545" transform="translate(2066.03125 0)"/>
+ </g>
+ </g>
+ <g id="text_3">
+ <!-- Graphicle 0.1.3 -->
+ <g style="fill: #c9ced8" transform="translate(698.296875 60) scale(0.18 -0.18)">
+ <defs>
+ <path id="Inter-Medium-8d" d="M 2472 -63
+Q 1841 -63 1362 228
+Q 884 519 618 1053
+Q 353 1588 353 2325
+Q 353 3069 623 3605
+Q 894 4141 1366 4430
+Q 1838 4719 2441 4719
+Q 2944 4719 3353 4523
+Q 3763 4328 4030 3983
+Q 4297 3638 4375 3184
+L 3644 3184
+Q 3516 3594 3211 3831
+Q 2906 4069 2447 4069
+Q 2053 4069 1739 3869
+Q 1425 3669 1242 3280
+Q 1059 2891 1059 2328
+Q 1059 1766 1242 1378
+Q 1425 991 1744 789
+Q 2063 588 2475 588
+Q 3028 588 3367 914
+Q 3706 1241 3719 1800
+L 2578 1800
+L 2578 2388
+L 4416 2388
+L 4416 1853
+Q 4416 1266 4164 836
+Q 3913 406 3475 171
+Q 3038 -63 2472 -63
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Medium-354" d="M 463 0
+L 463 3494
+L 1128 3494
+L 1128 2931
+L 1166 2931
+Q 1259 3216 1501 3380
+Q 1744 3544 2050 3544
+Q 2116 3544 2202 3537
+Q 2288 3531 2341 3525
+L 2341 2869
+Q 2303 2878 2197 2892
+Q 2091 2906 1981 2906
+Q 1622 2906 1386 2686
+Q 1150 2466 1150 2122
+L 1150 0
+L 463 0
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Medium-1fb" d="M 1441 -78
+Q 1106 -78 839 45
+Q 572 169 415 406
+Q 259 644 259 988
+Q 259 1284 375 1476
+Q 491 1669 684 1780
+Q 878 1891 1117 1947
+Q 1356 2003 1603 2031
+Q 2066 2084 2275 2123
+Q 2484 2163 2484 2347
+L 2484 2366
+Q 2484 2656 2314 2817
+Q 2144 2978 1816 2978
+Q 1472 2978 1275 2828
+Q 1078 2678 1006 2500
+L 359 2669
+Q 478 2981 700 3172
+Q 922 3363 1208 3450
+Q 1494 3538 1806 3538
+Q 2016 3538 2253 3488
+Q 2491 3438 2700 3308
+Q 2909 3178 3040 2937
+Q 3172 2697 3172 2319
+L 3172 0
+L 2506 0
+L 2506 478
+L 2472 478
+Q 2369 272 2117 97
+Q 1866 -78 1441 -78
+z
+M 1594 475
+Q 1872 475 2072 586
+Q 2272 697 2380 875
+Q 2488 1053 2488 1259
+L 2488 1706
+Q 2438 1656 2273 1620
+Q 2109 1584 1928 1559
+Q 1747 1534 1641 1522
+Q 1350 1481 1142 1364
+Q 934 1247 934 978
+Q 934 728 1120 601
+Q 1306 475 1594 475
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Medium-34b" d="M 463 -1306
+L 463 3494
+L 1131 3494
+L 1131 2925
+L 1188 2925
+Q 1247 3031 1358 3176
+Q 1469 3322 1669 3430
+Q 1869 3538 2197 3538
+Q 2616 3538 2945 3325
+Q 3275 3113 3465 2709
+Q 3656 2306 3656 1738
+Q 3656 1175 3468 769
+Q 3281 363 2951 147
+Q 2622 -69 2197 -69
+Q 1878 -69 1678 39
+Q 1478 147 1364 290
+Q 1250 434 1188 547
+L 1150 547
+L 1150 -1306
+L 463 -1306
+z
+M 2044 516
+Q 2344 516 2545 678
+Q 2747 841 2850 1119
+Q 2953 1397 2953 1744
+Q 2953 2088 2851 2361
+Q 2750 2634 2548 2793
+Q 2347 2953 2044 2953
+Q 1600 2953 1369 2620
+Q 1138 2288 1138 1744
+Q 1138 1197 1372 856
+Q 1606 516 2044 516
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Medium-29e" d="M 1150 2069
+L 1150 0
+L 463 0
+L 463 4656
+L 1144 4656
+L 1144 2866
+Q 1309 3213 1575 3375
+Q 1841 3538 2200 3538
+Q 2734 3538 3062 3202
+Q 3391 2866 3391 2219
+L 3391 0
+L 2700 0
+L 2700 2134
+Q 2700 2513 2503 2725
+Q 2306 2938 1963 2938
+Q 1613 2938 1381 2711
+Q 1150 2484 1150 2069
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Medium-2b1" d="M 463 0
+L 463 3494
+L 1150 3494
+L 1150 0
+L 463 0
+z
+M 809 4028
+Q 631 4028 504 4147
+Q 378 4266 378 4434
+Q 378 4606 504 4725
+Q 631 4844 809 4844
+Q 987 4844 1115 4725
+Q 1243 4606 1243 4434
+Q 1243 4266 1115 4147
+Q 987 4028 809 4028
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Medium-24a" d="M 1931 -72
+Q 1438 -72 1072 153
+Q 706 378 503 783
+Q 300 1188 300 1728
+Q 300 2272 503 2680
+Q 706 3088 1072 3313
+Q 1438 3538 1931 3538
+Q 2475 3538 2870 3264
+Q 3266 2991 3394 2506
+L 2741 2350
+Q 2669 2622 2461 2789
+Q 2253 2956 1934 2956
+Q 1619 2956 1411 2790
+Q 1203 2625 1101 2345
+Q 1000 2066 1000 1728
+Q 1000 1394 1101 1117
+Q 1203 841 1411 675
+Q 1619 509 1934 509
+Q 2259 509 2471 682
+Q 2684 856 2753 1141
+L 3403 984
+Q 3275 491 2878 209
+Q 2481 -72 1931 -72
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Medium-2e0" d="M 1150 4656
+L 1150 0
+L 463 0
+L 463 4656
+L 1150 4656
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Medium-266" d="M 1969 -72
+Q 1453 -72 1078 150
+Q 703 372 501 775
+Q 300 1178 300 1722
+Q 300 2259 498 2668
+Q 697 3078 1059 3308
+Q 1422 3538 1909 3538
+Q 2306 3538 2664 3361
+Q 3022 3184 3245 2798
+Q 3469 2413 3469 1781
+L 3469 1538
+L 991 1538
+Q 1009 1031 1278 764
+Q 1547 497 1975 497
+Q 2263 497 2470 622
+Q 2678 747 2769 991
+L 3416 838
+Q 3291 428 2909 178
+Q 2528 -72 1969 -72
+z
+M 994 2050
+L 2788 2050
+Q 2750 2463 2529 2716
+Q 2309 2969 1913 2969
+Q 1500 2969 1261 2698
+Q 1022 2428 994 2050
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Medium-6f1" transform="scale(0.015625)"/>
+ <path id="Inter-Medium-53d" d="M 2066 -63
+Q 1253 -63 803 562
+Q 353 1188 353 2325
+Q 353 3456 804 4087
+Q 1256 4719 2066 4719
+Q 2875 4719 3326 4087
+Q 3778 3456 3778 2325
+Q 3778 1191 3329 564
+Q 2881 -63 2066 -63
+z
+M 2066 547
+Q 2550 547 2811 1012
+Q 3072 1478 3072 2325
+Q 3072 3175 2811 3644
+Q 2550 4113 2066 4113
+Q 1581 4113 1318 3642
+Q 1056 3172 1056 2325
+Q 1056 1478 1318 1012
+Q 1581 547 2066 547
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Medium-5de" d="M 972 -47
+Q 778 -47 643 86
+Q 509 219 509 413
+Q 509 606 643 740
+Q 778 875 972 875
+Q 1166 875 1298 740
+Q 1431 606 1431 413
+Q 1431 219 1298 86
+Q 1166 -47 972 -47
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Medium-53e" d="M 2141 4656
+L 2141 0
+L 1434 0
+L 1434 4009
+L 1403 4009
+L 297 3203
+L 297 3919
+L 1316 4656
+L 2141 4656
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Medium-541" d="M 2009 -63
+Q 1538 -63 1170 100
+Q 803 263 589 550
+Q 375 838 363 1219
+L 1084 1219
+Q 1103 909 1365 729
+Q 1628 550 2003 550
+Q 2409 550 2673 758
+Q 2938 966 2938 1303
+Q 2938 1650 2672 1870
+Q 2406 2091 1928 2091
+L 1531 2091
+L 1531 2672
+L 1928 2672
+Q 2313 2672 2555 2873
+Q 2797 3075 2797 3409
+Q 2797 3731 2584 3926
+Q 2372 4122 2016 4122
+Q 1678 4122 1418 3942
+Q 1159 3763 1147 3444
+L 459 3444
+Q 472 3822 683 4109
+Q 894 4397 1245 4558
+Q 1597 4719 2028 4719
+Q 2475 4719 2804 4544
+Q 3134 4369 3312 4080
+Q 3491 3791 3491 3450
+Q 3491 3056 3272 2786
+Q 3053 2516 2688 2419
+L 2688 2384
+Q 3153 2313 3406 2014
+Q 3659 1716 3659 1278
+Q 3659 891 3445 587
+Q 3231 284 2859 110
+Q 2488 -63 2009 -63
+z
+" transform="scale(0.015625)"/>
+ </defs>
+ <use xlink:href="#Inter-Medium-8d"/>
+ <use xlink:href="#Inter-Medium-354" transform="translate(74.75 0)"/>
+ <use xlink:href="#Inter-Medium-1fb" transform="translate(112.984375 0)"/>
+ <use xlink:href="#Inter-Medium-34b" transform="translate(169.765625 0)"/>
+ <use xlink:href="#Inter-Medium-29e" transform="translate(231.578125 0)"/>
+ <use xlink:href="#Inter-Medium-2b1" transform="translate(291.734375 0)"/>
+ <use xlink:href="#Inter-Medium-24a" transform="translate(316.9375 0)"/>
+ <use xlink:href="#Inter-Medium-2e0" transform="translate(374.65625 0)"/>
+ <use xlink:href="#Inter-Medium-266" transform="translate(399.859375 0)"/>
+ <use xlink:href="#Inter-Medium-6f1" transform="translate(458.59375 0)"/>
+ <use xlink:href="#Inter-Medium-53d" transform="translate(485.25 0)"/>
+ <use xlink:href="#Inter-Medium-5de" transform="translate(547.109375 0)"/>
+ <use xlink:href="#Inter-Medium-53e" transform="translate(568.65625 0)"/>
+ <use xlink:href="#Inter-Medium-5de" transform="translate(610.15625 0)"/>
+ <use xlink:href="#Inter-Medium-541" transform="translate(637.953125 0)"/>
+ </g>
+ </g>
+ <g id="text_4">
+ <!-- Graphicle 0.1.2 -->
+ <g style="fill: #c9ced8" transform="translate(876.40625 60) scale(0.18 -0.18)">
+ <defs>
+ <path id="Inter-Medium-53f" d="M 450 0
+L 450 516
+L 2031 2150
+Q 2394 2531 2581 2797
+Q 2769 3063 2769 3369
+Q 2769 3719 2533 3920
+Q 2297 4122 1944 4122
+Q 1572 4122 1350 3898
+Q 1128 3675 1128 3300
+L 444 3300
+Q 444 3725 641 4045
+Q 838 4366 1180 4542
+Q 1522 4719 1956 4719
+Q 2400 4719 2736 4544
+Q 3072 4369 3262 4070
+Q 3453 3772 3453 3394
+Q 3453 3141 3358 2895
+Q 3263 2650 3023 2344
+Q 2784 2038 2350 1600
+L 1438 647
+L 1438 609
+L 3525 609
+L 3525 0
+L 450 0
+z
+" transform="scale(0.015625)"/>
+ </defs>
+ <use xlink:href="#Inter-Medium-8d"/>
+ <use xlink:href="#Inter-Medium-354" transform="translate(74.75 0)"/>
+ <use xlink:href="#Inter-Medium-1fb" transform="translate(112.984375 0)"/>
+ <use xlink:href="#Inter-Medium-34b" transform="translate(169.765625 0)"/>
+ <use xlink:href="#Inter-Medium-29e" transform="translate(231.578125 0)"/>
+ <use xlink:href="#Inter-Medium-2b1" transform="translate(291.734375 0)"/>
+ <use xlink:href="#Inter-Medium-24a" transform="translate(316.9375 0)"/>
+ <use xlink:href="#Inter-Medium-2e0" transform="translate(374.65625 0)"/>
+ <use xlink:href="#Inter-Medium-266" transform="translate(399.859375 0)"/>
+ <use xlink:href="#Inter-Medium-6f1" transform="translate(458.59375 0)"/>
+ <use xlink:href="#Inter-Medium-53d" transform="translate(485.25 0)"/>
+ <use xlink:href="#Inter-Medium-5de" transform="translate(547.109375 0)"/>
+ <use xlink:href="#Inter-Medium-53e" transform="translate(568.65625 0)"/>
+ <use xlink:href="#Inter-Medium-5de" transform="translate(610.15625 0)"/>
+ <use xlink:href="#Inter-Medium-53f" transform="translate(640.484375 0)"/>
+ </g>
+ </g>
+ <g id="text_5">
+ <!-- BM25 (SWE-bench style) -->
+ <g style="fill: #c9ced8" transform="translate(1054.78125 60) scale(0.18 -0.18)">
+ <defs>
+ <path id="Inter-Medium-41" d="M 516 0
+L 516 4656
+L 2231 4656
+Q 2725 4656 3050 4493
+Q 3375 4331 3536 4054
+Q 3697 3778 3697 3434
+Q 3697 2997 3465 2764
+Q 3234 2531 2909 2450
+L 2909 2403
+Q 3144 2391 3366 2255
+Q 3588 2119 3733 1866
+Q 3878 1613 3878 1256
+Q 3878 897 3711 612
+Q 3544 328 3195 164
+Q 2847 0 2306 0
+L 516 0
+z
+M 1228 613
+L 2234 613
+Q 2738 613 2955 806
+Q 3172 1000 3172 1291
+Q 3172 1619 2926 1855
+Q 2681 2091 2263 2091
+L 1228 2091
+L 1228 613
+z
+M 1228 2641
+L 2163 2641
+Q 2516 2641 2756 2841
+Q 2997 3041 2997 3375
+Q 2997 3663 2795 3855
+Q 2594 4047 2181 4047
+L 1228 4047
+L 1228 2641
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Medium-124" d="M 516 0
+L 516 4656
+L 1566 4656
+L 2581 1984
+Q 2628 1859 2687 1661
+Q 2747 1463 2809 1234
+Q 2872 1006 2925 794
+Q 2981 1000 3043 1228
+Q 3106 1456 3165 1656
+Q 3225 1856 3272 1984
+L 4272 4656
+L 5328 4656
+L 5328 0
+L 4619 0
+L 4619 2506
+Q 4619 2763 4626 3167
+Q 4634 3572 4644 3963
+Q 4563 3678 4475 3400
+Q 4388 3122 4309 2886
+Q 4231 2650 4178 2506
+L 3225 0
+L 2616 0
+L 1650 2506
+Q 1569 2716 1442 3116
+Q 1316 3516 1181 3947
+Q 1188 3703 1194 3437
+Q 1200 3172 1204 2928
+Q 1209 2684 1209 2506
+L 1209 0
+L 516 0
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Medium-543" d="M 1897 -63
+Q 1463 -63 1122 103
+Q 781 269 579 559
+Q 378 850 363 1219
+L 1056 1219
+Q 1081 919 1322 728
+Q 1563 538 1897 538
+Q 2294 538 2551 806
+Q 2809 1075 2809 1494
+Q 2809 1775 2687 1997
+Q 2566 2219 2353 2345
+Q 2141 2472 1866 2472
+Q 1653 2472 1440 2398
+Q 1228 2325 1100 2209
+L 444 2303
+L 703 4656
+L 3275 4656
+L 3275 4047
+L 1300 4047
+L 1153 2747
+L 1178 2747
+Q 1316 2884 1542 2970
+Q 1769 3056 2031 3056
+Q 2456 3056 2789 2856
+Q 3122 2656 3314 2306
+Q 3506 1956 3506 1506
+Q 3506 1053 3300 698
+Q 3094 344 2730 140
+Q 2366 -63 1897 -63
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Medium-5a6" d="M 631 2191
+Q 631 2700 734 3259
+Q 838 3819 1020 4334
+Q 1203 4850 1438 5235
+L 2091 5235
+Q 1853 4744 1683 4216
+Q 1513 3688 1422 3169
+Q 1331 2650 1331 2191
+Q 1331 1572 1512 920
+Q 1694 269 2091 -578
+L 1438 -578
+Q 1038 94 834 797
+Q 631 1500 631 2191
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Medium-18d" d="M 2078 -78
+Q 1294 -78 828 289
+Q 363 656 331 1294
+L 1047 1294
+Q 1078 913 1375 730
+Q 1672 547 2075 547
+Q 2519 547 2809 753
+Q 3100 959 3100 1297
+Q 3100 1600 2845 1748
+Q 2591 1897 2216 1997
+L 1672 2147
+Q 1100 2300 779 2600
+Q 459 2900 459 3378
+Q 459 3781 676 4082
+Q 894 4384 1267 4551
+Q 1641 4719 2109 4719
+Q 2588 4719 2952 4551
+Q 3316 4384 3523 4092
+Q 3731 3800 3741 3431
+L 3047 3431
+Q 3013 3750 2752 3925
+Q 2491 4100 2094 4100
+Q 1672 4100 1422 3908
+Q 1172 3716 1172 3419
+Q 1172 3197 1306 3061
+Q 1441 2925 1636 2845
+Q 1831 2766 2009 2719
+L 2463 2600
+Q 2684 2544 2920 2448
+Q 3156 2353 3356 2201
+Q 3556 2050 3679 1826
+Q 3803 1603 3803 1288
+Q 3803 894 3600 584
+Q 3397 275 3011 98
+Q 2625 -78 2078 -78
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Medium-1cb" d="M 1422 0
+L 159 4656
+L 909 4656
+L 1581 1988
+Q 1656 1681 1722 1348
+Q 1788 1016 1847 678
+Q 1913 1016 1980 1348
+Q 2047 1681 2128 1988
+L 2819 4656
+L 3600 4656
+L 4284 1988
+Q 4363 1684 4431 1356
+Q 4500 1028 4566 697
+Q 4625 1028 4692 1356
+Q 4759 1684 4831 1988
+L 5503 4656
+L 6259 4656
+L 4991 0
+L 4169 0
+L 3428 2759
+Q 3366 2994 3311 3259
+Q 3256 3525 3206 3828
+Q 3156 3541 3104 3280
+Q 3053 3019 2984 2759
+L 2247 0
+L 1422 0
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Medium-5f" d="M 516 0
+L 516 4656
+L 3447 4656
+L 3447 4044
+L 1228 4044
+L 1228 2656
+L 3291 2656
+L 3291 2047
+L 1228 2047
+L 1228 613
+L 3466 613
+L 3466 0
+L 516 0
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Medium-5b3" d="M 2516 2263
+L 2516 1666
+L 447 1666
+L 447 2263
+L 2516 2263
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Medium-242" d="M 2197 -69
+Q 1878 -69 1678 39
+Q 1478 147 1364 290
+Q 1250 434 1188 547
+L 1131 547
+L 1131 0
+L 463 0
+L 463 4656
+L 1150 4656
+L 1150 2925
+L 1188 2925
+Q 1247 3031 1358 3176
+Q 1469 3322 1669 3430
+Q 1869 3538 2197 3538
+Q 2616 3538 2945 3325
+Q 3275 3113 3465 2709
+Q 3656 2306 3656 1738
+Q 3656 1175 3468 769
+Q 3281 363 2951 147
+Q 2622 -69 2197 -69
+z
+M 2044 516
+Q 2344 516 2545 678
+Q 2747 841 2850 1119
+Q 2953 1397 2953 1744
+Q 2953 2088 2851 2361
+Q 2750 2634 2548 2793
+Q 2347 2953 2044 2953
+Q 1600 2953 1369 2620
+Q 1138 2288 1138 1744
+Q 1138 1197 1372 856
+Q 1606 516 2044 516
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Medium-305" d="M 1150 2069
+L 1150 0
+L 463 0
+L 463 3494
+L 1119 3494
+L 1122 2822
+Q 1284 3191 1557 3364
+Q 1831 3538 2200 3538
+Q 2734 3538 3061 3202
+Q 3388 2866 3388 2219
+L 3388 0
+L 2700 0
+L 2700 2134
+Q 2700 2513 2503 2725
+Q 2306 2938 1963 2938
+Q 1613 2938 1381 2711
+Q 1150 2484 1150 2069
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Medium-367" d="M 1716 -72
+Q 1147 -72 773 173
+Q 400 419 306 884
+L 953 1019
+Q 1094 484 1722 484
+Q 2056 484 2251 623
+Q 2447 763 2447 956
+Q 2447 1288 1956 1397
+L 1369 1531
+Q 406 1747 406 2497
+Q 406 2809 579 3043
+Q 753 3278 1058 3408
+Q 1363 3538 1759 3538
+Q 2325 3538 2647 3295
+Q 2969 3053 3081 2666
+L 2466 2531
+Q 2400 2716 2237 2855
+Q 2075 2994 1766 2994
+Q 1481 2994 1290 2866
+Q 1100 2738 1100 2541
+Q 1100 2366 1226 2258
+Q 1353 2150 1641 2084
+L 2203 1959
+Q 3156 1744 3156 1016
+Q 3156 697 2973 451
+Q 2791 206 2466 67
+Q 2141 -72 1716 -72
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Medium-379" d="M 1956 3494
+L 1956 2934
+L 1259 2934
+L 1259 944
+Q 1259 734 1348 636
+Q 1438 538 1641 538
+Q 1697 538 1783 550
+Q 1869 563 1931 575
+L 2053 25
+Q 1944 -13 1817 -30
+Q 1691 -47 1572 -47
+Q 1097 -47 834 198
+Q 572 444 572 888
+L 572 2934
+L 63 2934
+L 63 3494
+L 572 3494
+L 572 4325
+L 1259 4325
+L 1259 3494
+L 1956 3494
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Medium-3e6" d="M 416 -1256
+L 584 -697
+L 663 -716
+Q 928 -788 1114 -698
+Q 1300 -609 1397 -272
+L 1472 -16
+L 144 3494
+L 888 3494
+L 1578 1509
+Q 1656 1278 1715 1053
+Q 1775 828 1831 603
+Q 1891 828 1953 1054
+Q 2016 1281 2097 1509
+L 2800 3494
+L 3538 3494
+L 2019 -484
+Q 1859 -903 1589 -1117
+Q 1319 -1331 897 -1331
+Q 734 -1331 607 -1307
+Q 481 -1284 416 -1256
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Medium-59e" d="M 269 -872
+Q 541 -294 708 182
+Q 875 659 953 1076
+Q 1031 1494 1031 1897
+Q 1031 2356 939 2875
+Q 847 3394 676 3922
+Q 506 4450 269 4941
+L 925 4941
+Q 1159 4559 1340 4042
+Q 1522 3525 1626 2965
+Q 1731 2406 1731 1897
+Q 1731 1197 1523 494
+Q 1316 -209 925 -872
+L 269 -872
+z
+" transform="scale(0.015625)"/>
+ </defs>
+ <use xlink:href="#Inter-Medium-41"/>
+ <use xlink:href="#Inter-Medium-124" transform="translate(65.671875 0)"/>
+ <use xlink:href="#Inter-Medium-53f" transform="translate(156.9375 0)"/>
+ <use xlink:href="#Inter-Medium-543" transform="translate(218.5625 0)"/>
+ <use xlink:href="#Inter-Medium-6f1" transform="translate(278.859375 0)"/>
+ <use xlink:href="#Inter-Medium-5a6" transform="translate(305.515625 0)"/>
+ <use xlink:href="#Inter-Medium-18d" transform="translate(342.375 0)"/>
+ <use xlink:href="#Inter-Medium-1cb" transform="translate(406.96875 0)"/>
+ <use xlink:href="#Inter-Medium-5f" transform="translate(507.265625 0)"/>
+ <use xlink:href="#Inter-Medium-5b3" transform="translate(567.5625 0)"/>
+ <use xlink:href="#Inter-Medium-242" transform="translate(613.796875 0)"/>
+ <use xlink:href="#Inter-Medium-266" transform="translate(675.609375 0)"/>
+ <use xlink:href="#Inter-Medium-305" transform="translate(734.34375 0)"/>
+ <use xlink:href="#Inter-Medium-24a" transform="translate(794.5 0)"/>
+ <use xlink:href="#Inter-Medium-29e" transform="translate(852.21875 0)"/>
+ <use xlink:href="#Inter-Medium-6f1" transform="translate(912.375 0)"/>
+ <use xlink:href="#Inter-Medium-367" transform="translate(939.03125 0)"/>
+ <use xlink:href="#Inter-Medium-379" transform="translate(992.890625 0)"/>
+ <use xlink:href="#Inter-Medium-3e6" transform="translate(1028.96875 0)"/>
+ <use xlink:href="#Inter-Medium-2e0" transform="translate(1086.875 0)"/>
+ <use xlink:href="#Inter-Medium-266" transform="translate(1112.078125 0)"/>
+ <use xlink:href="#Inter-Medium-59e" transform="translate(1169.640625 0)"/>
+ </g>
+ </g>
+ <g id="text_6">
+ <!-- grep for the issue's names -->
+ <g style="fill: #c9ced8" transform="translate(1324 60) scale(0.18 -0.18)">
+ <defs>
+ <path id="Inter-Medium-292" d="M 1925 -1381
+Q 1319 -1381 953 -1159
+Q 588 -938 441 -622
+L 1016 -350
+Q 1078 -450 1183 -561
+Q 1288 -672 1464 -750
+Q 1641 -828 1922 -828
+Q 2319 -828 2569 -639
+Q 2819 -450 2819 -47
+L 2819 634
+L 2759 634
+Q 2697 519 2586 384
+Q 2475 250 2276 151
+Q 2078 53 1759 53
+Q 1347 53 1017 247
+Q 688 441 494 820
+Q 300 1200 300 1759
+Q 300 2316 492 2714
+Q 684 3113 1015 3325
+Q 1347 3538 1769 3538
+Q 2091 3538 2292 3430
+Q 2494 3322 2608 3178
+Q 2722 3034 2781 2925
+L 2831 2925
+L 2831 3494
+L 3503 3494
+L 3503 -50
+Q 3503 -509 3293 -803
+Q 3084 -1097 2728 -1239
+Q 2372 -1381 1925 -1381
+z
+M 1919 625
+Q 2356 625 2589 928
+Q 2822 1231 2822 1769
+Q 2822 2294 2592 2623
+Q 2363 2953 1919 2953
+Q 1616 2953 1411 2795
+Q 1206 2638 1104 2370
+Q 1003 2103 1003 1769
+Q 1003 1256 1236 940
+Q 1469 625 1919 625
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Medium-287" d="M 2194 3494
+L 2194 2934
+L 1413 2934
+L 1413 0
+L 725 0
+L 725 2934
+L 63 2934
+L 63 3494
+L 725 3494
+L 725 3894
+Q 725 4219 870 4437
+Q 1016 4656 1252 4765
+Q 1488 4875 1766 4875
+Q 1972 4875 2120 4842
+Q 2269 4809 2341 4781
+L 2181 4225
+Q 2131 4238 2056 4256
+Q 1981 4275 1875 4275
+Q 1628 4275 1520 4153
+Q 1413 4031 1413 3800
+L 1413 3494
+L 2194 3494
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Medium-316" d="M 1931 -72
+Q 1441 -72 1073 153
+Q 706 378 503 783
+Q 300 1188 300 1728
+Q 300 2272 503 2680
+Q 706 3088 1073 3313
+Q 1441 3538 1931 3538
+Q 2425 3538 2792 3313
+Q 3159 3088 3362 2680
+Q 3566 2272 3566 1728
+Q 3566 1188 3362 783
+Q 3159 378 2792 153
+Q 2425 -72 1931 -72
+z
+M 1931 509
+Q 2250 509 2458 676
+Q 2666 844 2767 1120
+Q 2869 1397 2869 1728
+Q 2869 2063 2767 2342
+Q 2666 2622 2458 2789
+Q 2250 2956 1931 2956
+Q 1616 2956 1409 2789
+Q 1203 2622 1101 2342
+Q 1000 2063 1000 1728
+Q 1000 1397 1101 1120
+Q 1203 844 1409 676
+Q 1616 509 1931 509
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Medium-393" d="M 1653 -44
+Q 1119 -44 791 292
+Q 463 628 463 1275
+L 463 3494
+L 1150 3494
+L 1150 1359
+Q 1150 981 1348 768
+Q 1547 556 1888 556
+Q 2238 556 2469 782
+Q 2700 1009 2700 1425
+L 2700 3494
+L 3391 3494
+L 3391 0
+L 2731 0
+L 2728 678
+Q 2563 297 2289 126
+Q 2016 -44 1653 -44
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Medium-5cc" d="M 725 2828
+L 647 4656
+L 1353 4656
+L 1275 2828
+L 725 2828
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Medium-2fe" d="M 463 0
+L 463 3494
+L 1116 3494
+L 1131 2841
+Q 1266 3203 1534 3378
+Q 1803 3553 2116 3553
+Q 2456 3553 2681 3359
+Q 2906 3166 3009 2819
+Q 3141 3172 3442 3362
+Q 3744 3553 4116 3553
+Q 4425 3553 4675 3418
+Q 4925 3284 5073 3018
+Q 5222 2753 5222 2356
+L 5222 0
+L 4534 0
+L 4534 2288
+Q 4534 2638 4339 2794
+Q 4144 2950 3878 2950
+Q 3553 2950 3367 2750
+Q 3181 2550 3181 2238
+L 3181 0
+L 2503 0
+L 2503 2331
+Q 2503 2613 2323 2781
+Q 2144 2950 1866 2950
+Q 1578 2950 1364 2751
+Q 1150 2553 1150 2172
+L 1150 0
+L 463 0
+z
+" transform="scale(0.015625)"/>
+ </defs>
+ <use xlink:href="#Inter-Medium-292"/>
+ <use xlink:href="#Inter-Medium-354" transform="translate(61.96875 0)"/>
+ <use xlink:href="#Inter-Medium-266" transform="translate(98.734375 0)"/>
+ <use xlink:href="#Inter-Medium-34b" transform="translate(157.46875 0)"/>
+ <use xlink:href="#Inter-Medium-6f1" transform="translate(219.28125 0)"/>
+ <use xlink:href="#Inter-Medium-287" transform="translate(245.9375 0)"/>
+ <use xlink:href="#Inter-Medium-316" transform="translate(281.1875 0)"/>
+ <use xlink:href="#Inter-Medium-354" transform="translate(341.59375 0)"/>
+ <use xlink:href="#Inter-Medium-6f1" transform="translate(380.265625 0)"/>
+ <use xlink:href="#Inter-Medium-379" transform="translate(406.921875 0)"/>
+ <use xlink:href="#Inter-Medium-29e" transform="translate(441.046875 0)"/>
+ <use xlink:href="#Inter-Medium-266" transform="translate(501.203125 0)"/>
+ <use xlink:href="#Inter-Medium-6f1" transform="translate(559.9375 0)"/>
+ <use xlink:href="#Inter-Medium-2b1" transform="translate(586.59375 0)"/>
+ <use xlink:href="#Inter-Medium-367" transform="translate(611.796875 0)"/>
+ <use xlink:href="#Inter-Medium-367" transform="translate(665.65625 0)"/>
+ <use xlink:href="#Inter-Medium-393" transform="translate(719.515625 0)"/>
+ <use xlink:href="#Inter-Medium-266" transform="translate(779.671875 0)"/>
+ <use xlink:href="#Inter-Medium-5cc" transform="translate(836.75 0)"/>
+ <use xlink:href="#Inter-Medium-367" transform="translate(867.796875 0)"/>
+ <use xlink:href="#Inter-Medium-6f1" transform="translate(921.65625 0)"/>
+ <use xlink:href="#Inter-Medium-305" transform="translate(948.3125 0)"/>
+ <use xlink:href="#Inter-Medium-1fb" transform="translate(1008.46875 0)"/>
+ <use xlink:href="#Inter-Medium-2fe" transform="translate(1065.25 0)"/>
+ <use xlink:href="#Inter-Medium-266" transform="translate(1154.0625 0)"/>
+ <use xlink:href="#Inter-Medium-367" transform="translate(1212.796875 0)"/>
+ </g>
+ </g>
+ <g id="text_7">
+ <!-- Finding the files a fix changes: 100 SWE-bench Verified issues, held out from tuning -->
+ <g style="fill: #f4f6fa" transform="translate(48 112) scale(0.34 -0.34)">
+ <defs>
+ <path id="InterDisplay-SemiBold-89" d="M 388 0
+L 388 4656
+L 3519 4656
+L 3519 3941
+L 1213 3941
+L 1213 2669
+L 3353 2669
+L 3353 1969
+L 1213 1969
+L 1213 0
+L 388 0
+z
+" transform="scale(0.015625)"/>
+ <path id="InterDisplay-SemiBold-2b1" d="M 350 0
+L 350 3300
+L 1138 3300
+L 1138 0
+L 350 0
+z
+M 743 3791
+Q 540 3791 406 3920
+Q 272 4050 272 4241
+Q 272 4431 406 4559
+Q 540 4688 743 4688
+Q 943 4688 1077 4559
+Q 1212 4431 1212 4241
+Q 1212 4050 1077 3920
+Q 943 3791 743 3791
+z
+" transform="scale(0.015625)"/>
+ <path id="InterDisplay-SemiBold-305" d="M 1138 1866
+L 1138 0
+L 350 0
+L 350 3300
+L 1125 3300
+L 1125 2794
+Q 1469 3366 2138 3366
+Q 2656 3366 2986 3031
+Q 3316 2697 3316 2063
+L 3316 0
+L 2525 0
+L 2525 1938
+Q 2525 2300 2350 2487
+Q 2175 2675 1859 2675
+Q 1550 2675 1344 2481
+Q 1138 2288 1138 1866
+z
+" transform="scale(0.015625)"/>
+ <path id="InterDisplay-SemiBold-255" d="M 1625 -66
+Q 1194 -66 872 150
+Q 550 366 373 752
+Q 197 1138 197 1653
+Q 197 2159 375 2545
+Q 553 2931 875 3148
+Q 1197 3366 1619 3366
+Q 1941 3366 2197 3234
+Q 2453 3103 2613 2831
+L 2619 2831
+L 2619 4656
+L 3406 4656
+L 3406 0
+L 2631 0
+L 2631 503
+L 2625 503
+Q 2469 216 2208 75
+Q 1947 -66 1625 -66
+z
+M 1809 594
+Q 2197 594 2430 883
+Q 2663 1172 2663 1653
+Q 2663 2134 2430 2423
+Q 2197 2713 1809 2713
+Q 1444 2713 1219 2438
+Q 994 2163 994 1653
+Q 994 1141 1219 867
+Q 1444 594 1809 594
+z
+" transform="scale(0.015625)"/>
+ <path id="InterDisplay-SemiBold-292" d="M 1847 -1350
+Q 1194 -1350 809 -1069
+Q 425 -788 359 -306
+L 1131 -306
+Q 1188 -519 1378 -630
+Q 1569 -741 1847 -741
+Q 2216 -741 2420 -541
+Q 2625 -341 2625 38
+L 2625 541
+L 2622 541
+Q 2463 250 2206 114
+Q 1950 -22 1625 -22
+Q 1194 -22 872 193
+Q 550 409 373 789
+Q 197 1169 197 1666
+Q 197 2166 375 2550
+Q 553 2934 875 3150
+Q 1197 3366 1619 3366
+Q 1941 3366 2202 3230
+Q 2463 3094 2625 2809
+L 2628 2809
+L 2628 3300
+L 3406 3300
+L 3406 84
+Q 3406 -425 3203 -742
+Q 3000 -1059 2647 -1204
+Q 2294 -1350 1847 -1350
+z
+M 1809 628
+Q 2197 628 2430 914
+Q 2663 1200 2663 1675
+Q 2663 2150 2430 2436
+Q 2197 2722 1809 2722
+Q 1444 2722 1219 2450
+Q 994 2178 994 1675
+Q 994 1169 1219 898
+Q 1444 628 1809 628
+z
+" transform="scale(0.015625)"/>
+ <path id="InterDisplay-SemiBold-6f1" transform="scale(0.015625)"/>
+ <path id="InterDisplay-SemiBold-379" d="M 2091 3300
+L 2091 2666
+L 1419 2666
+L 1419 947
+Q 1419 769 1491 701
+Q 1563 634 1753 634
+L 2091 634
+L 2091 0
+L 1616 0
+Q 1113 0 870 203
+Q 628 406 628 831
+L 628 2666
+L 53 2666
+L 53 3300
+L 628 3300
+L 628 4200
+L 1419 4200
+L 1419 3300
+L 2091 3300
+z
+" transform="scale(0.015625)"/>
+ <path id="InterDisplay-SemiBold-29e" d="M 1138 1866
+L 1138 0
+L 350 0
+L 350 4656
+L 1138 4656
+L 1138 2816
+Q 1481 3366 2138 3366
+Q 2656 3366 2986 3031
+Q 3316 2697 3316 2063
+L 3316 0
+L 2525 0
+L 2525 1938
+Q 2525 2300 2350 2487
+Q 2175 2675 1859 2675
+Q 1550 2675 1344 2481
+Q 1138 2288 1138 1866
+z
+" transform="scale(0.015625)"/>
+ <path id="InterDisplay-SemiBold-266" d="M 1806 -75
+Q 1313 -75 950 147
+Q 588 369 392 758
+Q 197 1147 197 1647
+Q 197 2150 398 2539
+Q 600 2928 956 3151
+Q 1313 3375 1775 3375
+Q 2250 3375 2606 3156
+Q 2963 2938 3159 2552
+Q 3356 2166 3356 1659
+L 3356 1444
+L 969 1444
+Q 984 1041 1206 794
+Q 1428 547 1825 547
+Q 2122 547 2315 676
+Q 2509 806 2578 1019
+L 3316 1019
+Q 3253 697 3042 450
+Q 2831 203 2512 64
+Q 2194 -75 1806 -75
+z
+M 975 1988
+L 2600 1988
+Q 2563 2341 2345 2545
+Q 2128 2750 1788 2750
+Q 1444 2750 1230 2545
+Q 1016 2341 975 1988
+z
+" transform="scale(0.015625)"/>
+ <path id="InterDisplay-SemiBold-287" d="M 2109 3300
+L 2109 2666
+L 1438 2666
+L 1438 0
+L 647 0
+L 647 2666
+L 53 2666
+L 53 3300
+L 647 3300
+L 647 3781
+Q 647 4206 905 4431
+Q 1163 4656 1650 4656
+L 2109 4656
+L 2109 4022
+L 1806 4022
+Q 1603 4022 1520 3937
+Q 1438 3853 1438 3650
+L 1438 3300
+L 2109 3300
+z
+" transform="scale(0.015625)"/>
+ <path id="InterDisplay-SemiBold-2e0" d="M 1138 4656
+L 1138 0
+L 350 0
+L 350 4656
+L 1138 4656
+z
+" transform="scale(0.015625)"/>
+ <path id="InterDisplay-SemiBold-367" d="M 1644 -78
+Q 1041 -78 636 205
+Q 231 488 194 1019
+L 972 1019
+Q 997 778 1165 645
+Q 1334 513 1631 513
+Q 1916 513 2080 625
+Q 2244 738 2244 913
+Q 2244 1063 2122 1153
+Q 2000 1244 1794 1288
+L 1231 1403
+Q 269 1603 269 2356
+Q 269 2813 631 3092
+Q 994 3372 1597 3372
+Q 2197 3372 2573 3076
+Q 2950 2781 2963 2272
+L 2222 2272
+Q 2216 2494 2050 2637
+Q 1884 2781 1616 2781
+Q 1356 2781 1206 2665
+Q 1056 2550 1056 2381
+Q 1056 2234 1172 2142
+Q 1288 2050 1494 2003
+L 2088 1881
+Q 2578 1778 2811 1556
+Q 3044 1334 3044 972
+Q 3044 650 2864 414
+Q 2684 178 2368 50
+Q 2053 -78 1644 -78
+z
+" transform="scale(0.015625)"/>
+ <path id="InterDisplay-SemiBold-1fb" d="M 1356 -53
+Q 863 -53 539 195
+Q 216 444 216 938
+Q 216 1313 398 1517
+Q 581 1722 876 1815
+Q 1172 1909 1513 1944
+Q 1972 1997 2153 2037
+Q 2334 2078 2334 2247
+L 2334 2272
+Q 2334 2484 2173 2618
+Q 2013 2753 1731 2753
+Q 1444 2753 1264 2618
+Q 1084 2484 1069 2275
+L 309 2275
+Q 338 2766 719 3066
+Q 1100 3366 1747 3366
+Q 2391 3366 2753 3066
+Q 3116 2766 3116 2250
+L 3116 0
+L 2341 0
+L 2341 466
+L 2328 466
+Q 2209 247 1984 97
+Q 1759 -53 1356 -53
+z
+M 1550 531
+Q 1938 531 2138 732
+Q 2338 934 2338 1222
+L 2338 1578
+Q 2266 1531 2059 1492
+Q 1853 1453 1609 1416
+Q 1356 1378 1170 1273
+Q 984 1169 984 944
+Q 984 750 1137 640
+Q 1291 531 1550 531
+z
+" transform="scale(0.015625)"/>
+ <path id="InterDisplay-SemiBold-3e1" d="M 56 0
+L 1253 1681
+L 134 3300
+L 1013 3300
+L 1356 2775
+Q 1447 2631 1531 2492
+Q 1616 2353 1700 2216
+Q 1784 2353 1870 2492
+Q 1956 2631 2047 2775
+L 2397 3300
+L 3263 3300
+L 2134 1697
+L 3316 0
+L 2434 0
+L 2041 588
+Q 1950 734 1862 871
+Q 1775 1009 1691 1147
+Q 1603 1009 1515 871
+Q 1428 734 1334 588
+L 934 0
+L 56 0
+z
+" transform="scale(0.015625)"/>
+ <path id="InterDisplay-SemiBold-24a" d="M 1809 -75
+Q 1328 -75 964 144
+Q 600 363 398 750
+Q 197 1138 197 1647
+Q 197 2156 398 2545
+Q 600 2934 964 3154
+Q 1328 3375 1809 3375
+Q 2225 3375 2550 3214
+Q 2875 3053 3073 2770
+Q 3272 2488 3306 2119
+L 2534 2119
+Q 2491 2384 2308 2551
+Q 2125 2719 1819 2719
+Q 1431 2719 1212 2428
+Q 994 2138 994 1647
+Q 994 1159 1212 870
+Q 1431 581 1819 581
+Q 2128 581 2300 745
+Q 2472 909 2528 1184
+L 3306 1184
+Q 3278 822 3079 537
+Q 2881 253 2554 89
+Q 2228 -75 1809 -75
+z
+" transform="scale(0.015625)"/>
+ <path id="InterDisplay-SemiBold-5e1" d="M 756 -56
+Q 553 -56 412 86
+Q 272 228 272 428
+Q 272 631 412 772
+Q 553 913 756 913
+Q 959 913 1100 772
+Q 1241 631 1241 428
+Q 1241 228 1100 86
+Q 959 -56 756 -56
+z
+M 756 2216
+Q 553 2216 412 2358
+Q 272 2500 272 2700
+Q 272 2903 412 3044
+Q 553 3185 756 3185
+Q 959 3185 1100 3044
+Q 1241 2903 1241 2700
+Q 1241 2500 1100 2358
+Q 959 2216 756 2216
+z
+" transform="scale(0.015625)"/>
+ <path id="InterDisplay-SemiBold-53e" d="M 2050 4656
+L 2050 0
+L 1253 0
+L 1253 3875
+L 1247 3875
+L 131 3153
+L 131 3909
+L 1288 4656
+L 2050 4656
+z
+" transform="scale(0.015625)"/>
+ <path id="InterDisplay-SemiBold-53d" d="M 2041 -75
+Q 1478 -75 1072 219
+Q 666 513 445 1050
+Q 225 1588 225 2325
+Q 225 3066 445 3605
+Q 666 4144 1072 4437
+Q 1478 4731 2041 4731
+Q 2603 4731 3011 4437
+Q 3419 4144 3637 3605
+Q 3856 3066 3856 2325
+Q 3856 1588 3637 1048
+Q 3419 509 3011 217
+Q 2603 -75 2041 -75
+z
+M 2041 606
+Q 2522 606 2798 1065
+Q 3075 1525 3075 2325
+Q 3075 3131 2798 3590
+Q 2522 4050 2041 4050
+Q 1559 4050 1282 3590
+Q 1006 3131 1006 2325
+Q 1006 1525 1282 1065
+Q 1559 606 2041 606
+z
+" transform="scale(0.015625)"/>
+ <path id="InterDisplay-SemiBold-18d" d="M 2072 -75
+Q 1206 -75 717 348
+Q 228 772 228 1519
+L 1038 1519
+Q 1044 1097 1317 859
+Q 1591 622 2078 622
+Q 2513 622 2778 805
+Q 3044 988 3044 1294
+Q 3044 1541 2844 1695
+Q 2644 1850 2178 1956
+L 1678 2069
+Q 981 2228 650 2540
+Q 319 2853 319 3344
+Q 319 3759 533 4071
+Q 747 4384 1133 4557
+Q 1519 4731 2031 4731
+Q 2813 4731 3270 4334
+Q 3728 3938 3747 3244
+L 2963 3244
+Q 2938 3613 2688 3822
+Q 2438 4031 2028 4031
+Q 1641 4031 1394 3850
+Q 1147 3669 1147 3384
+Q 1147 3150 1342 3004
+Q 1538 2859 1994 2756
+L 2466 2647
+Q 3191 2488 3528 2172
+Q 3866 1856 3866 1344
+Q 3866 909 3647 590
+Q 3428 272 3025 98
+Q 2622 -75 2072 -75
+z
+" transform="scale(0.015625)"/>
+ <path id="InterDisplay-SemiBold-1cb" d="M 1297 0
+L 41 4656
+L 913 4656
+L 1528 2147
+Q 1600 1841 1664 1536
+Q 1728 1231 1788 925
+Q 1850 1231 1919 1536
+Q 1988 1841 2063 2147
+L 2703 4656
+L 3575 4656
+L 4209 2147
+Q 4284 1844 4353 1542
+Q 4422 1241 4484 941
+Q 4603 1531 4747 2147
+L 5363 4656
+L 6238 4656
+L 4978 0
+L 4044 0
+L 3331 2694
+Q 3281 2884 3234 3095
+Q 3188 3306 3138 3538
+Q 3088 3306 3041 3095
+Q 2994 2884 2944 2694
+L 2234 0
+L 1297 0
+z
+" transform="scale(0.015625)"/>
+ <path id="InterDisplay-SemiBold-5f" d="M 388 0
+L 388 4656
+L 3622 4656
+L 3622 3941
+L 1213 3941
+L 1213 2716
+L 3441 2716
+L 3441 2013
+L 1213 2013
+L 1213 716
+L 3622 716
+L 3622 0
+L 388 0
+z
+" transform="scale(0.015625)"/>
+ <path id="InterDisplay-SemiBold-5b3" d="M 2450 2188
+L 2450 1525
+L 363 1525
+L 363 2188
+L 2450 2188
+z
+" transform="scale(0.015625)"/>
+ <path id="InterDisplay-SemiBold-242" d="M 2131 -66
+Q 1806 -66 1545 75
+Q 1284 216 1131 503
+L 1125 503
+L 1125 0
+L 350 0
+L 350 4656
+L 1138 4656
+L 1138 2831
+L 1144 2831
+Q 1303 3103 1559 3234
+Q 1816 3366 2134 3366
+Q 2559 3366 2879 3148
+Q 3200 2931 3379 2545
+Q 3559 2159 3559 1653
+Q 3559 1138 3382 752
+Q 3206 366 2884 150
+Q 2563 -66 2131 -66
+z
+M 1947 594
+Q 2313 594 2538 867
+Q 2763 1141 2763 1653
+Q 2763 2163 2538 2438
+Q 2313 2713 1947 2713
+Q 1559 2713 1326 2423
+Q 1094 2134 1094 1653
+Q 1094 1172 1326 883
+Q 1559 594 1947 594
+z
+" transform="scale(0.015625)"/>
+ <path id="InterDisplay-SemiBold-1c8" d="M 1703 0
+L 41 4656
+L 934 4656
+L 1775 2209
+Q 1869 1916 1980 1555
+Q 2091 1194 2225 750
+Q 2356 1194 2465 1555
+Q 2575 1916 2666 2209
+L 3478 4656
+L 4363 4656
+L 2731 0
+L 1703 0
+z
+" transform="scale(0.015625)"/>
+ <path id="InterDisplay-SemiBold-354" d="M 350 0
+L 350 3300
+L 1109 3300
+L 1109 2753
+L 1119 2753
+Q 1209 3034 1404 3182
+Q 1600 3331 1919 3331
+Q 2000 3331 2064 3326
+Q 2128 3322 2175 3319
+L 2175 2619
+Q 2131 2625 2025 2634
+Q 1919 2644 1803 2644
+Q 1522 2644 1330 2450
+Q 1138 2256 1138 1869
+L 1138 0
+L 350 0
+z
+" transform="scale(0.015625)"/>
+ <path id="InterDisplay-SemiBold-393" d="M 1525 -66
+Q 1006 -66 678 268
+Q 350 603 350 1238
+L 350 3300
+L 1138 3300
+L 1138 1363
+Q 1138 1000 1313 812
+Q 1488 625 1803 625
+Q 2116 625 2320 819
+Q 2525 1013 2525 1434
+L 2525 3300
+L 3316 3300
+L 3316 0
+L 2541 0
+L 2541 506
+Q 2194 -66 1525 -66
+z
+" transform="scale(0.015625)"/>
+ <path id="InterDisplay-SemiBold-5dd" d="M 156 -943
+L 403 722
+L 1181 722
+L 716 -943
+L 156 -943
+z
+" transform="scale(0.015625)"/>
+ <path id="InterDisplay-SemiBold-316" d="M 1825 -75
+Q 1338 -75 972 142
+Q 606 359 401 746
+Q 197 1134 197 1647
+Q 197 2159 401 2548
+Q 606 2938 972 3156
+Q 1338 3375 1825 3375
+Q 2309 3375 2676 3156
+Q 3044 2938 3248 2548
+Q 3453 2159 3453 1647
+Q 3453 1134 3248 746
+Q 3044 359 2676 142
+Q 2309 -75 1825 -75
+z
+M 1825 584
+Q 2203 584 2428 868
+Q 2653 1153 2653 1647
+Q 2653 2141 2428 2428
+Q 2203 2716 1825 2716
+Q 1444 2716 1219 2430
+Q 994 2144 994 1647
+Q 994 1153 1219 868
+Q 1444 584 1825 584
+z
+" transform="scale(0.015625)"/>
+ <path id="InterDisplay-SemiBold-2fe" d="M 350 0
+L 350 3300
+L 1113 3300
+L 1113 2728
+Q 1263 3047 1528 3206
+Q 1794 3366 2106 3366
+Q 2441 3366 2697 3195
+Q 2953 3025 3056 2741
+Q 3188 3025 3466 3195
+Q 3744 3366 4106 3366
+Q 4575 3366 4894 3062
+Q 5213 2759 5213 2178
+L 5213 0
+L 4422 0
+L 4422 2066
+Q 4422 2394 4242 2545
+Q 4063 2697 3809 2697
+Q 3509 2697 3336 2509
+Q 3163 2322 3163 2025
+L 3163 0
+L 2397 0
+L 2397 2103
+Q 2397 2372 2228 2534
+Q 2059 2697 1797 2697
+Q 1531 2697 1334 2511
+Q 1138 2325 1138 1969
+L 1138 0
+L 350 0
+z
+" transform="scale(0.015625)"/>
+ </defs>
+ <use xlink:href="#InterDisplay-SemiBold-89"/>
+ <use xlink:href="#InterDisplay-SemiBold-2b1" transform="translate(57.234375 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-305" transform="translate(80.484375 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-255" transform="translate(137.765625 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-2b1" transform="translate(196.453125 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-305" transform="translate(219.703125 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-292" transform="translate(276.984375 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-6f1" transform="translate(335.671875 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-379" transform="translate(358.28125 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-29e" transform="translate(393.25 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-266" transform="translate(450.53125 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-6f1" transform="translate(505.859375 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-287" transform="translate(528.46875 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-2b1" transform="translate(563.375 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-2e0" transform="translate(586.625 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-266" transform="translate(609.875 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-367" transform="translate(665.203125 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-6f1" transform="translate(715.6875 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-1fb" transform="translate(738.296875 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-6f1" transform="translate(792.40625 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-287" transform="translate(815.015625 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-2b1" transform="translate(849.921875 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-3e1" transform="translate(873.171875 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-6f1" transform="translate(925.859375 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-24a" transform="translate(948.46875 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-29e" transform="translate(1002.90625 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-1fb" transform="translate(1060.1875 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-305" transform="translate(1114.296875 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-292" transform="translate(1171.578125 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-266" transform="translate(1230.265625 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-367" transform="translate(1285.59375 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-5e1" transform="translate(1336.078125 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-6f1" transform="translate(1359.71875 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-53e" transform="translate(1382.328125 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-53d" transform="translate(1420.359375 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-53d" transform="translate(1484.125 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-6f1" transform="translate(1547.890625 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-18d" transform="translate(1570.5 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-1cb" transform="translate(1634.46875 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-5f" transform="translate(1732.5625 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-5b3" transform="translate(1792.421875 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-242" transform="translate(1836.375 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-266" transform="translate(1895.0625 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-305" transform="translate(1950.390625 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-24a" transform="translate(2007.671875 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-29e" transform="translate(2062.109375 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-6f1" transform="translate(2119.390625 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-1c8" transform="translate(2142 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-266" transform="translate(2203.28125 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-354" transform="translate(2258.609375 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-2b1" transform="translate(2294.546875 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-287" transform="translate(2317.796875 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-2b1" transform="translate(2352.703125 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-266" transform="translate(2375.953125 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-255" transform="translate(2431.28125 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-6f1" transform="translate(2489.96875 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-2b1" transform="translate(2512.578125 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-367" transform="translate(2535.828125 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-367" transform="translate(2586.3125 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-393" transform="translate(2636.796875 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-266" transform="translate(2694.078125 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-367" transform="translate(2749.40625 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-5dd" transform="translate(2799.890625 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-6f1" transform="translate(2821.484375 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-29e" transform="translate(2844.09375 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-266" transform="translate(2901.375 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-2e0" transform="translate(2956.703125 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-255" transform="translate(2979.953125 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-6f1" transform="translate(3038.640625 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-316" transform="translate(3061.25 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-393" transform="translate(3118.234375 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-379" transform="translate(3175.515625 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-6f1" transform="translate(3210.484375 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-287" transform="translate(3233.09375 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-354" transform="translate(3268 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-316" transform="translate(3302.953125 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-2fe" transform="translate(3359.9375 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-6f1" transform="translate(3446.796875 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-379" transform="translate(3469.40625 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-393" transform="translate(3504.375 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-305" transform="translate(3561.65625 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-2b1" transform="translate(3618.9375 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-305" transform="translate(3642.1875 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-292" transform="translate(3699.46875 0)"/>
+ </g>
+ </g>
+ <g id="text_8">
+ <!-- For each issue: is a file the fix changed among the first k files? Graphicle: the files its context packet cites, then lists. No model calls. Higher is better. -->
+ <g style="fill: #8a93a6" transform="translate(48 146) scale(0.2 -0.2)">
+ <defs>
+ <path id="Inter-Regular-89" d="M 563 0
+L 563 4656
+L 3378 4656
+L 3378 4131
+L 1156 4131
+L 1156 2538
+L 3166 2538
+L 3166 2013
+L 1156 2013
+L 1156 0
+L 563 0
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Regular-367" d="M 1681 -75
+Q 1144 -75 787 159
+Q 431 394 338 847
+L 872 975
+Q 947 688 1155 553
+Q 1363 419 1675 419
+Q 2041 419 2258 575
+Q 2475 731 2475 947
+Q 2475 1306 1963 1428
+L 1381 1566
+Q 444 1788 444 2519
+Q 444 2819 612 3048
+Q 781 3278 1073 3408
+Q 1366 3538 1738 3538
+Q 2278 3538 2576 3302
+Q 2875 3066 2994 2697
+L 2484 2566
+Q 2413 2753 2245 2906
+Q 2078 3059 1741 3059
+Q 1428 3059 1220 2915
+Q 1013 2772 1013 2553
+Q 1013 2359 1153 2242
+Q 1294 2125 1600 2053
+L 2128 1928
+Q 2603 1816 2831 1580
+Q 3059 1344 3059 984
+Q 3059 678 2886 439
+Q 2713 200 2402 62
+Q 2091 -75 1681 -75
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Regular-393" d="M 1678 -44
+Q 1150 -44 822 284
+Q 494 613 494 1275
+L 494 3494
+L 1056 3494
+L 1056 1322
+Q 1056 919 1268 691
+Q 1481 463 1847 463
+Q 2222 463 2473 708
+Q 2725 953 2725 1400
+L 2725 3494
+L 3291 3494
+L 3291 0
+L 2747 0
+L 2747 653
+Q 2575 272 2298 114
+Q 2022 -44 1678 -44
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Regular-5e1" d="M 922 -41
+Q 747 -41 623 82
+Q 500 206 500 381
+Q 500 556 623 679
+Q 747 803 922 803
+Q 1097 803 1220 679
+Q 1344 556 1344 381
+Q 1344 206 1220 82
+Q 1097 -41 922 -41
+z
+M 922 2487
+Q 747 2487 623 2610
+Q 500 2734 500 2909
+Q 500 3084 623 3207
+Q 747 3331 922 3331
+Q 1097 3331 1220 3207
+Q 1344 3084 1344 2909
+Q 1344 2734 1220 2610
+Q 1097 2487 922 2487
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Regular-3e1" d="M 203 0
+L 1431 1794
+L 275 3494
+L 931 3494
+L 1366 2816
+Q 1484 2628 1579 2461
+Q 1675 2294 1766 2134
+Q 1850 2294 1937 2461
+Q 2025 2628 2147 2816
+L 2591 3494
+L 3234 3494
+L 2066 1763
+L 3291 0
+L 2638 0
+L 2125 784
+Q 2009 963 1918 1123
+Q 1828 1284 1741 1431
+Q 1659 1284 1575 1123
+Q 1491 963 1372 784
+L 853 0
+L 203 0
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Regular-292" d="M 1909 -1381
+Q 1328 -1381 981 -1168
+Q 634 -956 472 -669
+L 928 -375
+Q 1003 -475 1114 -597
+Q 1225 -719 1414 -805
+Q 1603 -891 1909 -891
+Q 2328 -891 2598 -691
+Q 2869 -491 2869 -59
+L 2869 641
+L 2816 641
+Q 2756 541 2648 403
+Q 2541 266 2339 161
+Q 2138 56 1800 56
+Q 1381 56 1047 254
+Q 713 453 519 834
+Q 325 1216 325 1763
+Q 325 2303 515 2701
+Q 706 3100 1042 3319
+Q 1378 3538 1813 3538
+Q 2150 3538 2351 3427
+Q 2553 3316 2662 3172
+Q 2772 3028 2831 2934
+L 2884 2934
+L 2884 3494
+L 3431 3494
+L 3431 -91
+Q 3431 -541 3228 -827
+Q 3025 -1113 2679 -1247
+Q 2334 -1381 1909 -1381
+z
+M 1894 556
+Q 2369 556 2622 879
+Q 2875 1203 2875 1775
+Q 2875 2331 2626 2682
+Q 2378 3034 1894 3034
+Q 1563 3034 1341 2864
+Q 1119 2694 1008 2409
+Q 897 2125 897 1775
+Q 897 1238 1150 897
+Q 1403 556 1894 556
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Regular-255" d="M 1803 -75
+Q 1369 -75 1034 147
+Q 700 369 512 775
+Q 325 1181 325 1738
+Q 325 2291 514 2695
+Q 703 3100 1037 3319
+Q 1372 3538 1806 3538
+Q 2147 3538 2347 3425
+Q 2547 3313 2655 3170
+Q 2763 3028 2819 2934
+L 2863 2934
+L 2863 4656
+L 3425 4656
+L 3425 0
+L 2881 0
+L 2881 541
+L 2819 541
+Q 2763 444 2652 298
+Q 2541 153 2339 39
+Q 2138 -75 1803 -75
+z
+M 1888 428
+Q 2363 428 2616 793
+Q 2869 1159 2869 1744
+Q 2869 2322 2620 2678
+Q 2372 3034 1888 3034
+Q 1556 3034 1336 2862
+Q 1116 2691 1006 2398
+Q 897 2106 897 1744
+Q 897 1378 1008 1079
+Q 1119 781 1341 604
+Q 1563 428 1888 428
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Regular-597" d="M 1197 1403
+L 1197 1438
+Q 1197 1866 1280 2098
+Q 1363 2331 1519 2467
+Q 1675 2603 1891 2731
+Q 2097 2856 2237 3048
+Q 2378 3241 2378 3513
+Q 2378 3838 2156 4030
+Q 1934 4222 1619 4222
+Q 1344 4222 1109 4048
+Q 875 3875 850 3484
+L 256 3484
+Q 272 3878 458 4153
+Q 644 4428 947 4573
+Q 1250 4719 1619 4719
+Q 2025 4719 2323 4561
+Q 2622 4403 2787 4125
+Q 2953 3847 2953 3491
+Q 2953 3113 2787 2844
+Q 2622 2575 2319 2391
+Q 2119 2269 1995 2155
+Q 1872 2041 1817 1878
+Q 1763 1716 1763 1438
+L 1763 1403
+L 1197 1403
+z
+M 1488 -41
+Q 1313 -41 1189 82
+Q 1066 206 1066 378
+Q 1066 553 1189 676
+Q 1313 800 1488 800
+Q 1663 800 1784 676
+Q 1906 553 1906 378
+Q 1906 206 1784 82
+Q 1663 -41 1488 -41
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Regular-8d" d="M 2466 -63
+Q 1844 -63 1375 228
+Q 906 519 643 1055
+Q 381 1591 381 2325
+Q 381 3066 643 3602
+Q 906 4138 1368 4428
+Q 1831 4719 2428 4719
+Q 2922 4719 3323 4526
+Q 3725 4334 3990 3992
+Q 4256 3650 4341 3197
+L 3728 3197
+Q 3584 3644 3254 3906
+Q 2925 4169 2431 4169
+Q 2022 4169 1687 3958
+Q 1353 3747 1156 3336
+Q 959 2925 959 2325
+Q 959 1731 1157 1322
+Q 1356 913 1697 700
+Q 2038 488 2466 488
+Q 2853 488 3150 650
+Q 3447 813 3617 1113
+Q 3788 1413 3794 1822
+L 2588 1822
+L 2588 2341
+L 4375 2341
+L 4375 1831
+Q 4375 1253 4128 828
+Q 3881 403 3451 170
+Q 3022 -63 2466 -63
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Regular-34b" d="M 494 -1306
+L 494 3494
+L 1038 3494
+L 1038 2934
+L 1100 2934
+Q 1159 3028 1265 3170
+Q 1372 3313 1572 3425
+Q 1772 3538 2113 3538
+Q 2550 3538 2883 3319
+Q 3216 3100 3405 2695
+Q 3594 2291 3594 1738
+Q 3594 1181 3406 775
+Q 3219 369 2886 147
+Q 2553 -75 2116 -75
+Q 1784 -75 1581 39
+Q 1378 153 1268 298
+Q 1159 444 1100 541
+L 1056 541
+L 1056 -1306
+L 494 -1306
+z
+M 2031 428
+Q 2359 428 2579 604
+Q 2800 781 2911 1079
+Q 3022 1378 3022 1744
+Q 3022 2106 2912 2398
+Q 2803 2691 2583 2862
+Q 2363 3034 2031 3034
+Q 1550 3034 1300 2678
+Q 1050 2322 1050 1744
+Q 1050 1159 1303 793
+Q 1556 428 2031 428
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Regular-5de" d="M 922 -41
+Q 747 -41 623 82
+Q 500 206 500 381
+Q 500 556 623 679
+Q 747 803 922 803
+Q 1097 803 1220 679
+Q 1344 556 1344 381
+Q 1344 206 1220 82
+Q 1097 -41 922 -41
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Regular-12c" d="M 563 0
+L 563 4656
+L 1263 4656
+L 3156 1678
+Q 3250 1528 3398 1273
+Q 3547 1019 3706 703
+Q 3678 1041 3672 1327
+Q 3666 1613 3666 1800
+L 3666 4656
+L 4259 4656
+L 4259 0
+L 3553 0
+L 1866 2650
+Q 1759 2816 1654 2991
+Q 1550 3166 1422 3394
+Q 1294 3622 1113 3944
+Q 1131 3497 1145 3161
+Q 1159 2825 1159 2656
+L 1159 0
+L 563 0
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Regular-a1" d="M 563 0
+L 563 4656
+L 1156 4656
+L 1156 2644
+L 3600 2644
+L 3600 4656
+L 4194 4656
+L 4194 0
+L 3600 0
+L 3600 2119
+L 1156 2119
+L 1156 0
+L 563 0
+z
+" transform="scale(0.015625)"/>
+ </defs>
+ <use xlink:href="#Inter-Regular-89"/>
+ <use xlink:href="#Inter-Regular-316" transform="translate(55.078125 0)"/>
+ <use xlink:href="#Inter-Regular-354" transform="translate(115.046875 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(152.6875 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(180.8125 0)"/>
+ <use xlink:href="#Inter-Regular-1fb" transform="translate(240.09375 0)"/>
+ <use xlink:href="#Inter-Regular-24a" transform="translate(296.25 0)"/>
+ <use xlink:href="#Inter-Regular-29e" transform="translate(353.375 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(412.5 0)"/>
+ <use xlink:href="#Inter-Regular-2b1" transform="translate(440.625 0)"/>
+ <use xlink:href="#Inter-Regular-367" transform="translate(464.84375 0)"/>
+ <use xlink:href="#Inter-Regular-367" transform="translate(517.625 0)"/>
+ <use xlink:href="#Inter-Regular-393" transform="translate(570.40625 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(629.53125 0)"/>
+ <use xlink:href="#Inter-Regular-5e1" transform="translate(687.828125 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(716.640625 0)"/>
+ <use xlink:href="#Inter-Regular-2b1" transform="translate(744.765625 0)"/>
+ <use xlink:href="#Inter-Regular-367" transform="translate(768.984375 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(821.765625 0)"/>
+ <use xlink:href="#Inter-Regular-1fb" transform="translate(849.890625 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(906.046875 0)"/>
+ <use xlink:href="#Inter-Regular-287" transform="translate(934.171875 0)"/>
+ <use xlink:href="#Inter-Regular-2b1" transform="translate(971.1875 0)"/>
+ <use xlink:href="#Inter-Regular-2e0" transform="translate(995.40625 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(1019.625 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(1077.921875 0)"/>
+ <use xlink:href="#Inter-Regular-379" transform="translate(1106.046875 0)"/>
+ <use xlink:href="#Inter-Regular-29e" transform="translate(1138.765625 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(1197.890625 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(1256.1875 0)"/>
+ <use xlink:href="#Inter-Regular-287" transform="translate(1284.3125 0)"/>
+ <use xlink:href="#Inter-Regular-2b1" transform="translate(1321.328125 0)"/>
+ <use xlink:href="#Inter-Regular-3e1" transform="translate(1345.546875 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(1400.140625 0)"/>
+ <use xlink:href="#Inter-Regular-24a" transform="translate(1428.265625 0)"/>
+ <use xlink:href="#Inter-Regular-29e" transform="translate(1485.390625 0)"/>
+ <use xlink:href="#Inter-Regular-1fb" transform="translate(1544.515625 0)"/>
+ <use xlink:href="#Inter-Regular-305" transform="translate(1600.671875 0)"/>
+ <use xlink:href="#Inter-Regular-292" transform="translate(1659.75 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(1721.078125 0)"/>
+ <use xlink:href="#Inter-Regular-255" transform="translate(1779.375 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(1840.609375 0)"/>
+ <use xlink:href="#Inter-Regular-1fb" transform="translate(1868.734375 0)"/>
+ <use xlink:href="#Inter-Regular-2fe" transform="translate(1924.890625 0)"/>
+ <use xlink:href="#Inter-Regular-316" transform="translate(2012.484375 0)"/>
+ <use xlink:href="#Inter-Regular-305" transform="translate(2072.453125 0)"/>
+ <use xlink:href="#Inter-Regular-292" transform="translate(2131.53125 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(2192.859375 0)"/>
+ <use xlink:href="#Inter-Regular-379" transform="translate(2220.984375 0)"/>
+ <use xlink:href="#Inter-Regular-29e" transform="translate(2253.703125 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(2312.828125 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(2371.125 0)"/>
+ <use xlink:href="#Inter-Regular-287" transform="translate(2399.25 0)"/>
+ <use xlink:href="#Inter-Regular-2b1" transform="translate(2436.265625 0)"/>
+ <use xlink:href="#Inter-Regular-354" transform="translate(2460.484375 0)"/>
+ <use xlink:href="#Inter-Regular-367" transform="translate(2498.125 0)"/>
+ <use xlink:href="#Inter-Regular-379" transform="translate(2550.90625 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(2583.625 0)"/>
+ <use xlink:href="#Inter-Regular-2d7" transform="translate(2611.75 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(2666.640625 0)"/>
+ <use xlink:href="#Inter-Regular-287" transform="translate(2694.765625 0)"/>
+ <use xlink:href="#Inter-Regular-2b1" transform="translate(2731.78125 0)"/>
+ <use xlink:href="#Inter-Regular-2e0" transform="translate(2756 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(2780.21875 0)"/>
+ <use xlink:href="#Inter-Regular-367" transform="translate(2838.515625 0)"/>
+ <use xlink:href="#Inter-Regular-597" transform="translate(2891.296875 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(2942.421875 0)"/>
+ <use xlink:href="#Inter-Regular-8d" transform="translate(2970.546875 0)"/>
+ <use xlink:href="#Inter-Regular-354" transform="translate(3045.15625 0)"/>
+ <use xlink:href="#Inter-Regular-1fb" transform="translate(3082.796875 0)"/>
+ <use xlink:href="#Inter-Regular-34b" transform="translate(3138.953125 0)"/>
+ <use xlink:href="#Inter-Regular-29e" transform="translate(3200.1875 0)"/>
+ <use xlink:href="#Inter-Regular-2b1" transform="translate(3259.3125 0)"/>
+ <use xlink:href="#Inter-Regular-24a" transform="translate(3283.53125 0)"/>
+ <use xlink:href="#Inter-Regular-2e0" transform="translate(3340.65625 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(3364.875 0)"/>
+ <use xlink:href="#Inter-Regular-5e1" transform="translate(3423.171875 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(3451.984375 0)"/>
+ <use xlink:href="#Inter-Regular-379" transform="translate(3480.109375 0)"/>
+ <use xlink:href="#Inter-Regular-29e" transform="translate(3512.828125 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(3571.953125 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(3630.25 0)"/>
+ <use xlink:href="#Inter-Regular-287" transform="translate(3658.375 0)"/>
+ <use xlink:href="#Inter-Regular-2b1" transform="translate(3695.390625 0)"/>
+ <use xlink:href="#Inter-Regular-2e0" transform="translate(3719.609375 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(3743.828125 0)"/>
+ <use xlink:href="#Inter-Regular-367" transform="translate(3802.125 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(3854.90625 0)"/>
+ <use xlink:href="#Inter-Regular-2b1" transform="translate(3883.03125 0)"/>
+ <use xlink:href="#Inter-Regular-379" transform="translate(3907.25 0)"/>
+ <use xlink:href="#Inter-Regular-367" transform="translate(3939 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(3991.78125 0)"/>
+ <use xlink:href="#Inter-Regular-24a" transform="translate(4019.90625 0)"/>
+ <use xlink:href="#Inter-Regular-316" transform="translate(4077.03125 0)"/>
+ <use xlink:href="#Inter-Regular-305" transform="translate(4137 0)"/>
+ <use xlink:href="#Inter-Regular-379" transform="translate(4196.078125 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(4227.828125 0)"/>
+ <use xlink:href="#Inter-Regular-3e1" transform="translate(4283.875 0)"/>
+ <use xlink:href="#Inter-Regular-379" transform="translate(4340.421875 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(4373.140625 0)"/>
+ <use xlink:href="#Inter-Regular-34b" transform="translate(4401.265625 0)"/>
+ <use xlink:href="#Inter-Regular-1fb" transform="translate(4463.484375 0)"/>
+ <use xlink:href="#Inter-Regular-24a" transform="translate(4519.640625 0)"/>
+ <use xlink:href="#Inter-Regular-2d7" transform="translate(4576.765625 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(4629.40625 0)"/>
+ <use xlink:href="#Inter-Regular-379" transform="translate(4687.703125 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(4720.421875 0)"/>
+ <use xlink:href="#Inter-Regular-24a" transform="translate(4748.546875 0)"/>
+ <use xlink:href="#Inter-Regular-2b1" transform="translate(4805.671875 0)"/>
+ <use xlink:href="#Inter-Regular-379" transform="translate(4829.890625 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(4861.640625 0)"/>
+ <use xlink:href="#Inter-Regular-367" transform="translate(4919.9375 0)"/>
+ <use xlink:href="#Inter-Regular-5dd" transform="translate(4972.71875 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(5001.53125 0)"/>
+ <use xlink:href="#Inter-Regular-379" transform="translate(5029.65625 0)"/>
+ <use xlink:href="#Inter-Regular-29e" transform="translate(5062.375 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(5121.5 0)"/>
+ <use xlink:href="#Inter-Regular-305" transform="translate(5179.796875 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(5238.875 0)"/>
+ <use xlink:href="#Inter-Regular-2e0" transform="translate(5267 0)"/>
+ <use xlink:href="#Inter-Regular-2b1" transform="translate(5291.21875 0)"/>
+ <use xlink:href="#Inter-Regular-367" transform="translate(5315.4375 0)"/>
+ <use xlink:href="#Inter-Regular-379" transform="translate(5368.21875 0)"/>
+ <use xlink:href="#Inter-Regular-367" transform="translate(5399.96875 0)"/>
+ <use xlink:href="#Inter-Regular-5de" transform="translate(5452.75 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(5481.5625 0)"/>
+ <use xlink:href="#Inter-Regular-12c" transform="translate(5509.6875 0)"/>
+ <use xlink:href="#Inter-Regular-316" transform="translate(5585.03125 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(5645 0)"/>
+ <use xlink:href="#Inter-Regular-2fe" transform="translate(5673.125 0)"/>
+ <use xlink:href="#Inter-Regular-316" transform="translate(5760.71875 0)"/>
+ <use xlink:href="#Inter-Regular-255" transform="translate(5820.6875 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(5881.921875 0)"/>
+ <use xlink:href="#Inter-Regular-2e0" transform="translate(5940.21875 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(5964.4375 0)"/>
+ <use xlink:href="#Inter-Regular-24a" transform="translate(5992.5625 0)"/>
+ <use xlink:href="#Inter-Regular-1fb" transform="translate(6050.671875 0)"/>
+ <use xlink:href="#Inter-Regular-2e0" transform="translate(6106.828125 0)"/>
+ <use xlink:href="#Inter-Regular-2e0" transform="translate(6131.046875 0)"/>
+ <use xlink:href="#Inter-Regular-367" transform="translate(6155.265625 0)"/>
+ <use xlink:href="#Inter-Regular-5de" transform="translate(6208.046875 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(6236.859375 0)"/>
+ <use xlink:href="#Inter-Regular-a1" transform="translate(6264.984375 0)"/>
+ <use xlink:href="#Inter-Regular-2b1" transform="translate(6339.296875 0)"/>
+ <use xlink:href="#Inter-Regular-292" transform="translate(6363.515625 0)"/>
+ <use xlink:href="#Inter-Regular-29e" transform="translate(6424.84375 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(6483.96875 0)"/>
+ <use xlink:href="#Inter-Regular-354" transform="translate(6542.265625 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(6579.90625 0)"/>
+ <use xlink:href="#Inter-Regular-2b1" transform="translate(6608.03125 0)"/>
+ <use xlink:href="#Inter-Regular-367" transform="translate(6632.25 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(6685.03125 0)"/>
+ <use xlink:href="#Inter-Regular-242" transform="translate(6713.15625 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(6774.390625 0)"/>
+ <use xlink:href="#Inter-Regular-379" transform="translate(6832.6875 0)"/>
+ <use xlink:href="#Inter-Regular-379" transform="translate(6865.40625 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(6897.15625 0)"/>
+ <use xlink:href="#Inter-Regular-354" transform="translate(6955.453125 0)"/>
+ <use xlink:href="#Inter-Regular-5de" transform="translate(6986.84375 0)"/>
+ </g>
+ </g>
+ <g id="text_9">
+ <!-- Graphicle 0.1.3 and the 0.1.2 release binary run graphicle context on the issue's prompt, with their defaults. BM25: SWE-bench style, one document per source file. grep: rg 14.1.1 -->
+ <g style="fill: #8a93a6" transform="translate(48 796) scale(0.18 -0.18)">
+ <defs>
+ <path id="Inter-Regular-541" d="M 1984 -63
+Q 1528 -63 1175 93
+Q 822 250 614 528
+Q 406 806 391 1175
+L 991 1175
+Q 1016 844 1297 651
+Q 1578 459 1975 459
+Q 2413 459 2698 684
+Q 2984 909 2984 1272
+Q 2984 1650 2703 1889
+Q 2422 2128 1903 2128
+L 1525 2128
+L 1525 2644
+L 1903 2644
+Q 2313 2644 2567 2861
+Q 2822 3078 2822 3438
+Q 2822 3784 2597 3993
+Q 2372 4203 1991 4203
+Q 1753 4203 1545 4117
+Q 1338 4031 1205 3872
+Q 1072 3713 1063 3484
+L 491 3484
+Q 503 3850 709 4128
+Q 916 4406 1255 4562
+Q 1594 4719 2003 4719
+Q 2438 4719 2752 4544
+Q 3066 4369 3234 4084
+Q 3403 3800 3403 3469
+Q 3403 3075 3195 2800
+Q 2988 2525 2631 2419
+L 2631 2381
+Q 3078 2309 3325 2007
+Q 3572 1706 3572 1266
+Q 3572 884 3365 584
+Q 3159 284 2800 110
+Q 2441 -63 1984 -63
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Regular-3e6" d="M 438 -1266
+L 581 -778
+L 641 -794
+Q 900 -863 1087 -773
+Q 1275 -684 1403 -309
+L 1503 -19
+L 169 3494
+L 784 3494
+L 1528 1422
+Q 1609 1194 1673 969
+Q 1738 744 1797 525
+Q 1856 744 1920 969
+Q 1984 1194 2066 1422
+L 2816 3494
+L 3428 3494
+L 1894 -522
+Q 1734 -938 1478 -1134
+Q 1222 -1331 850 -1331
+Q 700 -1331 590 -1309
+Q 481 -1288 438 -1266
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Regular-5cc" d="M 725 2884
+L 656 4656
+L 1263 4656
+L 1194 2884
+L 725 2884
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Regular-3d8" d="M 1278 0
+L 219 3494
+L 816 3494
+L 1241 1969
+Q 1316 1697 1403 1358
+Q 1491 1019 1575 603
+Q 1659 1003 1742 1340
+Q 1825 1678 1906 1969
+L 2325 3494
+L 2925 3494
+L 3338 1969
+Q 3413 1688 3495 1352
+Q 3578 1016 3659 613
+Q 3747 1013 3833 1348
+Q 3919 1684 3997 1969
+L 4422 3494
+L 5019 3494
+L 3959 0
+L 3400 0
+L 2947 1581
+Q 2859 1881 2779 2200
+Q 2700 2519 2619 2853
+Q 2541 2519 2458 2197
+Q 2375 1875 2291 1581
+L 1838 0
+L 1278 0
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Regular-41" d="M 563 0
+L 563 4656
+L 2213 4656
+Q 2700 4656 3017 4489
+Q 3334 4322 3489 4042
+Q 3644 3763 3644 3422
+Q 3644 3122 3537 2926
+Q 3431 2731 3257 2615
+Q 3084 2500 2881 2444
+L 2881 2400
+Q 3100 2388 3317 2250
+Q 3534 2113 3679 1859
+Q 3825 1606 3825 1241
+Q 3825 891 3664 609
+Q 3503 328 3159 164
+Q 2816 0 2266 0
+L 563 0
+z
+M 1156 525
+L 2250 525
+Q 2794 525 3023 734
+Q 3253 944 3253 1247
+Q 3253 1481 3134 1678
+Q 3016 1875 2798 1994
+Q 2581 2113 2281 2113
+L 1156 2113
+L 1156 525
+z
+M 1156 2613
+L 2181 2613
+Q 2556 2613 2815 2831
+Q 3075 3050 3075 3409
+Q 3075 3713 2864 3922
+Q 2653 4131 2200 4131
+L 1156 4131
+L 1156 2613
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Regular-124" d="M 563 0
+L 563 4656
+L 1406 4656
+L 2553 1719
+Q 2619 1550 2716 1247
+Q 2813 944 2897 659
+Q 2978 934 3075 1239
+Q 3172 1544 3241 1719
+L 4372 4656
+L 5219 4656
+L 5219 0
+L 4634 0
+L 4634 2659
+Q 4634 2916 4640 3287
+Q 4647 3659 4656 4022
+Q 4528 3622 4398 3244
+Q 4269 2866 4188 2659
+L 3147 0
+L 2631 0
+L 1575 2659
+Q 1497 2856 1370 3229
+Q 1244 3603 1106 4013
+Q 1113 3681 1120 3304
+Q 1128 2928 1128 2659
+L 1128 0
+L 563 0
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Regular-543" d="M 1863 -63
+Q 1453 -63 1128 98
+Q 803 259 609 539
+Q 416 819 400 1175
+L 975 1175
+Q 1003 863 1258 661
+Q 1513 459 1863 459
+Q 2144 459 2364 590
+Q 2584 722 2709 953
+Q 2834 1184 2834 1478
+Q 2834 1778 2703 2015
+Q 2572 2253 2345 2389
+Q 2119 2525 1825 2525
+Q 1609 2525 1387 2456
+Q 1166 2388 1028 2281
+L 472 2350
+L 747 4656
+L 3197 4656
+L 3197 4134
+L 1247 4134
+L 1088 2775
+L 1113 2775
+Q 1256 2894 1475 2970
+Q 1694 3047 1934 3047
+Q 2363 3047 2697 2845
+Q 3031 2644 3223 2291
+Q 3416 1938 3416 1488
+Q 3416 1041 3214 691
+Q 3013 341 2663 139
+Q 2313 -63 1863 -63
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Regular-5e2" d="M 922 640
+Q 747 640 623 763
+Q 500 887 500 1062
+Q 500 1237 623 1360
+Q 747 1484 922 1484
+Q 1097 1484 1220 1360
+Q 1344 1237 1344 1062
+Q 1344 887 1220 763
+Q 1097 640 922 640
+z
+M 922 3168
+Q 747 3168 623 3291
+Q 500 3415 500 3590
+Q 500 3765 623 3888
+Q 747 4012 922 4012
+Q 1097 4012 1220 3888
+Q 1344 3765 1344 3590
+Q 1344 3415 1220 3291
+Q 1097 3168 922 3168
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Regular-18d" d="M 2053 -81
+Q 1297 -81 850 276
+Q 403 634 363 1219
+L 972 1219
+Q 997 956 1150 786
+Q 1303 616 1542 533
+Q 1781 450 2053 450
+Q 2369 450 2620 553
+Q 2872 656 3019 843
+Q 3166 1031 3166 1278
+Q 3166 1503 3039 1643
+Q 2913 1784 2703 1875
+Q 2494 1966 2244 2034
+L 1681 2194
+Q 1119 2353 806 2650
+Q 494 2947 494 3409
+Q 494 3803 706 4098
+Q 919 4394 1281 4556
+Q 1644 4719 2094 4719
+Q 2553 4719 2906 4556
+Q 3259 4394 3464 4114
+Q 3669 3834 3681 3481
+L 3100 3481
+Q 3059 3822 2775 4008
+Q 2491 4194 2075 4194
+Q 1622 4194 1347 3980
+Q 1072 3766 1072 3438
+Q 1072 3194 1223 3045
+Q 1375 2897 1583 2814
+Q 1791 2731 1959 2684
+L 2425 2556
+Q 2613 2506 2839 2418
+Q 3066 2331 3272 2186
+Q 3478 2041 3611 1817
+Q 3744 1594 3744 1269
+Q 3744 888 3545 581
+Q 3347 275 2969 97
+Q 2591 -81 2053 -81
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Regular-1cb" d="M 1431 0
+L 163 4656
+L 769 4656
+L 1506 1800
+Q 1581 1500 1650 1190
+Q 1719 881 1781 553
+Q 1844 881 1912 1190
+Q 1981 1500 2063 1800
+L 2816 4656
+L 3491 4656
+L 4238 1800
+Q 4394 1216 4522 572
+Q 4581 894 4651 1198
+Q 4722 1503 4797 1800
+L 5531 4656
+L 6144 4656
+L 4869 0
+L 4178 0
+L 3378 2950
+Q 3319 3172 3261 3425
+Q 3203 3678 3150 3984
+Q 3097 3700 3044 3451
+Q 2991 3203 2922 2950
+L 2125 0
+L 1431 0
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Regular-5f" d="M 563 0
+L 563 4656
+L 3400 4656
+L 3400 4131
+L 1156 4131
+L 1156 2613
+L 3247 2613
+L 3247 2088
+L 1156 2088
+L 1156 525
+L 3428 525
+L 3428 0
+L 563 0
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Regular-5b3" d="M 2494 2247
+L 2494 1728
+L 450 1728
+L 450 2247
+L 2494 2247
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Regular-542" d="M 375 947
+L 375 1431
+L 2413 4656
+L 3134 4656
+L 3134 1469
+L 3766 1469
+L 3766 947
+L 3134 947
+L 3134 0
+L 2566 0
+L 2566 947
+L 375 947
+z
+M 2569 1469
+L 2569 3913
+L 2531 3913
+L 1009 1506
+L 1009 1469
+L 2569 1469
+z
+" transform="scale(0.015625)"/>
+ </defs>
+ <use xlink:href="#Inter-Regular-8d"/>
+ <use xlink:href="#Inter-Regular-354" transform="translate(74.609375 0)"/>
+ <use xlink:href="#Inter-Regular-1fb" transform="translate(112.25 0)"/>
+ <use xlink:href="#Inter-Regular-34b" transform="translate(168.40625 0)"/>
+ <use xlink:href="#Inter-Regular-29e" transform="translate(229.640625 0)"/>
+ <use xlink:href="#Inter-Regular-2b1" transform="translate(288.765625 0)"/>
+ <use xlink:href="#Inter-Regular-24a" transform="translate(312.984375 0)"/>
+ <use xlink:href="#Inter-Regular-2e0" transform="translate(370.109375 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(394.328125 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(452.625 0)"/>
+ <use xlink:href="#Inter-Regular-53d" transform="translate(480.75 0)"/>
+ <use xlink:href="#Inter-Regular-5de" transform="translate(541.3125 0)"/>
+ <use xlink:href="#Inter-Regular-53e" transform="translate(561.484375 0)"/>
+ <use xlink:href="#Inter-Regular-5de" transform="translate(602.15625 0)"/>
+ <use xlink:href="#Inter-Regular-541" transform="translate(628.28125 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(690.046875 0)"/>
+ <use xlink:href="#Inter-Regular-1fb" transform="translate(718.171875 0)"/>
+ <use xlink:href="#Inter-Regular-305" transform="translate(774.328125 0)"/>
+ <use xlink:href="#Inter-Regular-255" transform="translate(833.40625 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(894.640625 0)"/>
+ <use xlink:href="#Inter-Regular-379" transform="translate(922.765625 0)"/>
+ <use xlink:href="#Inter-Regular-29e" transform="translate(955.484375 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(1014.609375 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(1072.90625 0)"/>
+ <use xlink:href="#Inter-Regular-53d" transform="translate(1101.03125 0)"/>
+ <use xlink:href="#Inter-Regular-5de" transform="translate(1161.59375 0)"/>
+ <use xlink:href="#Inter-Regular-53e" transform="translate(1181.765625 0)"/>
+ <use xlink:href="#Inter-Regular-5de" transform="translate(1222.4375 0)"/>
+ <use xlink:href="#Inter-Regular-53f" transform="translate(1251.25 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(1312.234375 0)"/>
+ <use xlink:href="#Inter-Regular-354" transform="translate(1340.359375 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(1376.34375 0)"/>
+ <use xlink:href="#Inter-Regular-2e0" transform="translate(1434.640625 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(1458.859375 0)"/>
+ <use xlink:href="#Inter-Regular-1fb" transform="translate(1518.140625 0)"/>
+ <use xlink:href="#Inter-Regular-367" transform="translate(1574.296875 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(1627.078125 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(1685.375 0)"/>
+ <use xlink:href="#Inter-Regular-242" transform="translate(1713.5 0)"/>
+ <use xlink:href="#Inter-Regular-2b1" transform="translate(1774.734375 0)"/>
+ <use xlink:href="#Inter-Regular-305" transform="translate(1798.953125 0)"/>
+ <use xlink:href="#Inter-Regular-1fb" transform="translate(1858.03125 0)"/>
+ <use xlink:href="#Inter-Regular-354" transform="translate(1914.1875 0)"/>
+ <use xlink:href="#Inter-Regular-3e6" transform="translate(1953.390625 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(2009.59375 0)"/>
+ <use xlink:href="#Inter-Regular-354" transform="translate(2037.71875 0)"/>
+ <use xlink:href="#Inter-Regular-393" transform="translate(2075.359375 0)"/>
+ <use xlink:href="#Inter-Regular-305" transform="translate(2134.484375 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(2193.5625 0)"/>
+ <use xlink:href="#Inter-Regular-292" transform="translate(2221.6875 0)"/>
+ <use xlink:href="#Inter-Regular-354" transform="translate(2283.015625 0)"/>
+ <use xlink:href="#Inter-Regular-1fb" transform="translate(2320.65625 0)"/>
+ <use xlink:href="#Inter-Regular-34b" transform="translate(2376.8125 0)"/>
+ <use xlink:href="#Inter-Regular-29e" transform="translate(2438.046875 0)"/>
+ <use xlink:href="#Inter-Regular-2b1" transform="translate(2497.171875 0)"/>
+ <use xlink:href="#Inter-Regular-24a" transform="translate(2521.390625 0)"/>
+ <use xlink:href="#Inter-Regular-2e0" transform="translate(2578.515625 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(2602.734375 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(2661.03125 0)"/>
+ <use xlink:href="#Inter-Regular-24a" transform="translate(2689.15625 0)"/>
+ <use xlink:href="#Inter-Regular-316" transform="translate(2746.28125 0)"/>
+ <use xlink:href="#Inter-Regular-305" transform="translate(2806.25 0)"/>
+ <use xlink:href="#Inter-Regular-379" transform="translate(2865.328125 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(2897.078125 0)"/>
+ <use xlink:href="#Inter-Regular-3e1" transform="translate(2953.125 0)"/>
+ <use xlink:href="#Inter-Regular-379" transform="translate(3009.671875 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(3042.390625 0)"/>
+ <use xlink:href="#Inter-Regular-316" transform="translate(3070.515625 0)"/>
+ <use xlink:href="#Inter-Regular-305" transform="translate(3130.484375 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(3189.5625 0)"/>
+ <use xlink:href="#Inter-Regular-379" transform="translate(3217.6875 0)"/>
+ <use xlink:href="#Inter-Regular-29e" transform="translate(3250.40625 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(3309.53125 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(3367.828125 0)"/>
+ <use xlink:href="#Inter-Regular-2b1" transform="translate(3395.953125 0)"/>
+ <use xlink:href="#Inter-Regular-367" transform="translate(3420.171875 0)"/>
+ <use xlink:href="#Inter-Regular-367" transform="translate(3472.953125 0)"/>
+ <use xlink:href="#Inter-Regular-393" transform="translate(3525.734375 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(3584.859375 0)"/>
+ <use xlink:href="#Inter-Regular-5cc" transform="translate(3641.6875 0)"/>
+ <use xlink:href="#Inter-Regular-367" transform="translate(3671.671875 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(3724.453125 0)"/>
+ <use xlink:href="#Inter-Regular-34b" transform="translate(3752.578125 0)"/>
+ <use xlink:href="#Inter-Regular-354" transform="translate(3813.8125 0)"/>
+ <use xlink:href="#Inter-Regular-316" transform="translate(3849.796875 0)"/>
+ <use xlink:href="#Inter-Regular-2fe" transform="translate(3909.765625 0)"/>
+ <use xlink:href="#Inter-Regular-34b" transform="translate(3997.359375 0)"/>
+ <use xlink:href="#Inter-Regular-379" transform="translate(4058.59375 0)"/>
+ <use xlink:href="#Inter-Regular-5dd" transform="translate(4091.3125 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(4120.125 0)"/>
+ <use xlink:href="#Inter-Regular-3d8" transform="translate(4148.25 0)"/>
+ <use xlink:href="#Inter-Regular-2b1" transform="translate(4230.09375 0)"/>
+ <use xlink:href="#Inter-Regular-379" transform="translate(4254.3125 0)"/>
+ <use xlink:href="#Inter-Regular-29e" transform="translate(4287.03125 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(4346.15625 0)"/>
+ <use xlink:href="#Inter-Regular-379" transform="translate(4374.28125 0)"/>
+ <use xlink:href="#Inter-Regular-29e" transform="translate(4407 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(4466.125 0)"/>
+ <use xlink:href="#Inter-Regular-2b1" transform="translate(4524.421875 0)"/>
+ <use xlink:href="#Inter-Regular-354" transform="translate(4548.640625 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(4586.28125 0)"/>
+ <use xlink:href="#Inter-Regular-255" transform="translate(4614.40625 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(4675.640625 0)"/>
+ <use xlink:href="#Inter-Regular-287" transform="translate(4733.9375 0)"/>
+ <use xlink:href="#Inter-Regular-1fb" transform="translate(4769.390625 0)"/>
+ <use xlink:href="#Inter-Regular-393" transform="translate(4825.546875 0)"/>
+ <use xlink:href="#Inter-Regular-2e0" transform="translate(4884.671875 0)"/>
+ <use xlink:href="#Inter-Regular-379" transform="translate(4910.359375 0)"/>
+ <use xlink:href="#Inter-Regular-367" transform="translate(4942.109375 0)"/>
+ <use xlink:href="#Inter-Regular-5de" transform="translate(4994.890625 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(5023.703125 0)"/>
+ <use xlink:href="#Inter-Regular-41" transform="translate(5051.828125 0)"/>
+ <use xlink:href="#Inter-Regular-124" transform="translate(5117.265625 0)"/>
+ <use xlink:href="#Inter-Regular-53f" transform="translate(5207.59375 0)"/>
+ <use xlink:href="#Inter-Regular-543" transform="translate(5268.578125 0)"/>
+ <use xlink:href="#Inter-Regular-5e2" transform="translate(5327.90625 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(5356.71875 0)"/>
+ <use xlink:href="#Inter-Regular-18d" transform="translate(5384.84375 0)"/>
+ <use xlink:href="#Inter-Regular-1cb" transform="translate(5449 0)"/>
+ <use xlink:href="#Inter-Regular-5f" transform="translate(5547.53125 0)"/>
+ <use xlink:href="#Inter-Regular-5b3" transform="translate(5607.640625 0)"/>
+ <use xlink:href="#Inter-Regular-242" transform="translate(5653.640625 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(5714.875 0)"/>
+ <use xlink:href="#Inter-Regular-305" transform="translate(5773.171875 0)"/>
+ <use xlink:href="#Inter-Regular-24a" transform="translate(5832.25 0)"/>
+ <use xlink:href="#Inter-Regular-29e" transform="translate(5889.375 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(5948.5 0)"/>
+ <use xlink:href="#Inter-Regular-367" transform="translate(5976.625 0)"/>
+ <use xlink:href="#Inter-Regular-379" transform="translate(6029.40625 0)"/>
+ <use xlink:href="#Inter-Regular-3e6" transform="translate(6064.078125 0)"/>
+ <use xlink:href="#Inter-Regular-2e0" transform="translate(6120.765625 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(6144.984375 0)"/>
+ <use xlink:href="#Inter-Regular-5dd" transform="translate(6203.28125 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(6232.09375 0)"/>
+ <use xlink:href="#Inter-Regular-316" transform="translate(6260.21875 0)"/>
+ <use xlink:href="#Inter-Regular-305" transform="translate(6320.1875 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(6379.265625 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(6437.5625 0)"/>
+ <use xlink:href="#Inter-Regular-255" transform="translate(6465.6875 0)"/>
+ <use xlink:href="#Inter-Regular-316" transform="translate(6526.921875 0)"/>
+ <use xlink:href="#Inter-Regular-24a" transform="translate(6586.890625 0)"/>
+ <use xlink:href="#Inter-Regular-393" transform="translate(6644.015625 0)"/>
+ <use xlink:href="#Inter-Regular-2fe" transform="translate(6703.140625 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(6790.734375 0)"/>
+ <use xlink:href="#Inter-Regular-305" transform="translate(6849.03125 0)"/>
+ <use xlink:href="#Inter-Regular-379" transform="translate(6908.109375 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(6940.828125 0)"/>
+ <use xlink:href="#Inter-Regular-34b" transform="translate(6968.953125 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(7030.1875 0)"/>
+ <use xlink:href="#Inter-Regular-354" transform="translate(7088.484375 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(7126.125 0)"/>
+ <use xlink:href="#Inter-Regular-367" transform="translate(7154.25 0)"/>
+ <use xlink:href="#Inter-Regular-316" transform="translate(7207.03125 0)"/>
+ <use xlink:href="#Inter-Regular-393" transform="translate(7267 0)"/>
+ <use xlink:href="#Inter-Regular-354" transform="translate(7326.125 0)"/>
+ <use xlink:href="#Inter-Regular-24a" transform="translate(7362.109375 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(7419.234375 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(7477.53125 0)"/>
+ <use xlink:href="#Inter-Regular-287" transform="translate(7505.65625 0)"/>
+ <use xlink:href="#Inter-Regular-2b1" transform="translate(7542.671875 0)"/>
+ <use xlink:href="#Inter-Regular-2e0" transform="translate(7566.890625 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(7591.109375 0)"/>
+ <use xlink:href="#Inter-Regular-5de" transform="translate(7649.40625 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(7678.21875 0)"/>
+ <use xlink:href="#Inter-Regular-292" transform="translate(7706.34375 0)"/>
+ <use xlink:href="#Inter-Regular-354" transform="translate(7767.671875 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(7803.65625 0)"/>
+ <use xlink:href="#Inter-Regular-34b" transform="translate(7861.953125 0)"/>
+ <use xlink:href="#Inter-Regular-5e1" transform="translate(7923.1875 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(7952 0)"/>
+ <use xlink:href="#Inter-Regular-354" transform="translate(7980.125 0)"/>
+ <use xlink:href="#Inter-Regular-292" transform="translate(8016.109375 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(8077.4375 0)"/>
+ <use xlink:href="#Inter-Regular-53e" transform="translate(8105.5625 0)"/>
+ <use xlink:href="#Inter-Regular-542" transform="translate(8146.234375 0)"/>
+ <use xlink:href="#Inter-Regular-5de" transform="translate(8207.453125 0)"/>
+ <use xlink:href="#Inter-Regular-53e" transform="translate(8227.625 0)"/>
+ <use xlink:href="#Inter-Regular-5de" transform="translate(8268.296875 0)"/>
+ <use xlink:href="#Inter-Regular-53e" transform="translate(8288.46875 0)"/>
+ </g>
+ </g>
+ <g id="text_10">
+ <!-- for the identifiers and paths the issue names, files ranked by names matched. -->
+ <g style="fill: #8a93a6" transform="translate(48 821) scale(0.18 -0.18)">
+ <use xlink:href="#Inter-Regular-287"/>
+ <use xlink:href="#Inter-Regular-316" transform="translate(34.09375 0)"/>
+ <use xlink:href="#Inter-Regular-354" transform="translate(94.0625 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(131.703125 0)"/>
+ <use xlink:href="#Inter-Regular-379" transform="translate(159.828125 0)"/>
+ <use xlink:href="#Inter-Regular-29e" transform="translate(192.546875 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(251.671875 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(309.96875 0)"/>
+ <use xlink:href="#Inter-Regular-2b1" transform="translate(338.09375 0)"/>
+ <use xlink:href="#Inter-Regular-255" transform="translate(362.3125 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(423.546875 0)"/>
+ <use xlink:href="#Inter-Regular-305" transform="translate(481.84375 0)"/>
+ <use xlink:href="#Inter-Regular-379" transform="translate(540.921875 0)"/>
+ <use xlink:href="#Inter-Regular-2b1" transform="translate(573.640625 0)"/>
+ <use xlink:href="#Inter-Regular-287" transform="translate(597.859375 0)"/>
+ <use xlink:href="#Inter-Regular-2b1" transform="translate(634.875 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(659.09375 0)"/>
+ <use xlink:href="#Inter-Regular-354" transform="translate(717.390625 0)"/>
+ <use xlink:href="#Inter-Regular-367" transform="translate(755.03125 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(807.8125 0)"/>
+ <use xlink:href="#Inter-Regular-1fb" transform="translate(835.9375 0)"/>
+ <use xlink:href="#Inter-Regular-305" transform="translate(892.09375 0)"/>
+ <use xlink:href="#Inter-Regular-255" transform="translate(951.171875 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(1012.40625 0)"/>
+ <use xlink:href="#Inter-Regular-34b" transform="translate(1040.53125 0)"/>
+ <use xlink:href="#Inter-Regular-1fb" transform="translate(1102.75 0)"/>
+ <use xlink:href="#Inter-Regular-379" transform="translate(1158.90625 0)"/>
+ <use xlink:href="#Inter-Regular-29e" transform="translate(1191.625 0)"/>
+ <use xlink:href="#Inter-Regular-367" transform="translate(1250.75 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(1303.53125 0)"/>
+ <use xlink:href="#Inter-Regular-379" transform="translate(1331.65625 0)"/>
+ <use xlink:href="#Inter-Regular-29e" transform="translate(1364.375 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(1423.5 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(1481.796875 0)"/>
+ <use xlink:href="#Inter-Regular-2b1" transform="translate(1509.921875 0)"/>
+ <use xlink:href="#Inter-Regular-367" transform="translate(1534.140625 0)"/>
+ <use xlink:href="#Inter-Regular-367" transform="translate(1586.921875 0)"/>
+ <use xlink:href="#Inter-Regular-393" transform="translate(1639.703125 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(1698.828125 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(1757.125 0)"/>
+ <use xlink:href="#Inter-Regular-305" transform="translate(1785.25 0)"/>
+ <use xlink:href="#Inter-Regular-1fb" transform="translate(1844.328125 0)"/>
+ <use xlink:href="#Inter-Regular-2fe" transform="translate(1900.484375 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(1988.078125 0)"/>
+ <use xlink:href="#Inter-Regular-367" transform="translate(2046.375 0)"/>
+ <use xlink:href="#Inter-Regular-5dd" transform="translate(2099.15625 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(2127.96875 0)"/>
+ <use xlink:href="#Inter-Regular-287" transform="translate(2156.09375 0)"/>
+ <use xlink:href="#Inter-Regular-2b1" transform="translate(2193.109375 0)"/>
+ <use xlink:href="#Inter-Regular-2e0" transform="translate(2217.328125 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(2241.546875 0)"/>
+ <use xlink:href="#Inter-Regular-367" transform="translate(2299.84375 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(2352.625 0)"/>
+ <use xlink:href="#Inter-Regular-354" transform="translate(2380.75 0)"/>
+ <use xlink:href="#Inter-Regular-1fb" transform="translate(2418.390625 0)"/>
+ <use xlink:href="#Inter-Regular-305" transform="translate(2474.546875 0)"/>
+ <use xlink:href="#Inter-Regular-2d7" transform="translate(2533.625 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(2586.265625 0)"/>
+ <use xlink:href="#Inter-Regular-255" transform="translate(2644.5625 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(2705.796875 0)"/>
+ <use xlink:href="#Inter-Regular-242" transform="translate(2733.921875 0)"/>
+ <use xlink:href="#Inter-Regular-3e6" transform="translate(2793.203125 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(2849.40625 0)"/>
+ <use xlink:href="#Inter-Regular-305" transform="translate(2877.53125 0)"/>
+ <use xlink:href="#Inter-Regular-1fb" transform="translate(2936.609375 0)"/>
+ <use xlink:href="#Inter-Regular-2fe" transform="translate(2992.765625 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(3080.359375 0)"/>
+ <use xlink:href="#Inter-Regular-367" transform="translate(3138.65625 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(3191.4375 0)"/>
+ <use xlink:href="#Inter-Regular-2fe" transform="translate(3219.5625 0)"/>
+ <use xlink:href="#Inter-Regular-1fb" transform="translate(3307.15625 0)"/>
+ <use xlink:href="#Inter-Regular-379" transform="translate(3363.3125 0)"/>
+ <use xlink:href="#Inter-Regular-24a" transform="translate(3395.0625 0)"/>
+ <use xlink:href="#Inter-Regular-29e" transform="translate(3452.1875 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(3511.3125 0)"/>
+ <use xlink:href="#Inter-Regular-255" transform="translate(3569.609375 0)"/>
+ <use xlink:href="#Inter-Regular-5de" transform="translate(3630.84375 0)"/>
+ </g>
+ </g>
+ <g id="text_11">
+ <!-- This measures ranking, not whether a coding agent fixes more issues. The agent test of 0.1.3 is pending. -->
+ <g style="fill: #8a93a6" transform="translate(48 846) scale(0.18 -0.18)">
+ <defs>
+ <path id="Inter-Regular-19b" d="M 306 4131
+L 306 4656
+L 3825 4656
+L 3825 4131
+L 2366 4131
+L 2366 0
+L 1772 0
+L 1772 4131
+L 306 4131
+z
+" transform="scale(0.015625)"/>
+ </defs>
+ <use xlink:href="#Inter-Regular-19b"/>
+ <use xlink:href="#Inter-Regular-29e" transform="translate(64.546875 0)"/>
+ <use xlink:href="#Inter-Regular-2b1" transform="translate(123.671875 0)"/>
+ <use xlink:href="#Inter-Regular-367" transform="translate(147.890625 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(200.671875 0)"/>
+ <use xlink:href="#Inter-Regular-2fe" transform="translate(228.796875 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(316.390625 0)"/>
+ <use xlink:href="#Inter-Regular-1fb" transform="translate(375.671875 0)"/>
+ <use xlink:href="#Inter-Regular-367" transform="translate(431.828125 0)"/>
+ <use xlink:href="#Inter-Regular-393" transform="translate(484.609375 0)"/>
+ <use xlink:href="#Inter-Regular-354" transform="translate(543.734375 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(579.71875 0)"/>
+ <use xlink:href="#Inter-Regular-367" transform="translate(638.015625 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(690.796875 0)"/>
+ <use xlink:href="#Inter-Regular-354" transform="translate(718.921875 0)"/>
+ <use xlink:href="#Inter-Regular-1fb" transform="translate(756.5625 0)"/>
+ <use xlink:href="#Inter-Regular-305" transform="translate(812.71875 0)"/>
+ <use xlink:href="#Inter-Regular-2d7" transform="translate(871.796875 0)"/>
+ <use xlink:href="#Inter-Regular-2b1" transform="translate(926.6875 0)"/>
+ <use xlink:href="#Inter-Regular-305" transform="translate(950.90625 0)"/>
+ <use xlink:href="#Inter-Regular-292" transform="translate(1009.984375 0)"/>
+ <use xlink:href="#Inter-Regular-5dd" transform="translate(1071.3125 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(1100.125 0)"/>
+ <use xlink:href="#Inter-Regular-305" transform="translate(1128.25 0)"/>
+ <use xlink:href="#Inter-Regular-316" transform="translate(1187.328125 0)"/>
+ <use xlink:href="#Inter-Regular-379" transform="translate(1247.296875 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(1280.015625 0)"/>
+ <use xlink:href="#Inter-Regular-3d8" transform="translate(1308.140625 0)"/>
+ <use xlink:href="#Inter-Regular-29e" transform="translate(1389.984375 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(1449.109375 0)"/>
+ <use xlink:href="#Inter-Regular-379" transform="translate(1507.40625 0)"/>
+ <use xlink:href="#Inter-Regular-29e" transform="translate(1540.125 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(1599.25 0)"/>
+ <use xlink:href="#Inter-Regular-354" transform="translate(1657.546875 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(1695.1875 0)"/>
+ <use xlink:href="#Inter-Regular-1fb" transform="translate(1723.3125 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(1779.46875 0)"/>
+ <use xlink:href="#Inter-Regular-24a" transform="translate(1807.59375 0)"/>
+ <use xlink:href="#Inter-Regular-316" transform="translate(1864.71875 0)"/>
+ <use xlink:href="#Inter-Regular-255" transform="translate(1924.6875 0)"/>
+ <use xlink:href="#Inter-Regular-2b1" transform="translate(1985.921875 0)"/>
+ <use xlink:href="#Inter-Regular-305" transform="translate(2010.140625 0)"/>
+ <use xlink:href="#Inter-Regular-292" transform="translate(2069.21875 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(2130.546875 0)"/>
+ <use xlink:href="#Inter-Regular-1fb" transform="translate(2158.671875 0)"/>
+ <use xlink:href="#Inter-Regular-292" transform="translate(2214.828125 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(2276.15625 0)"/>
+ <use xlink:href="#Inter-Regular-305" transform="translate(2334.453125 0)"/>
+ <use xlink:href="#Inter-Regular-379" transform="translate(2393.53125 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(2426.25 0)"/>
+ <use xlink:href="#Inter-Regular-287" transform="translate(2454.375 0)"/>
+ <use xlink:href="#Inter-Regular-2b1" transform="translate(2491.390625 0)"/>
+ <use xlink:href="#Inter-Regular-3e1" transform="translate(2515.609375 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(2567.953125 0)"/>
+ <use xlink:href="#Inter-Regular-367" transform="translate(2626.25 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(2679.03125 0)"/>
+ <use xlink:href="#Inter-Regular-2fe" transform="translate(2707.15625 0)"/>
+ <use xlink:href="#Inter-Regular-316" transform="translate(2794.75 0)"/>
+ <use xlink:href="#Inter-Regular-354" transform="translate(2854.71875 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(2890.703125 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(2949 0)"/>
+ <use xlink:href="#Inter-Regular-2b1" transform="translate(2977.125 0)"/>
+ <use xlink:href="#Inter-Regular-367" transform="translate(3001.34375 0)"/>
+ <use xlink:href="#Inter-Regular-367" transform="translate(3054.125 0)"/>
+ <use xlink:href="#Inter-Regular-393" transform="translate(3106.90625 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(3166.03125 0)"/>
+ <use xlink:href="#Inter-Regular-367" transform="translate(3224.328125 0)"/>
+ <use xlink:href="#Inter-Regular-5de" transform="translate(3277.109375 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(3305.921875 0)"/>
+ <use xlink:href="#Inter-Regular-19b" transform="translate(3334.046875 0)"/>
+ <use xlink:href="#Inter-Regular-29e" transform="translate(3398.59375 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(3457.71875 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(3516.015625 0)"/>
+ <use xlink:href="#Inter-Regular-1fb" transform="translate(3544.140625 0)"/>
+ <use xlink:href="#Inter-Regular-292" transform="translate(3600.296875 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(3661.625 0)"/>
+ <use xlink:href="#Inter-Regular-305" transform="translate(3719.921875 0)"/>
+ <use xlink:href="#Inter-Regular-379" transform="translate(3779 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(3811.71875 0)"/>
+ <use xlink:href="#Inter-Regular-379" transform="translate(3839.84375 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(3871.59375 0)"/>
+ <use xlink:href="#Inter-Regular-367" transform="translate(3929.890625 0)"/>
+ <use xlink:href="#Inter-Regular-379" transform="translate(3982.671875 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(4015.390625 0)"/>
+ <use xlink:href="#Inter-Regular-316" transform="translate(4043.515625 0)"/>
+ <use xlink:href="#Inter-Regular-287" transform="translate(4103.484375 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(4140.5 0)"/>
+ <use xlink:href="#Inter-Regular-53d" transform="translate(4168.625 0)"/>
+ <use xlink:href="#Inter-Regular-5de" transform="translate(4229.1875 0)"/>
+ <use xlink:href="#Inter-Regular-53e" transform="translate(4249.359375 0)"/>
+ <use xlink:href="#Inter-Regular-5de" transform="translate(4290.03125 0)"/>
+ <use xlink:href="#Inter-Regular-541" transform="translate(4316.15625 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(4377.921875 0)"/>
+ <use xlink:href="#Inter-Regular-2b1" transform="translate(4406.046875 0)"/>
+ <use xlink:href="#Inter-Regular-367" transform="translate(4430.265625 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(4483.046875 0)"/>
+ <use xlink:href="#Inter-Regular-34b" transform="translate(4511.171875 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(4572.40625 0)"/>
+ <use xlink:href="#Inter-Regular-305" transform="translate(4630.703125 0)"/>
+ <use xlink:href="#Inter-Regular-255" transform="translate(4689.78125 0)"/>
+ <use xlink:href="#Inter-Regular-2b1" transform="translate(4751.015625 0)"/>
+ <use xlink:href="#Inter-Regular-305" transform="translate(4775.234375 0)"/>
+ <use xlink:href="#Inter-Regular-292" transform="translate(4834.3125 0)"/>
+ <use xlink:href="#Inter-Regular-5de" transform="translate(4895.640625 0)"/>
+ </g>
+ </g>
+ <g id="text_12">
+ <!-- Method, task list and limits: -->
+ <g style="fill: #8a93a6" transform="translate(48 871) scale(0.18 -0.18)">
+ <use xlink:href="#Inter-Regular-124"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(90.328125 0)"/>
+ <use xlink:href="#Inter-Regular-379" transform="translate(148.625 0)"/>
+ <use xlink:href="#Inter-Regular-29e" transform="translate(181.34375 0)"/>
+ <use xlink:href="#Inter-Regular-316" transform="translate(240.46875 0)"/>
+ <use xlink:href="#Inter-Regular-255" transform="translate(300.4375 0)"/>
+ <use xlink:href="#Inter-Regular-5dd" transform="translate(361.671875 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(390.484375 0)"/>
+ <use xlink:href="#Inter-Regular-379" transform="translate(418.609375 0)"/>
+ <use xlink:href="#Inter-Regular-1fb" transform="translate(451.8125 0)"/>
+ <use xlink:href="#Inter-Regular-367" transform="translate(507.96875 0)"/>
+ <use xlink:href="#Inter-Regular-2d7" transform="translate(560.75 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(615.640625 0)"/>
+ <use xlink:href="#Inter-Regular-2e0" transform="translate(643.765625 0)"/>
+ <use xlink:href="#Inter-Regular-2b1" transform="translate(667.984375 0)"/>
+ <use xlink:href="#Inter-Regular-367" transform="translate(692.203125 0)"/>
+ <use xlink:href="#Inter-Regular-379" transform="translate(744.984375 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(777.703125 0)"/>
+ <use xlink:href="#Inter-Regular-1fb" transform="translate(805.828125 0)"/>
+ <use xlink:href="#Inter-Regular-305" transform="translate(861.984375 0)"/>
+ <use xlink:href="#Inter-Regular-255" transform="translate(921.0625 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(982.296875 0)"/>
+ <use xlink:href="#Inter-Regular-2e0" transform="translate(1010.421875 0)"/>
+ <use xlink:href="#Inter-Regular-2b1" transform="translate(1034.640625 0)"/>
+ <use xlink:href="#Inter-Regular-2fe" transform="translate(1058.859375 0)"/>
+ <use xlink:href="#Inter-Regular-2b1" transform="translate(1146.453125 0)"/>
+ <use xlink:href="#Inter-Regular-379" transform="translate(1170.671875 0)"/>
+ <use xlink:href="#Inter-Regular-367" transform="translate(1202.421875 0)"/>
+ <use xlink:href="#Inter-Regular-5e1" transform="translate(1255.203125 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(1284.015625 0)"/>
+ </g>
+ </g>
+ <g id="text_13">
+ <!-- github.com/graphicle-ai/graphicle/blob/main/docs/benchmarks/retrieval.md -->
+ <g style="fill: #8a93a6" transform="translate(284.203125 871) scale(0.17 -0.17)">
+ <defs>
+ <path id="JetBrainsMono-Regular-f5" d="M 1030 -1152
+L 1030 -627
+L 2022 -627
+Q 2323 -627 2496 -457
+Q 2669 -288 2669 0
+L 2669 320
+L 2682 896
+L 2662 896
+Q 2611 582 2361 412
+Q 2112 243 1734 243
+Q 1190 243 876 588
+Q 563 934 563 1536
+L 563 2278
+Q 563 2880 876 3232
+Q 1190 3584 1734 3584
+Q 2112 3584 2361 3405
+Q 2611 3226 2662 2912
+L 2675 2912
+L 2675 3520
+L 3245 3520
+L 3245 0
+Q 3245 -531 2915 -841
+Q 2586 -1152 2016 -1152
+L 1030 -1152
+z
+M 1907 723
+Q 2266 723 2470 947
+Q 2675 1171 2675 1568
+L 2675 2240
+Q 2675 2637 2470 2861
+Q 2266 3085 1907 3085
+Q 1542 3085 1340 2873
+Q 1139 2662 1139 2304
+L 1139 1504
+Q 1139 1146 1340 934
+Q 1542 723 1907 723
+z
+" transform="scale(0.015625)"/>
+ <path id="JetBrainsMono-Regular-ff" d="M 544 0
+L 544 525
+L 1792 525
+L 1792 2995
+L 672 2995
+L 672 3520
+L 2368 3520
+L 2368 525
+L 3552 525
+L 3552 0
+L 544 0
+z
+M 2016 4154
+Q 1805 4154 1683 4262
+Q 1562 4371 1562 4557
+Q 1562 4749 1683 4861
+Q 1805 4973 2016 4973
+Q 2227 4973 2348 4861
+Q 2470 4749 2470 4557
+Q 2470 4371 2348 4262
+Q 2227 4154 2016 4154
+z
+" transform="scale(0.015625)"/>
+ <path id="JetBrainsMono-Regular-14c" d="M 2272 0
+Q 1837 0 1574 253
+Q 1312 506 1312 928
+L 1312 2995
+L 301 2995
+L 301 3520
+L 1312 3520
+L 1312 4512
+L 1888 4512
+L 1888 3520
+L 3328 3520
+L 3328 2995
+L 1888 2995
+L 1888 928
+Q 1888 749 1993 637
+Q 2099 525 2272 525
+L 3296 525
+L 3296 0
+L 2272 0
+z
+" transform="scale(0.015625)"/>
+ <path id="JetBrainsMono-Regular-fc" d="M 589 0
+L 589 4672
+L 1165 4672
+L 1165 2848
+L 1171 2848
+Q 1216 3200 1459 3392
+Q 1702 3584 2106 3584
+Q 2637 3584 2950 3257
+Q 3264 2931 3264 2368
+L 3264 0
+L 2688 0
+L 2688 2272
+Q 2688 2669 2486 2883
+Q 2285 3098 1939 3098
+Q 1581 3098 1373 2874
+Q 1165 2650 1165 2240
+L 1165 0
+L 589 0
+z
+" transform="scale(0.015625)"/>
+ <path id="JetBrainsMono-Regular-151" d="M 1914 -64
+Q 1306 -64 941 297
+Q 576 659 576 1280
+L 576 3520
+L 1152 3520
+L 1152 1280
+Q 1152 896 1357 669
+Q 1562 442 1914 442
+Q 2272 442 2480 669
+Q 2688 896 2688 1280
+L 2688 3520
+L 3264 3520
+L 3264 1280
+Q 3264 659 2893 297
+Q 2522 -64 1914 -64
+z
+" transform="scale(0.015625)"/>
+ <path id="JetBrainsMono-Regular-d6" d="M 2125 -64
+Q 1728 -64 1472 131
+Q 1216 326 1171 672
+L 1165 672
+L 1165 0
+L 589 0
+L 589 4672
+L 1165 4672
+L 1165 3648
+L 1152 2848
+L 1158 2848
+Q 1210 3187 1469 3385
+Q 1728 3584 2125 3584
+Q 2656 3584 2969 3232
+Q 3283 2880 3283 2272
+L 3283 1242
+Q 3283 640 2969 288
+Q 2656 -64 2125 -64
+z
+M 1933 435
+Q 2298 435 2502 627
+Q 2707 819 2707 1248
+L 2707 2272
+Q 2707 2707 2502 2896
+Q 2298 3085 1933 3085
+Q 1581 3085 1373 2861
+Q 1165 2637 1165 2240
+L 1165 1280
+Q 1165 883 1373 659
+Q 1581 435 1933 435
+z
+" transform="scale(0.015625)"/>
+ <path id="JetBrainsMono-Regular-329" d="M 1920 -64
+Q 1683 -64 1539 77
+Q 1395 218 1395 442
+Q 1395 678 1539 825
+Q 1683 973 1920 973
+Q 2157 973 2301 825
+Q 2445 678 2445 442
+Q 2445 218 2301 77
+Q 2157 -64 1920 -64
+z
+" transform="scale(0.015625)"/>
+ <path id="JetBrainsMono-Regular-d7" d="M 1971 -64
+Q 1331 -64 947 294
+Q 563 653 563 1280
+L 563 2240
+Q 563 2867 947 3225
+Q 1331 3584 1971 3584
+Q 2579 3584 2953 3257
+Q 3328 2931 3347 2368
+L 2771 2368
+Q 2752 2707 2541 2889
+Q 2330 3072 1971 3072
+Q 1594 3072 1366 2857
+Q 1139 2643 1139 2246
+L 1139 1280
+Q 1139 883 1366 665
+Q 1594 448 1971 448
+Q 2330 448 2541 633
+Q 2752 819 2771 1152
+L 3347 1152
+Q 3328 589 2953 262
+Q 2579 -64 1971 -64
+z
+" transform="scale(0.015625)"/>
+ <path id="JetBrainsMono-Regular-122" d="M 1920 -51
+Q 1286 -51 912 320
+Q 538 691 538 1357
+L 538 2163
+Q 538 2835 909 3203
+Q 1280 3571 1920 3571
+Q 2560 3571 2931 3203
+Q 3302 2835 3302 2163
+L 3302 1357
+Q 3302 691 2928 320
+Q 2554 -51 1920 -51
+z
+M 1920 461
+Q 2298 461 2512 672
+Q 2726 883 2726 1293
+L 2726 2227
+Q 2726 2637 2512 2848
+Q 2298 3059 1920 3059
+Q 1549 3059 1331 2848
+Q 1114 2637 1114 2227
+L 1114 1293
+Q 1114 883 1331 672
+Q 1549 461 1920 461
+z
+" transform="scale(0.015625)"/>
+ <path id="JetBrainsMono-Regular-11a" d="M 384 0
+L 384 3520
+L 883 3520
+L 883 3053
+L 896 3053
+Q 928 3290 1085 3437
+Q 1242 3584 1485 3584
+Q 1715 3584 1875 3449
+Q 2035 3315 2106 3085
+L 2112 3085
+Q 2157 3315 2313 3449
+Q 2470 3584 2714 3584
+Q 3053 3584 3254 3331
+Q 3456 3078 3456 2675
+L 3456 0
+L 2918 0
+L 2918 2682
+Q 2918 2893 2816 3017
+Q 2714 3142 2534 3142
+Q 2362 3142 2259 3020
+Q 2157 2899 2157 2688
+L 2157 0
+L 1683 0
+L 1683 2682
+Q 1683 2893 1580 3017
+Q 1478 3142 1306 3142
+Q 1126 3142 1024 3020
+Q 922 2899 922 2688
+L 922 0
+L 384 0
+z
+" transform="scale(0.015625)"/>
+ <path id="JetBrainsMono-Regular-33d" d="M 480 -704
+L 2752 5312
+L 3360 5312
+L 1088 -704
+L 480 -704
+z
+" transform="scale(0.015625)"/>
+ <path id="JetBrainsMono-Regular-140" d="M 717 0
+L 717 3520
+L 1293 3520
+L 1293 2848
+L 1306 2848
+Q 1350 3187 1593 3385
+Q 1837 3584 2246 3584
+Q 2797 3584 3094 3254
+Q 3392 2925 3392 2317
+L 3392 2016
+L 2816 2016
+L 2816 2317
+Q 2816 3085 2067 3085
+Q 1690 3085 1491 2867
+Q 1293 2650 1293 2240
+L 1293 0
+L 717 0
+z
+" transform="scale(0.015625)"/>
+ <path id="JetBrainsMono-Regular-bd" d="M 1613 -64
+Q 1069 -64 749 240
+Q 429 544 429 1037
+Q 429 1363 576 1606
+Q 723 1850 985 1987
+Q 1248 2125 1587 2125
+L 2675 2125
+L 2675 2400
+Q 2675 3085 1926 3085
+Q 1594 3085 1389 2963
+Q 1184 2842 1171 2624
+L 595 2624
+Q 627 3040 982 3312
+Q 1338 3584 1926 3584
+Q 2566 3584 2908 3277
+Q 3251 2970 3251 2419
+L 3251 0
+L 2682 0
+L 2682 640
+L 2669 640
+Q 2618 314 2342 125
+Q 2067 -64 1613 -64
+z
+M 1754 422
+Q 2176 422 2425 627
+Q 2675 832 2675 1184
+L 2675 1677
+L 1651 1677
+Q 1370 1677 1194 1507
+Q 1018 1338 1018 1056
+Q 1018 762 1213 592
+Q 1408 422 1754 422
+z
+" transform="scale(0.015625)"/>
+ <path id="JetBrainsMono-Regular-13d" d="M 589 -1152
+L 589 3520
+L 1165 3520
+L 1165 2848
+L 1171 2848
+Q 1216 3194 1472 3389
+Q 1728 3584 2125 3584
+Q 2656 3584 2969 3235
+Q 3283 2886 3283 2278
+L 3283 1248
+Q 3283 640 2969 288
+Q 2656 -64 2125 -64
+Q 1728 -64 1472 134
+Q 1216 333 1171 672
+L 1152 672
+L 1165 -128
+L 1165 -1152
+L 589 -1152
+z
+M 1933 435
+Q 2298 435 2502 627
+Q 2707 819 2707 1248
+L 2707 2272
+Q 2707 2707 2502 2896
+Q 2298 3085 1933 3085
+Q 1581 3085 1373 2861
+Q 1165 2637 1165 2240
+L 1165 1280
+Q 1165 883 1373 659
+Q 1581 435 1933 435
+z
+" transform="scale(0.015625)"/>
+ <path id="JetBrainsMono-Regular-113" d="M 2432 0
+Q 1965 0 1686 272
+Q 1408 544 1408 992
+L 1408 4147
+L 192 4147
+L 192 4672
+L 1984 4672
+L 1984 992
+Q 1984 774 2105 649
+Q 2227 525 2432 525
+L 3520 525
+L 3520 0
+L 2432 0
+z
+" transform="scale(0.015625)"/>
+ <path id="JetBrainsMono-Regular-e1" d="M 1920 -64
+Q 1299 -64 918 310
+Q 538 685 538 1344
+L 538 2176
+Q 538 2835 918 3209
+Q 1299 3584 1920 3584
+Q 2336 3584 2646 3417
+Q 2957 3251 3129 2950
+Q 3302 2650 3302 2240
+L 3302 1613
+L 1101 1613
+L 1101 1280
+Q 1101 890 1325 662
+Q 1549 435 1920 435
+Q 2240 435 2448 560
+Q 2656 685 2701 896
+L 3277 896
+Q 3219 454 2848 195
+Q 2477 -64 1920 -64
+z
+M 1101 2061
+L 2739 2061
+L 2739 2240
+Q 2739 2656 2524 2883
+Q 2310 3110 1920 3110
+Q 1530 3110 1315 2883
+Q 1101 2656 1101 2240
+L 1101 2061
+z
+" transform="scale(0.015625)"/>
+ <path id="JetBrainsMono-Regular-357" d="M 896 1856
+L 896 2368
+L 2944 2368
+L 2944 1856
+L 896 1856
+z
+" transform="scale(0.015625)"/>
+ <path id="JetBrainsMono-Regular-11b" d="M 589 0
+L 589 3520
+L 1165 3520
+L 1165 2848
+L 1171 2848
+Q 1216 3200 1459 3392
+Q 1702 3584 2106 3584
+Q 2637 3584 2950 3257
+Q 3264 2931 3264 2368
+L 3264 0
+L 2688 0
+L 2688 2266
+Q 2688 2669 2486 2883
+Q 2285 3098 1939 3098
+Q 1581 3098 1373 2874
+Q 1165 2650 1165 2240
+L 1165 0
+L 589 0
+z
+" transform="scale(0.015625)"/>
+ <path id="JetBrainsMono-Regular-dd" d="M 1715 -64
+Q 1190 -64 873 288
+Q 557 640 557 1242
+L 557 2272
+Q 557 2880 870 3232
+Q 1184 3584 1715 3584
+Q 2112 3584 2371 3385
+Q 2630 3187 2682 2848
+L 2688 2848
+L 2675 3648
+L 2675 4672
+L 3251 4672
+L 3251 0
+L 2675 0
+L 2675 672
+L 2669 672
+Q 2624 326 2368 131
+Q 2112 -64 1715 -64
+z
+M 1907 435
+Q 2266 435 2470 659
+Q 2675 883 2675 1280
+L 2675 2240
+Q 2675 2637 2470 2861
+Q 2266 3085 1907 3085
+Q 1542 3085 1337 2896
+Q 1133 2707 1133 2272
+L 1133 1248
+Q 1133 819 1337 627
+Q 1542 435 1907 435
+z
+" transform="scale(0.015625)"/>
+ <path id="JetBrainsMono-Regular-144" d="M 1779 -51
+Q 1190 -51 867 214
+Q 544 480 544 966
+L 1120 966
+Q 1120 723 1293 585
+Q 1466 448 1779 448
+L 2061 448
+Q 2381 448 2557 589
+Q 2733 730 2733 986
+Q 2733 1440 2317 1498
+L 1344 1638
+Q 986 1690 787 1936
+Q 589 2182 589 2586
+Q 589 3046 905 3308
+Q 1222 3571 1779 3571
+L 2061 3571
+Q 2573 3571 2896 3318
+Q 3219 3066 3245 2656
+L 2662 2656
+Q 2650 2842 2486 2963
+Q 2323 3085 2061 3085
+L 1779 3085
+Q 1485 3085 1318 2950
+Q 1152 2816 1152 2586
+Q 1152 2214 1491 2163
+L 2400 2035
+Q 3296 1907 3296 986
+Q 3296 493 2973 221
+Q 2650 -51 2061 -51
+L 1779 -51
+z
+" transform="scale(0.015625)"/>
+ <path id="JetBrainsMono-Regular-110" d="M 621 0
+L 621 4672
+L 1197 4672
+L 1197 2067
+L 1869 2067
+L 2854 3520
+L 3514 3520
+L 2381 1843
+L 3578 0
+L 2906 0
+L 1882 1568
+L 1197 1568
+L 1197 0
+L 621 0
+z
+" transform="scale(0.015625)"/>
+ <path id="JetBrainsMono-Regular-169" d="M 1542 0
+L 346 3520
+L 966 3520
+L 1734 1152
+Q 1805 941 1856 745
+Q 1907 550 1933 442
+Q 1965 550 2009 745
+Q 2054 941 2118 1152
+L 2886 3520
+L 3494 3520
+L 2298 0
+L 1542 0
+z
+" transform="scale(0.015625)"/>
+ </defs>
+ <use xlink:href="#JetBrainsMono-Regular-f5"/>
+ <use xlink:href="#JetBrainsMono-Regular-ff" transform="translate(60 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-14c" transform="translate(120 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-fc" transform="translate(180 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-151" transform="translate(240 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-d6" transform="translate(300 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-329" transform="translate(360 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-d7" transform="translate(420 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-122" transform="translate(480 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-11a" transform="translate(540 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-33d" transform="translate(600 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-f5" transform="translate(660 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-140" transform="translate(720 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-bd" transform="translate(780 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-13d" transform="translate(840 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-fc" transform="translate(900 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-ff" transform="translate(960 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-d7" transform="translate(1020 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-113" transform="translate(1080 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-e1" transform="translate(1140 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-357" transform="translate(1200 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-bd" transform="translate(1260 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-ff" transform="translate(1320 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-33d" transform="translate(1380 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-f5" transform="translate(1440 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-140" transform="translate(1500 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-bd" transform="translate(1560 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-13d" transform="translate(1620 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-fc" transform="translate(1680 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-ff" transform="translate(1740 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-d7" transform="translate(1800 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-113" transform="translate(1860 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-e1" transform="translate(1920 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-33d" transform="translate(1980 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-d6" transform="translate(2040 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-113" transform="translate(2100 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-122" transform="translate(2160 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-d6" transform="translate(2220 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-33d" transform="translate(2280 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-11a" transform="translate(2340 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-bd" transform="translate(2400 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-ff" transform="translate(2460 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-11b" transform="translate(2520 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-33d" transform="translate(2580 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-dd" transform="translate(2640 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-122" transform="translate(2700 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-d7" transform="translate(2760 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-144" transform="translate(2820 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-33d" transform="translate(2880 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-d6" transform="translate(2940 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-e1" transform="translate(3000 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-11b" transform="translate(3060 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-d7" transform="translate(3120 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-fc" transform="translate(3180 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-11a" transform="translate(3240 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-bd" transform="translate(3300 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-140" transform="translate(3360 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-110" transform="translate(3420 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-144" transform="translate(3480 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-33d" transform="translate(3540 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-140" transform="translate(3600 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-e1" transform="translate(3660 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-14c" transform="translate(3720 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-140" transform="translate(3780 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-ff" transform="translate(3840 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-e1" transform="translate(3900 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-169" transform="translate(3960 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-bd" transform="translate(4020 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-113" transform="translate(4080 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-329" transform="translate(4140 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-11a" transform="translate(4200 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-dd" transform="translate(4260 0)"/>
+ </g>
+ </g>
+ <g id="text_14">
+ <!-- Top 1 -->
+ <g style="fill: #f4f6fa" transform="translate(48 206) scale(0.26 -0.26)">
+ <defs>
+ <path id="Inter-SemiBold-19b" d="M 259 3953
+L 259 4656
+L 3966 4656
+L 3966 3953
+L 2531 3953
+L 2531 0
+L 1697 0
+L 1697 3953
+L 259 3953
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-SemiBold-316" d="M 1947 -72
+Q 1438 -72 1063 154
+Q 688 381 483 786
+Q 278 1191 278 1728
+Q 278 2272 483 2680
+Q 688 3088 1063 3313
+Q 1438 3538 1947 3538
+Q 2456 3538 2831 3313
+Q 3206 3088 3412 2680
+Q 3619 2272 3619 1728
+Q 3619 1191 3412 786
+Q 3206 381 2831 154
+Q 2456 -72 1947 -72
+z
+M 1947 588
+Q 2231 588 2418 741
+Q 2606 894 2700 1153
+Q 2794 1413 2794 1731
+Q 2794 2053 2700 2312
+Q 2606 2572 2418 2725
+Q 2231 2878 1947 2878
+Q 1666 2878 1478 2725
+Q 1291 2572 1198 2312
+Q 1106 2053 1106 1731
+Q 1106 1413 1198 1153
+Q 1291 894 1478 741
+Q 1666 588 1947 588
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-SemiBold-34b" d="M 431 -1306
+L 431 3494
+L 1225 3494
+L 1225 2916
+L 1278 2916
+Q 1338 3038 1453 3183
+Q 1569 3328 1769 3433
+Q 1969 3538 2278 3538
+Q 2681 3538 3007 3331
+Q 3334 3125 3526 2723
+Q 3719 2322 3719 1741
+Q 3719 1166 3530 762
+Q 3341 359 3016 148
+Q 2691 -63 2275 -63
+Q 1975 -63 1776 39
+Q 1578 141 1459 284
+Q 1341 428 1278 553
+L 1244 553
+L 1244 -1306
+L 431 -1306
+z
+M 2056 606
+Q 2463 606 2673 929
+Q 2884 1253 2884 1744
+Q 2884 2231 2676 2550
+Q 2469 2869 2056 2869
+Q 1653 2869 1440 2561
+Q 1228 2253 1228 1744
+Q 1228 1234 1443 920
+Q 1659 606 2056 606
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-SemiBold-6f1" transform="scale(0.015625)"/>
+ <path id="Inter-SemiBold-53e" d="M 2241 4656
+L 2241 0
+L 1413 0
+L 1413 3913
+L 1381 3913
+L 294 3131
+L 294 3925
+L 1316 4656
+L 2241 4656
+z
+" transform="scale(0.015625)"/>
+ </defs>
+ <use xlink:href="#Inter-SemiBold-19b"/>
+ <use xlink:href="#Inter-SemiBold-316" transform="translate(58.203125 0)"/>
+ <use xlink:href="#Inter-SemiBold-34b" transform="translate(119.09375 0)"/>
+ <use xlink:href="#Inter-SemiBold-6f1" transform="translate(181.5 0)"/>
+ <use xlink:href="#Inter-SemiBold-53e" transform="translate(206.703125 0)"/>
+ </g>
+ </g>
+ <g id="text_15">
+ <!-- Issues of 100 with a changed file first -->
+ <g style="fill: #8a93a6" transform="translate(48 236) scale(0.18 -0.18)">
+ <defs>
+ <path id="Inter-Regular-c5" d="M 1156 4656
+L 1156 0
+L 563 0
+L 563 4656
+L 1156 4656
+z
+" transform="scale(0.015625)"/>
+ </defs>
+ <use xlink:href="#Inter-Regular-c5"/>
+ <use xlink:href="#Inter-Regular-367" transform="translate(26.859375 0)"/>
+ <use xlink:href="#Inter-Regular-367" transform="translate(79.640625 0)"/>
+ <use xlink:href="#Inter-Regular-393" transform="translate(132.421875 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(191.546875 0)"/>
+ <use xlink:href="#Inter-Regular-367" transform="translate(249.84375 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(302.625 0)"/>
+ <use xlink:href="#Inter-Regular-316" transform="translate(330.75 0)"/>
+ <use xlink:href="#Inter-Regular-287" transform="translate(390.71875 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(427.734375 0)"/>
+ <use xlink:href="#Inter-Regular-53e" transform="translate(455.859375 0)"/>
+ <use xlink:href="#Inter-Regular-53d" transform="translate(496.53125 0)"/>
+ <use xlink:href="#Inter-Regular-53d" transform="translate(559.625 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(622.71875 0)"/>
+ <use xlink:href="#Inter-Regular-3d8" transform="translate(650.84375 0)"/>
+ <use xlink:href="#Inter-Regular-2b1" transform="translate(732.6875 0)"/>
+ <use xlink:href="#Inter-Regular-379" transform="translate(756.90625 0)"/>
+ <use xlink:href="#Inter-Regular-29e" transform="translate(789.625 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(848.75 0)"/>
+ <use xlink:href="#Inter-Regular-1fb" transform="translate(876.875 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(933.03125 0)"/>
+ <use xlink:href="#Inter-Regular-24a" transform="translate(961.15625 0)"/>
+ <use xlink:href="#Inter-Regular-29e" transform="translate(1018.28125 0)"/>
+ <use xlink:href="#Inter-Regular-1fb" transform="translate(1077.40625 0)"/>
+ <use xlink:href="#Inter-Regular-305" transform="translate(1133.5625 0)"/>
+ <use xlink:href="#Inter-Regular-292" transform="translate(1192.640625 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(1253.96875 0)"/>
+ <use xlink:href="#Inter-Regular-255" transform="translate(1312.265625 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(1373.5 0)"/>
+ <use xlink:href="#Inter-Regular-287" transform="translate(1401.625 0)"/>
+ <use xlink:href="#Inter-Regular-2b1" transform="translate(1438.640625 0)"/>
+ <use xlink:href="#Inter-Regular-2e0" transform="translate(1462.859375 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(1487.078125 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(1545.375 0)"/>
+ <use xlink:href="#Inter-Regular-287" transform="translate(1573.5 0)"/>
+ <use xlink:href="#Inter-Regular-2b1" transform="translate(1610.515625 0)"/>
+ <use xlink:href="#Inter-Regular-354" transform="translate(1634.734375 0)"/>
+ <use xlink:href="#Inter-Regular-367" transform="translate(1672.375 0)"/>
+ <use xlink:href="#Inter-Regular-379" transform="translate(1725.15625 0)"/>
+ </g>
+ </g>
+ <g id="text_16">
+ <!-- 43 -->
+ <g style="fill: #f4f6fa" transform="translate(72.745937 477.84) scale(0.28 -0.28)">
+ <defs>
+ <path id="Inter-Bold-542" d="M 316 828
+L 316 1581
+L 2263 4656
+L 3459 4656
+L 3459 1597
+L 4041 1597
+L 4041 828
+L 3459 828
+L 3459 0
+L 2544 0
+L 2544 828
+L 316 828
+z
+M 2563 1597
+L 2563 3606
+L 2525 3606
+L 1278 1634
+L 1278 1597
+L 2563 1597
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Bold-541" d="M 2059 -63
+Q 1553 -63 1161 110
+Q 769 284 542 593
+Q 316 903 309 1306
+L 1269 1306
+Q 1281 1044 1506 886
+Q 1731 728 2063 728
+Q 2406 728 2625 904
+Q 2844 1081 2844 1366
+Q 2844 1653 2612 1836
+Q 2381 2019 1975 2019
+L 1544 2019
+L 1544 2728
+L 1975 2728
+Q 2316 2728 2530 2900
+Q 2744 3072 2744 3353
+Q 2744 3622 2558 3789
+Q 2372 3956 2069 3956
+Q 1766 3956 1545 3797
+Q 1325 3638 1319 3366
+L 400 3366
+Q 406 3763 628 4069
+Q 850 4375 1226 4547
+Q 1603 4719 2075 4719
+Q 2553 4719 2912 4544
+Q 3272 4369 3470 4072
+Q 3669 3775 3669 3413
+Q 3669 3019 3426 2758
+Q 3184 2497 2797 2422
+L 2797 2388
+Q 3306 2322 3572 2030
+Q 3838 1738 3838 1303
+Q 3838 906 3609 598
+Q 3381 291 2979 114
+Q 2578 -63 2059 -63
+z
+" transform="scale(0.015625)"/>
+ </defs>
+ <use xlink:href="#Inter-Bold-542"/>
+ <use xlink:href="#Inter-Bold-541" transform="translate(67.625 0)"/>
+ </g>
+ </g>
+ <g id="text_17">
+ <!-- 0.1.3 -->
+ <g style="fill: #c9ced8" transform="translate(69.709375 652) scale(0.2 -0.2)">
+ <use xlink:href="#Inter-Medium-53d"/>
+ <use xlink:href="#Inter-Medium-5de" transform="translate(61.859375 0)"/>
+ <use xlink:href="#Inter-Medium-53e" transform="translate(83.40625 0)"/>
+ <use xlink:href="#Inter-Medium-5de" transform="translate(124.90625 0)"/>
+ <use xlink:href="#Inter-Medium-541" transform="translate(152.703125 0)"/>
+ </g>
+ </g>
+ <g id="text_18">
+ <!-- 13 -->
+ <g style="fill: #c9ced8" transform="translate(165.04125 571.44) scale(0.24 -0.24)">
+ <defs>
+ <path id="Inter-SemiBold-541" d="M 2034 -63
+Q 1544 -63 1164 104
+Q 784 272 565 572
+Q 347 872 334 1263
+L 1175 1263
+Q 1194 975 1437 806
+Q 1681 638 2034 638
+Q 2409 638 2650 831
+Q 2891 1025 2891 1334
+Q 2891 1653 2642 1854
+Q 2394 2056 1950 2056
+L 1538 2056
+L 1538 2700
+L 1950 2700
+Q 2313 2700 2541 2887
+Q 2769 3075 2769 3381
+Q 2769 3678 2570 3858
+Q 2372 4038 2044 4038
+Q 1722 4038 1483 3869
+Q 1244 3700 1234 3403
+L 431 3403
+Q 438 3791 655 4087
+Q 872 4384 1236 4551
+Q 1600 4719 2050 4719
+Q 2516 4719 2859 4544
+Q 3203 4369 3392 4076
+Q 3581 3784 3581 3431
+Q 3581 3038 3350 2772
+Q 3119 2506 2741 2422
+L 2741 2384
+Q 3228 2316 3489 2022
+Q 3750 1728 3750 1291
+Q 3750 900 3528 594
+Q 3306 288 2918 112
+Q 2531 -63 2034 -63
+z
+" transform="scale(0.015625)"/>
+ </defs>
+ <use xlink:href="#Inter-SemiBold-53e"/>
+ <use xlink:href="#Inter-SemiBold-541" transform="translate(42.28125 0)"/>
+ </g>
+ </g>
+ <g id="text_19">
+ <!-- 0.1.2 -->
+ <g style="fill: #c9ced8" transform="translate(156.064063 652) scale(0.2 -0.2)">
+ <use xlink:href="#Inter-Medium-53d"/>
+ <use xlink:href="#Inter-Medium-5de" transform="translate(61.859375 0)"/>
+ <use xlink:href="#Inter-Medium-53e" transform="translate(83.40625 0)"/>
+ <use xlink:href="#Inter-Medium-5de" transform="translate(124.90625 0)"/>
+ <use xlink:href="#Inter-Medium-53f" transform="translate(155.234375 0)"/>
+ </g>
+ </g>
+ <g id="text_20">
+ <!-- 35 -->
+ <g style="fill: #c9ced8" transform="translate(249.266875 502.8) scale(0.24 -0.24)">
+ <defs>
+ <path id="Inter-SemiBold-543" d="M 1931 -63
+Q 1475 -63 1117 109
+Q 759 281 550 579
+Q 341 878 328 1263
+L 1141 1263
+Q 1156 975 1384 795
+Q 1613 616 1931 616
+Q 2303 616 2545 866
+Q 2788 1116 2788 1509
+Q 2788 1906 2539 2164
+Q 2291 2422 1906 2422
+Q 1694 2422 1492 2342
+Q 1291 2263 1172 2134
+L 416 2256
+L 659 4656
+L 3353 4656
+L 3353 3956
+L 1350 3956
+L 1219 2719
+L 1244 2719
+Q 1375 2872 1611 2970
+Q 1847 3069 2128 3069
+Q 2550 3069 2883 2870
+Q 3216 2672 3406 2323
+Q 3597 1975 3597 1528
+Q 3597 1066 3384 706
+Q 3172 347 2797 142
+Q 2422 -63 1931 -63
+z
+" transform="scale(0.015625)"/>
+ </defs>
+ <use xlink:href="#Inter-SemiBold-541"/>
+ <use xlink:href="#Inter-SemiBold-543" transform="translate(63.625 0)"/>
+ </g>
+ </g>
+ <g id="text_21">
+ <!-- BM25 -->
+ <g style="fill: #c9ced8" transform="translate(236.364062 652) scale(0.2 -0.2)">
+ <use xlink:href="#Inter-Medium-41"/>
+ <use xlink:href="#Inter-Medium-124" transform="translate(65.671875 0)"/>
+ <use xlink:href="#Inter-Medium-53f" transform="translate(156.9375 0)"/>
+ <use xlink:href="#Inter-Medium-543" transform="translate(218.5625 0)"/>
+ </g>
+ </g>
+ <g id="text_22">
+ <!-- 20 -->
+ <g style="fill: #c9ced8" transform="translate(335.35625 549.6) scale(0.24 -0.24)">
+ <defs>
+ <path id="Inter-SemiBold-53f" d="M 419 0
+L 419 600
+L 2034 2191
+Q 2375 2538 2553 2784
+Q 2731 3031 2731 3328
+Q 2731 3656 2511 3847
+Q 2291 4038 1959 4038
+Q 1609 4038 1400 3830
+Q 1191 3622 1191 3263
+L 394 3263
+Q 394 3703 595 4031
+Q 797 4359 1153 4539
+Q 1509 4719 1969 4719
+Q 2434 4719 2787 4544
+Q 3141 4369 3337 4064
+Q 3534 3759 3534 3369
+Q 3534 3113 3436 2863
+Q 3338 2613 3088 2303
+Q 2838 1994 2384 1556
+L 1575 731
+L 1575 697
+L 3603 697
+L 3603 0
+L 419 0
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-SemiBold-53d" d="M 2113 -63
+Q 1263 -63 792 564
+Q 322 1191 322 2325
+Q 322 3456 794 4087
+Q 1266 4719 2113 4719
+Q 2956 4719 3428 4087
+Q 3900 3456 3900 2325
+Q 3900 1191 3429 564
+Q 2959 -63 2113 -63
+z
+M 2113 638
+Q 2569 638 2814 1078
+Q 3059 1519 3059 2325
+Q 3059 3134 2814 3578
+Q 2569 4022 2113 4022
+Q 1656 4022 1409 3576
+Q 1163 3131 1163 2325
+Q 1163 1519 1408 1078
+Q 1653 638 2113 638
+z
+" transform="scale(0.015625)"/>
+ </defs>
+ <use xlink:href="#Inter-SemiBold-53f"/>
+ <use xlink:href="#Inter-SemiBold-53d" transform="translate(62.3125 0)"/>
+ </g>
+ </g>
+ <g id="text_23">
+ <!-- grep -->
+ <g style="fill: #c9ced8" transform="translate(328.821875 652) scale(0.2 -0.2)">
+ <use xlink:href="#Inter-Medium-292"/>
+ <use xlink:href="#Inter-Medium-354" transform="translate(61.96875 0)"/>
+ <use xlink:href="#Inter-Medium-266" transform="translate(98.734375 0)"/>
+ <use xlink:href="#Inter-Medium-34b" transform="translate(157.46875 0)"/>
+ </g>
+ </g>
+ <g id="text_24">
+ <!-- 0.1.3 vs BM25, McNemar exact: -->
+ <g style="fill: #8a93a6" transform="translate(48 696) scale(0.18 -0.18)">
+ <use xlink:href="#Inter-Regular-53d"/>
+ <use xlink:href="#Inter-Regular-5de" transform="translate(60.5625 0)"/>
+ <use xlink:href="#Inter-Regular-53e" transform="translate(80.734375 0)"/>
+ <use xlink:href="#Inter-Regular-5de" transform="translate(121.40625 0)"/>
+ <use xlink:href="#Inter-Regular-541" transform="translate(147.53125 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(209.296875 0)"/>
+ <use xlink:href="#Inter-Regular-3d4" transform="translate(237.421875 0)"/>
+ <use xlink:href="#Inter-Regular-367" transform="translate(293.625 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(346.40625 0)"/>
+ <use xlink:href="#Inter-Regular-41" transform="translate(374.53125 0)"/>
+ <use xlink:href="#Inter-Regular-124" transform="translate(439.96875 0)"/>
+ <use xlink:href="#Inter-Regular-53f" transform="translate(530.296875 0)"/>
+ <use xlink:href="#Inter-Regular-543" transform="translate(591.28125 0)"/>
+ <use xlink:href="#Inter-Regular-5dd" transform="translate(647.921875 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(676.734375 0)"/>
+ <use xlink:href="#Inter-Regular-124" transform="translate(704.859375 0)"/>
+ <use xlink:href="#Inter-Regular-24a" transform="translate(795.1875 0)"/>
+ <use xlink:href="#Inter-Regular-12c" transform="translate(852.3125 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(927.65625 0)"/>
+ <use xlink:href="#Inter-Regular-2fe" transform="translate(985.953125 0)"/>
+ <use xlink:href="#Inter-Regular-1fb" transform="translate(1073.546875 0)"/>
+ <use xlink:href="#Inter-Regular-354" transform="translate(1129.703125 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(1167.34375 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(1195.46875 0)"/>
+ <use xlink:href="#Inter-Regular-3e1" transform="translate(1251.515625 0)"/>
+ <use xlink:href="#Inter-Regular-1fb" transform="translate(1306.109375 0)"/>
+ <use xlink:href="#Inter-Regular-24a" transform="translate(1362.265625 0)"/>
+ <use xlink:href="#Inter-Regular-379" transform="translate(1419.390625 0)"/>
+ <use xlink:href="#Inter-Regular-5e1" transform="translate(1452.109375 0)"/>
+ </g>
+ </g>
+ <g id="text_25">
+ <!-- +8 issues, p = 0.200, not significant -->
+ <g style="fill: #c9ced8" transform="translate(59.994531 734) scale(0.18 -0.18)">
+ <defs>
+ <path id="Inter-SemiBold-5ff" d="M 1800 734
+L 1800 1975
+L 584 1975
+L 584 2640
+L 1800 2640
+L 1800 3878
+L 2506 3878
+L 2506 2640
+L 3725 2640
+L 3725 1975
+L 2506 1975
+L 2506 734
+L 1800 734
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-SemiBold-547" d="M 2047 -63
+Q 1541 -63 1152 106
+Q 763 275 542 572
+Q 322 869 322 1247
+Q 322 1538 450 1784
+Q 578 2031 798 2197
+Q 1019 2363 1294 2409
+L 1294 2438
+Q 934 2519 712 2806
+Q 491 3094 491 3472
+Q 491 3831 692 4112
+Q 894 4394 1245 4556
+Q 1597 4719 2047 4719
+Q 2494 4719 2845 4556
+Q 3197 4394 3400 4112
+Q 3603 3831 3603 3472
+Q 3603 3094 3379 2806
+Q 3156 2519 2803 2438
+L 2803 2409
+Q 3072 2363 3292 2197
+Q 3513 2031 3644 1784
+Q 3775 1538 3775 1247
+Q 3775 869 3553 572
+Q 3331 275 2940 106
+Q 2550 -63 2047 -63
+z
+M 2047 581
+Q 2441 581 2677 781
+Q 2913 981 2913 1306
+Q 2913 1641 2666 1856
+Q 2419 2072 2047 2072
+Q 1669 2072 1423 1856
+Q 1178 1641 1178 1306
+Q 1178 981 1414 781
+Q 1650 581 2047 581
+z
+M 2047 2703
+Q 2369 2703 2578 2893
+Q 2788 3084 2788 3391
+Q 2788 3694 2581 3878
+Q 2375 4063 2047 4063
+Q 1716 4063 1511 3878
+Q 1306 3694 1306 3391
+Q 1306 3088 1514 2895
+Q 1722 2703 2047 2703
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-SemiBold-2b1" d="M 431 0
+L 431 3494
+L 1244 3494
+L 1244 0
+L 431 0
+z
+M 838 3988
+Q 644 3988 505 4117
+Q 366 4247 366 4434
+Q 366 4619 505 4748
+Q 644 4878 838 4878
+Q 1035 4878 1174 4748
+Q 1313 4619 1313 4434
+Q 1313 4247 1174 4117
+Q 1035 3988 838 3988
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-SemiBold-367" d="M 1753 -72
+Q 1150 -72 758 186
+Q 366 444 275 919
+L 1034 1063
+Q 1172 550 1769 550
+Q 2069 550 2245 670
+Q 2422 791 2422 969
+Q 2422 1266 1950 1369
+L 1353 1497
+Q 372 1709 372 2475
+Q 372 2800 550 3037
+Q 728 3275 1045 3406
+Q 1363 3538 1781 3538
+Q 2375 3538 2720 3291
+Q 3066 3044 3172 2638
+L 2447 2494
+Q 2384 2675 2228 2803
+Q 2072 2931 1791 2931
+Q 1534 2931 1359 2817
+Q 1184 2703 1184 2525
+Q 1184 2372 1298 2273
+Q 1413 2175 1681 2116
+L 2275 1991
+Q 3253 1781 3253 1047
+Q 3253 716 3062 464
+Q 2872 213 2533 70
+Q 2194 -72 1753 -72
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-SemiBold-393" d="M 1628 -44
+Q 1088 -44 759 300
+Q 431 644 431 1272
+L 431 3494
+L 1244 3494
+L 1244 1397
+Q 1244 1047 1426 847
+Q 1609 647 1928 647
+Q 2253 647 2462 856
+Q 2672 1066 2672 1447
+L 2672 3494
+L 3488 3494
+L 3488 0
+L 2716 0
+L 2709 700
+Q 2397 -44 1628 -44
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-SemiBold-266" d="M 1975 -72
+Q 1447 -72 1067 150
+Q 688 372 483 775
+Q 278 1178 278 1725
+Q 278 2263 479 2670
+Q 681 3078 1051 3308
+Q 1422 3538 1922 3538
+Q 2347 3538 2711 3352
+Q 3075 3166 3297 2777
+Q 3519 2388 3519 1775
+L 3519 1519
+L 1088 1519
+Q 1103 1053 1348 809
+Q 1594 566 1984 566
+Q 2253 566 2445 681
+Q 2638 797 2719 1019
+L 3466 866
+Q 3341 444 2948 186
+Q 2556 -72 1975 -72
+z
+M 1091 2072
+L 2728 2072
+Q 2691 2447 2489 2673
+Q 2288 2900 1925 2900
+Q 1553 2900 1336 2661
+Q 1119 2422 1091 2072
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-SemiBold-5dd" d="M 385 -1197
+L 660 687
+L 1497 687
+L 953 -1197
+L 385 -1197
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-SemiBold-5f0" d="M 647 772
+L 647 1472
+L 3663 1472
+L 3663 772
+L 647 772
+z
+M 647 2225
+L 647 2919
+L 3663 2919
+L 3663 2225
+L 647 2225
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-SemiBold-5de" d="M 1019 -53
+Q 809 -53 664 90
+Q 519 234 519 447
+Q 519 656 664 800
+Q 809 944 1019 944
+Q 1231 944 1376 800
+Q 1522 656 1522 447
+Q 1522 234 1376 90
+Q 1231 -53 1019 -53
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-SemiBold-305" d="M 1244 2047
+L 1244 0
+L 431 0
+L 431 3494
+L 1200 3494
+L 1209 2797
+Q 1522 3538 2291 3538
+Q 2831 3538 3157 3194
+Q 3484 2850 3484 2222
+L 3484 0
+L 2672 0
+L 2672 2097
+Q 2672 2447 2490 2647
+Q 2309 2847 1991 2847
+Q 1666 2847 1455 2637
+Q 1244 2428 1244 2047
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-SemiBold-379" d="M 2047 3494
+L 2047 2856
+L 1372 2856
+L 1372 984
+Q 1372 794 1451 705
+Q 1531 616 1719 616
+Q 1775 616 1865 630
+Q 1956 644 2016 656
+L 2144 28
+Q 2009 -13 1868 -30
+Q 1728 -47 1600 -47
+Q 1097 -47 828 203
+Q 559 453 559 916
+L 559 2856
+L 63 2856
+L 63 3494
+L 559 3494
+L 559 4325
+L 1372 4325
+L 1372 3494
+L 2047 3494
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-SemiBold-292" d="M 1938 -1381
+Q 1306 -1381 925 -1150
+Q 544 -919 413 -572
+L 1100 -325
+Q 1181 -475 1367 -619
+Q 1553 -763 1934 -763
+Q 2313 -763 2541 -586
+Q 2769 -409 2769 -34
+L 2769 625
+L 2700 625
+Q 2638 500 2522 365
+Q 2406 231 2212 142
+Q 2019 53 1716 53
+Q 1316 53 989 242
+Q 663 431 470 809
+Q 278 1188 278 1756
+Q 278 2328 470 2726
+Q 663 3125 991 3331
+Q 1319 3538 1722 3538
+Q 2031 3538 2231 3434
+Q 2431 3331 2550 3186
+Q 2669 3041 2731 2916
+L 2775 2916
+L 2775 3494
+L 3572 3494
+L 3572 -9
+Q 3572 -478 3359 -781
+Q 3147 -1084 2778 -1232
+Q 2409 -1381 1938 -1381
+z
+M 1944 694
+Q 2341 694 2556 978
+Q 2772 1263 2772 1763
+Q 2772 2259 2559 2564
+Q 2347 2869 1944 2869
+Q 1531 2869 1320 2553
+Q 1109 2238 1109 1763
+Q 1109 1278 1321 986
+Q 1534 694 1944 694
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-SemiBold-287" d="M 2269 3494
+L 2269 2856
+L 1513 2856
+L 1513 0
+L 703 0
+L 703 2856
+L 63 2856
+L 63 3494
+L 703 3494
+L 703 3828
+Q 703 4175 850 4408
+Q 997 4641 1242 4758
+Q 1488 4875 1788 4875
+Q 2003 4875 2168 4840
+Q 2334 4806 2413 4778
+L 2247 4147
+Q 2194 4163 2117 4180
+Q 2041 4197 1938 4197
+Q 1709 4197 1611 4084
+Q 1513 3972 1513 3766
+L 1513 3494
+L 2269 3494
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-SemiBold-24a" d="M 1947 -72
+Q 1438 -72 1063 154
+Q 688 381 483 786
+Q 278 1191 278 1728
+Q 278 2272 483 2680
+Q 688 3088 1063 3313
+Q 1438 3538 1947 3538
+Q 2531 3538 2936 3245
+Q 3341 2953 3453 2441
+L 2694 2281
+Q 2628 2553 2437 2715
+Q 2247 2878 1953 2878
+Q 1528 2878 1317 2550
+Q 1106 2222 1106 1731
+Q 1106 1409 1200 1150
+Q 1294 891 1481 739
+Q 1669 588 1953 588
+Q 2253 588 2445 758
+Q 2638 928 2703 1209
+L 3463 1050
+Q 3350 528 2944 228
+Q 2538 -72 1947 -72
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-SemiBold-1fb" d="M 1406 -72
+Q 1075 -72 809 48
+Q 544 169 391 403
+Q 238 638 238 981
+Q 238 1375 430 1592
+Q 622 1809 926 1907
+Q 1231 2006 1569 2041
+Q 2025 2091 2228 2133
+Q 2431 2175 2431 2356
+L 2431 2372
+Q 2431 2628 2275 2770
+Q 2119 2913 1822 2913
+Q 1516 2913 1334 2778
+Q 1153 2644 1091 2472
+L 338 2625
+Q 491 3088 892 3313
+Q 1294 3538 1819 3538
+Q 2066 3538 2317 3480
+Q 2569 3422 2778 3286
+Q 2988 3150 3116 2917
+Q 3244 2684 3244 2334
+L 3244 0
+L 2466 0
+L 2466 481
+L 2434 481
+Q 2319 256 2066 92
+Q 1813 -72 1406 -72
+z
+M 1616 531
+Q 1991 531 2214 747
+Q 2438 963 2438 1253
+L 2438 1666
+Q 2381 1622 2237 1589
+Q 2094 1556 1933 1532
+Q 1772 1509 1666 1494
+Q 1391 1456 1208 1343
+Q 1025 1231 1025 991
+Q 1025 766 1190 648
+Q 1356 531 1616 531
+z
+" transform="scale(0.015625)"/>
+ </defs>
+ <use xlink:href="#Inter-SemiBold-5ff"/>
+ <use xlink:href="#Inter-SemiBold-547" transform="translate(67.28125 0)"/>
+ <use xlink:href="#Inter-SemiBold-6f1" transform="translate(131.296875 0)"/>
+ <use xlink:href="#Inter-SemiBold-2b1" transform="translate(156.5 0)"/>
+ <use xlink:href="#Inter-SemiBold-367" transform="translate(182.671875 0)"/>
+ <use xlink:href="#Inter-SemiBold-367" transform="translate(237.609375 0)"/>
+ <use xlink:href="#Inter-SemiBold-393" transform="translate(292.546875 0)"/>
+ <use xlink:href="#Inter-SemiBold-266" transform="translate(353.78125 0)"/>
+ <use xlink:href="#Inter-SemiBold-367" transform="translate(412.90625 0)"/>
+ <use xlink:href="#Inter-SemiBold-5dd" transform="translate(467.84375 0)"/>
+ <use xlink:href="#Inter-SemiBold-6f1" transform="translate(497.6875 0)"/>
+ <use xlink:href="#Inter-SemiBold-34b" transform="translate(522.890625 0)"/>
+ <use xlink:href="#Inter-SemiBold-6f1" transform="translate(585.296875 0)"/>
+ <use xlink:href="#Inter-SemiBold-5f0" transform="translate(610.5 0)"/>
+ <use xlink:href="#Inter-SemiBold-6f1" transform="translate(677.78125 0)"/>
+ <use xlink:href="#Inter-SemiBold-53d" transform="translate(702.984375 0)"/>
+ <use xlink:href="#Inter-SemiBold-5de" transform="translate(766.171875 0)"/>
+ <use xlink:href="#Inter-SemiBold-53f" transform="translate(798.0625 0)"/>
+ <use xlink:href="#Inter-SemiBold-53d" transform="translate(860.375 0)"/>
+ <use xlink:href="#Inter-SemiBold-53d" transform="translate(926.34375 0)"/>
+ <use xlink:href="#Inter-SemiBold-5dd" transform="translate(989.53125 0)"/>
+ <use xlink:href="#Inter-SemiBold-6f1" transform="translate(1019.375 0)"/>
+ <use xlink:href="#Inter-SemiBold-305" transform="translate(1044.578125 0)"/>
+ <use xlink:href="#Inter-SemiBold-316" transform="translate(1105.765625 0)"/>
+ <use xlink:href="#Inter-SemiBold-379" transform="translate(1166.65625 0)"/>
+ <use xlink:href="#Inter-SemiBold-6f1" transform="translate(1201.953125 0)"/>
+ <use xlink:href="#Inter-SemiBold-367" transform="translate(1227.15625 0)"/>
+ <use xlink:href="#Inter-SemiBold-2b1" transform="translate(1282.09375 0)"/>
+ <use xlink:href="#Inter-SemiBold-292" transform="translate(1308.265625 0)"/>
+ <use xlink:href="#Inter-SemiBold-305" transform="translate(1370.8125 0)"/>
+ <use xlink:href="#Inter-SemiBold-2b1" transform="translate(1432 0)"/>
+ <use xlink:href="#Inter-SemiBold-287" transform="translate(1458.171875 0)"/>
+ <use xlink:href="#Inter-SemiBold-2b1" transform="translate(1497.640625 0)"/>
+ <use xlink:href="#Inter-SemiBold-24a" transform="translate(1523.8125 0)"/>
+ <use xlink:href="#Inter-SemiBold-1fb" transform="translate(1583.046875 0)"/>
+ <use xlink:href="#Inter-SemiBold-305" transform="translate(1640.46875 0)"/>
+ <use xlink:href="#Inter-SemiBold-379" transform="translate(1701.65625 0)"/>
+ </g>
+ </g>
+ <g id="text_26">
+ <!-- Top 5 -->
+ <g style="fill: #f4f6fa" transform="translate(434 206) scale(0.26 -0.26)">
+ <use xlink:href="#Inter-SemiBold-19b"/>
+ <use xlink:href="#Inter-SemiBold-316" transform="translate(58.203125 0)"/>
+ <use xlink:href="#Inter-SemiBold-34b" transform="translate(119.09375 0)"/>
+ <use xlink:href="#Inter-SemiBold-6f1" transform="translate(181.5 0)"/>
+ <use xlink:href="#Inter-SemiBold-543" transform="translate(206.703125 0)"/>
+ </g>
+ </g>
+ <g id="text_27">
+ <!-- Issues of 100 with a changed file in the -->
+ <g style="fill: #8a93a6" transform="translate(434 236) scale(0.18 -0.18)">
+ <use xlink:href="#Inter-Regular-c5"/>
+ <use xlink:href="#Inter-Regular-367" transform="translate(26.859375 0)"/>
+ <use xlink:href="#Inter-Regular-367" transform="translate(79.640625 0)"/>
+ <use xlink:href="#Inter-Regular-393" transform="translate(132.421875 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(191.546875 0)"/>
+ <use xlink:href="#Inter-Regular-367" transform="translate(249.84375 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(302.625 0)"/>
+ <use xlink:href="#Inter-Regular-316" transform="translate(330.75 0)"/>
+ <use xlink:href="#Inter-Regular-287" transform="translate(390.71875 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(427.734375 0)"/>
+ <use xlink:href="#Inter-Regular-53e" transform="translate(455.859375 0)"/>
+ <use xlink:href="#Inter-Regular-53d" transform="translate(496.53125 0)"/>
+ <use xlink:href="#Inter-Regular-53d" transform="translate(559.625 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(622.71875 0)"/>
+ <use xlink:href="#Inter-Regular-3d8" transform="translate(650.84375 0)"/>
+ <use xlink:href="#Inter-Regular-2b1" transform="translate(732.6875 0)"/>
+ <use xlink:href="#Inter-Regular-379" transform="translate(756.90625 0)"/>
+ <use xlink:href="#Inter-Regular-29e" transform="translate(789.625 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(848.75 0)"/>
+ <use xlink:href="#Inter-Regular-1fb" transform="translate(876.875 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(933.03125 0)"/>
+ <use xlink:href="#Inter-Regular-24a" transform="translate(961.15625 0)"/>
+ <use xlink:href="#Inter-Regular-29e" transform="translate(1018.28125 0)"/>
+ <use xlink:href="#Inter-Regular-1fb" transform="translate(1077.40625 0)"/>
+ <use xlink:href="#Inter-Regular-305" transform="translate(1133.5625 0)"/>
+ <use xlink:href="#Inter-Regular-292" transform="translate(1192.640625 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(1253.96875 0)"/>
+ <use xlink:href="#Inter-Regular-255" transform="translate(1312.265625 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(1373.5 0)"/>
+ <use xlink:href="#Inter-Regular-287" transform="translate(1401.625 0)"/>
+ <use xlink:href="#Inter-Regular-2b1" transform="translate(1438.640625 0)"/>
+ <use xlink:href="#Inter-Regular-2e0" transform="translate(1462.859375 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(1487.078125 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(1545.375 0)"/>
+ <use xlink:href="#Inter-Regular-2b1" transform="translate(1573.5 0)"/>
+ <use xlink:href="#Inter-Regular-305" transform="translate(1597.71875 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(1656.796875 0)"/>
+ <use xlink:href="#Inter-Regular-379" transform="translate(1684.921875 0)"/>
+ <use xlink:href="#Inter-Regular-29e" transform="translate(1717.640625 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(1776.765625 0)"/>
+ </g>
+ </g>
+ <g id="text_28">
+ <!-- first 5 -->
+ <g style="fill: #8a93a6" transform="translate(434 260) scale(0.18 -0.18)">
+ <use xlink:href="#Inter-Regular-287"/>
+ <use xlink:href="#Inter-Regular-2b1" transform="translate(37.015625 0)"/>
+ <use xlink:href="#Inter-Regular-354" transform="translate(61.234375 0)"/>
+ <use xlink:href="#Inter-Regular-367" transform="translate(98.875 0)"/>
+ <use xlink:href="#Inter-Regular-379" transform="translate(151.65625 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(184.375 0)"/>
+ <use xlink:href="#Inter-Regular-543" transform="translate(212.5 0)"/>
+ </g>
+ </g>
+ <g id="text_29">
+ <!-- 75 -->
+ <g style="fill: #f4f6fa" transform="translate(460.535312 378) scale(0.28 -0.28)">
+ <defs>
+ <path id="Inter-Bold-546" d="M 553 0
+L 2491 3838
+L 2491 3869
+L 234 3869
+L 234 4656
+L 3488 4656
+L 3488 3856
+L 1544 0
+L 553 0
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Bold-543" d="M 1963 -63
+Q 1484 -63 1111 114
+Q 738 291 520 600
+Q 303 909 291 1306
+L 1222 1306
+Q 1234 1034 1450 864
+Q 1666 694 1963 694
+Q 2313 694 2538 925
+Q 2763 1156 2763 1525
+Q 2763 1897 2533 2133
+Q 2303 2369 1947 2369
+Q 1738 2369 1545 2284
+Q 1353 2200 1247 2063
+L 391 2213
+L 613 4656
+L 3431 4656
+L 3431 3869
+L 1403 3869
+L 1284 2691
+L 1309 2691
+Q 1434 2859 1679 2968
+Q 1925 3078 2225 3078
+Q 2647 3078 2976 2881
+Q 3306 2684 3497 2339
+Q 3688 1994 3688 1547
+Q 3688 1078 3470 715
+Q 3253 353 2864 145
+Q 2475 -63 1963 -63
+z
+" transform="scale(0.015625)"/>
+ </defs>
+ <use xlink:href="#Inter-Bold-546"/>
+ <use xlink:href="#Inter-Bold-543" transform="translate(57.1875 0)"/>
+ </g>
+ </g>
+ <g id="text_30">
+ <!-- 0.1.3 -->
+ <g style="fill: #c9ced8" transform="translate(455.709375 652) scale(0.2 -0.2)">
+ <use xlink:href="#Inter-Medium-53d"/>
+ <use xlink:href="#Inter-Medium-5de" transform="translate(61.859375 0)"/>
+ <use xlink:href="#Inter-Medium-53e" transform="translate(83.40625 0)"/>
+ <use xlink:href="#Inter-Medium-5de" transform="translate(124.90625 0)"/>
+ <use xlink:href="#Inter-Medium-541" transform="translate(152.703125 0)"/>
+ </g>
+ </g>
+ <g id="text_31">
+ <!-- 30 -->
+ <g style="fill: #c9ced8" transform="translate(548.19875 518.4) scale(0.24 -0.24)">
+ <use xlink:href="#Inter-SemiBold-541"/>
+ <use xlink:href="#Inter-SemiBold-53d" transform="translate(63.625 0)"/>
+ </g>
+ </g>
+ <g id="text_32">
+ <!-- 0.1.2 -->
+ <g style="fill: #c9ced8" transform="translate(542.064062 652) scale(0.2 -0.2)">
+ <use xlink:href="#Inter-Medium-53d"/>
+ <use xlink:href="#Inter-Medium-5de" transform="translate(61.859375 0)"/>
+ <use xlink:href="#Inter-Medium-53e" transform="translate(83.40625 0)"/>
+ <use xlink:href="#Inter-Medium-5de" transform="translate(124.90625 0)"/>
+ <use xlink:href="#Inter-Medium-53f" transform="translate(155.234375 0)"/>
+ </g>
+ </g>
+ <g id="text_33">
+ <!-- 61 -->
+ <g style="fill: #c9ced8" transform="translate(637.5 421.68) scale(0.24 -0.24)">
+ <defs>
+ <path id="Inter-SemiBold-545" d="M 2097 -63
+Q 1763 -63 1447 51
+Q 1131 166 876 425
+Q 622 684 472 1118
+Q 322 1553 322 2194
+Q 322 2991 545 3555
+Q 769 4119 1178 4419
+Q 1588 4719 2147 4719
+Q 2581 4719 2918 4547
+Q 3256 4375 3467 4078
+Q 3678 3781 3728 3403
+L 2909 3403
+Q 2844 3669 2647 3833
+Q 2450 3997 2147 3997
+Q 1659 3997 1396 3575
+Q 1134 3153 1134 2413
+L 1169 2413
+Q 1338 2716 1645 2886
+Q 1953 3056 2328 3056
+Q 2738 3056 3064 2861
+Q 3391 2666 3581 2322
+Q 3772 1978 3772 1538
+Q 3772 1078 3562 717
+Q 3353 356 2976 146
+Q 2600 -63 2097 -63
+z
+M 2094 616
+Q 2341 616 2537 736
+Q 2734 856 2848 1061
+Q 2963 1266 2963 1522
+Q 2963 1772 2852 1975
+Q 2741 2178 2545 2297
+Q 2350 2416 2103 2416
+Q 1856 2416 1657 2292
+Q 1459 2169 1343 1964
+Q 1228 1759 1228 1519
+Q 1228 1272 1340 1067
+Q 1453 863 1648 739
+Q 1844 616 2094 616
+z
+" transform="scale(0.015625)"/>
+ </defs>
+ <use xlink:href="#Inter-SemiBold-545"/>
+ <use xlink:href="#Inter-SemiBold-53e" transform="translate(63.96875 0)"/>
+ </g>
+ </g>
+ <g id="text_34">
+ <!-- BM25 -->
+ <g style="fill: #c9ced8" transform="translate(622.364063 652) scale(0.2 -0.2)">
+ <use xlink:href="#Inter-Medium-41"/>
+ <use xlink:href="#Inter-Medium-124" transform="translate(65.671875 0)"/>
+ <use xlink:href="#Inter-Medium-53f" transform="translate(156.9375 0)"/>
+ <use xlink:href="#Inter-Medium-543" transform="translate(218.5625 0)"/>
+ </g>
+ </g>
+ <g id="text_35">
+ <!-- 54 -->
+ <g style="fill: #c9ced8" transform="translate(721.40875 443.52) scale(0.24 -0.24)">
+ <defs>
+ <path id="Inter-SemiBold-542" d="M 334 866
+L 334 1531
+L 2313 4656
+L 3350 4656
+L 3350 1553
+L 3950 1553
+L 3950 866
+L 3350 866
+L 3350 0
+L 2550 0
+L 2550 866
+L 334 866
+z
+M 2566 1553
+L 2566 3706
+L 2528 3706
+L 1188 1591
+L 1188 1553
+L 2566 1553
+z
+" transform="scale(0.015625)"/>
+ </defs>
+ <use xlink:href="#Inter-SemiBold-543"/>
+ <use xlink:href="#Inter-SemiBold-542" transform="translate(61.234375 0)"/>
+ </g>
+ </g>
+ <g id="text_36">
+ <!-- grep -->
+ <g style="fill: #c9ced8" transform="translate(714.821875 652) scale(0.2 -0.2)">
+ <use xlink:href="#Inter-Medium-292"/>
+ <use xlink:href="#Inter-Medium-354" transform="translate(61.96875 0)"/>
+ <use xlink:href="#Inter-Medium-266" transform="translate(98.734375 0)"/>
+ <use xlink:href="#Inter-Medium-34b" transform="translate(157.46875 0)"/>
+ </g>
+ </g>
+ <g id="text_37">
+ <!-- 0.1.3 vs BM25, McNemar exact: -->
+ <g style="fill: #8a93a6" transform="translate(434 696) scale(0.18 -0.18)">
+ <use xlink:href="#Inter-Regular-53d"/>
+ <use xlink:href="#Inter-Regular-5de" transform="translate(60.5625 0)"/>
+ <use xlink:href="#Inter-Regular-53e" transform="translate(80.734375 0)"/>
+ <use xlink:href="#Inter-Regular-5de" transform="translate(121.40625 0)"/>
+ <use xlink:href="#Inter-Regular-541" transform="translate(147.53125 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(209.296875 0)"/>
+ <use xlink:href="#Inter-Regular-3d4" transform="translate(237.421875 0)"/>
+ <use xlink:href="#Inter-Regular-367" transform="translate(293.625 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(346.40625 0)"/>
+ <use xlink:href="#Inter-Regular-41" transform="translate(374.53125 0)"/>
+ <use xlink:href="#Inter-Regular-124" transform="translate(439.96875 0)"/>
+ <use xlink:href="#Inter-Regular-53f" transform="translate(530.296875 0)"/>
+ <use xlink:href="#Inter-Regular-543" transform="translate(591.28125 0)"/>
+ <use xlink:href="#Inter-Regular-5dd" transform="translate(647.921875 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(676.734375 0)"/>
+ <use xlink:href="#Inter-Regular-124" transform="translate(704.859375 0)"/>
+ <use xlink:href="#Inter-Regular-24a" transform="translate(795.1875 0)"/>
+ <use xlink:href="#Inter-Regular-12c" transform="translate(852.3125 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(927.65625 0)"/>
+ <use xlink:href="#Inter-Regular-2fe" transform="translate(985.953125 0)"/>
+ <use xlink:href="#Inter-Regular-1fb" transform="translate(1073.546875 0)"/>
+ <use xlink:href="#Inter-Regular-354" transform="translate(1129.703125 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(1167.34375 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(1195.46875 0)"/>
+ <use xlink:href="#Inter-Regular-3e1" transform="translate(1251.515625 0)"/>
+ <use xlink:href="#Inter-Regular-1fb" transform="translate(1306.109375 0)"/>
+ <use xlink:href="#Inter-Regular-24a" transform="translate(1362.265625 0)"/>
+ <use xlink:href="#Inter-Regular-379" transform="translate(1419.390625 0)"/>
+ <use xlink:href="#Inter-Regular-5e1" transform="translate(1452.109375 0)"/>
+ </g>
+ </g>
+ <g id="text_38">
+ <!-- +14 issues, p = 0.013 -->
+ <g style="fill: #ffffff" transform="translate(445.979688 734) scale(0.18 -0.18)">
+ <use xlink:href="#Inter-SemiBold-5ff"/>
+ <use xlink:href="#Inter-SemiBold-53e" transform="translate(67.28125 0)"/>
+ <use xlink:href="#Inter-SemiBold-542" transform="translate(109.5625 0)"/>
+ <use xlink:href="#Inter-SemiBold-6f1" transform="translate(176.171875 0)"/>
+ <use xlink:href="#Inter-SemiBold-2b1" transform="translate(201.375 0)"/>
+ <use xlink:href="#Inter-SemiBold-367" transform="translate(227.546875 0)"/>
+ <use xlink:href="#Inter-SemiBold-367" transform="translate(282.484375 0)"/>
+ <use xlink:href="#Inter-SemiBold-393" transform="translate(337.421875 0)"/>
+ <use xlink:href="#Inter-SemiBold-266" transform="translate(398.65625 0)"/>
+ <use xlink:href="#Inter-SemiBold-367" transform="translate(457.78125 0)"/>
+ <use xlink:href="#Inter-SemiBold-5dd" transform="translate(512.71875 0)"/>
+ <use xlink:href="#Inter-SemiBold-6f1" transform="translate(542.5625 0)"/>
+ <use xlink:href="#Inter-SemiBold-34b" transform="translate(567.765625 0)"/>
+ <use xlink:href="#Inter-SemiBold-6f1" transform="translate(630.171875 0)"/>
+ <use xlink:href="#Inter-SemiBold-5f0" transform="translate(655.375 0)"/>
+ <use xlink:href="#Inter-SemiBold-6f1" transform="translate(722.65625 0)"/>
+ <use xlink:href="#Inter-SemiBold-53d" transform="translate(747.859375 0)"/>
+ <use xlink:href="#Inter-SemiBold-5de" transform="translate(811.046875 0)"/>
+ <use xlink:href="#Inter-SemiBold-53d" transform="translate(840.15625 0)"/>
+ <use xlink:href="#Inter-SemiBold-53e" transform="translate(906.125 0)"/>
+ <use xlink:href="#Inter-SemiBold-541" transform="translate(948.40625 0)"/>
+ </g>
+ </g>
+ <g id="text_39">
+ <!-- Top 10 -->
+ <g style="fill: #f4f6fa" transform="translate(820 206) scale(0.26 -0.26)">
+ <use xlink:href="#Inter-SemiBold-19b"/>
+ <use xlink:href="#Inter-SemiBold-316" transform="translate(58.203125 0)"/>
+ <use xlink:href="#Inter-SemiBold-34b" transform="translate(119.09375 0)"/>
+ <use xlink:href="#Inter-SemiBold-6f1" transform="translate(181.5 0)"/>
+ <use xlink:href="#Inter-SemiBold-53e" transform="translate(206.703125 0)"/>
+ <use xlink:href="#Inter-SemiBold-53d" transform="translate(248.984375 0)"/>
+ </g>
+ </g>
+ <g id="text_40">
+ <!-- Issues of 100 with a changed file in the -->
+ <g style="fill: #8a93a6" transform="translate(820 236) scale(0.18 -0.18)">
+ <use xlink:href="#Inter-Regular-c5"/>
+ <use xlink:href="#Inter-Regular-367" transform="translate(26.859375 0)"/>
+ <use xlink:href="#Inter-Regular-367" transform="translate(79.640625 0)"/>
+ <use xlink:href="#Inter-Regular-393" transform="translate(132.421875 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(191.546875 0)"/>
+ <use xlink:href="#Inter-Regular-367" transform="translate(249.84375 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(302.625 0)"/>
+ <use xlink:href="#Inter-Regular-316" transform="translate(330.75 0)"/>
+ <use xlink:href="#Inter-Regular-287" transform="translate(390.71875 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(427.734375 0)"/>
+ <use xlink:href="#Inter-Regular-53e" transform="translate(455.859375 0)"/>
+ <use xlink:href="#Inter-Regular-53d" transform="translate(496.53125 0)"/>
+ <use xlink:href="#Inter-Regular-53d" transform="translate(559.625 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(622.71875 0)"/>
+ <use xlink:href="#Inter-Regular-3d8" transform="translate(650.84375 0)"/>
+ <use xlink:href="#Inter-Regular-2b1" transform="translate(732.6875 0)"/>
+ <use xlink:href="#Inter-Regular-379" transform="translate(756.90625 0)"/>
+ <use xlink:href="#Inter-Regular-29e" transform="translate(789.625 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(848.75 0)"/>
+ <use xlink:href="#Inter-Regular-1fb" transform="translate(876.875 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(933.03125 0)"/>
+ <use xlink:href="#Inter-Regular-24a" transform="translate(961.15625 0)"/>
+ <use xlink:href="#Inter-Regular-29e" transform="translate(1018.28125 0)"/>
+ <use xlink:href="#Inter-Regular-1fb" transform="translate(1077.40625 0)"/>
+ <use xlink:href="#Inter-Regular-305" transform="translate(1133.5625 0)"/>
+ <use xlink:href="#Inter-Regular-292" transform="translate(1192.640625 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(1253.96875 0)"/>
+ <use xlink:href="#Inter-Regular-255" transform="translate(1312.265625 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(1373.5 0)"/>
+ <use xlink:href="#Inter-Regular-287" transform="translate(1401.625 0)"/>
+ <use xlink:href="#Inter-Regular-2b1" transform="translate(1438.640625 0)"/>
+ <use xlink:href="#Inter-Regular-2e0" transform="translate(1462.859375 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(1487.078125 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(1545.375 0)"/>
+ <use xlink:href="#Inter-Regular-2b1" transform="translate(1573.5 0)"/>
+ <use xlink:href="#Inter-Regular-305" transform="translate(1597.71875 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(1656.796875 0)"/>
+ <use xlink:href="#Inter-Regular-379" transform="translate(1684.921875 0)"/>
+ <use xlink:href="#Inter-Regular-29e" transform="translate(1717.640625 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(1776.765625 0)"/>
+ </g>
+ </g>
+ <g id="text_41">
+ <!-- first 10 -->
+ <g style="fill: #8a93a6" transform="translate(820 260) scale(0.18 -0.18)">
+ <use xlink:href="#Inter-Regular-287"/>
+ <use xlink:href="#Inter-Regular-2b1" transform="translate(37.015625 0)"/>
+ <use xlink:href="#Inter-Regular-354" transform="translate(61.234375 0)"/>
+ <use xlink:href="#Inter-Regular-367" transform="translate(98.875 0)"/>
+ <use xlink:href="#Inter-Regular-379" transform="translate(151.65625 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(184.375 0)"/>
+ <use xlink:href="#Inter-Regular-53e" transform="translate(212.5 0)"/>
+ <use xlink:href="#Inter-Regular-53d" transform="translate(253.171875 0)"/>
+ </g>
+ </g>
+ <g id="text_42">
+ <!-- 82 -->
+ <g style="fill: #f4f6fa" transform="translate(845.319062 356.16) scale(0.28 -0.28)">
+ <defs>
+ <path id="Inter-Bold-547" d="M 2081 -63
+Q 1559 -63 1156 107
+Q 753 278 523 575
+Q 294 872 294 1250
+Q 294 1541 425 1786
+Q 556 2031 784 2195
+Q 1013 2359 1297 2406
+L 1297 2434
+Q 925 2513 694 2800
+Q 463 3088 463 3469
+Q 463 3828 672 4111
+Q 881 4394 1247 4556
+Q 1613 4719 2081 4719
+Q 2547 4719 2914 4556
+Q 3281 4394 3492 4111
+Q 3703 3828 3703 3469
+Q 3703 3088 3468 2800
+Q 3234 2513 2872 2434
+L 2872 2406
+Q 3150 2359 3376 2195
+Q 3603 2031 3739 1786
+Q 3875 1541 3875 1250
+Q 3875 872 3644 575
+Q 3413 278 3008 107
+Q 2603 -63 2081 -63
+z
+M 2081 644
+Q 2438 644 2658 833
+Q 2878 1022 2878 1325
+Q 2878 1634 2651 1832
+Q 2425 2031 2081 2031
+Q 1734 2031 1509 1832
+Q 1284 1634 1284 1325
+Q 1284 1025 1503 834
+Q 1722 644 2081 644
+z
+M 2081 2731
+Q 2378 2731 2573 2909
+Q 2769 3088 2769 3366
+Q 2769 3644 2576 3817
+Q 2384 3991 2081 3991
+Q 1778 3991 1586 3819
+Q 1394 3647 1394 3366
+Q 1394 3088 1587 2909
+Q 1781 2731 2081 2731
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Bold-53f" d="M 388 0
+L 388 688
+L 2038 2234
+Q 2353 2544 2523 2773
+Q 2694 3003 2694 3284
+Q 2694 3597 2489 3776
+Q 2284 3956 1972 3956
+Q 1647 3956 1451 3762
+Q 1256 3569 1256 3228
+L 344 3228
+Q 344 3681 551 4017
+Q 759 4353 1128 4536
+Q 1497 4719 1978 4719
+Q 2472 4719 2840 4542
+Q 3209 4366 3414 4056
+Q 3619 3747 3619 3344
+Q 3619 3084 3517 2831
+Q 3416 2578 3155 2264
+Q 2894 1950 2416 1513
+L 1713 819
+L 1713 784
+L 3681 784
+L 3681 0
+L 388 0
+z
+" transform="scale(0.015625)"/>
+ </defs>
+ <use xlink:href="#Inter-Bold-547"/>
+ <use xlink:href="#Inter-Bold-53f" transform="translate(65.09375 0)"/>
+ </g>
+ </g>
+ <g id="text_43">
+ <!-- 0.1.3 -->
+ <g style="fill: #c9ced8" transform="translate(841.709375 652) scale(0.2 -0.2)">
+ <use xlink:href="#Inter-Medium-53d"/>
+ <use xlink:href="#Inter-Medium-5de" transform="translate(61.859375 0)"/>
+ <use xlink:href="#Inter-Medium-53e" transform="translate(83.40625 0)"/>
+ <use xlink:href="#Inter-Medium-5de" transform="translate(124.90625 0)"/>
+ <use xlink:href="#Inter-Medium-541" transform="translate(152.703125 0)"/>
+ </g>
+ </g>
+ <g id="text_44">
+ <!-- 30 -->
+ <g style="fill: #c9ced8" transform="translate(934.19875 518.4) scale(0.24 -0.24)">
+ <use xlink:href="#Inter-SemiBold-541"/>
+ <use xlink:href="#Inter-SemiBold-53d" transform="translate(63.625 0)"/>
+ </g>
+ </g>
+ <g id="text_45">
+ <!-- 0.1.2 -->
+ <g style="fill: #c9ced8" transform="translate(928.064062 652) scale(0.2 -0.2)">
+ <use xlink:href="#Inter-Medium-53d"/>
+ <use xlink:href="#Inter-Medium-5de" transform="translate(61.859375 0)"/>
+ <use xlink:href="#Inter-Medium-53e" transform="translate(83.40625 0)"/>
+ <use xlink:href="#Inter-Medium-5de" transform="translate(124.90625 0)"/>
+ <use xlink:href="#Inter-Medium-53f" transform="translate(155.234375 0)"/>
+ </g>
+ </g>
+ <g id="text_46">
+ <!-- 77 -->
+ <g style="fill: #c9ced8" transform="translate(1022.185625 371.76) scale(0.24 -0.24)">
+ <defs>
+ <path id="Inter-SemiBold-546" d="M 578 0
+L 2559 3925
+L 2559 3956
+L 259 3956
+L 259 4656
+L 3428 4656
+L 3428 3938
+L 1447 0
+L 578 0
+z
+" transform="scale(0.015625)"/>
+ </defs>
+ <use xlink:href="#Inter-SemiBold-546"/>
+ <use xlink:href="#Inter-SemiBold-546" transform="translate(59.578125 0)"/>
+ </g>
+ </g>
+ <g id="text_47">
+ <!-- BM25 -->
+ <g style="fill: #c9ced8" transform="translate(1008.364063 652) scale(0.2 -0.2)">
+ <use xlink:href="#Inter-Medium-41"/>
+ <use xlink:href="#Inter-Medium-124" transform="translate(65.671875 0)"/>
+ <use xlink:href="#Inter-Medium-53f" transform="translate(156.9375 0)"/>
+ <use xlink:href="#Inter-Medium-543" transform="translate(218.5625 0)"/>
+ </g>
+ </g>
+ <g id="text_48">
+ <!-- 71 -->
+ <g style="fill: #c9ced8" transform="translate(1110.76125 390.48) scale(0.24 -0.24)">
+ <use xlink:href="#Inter-SemiBold-546"/>
+ <use xlink:href="#Inter-SemiBold-53e" transform="translate(57.625 0)"/>
+ </g>
+ </g>
+ <g id="text_49">
+ <!-- grep -->
+ <g style="fill: #c9ced8" transform="translate(1100.821875 652) scale(0.2 -0.2)">
+ <use xlink:href="#Inter-Medium-292"/>
+ <use xlink:href="#Inter-Medium-354" transform="translate(61.96875 0)"/>
+ <use xlink:href="#Inter-Medium-266" transform="translate(98.734375 0)"/>
+ <use xlink:href="#Inter-Medium-34b" transform="translate(157.46875 0)"/>
+ </g>
+ </g>
+ <g id="text_50">
+ <!-- 0.1.3 vs BM25, McNemar exact: -->
+ <g style="fill: #8a93a6" transform="translate(820 696) scale(0.18 -0.18)">
+ <use xlink:href="#Inter-Regular-53d"/>
+ <use xlink:href="#Inter-Regular-5de" transform="translate(60.5625 0)"/>
+ <use xlink:href="#Inter-Regular-53e" transform="translate(80.734375 0)"/>
+ <use xlink:href="#Inter-Regular-5de" transform="translate(121.40625 0)"/>
+ <use xlink:href="#Inter-Regular-541" transform="translate(147.53125 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(209.296875 0)"/>
+ <use xlink:href="#Inter-Regular-3d4" transform="translate(237.421875 0)"/>
+ <use xlink:href="#Inter-Regular-367" transform="translate(293.625 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(346.40625 0)"/>
+ <use xlink:href="#Inter-Regular-41" transform="translate(374.53125 0)"/>
+ <use xlink:href="#Inter-Regular-124" transform="translate(439.96875 0)"/>
+ <use xlink:href="#Inter-Regular-53f" transform="translate(530.296875 0)"/>
+ <use xlink:href="#Inter-Regular-543" transform="translate(591.28125 0)"/>
+ <use xlink:href="#Inter-Regular-5dd" transform="translate(647.921875 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(676.734375 0)"/>
+ <use xlink:href="#Inter-Regular-124" transform="translate(704.859375 0)"/>
+ <use xlink:href="#Inter-Regular-24a" transform="translate(795.1875 0)"/>
+ <use xlink:href="#Inter-Regular-12c" transform="translate(852.3125 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(927.65625 0)"/>
+ <use xlink:href="#Inter-Regular-2fe" transform="translate(985.953125 0)"/>
+ <use xlink:href="#Inter-Regular-1fb" transform="translate(1073.546875 0)"/>
+ <use xlink:href="#Inter-Regular-354" transform="translate(1129.703125 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(1167.34375 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(1195.46875 0)"/>
+ <use xlink:href="#Inter-Regular-3e1" transform="translate(1251.515625 0)"/>
+ <use xlink:href="#Inter-Regular-1fb" transform="translate(1306.109375 0)"/>
+ <use xlink:href="#Inter-Regular-24a" transform="translate(1362.265625 0)"/>
+ <use xlink:href="#Inter-Regular-379" transform="translate(1419.390625 0)"/>
+ <use xlink:href="#Inter-Regular-5e1" transform="translate(1452.109375 0)"/>
+ </g>
+ </g>
+ <g id="text_51">
+ <!-- +5 issues, p = 0.383, not significant -->
+ <g style="fill: #c9ced8" transform="translate(831.987656 734) scale(0.18 -0.18)">
+ <use xlink:href="#Inter-SemiBold-5ff"/>
+ <use xlink:href="#Inter-SemiBold-543" transform="translate(67.28125 0)"/>
+ <use xlink:href="#Inter-SemiBold-6f1" transform="translate(128.515625 0)"/>
+ <use xlink:href="#Inter-SemiBold-2b1" transform="translate(153.71875 0)"/>
+ <use xlink:href="#Inter-SemiBold-367" transform="translate(179.890625 0)"/>
+ <use xlink:href="#Inter-SemiBold-367" transform="translate(234.828125 0)"/>
+ <use xlink:href="#Inter-SemiBold-393" transform="translate(289.765625 0)"/>
+ <use xlink:href="#Inter-SemiBold-266" transform="translate(351 0)"/>
+ <use xlink:href="#Inter-SemiBold-367" transform="translate(410.125 0)"/>
+ <use xlink:href="#Inter-SemiBold-5dd" transform="translate(465.0625 0)"/>
+ <use xlink:href="#Inter-SemiBold-6f1" transform="translate(494.90625 0)"/>
+ <use xlink:href="#Inter-SemiBold-34b" transform="translate(520.109375 0)"/>
+ <use xlink:href="#Inter-SemiBold-6f1" transform="translate(582.515625 0)"/>
+ <use xlink:href="#Inter-SemiBold-5f0" transform="translate(607.71875 0)"/>
+ <use xlink:href="#Inter-SemiBold-6f1" transform="translate(675 0)"/>
+ <use xlink:href="#Inter-SemiBold-53d" transform="translate(700.203125 0)"/>
+ <use xlink:href="#Inter-SemiBold-5de" transform="translate(763.390625 0)"/>
+ <use xlink:href="#Inter-SemiBold-541" transform="translate(792.84375 0)"/>
+ <use xlink:href="#Inter-SemiBold-547" transform="translate(856.46875 0)"/>
+ <use xlink:href="#Inter-SemiBold-541" transform="translate(920.484375 0)"/>
+ <use xlink:href="#Inter-SemiBold-5dd" transform="translate(981.96875 0)"/>
+ <use xlink:href="#Inter-SemiBold-6f1" transform="translate(1011.8125 0)"/>
+ <use xlink:href="#Inter-SemiBold-305" transform="translate(1037.015625 0)"/>
+ <use xlink:href="#Inter-SemiBold-316" transform="translate(1098.203125 0)"/>
+ <use xlink:href="#Inter-SemiBold-379" transform="translate(1159.09375 0)"/>
+ <use xlink:href="#Inter-SemiBold-6f1" transform="translate(1194.390625 0)"/>
+ <use xlink:href="#Inter-SemiBold-367" transform="translate(1219.59375 0)"/>
+ <use xlink:href="#Inter-SemiBold-2b1" transform="translate(1274.53125 0)"/>
+ <use xlink:href="#Inter-SemiBold-292" transform="translate(1300.703125 0)"/>
+ <use xlink:href="#Inter-SemiBold-305" transform="translate(1363.25 0)"/>
+ <use xlink:href="#Inter-SemiBold-2b1" transform="translate(1424.4375 0)"/>
+ <use xlink:href="#Inter-SemiBold-287" transform="translate(1450.609375 0)"/>
+ <use xlink:href="#Inter-SemiBold-2b1" transform="translate(1490.078125 0)"/>
+ <use xlink:href="#Inter-SemiBold-24a" transform="translate(1516.25 0)"/>
+ <use xlink:href="#Inter-SemiBold-1fb" transform="translate(1575.484375 0)"/>
+ <use xlink:href="#Inter-SemiBold-305" transform="translate(1632.90625 0)"/>
+ <use xlink:href="#Inter-SemiBold-379" transform="translate(1694.09375 0)"/>
+ </g>
+ </g>
+ <g id="text_52">
+ <!-- MRR -->
+ <g style="fill: #f4f6fa" transform="translate(1206 206) scale(0.26 -0.26)">
+ <defs>
+ <path id="Inter-SemiBold-124" d="M 469 0
+L 469 4656
+L 1725 4656
+L 2609 2253
+Q 2656 2116 2717 1895
+Q 2778 1675 2840 1423
+Q 2903 1172 2956 941
+Q 3009 1169 3071 1420
+Q 3134 1672 3195 1892
+Q 3256 2113 3300 2253
+L 4175 4656
+L 5434 4656
+L 5434 0
+L 4603 0
+L 4603 2350
+Q 4603 2525 4608 2783
+Q 4613 3041 4620 3331
+Q 4628 3622 4631 3900
+Q 4553 3600 4465 3303
+Q 4378 3006 4300 2756
+Q 4222 2506 4166 2350
+L 3306 0
+L 2597 0
+L 1725 2350
+Q 1669 2500 1592 2744
+Q 1516 2988 1430 3281
+Q 1344 3575 1256 3875
+Q 1263 3613 1270 3327
+Q 1278 3041 1283 2784
+Q 1288 2528 1288 2350
+L 1288 0
+L 469 0
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-SemiBold-180" d="M 469 0
+L 469 4656
+L 2209 4656
+Q 3013 4656 3431 4243
+Q 3850 3831 3850 3166
+Q 3850 2694 3637 2353
+Q 3425 2013 3013 1850
+L 4022 0
+L 3088 0
+L 2172 1709
+L 1303 1709
+L 1303 0
+L 469 0
+z
+M 1303 2400
+L 2088 2400
+Q 2559 2400 2778 2598
+Q 2997 2797 2997 3166
+Q 2997 3541 2778 3748
+Q 2559 3956 2081 3956
+L 1303 3956
+L 1303 2400
+z
+" transform="scale(0.015625)"/>
+ </defs>
+ <use xlink:href="#Inter-SemiBold-124"/>
+ <use xlink:href="#Inter-SemiBold-180" transform="translate(92.234375 0)"/>
+ <use xlink:href="#Inter-SemiBold-180" transform="translate(157.46875 0)"/>
+ </g>
+ </g>
+ <g id="text_53">
+ <!-- Mean reciprocal rank of the first -->
+ <g style="fill: #8a93a6" transform="translate(1206 236) scale(0.18 -0.18)">
+ <use xlink:href="#Inter-Regular-124"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(90.328125 0)"/>
+ <use xlink:href="#Inter-Regular-1fb" transform="translate(149.609375 0)"/>
+ <use xlink:href="#Inter-Regular-305" transform="translate(205.765625 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(264.84375 0)"/>
+ <use xlink:href="#Inter-Regular-354" transform="translate(292.96875 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(328.953125 0)"/>
+ <use xlink:href="#Inter-Regular-24a" transform="translate(387.25 0)"/>
+ <use xlink:href="#Inter-Regular-2b1" transform="translate(444.375 0)"/>
+ <use xlink:href="#Inter-Regular-34b" transform="translate(468.59375 0)"/>
+ <use xlink:href="#Inter-Regular-354" transform="translate(529.828125 0)"/>
+ <use xlink:href="#Inter-Regular-316" transform="translate(565.8125 0)"/>
+ <use xlink:href="#Inter-Regular-24a" transform="translate(625.78125 0)"/>
+ <use xlink:href="#Inter-Regular-1fb" transform="translate(683.890625 0)"/>
+ <use xlink:href="#Inter-Regular-2e0" transform="translate(740.046875 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(764.265625 0)"/>
+ <use xlink:href="#Inter-Regular-354" transform="translate(792.390625 0)"/>
+ <use xlink:href="#Inter-Regular-1fb" transform="translate(830.03125 0)"/>
+ <use xlink:href="#Inter-Regular-305" transform="translate(886.1875 0)"/>
+ <use xlink:href="#Inter-Regular-2d7" transform="translate(945.265625 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(1000.15625 0)"/>
+ <use xlink:href="#Inter-Regular-316" transform="translate(1028.28125 0)"/>
+ <use xlink:href="#Inter-Regular-287" transform="translate(1088.25 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(1125.265625 0)"/>
+ <use xlink:href="#Inter-Regular-379" transform="translate(1153.390625 0)"/>
+ <use xlink:href="#Inter-Regular-29e" transform="translate(1186.109375 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(1245.234375 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(1303.53125 0)"/>
+ <use xlink:href="#Inter-Regular-287" transform="translate(1331.65625 0)"/>
+ <use xlink:href="#Inter-Regular-2b1" transform="translate(1368.671875 0)"/>
+ <use xlink:href="#Inter-Regular-354" transform="translate(1392.890625 0)"/>
+ <use xlink:href="#Inter-Regular-367" transform="translate(1430.53125 0)"/>
+ <use xlink:href="#Inter-Regular-379" transform="translate(1483.3125 0)"/>
+ </g>
+ </g>
+ <g id="text_54">
+ <!-- changed file -->
+ <g style="fill: #8a93a6" transform="translate(1206 260) scale(0.18 -0.18)">
+ <use xlink:href="#Inter-Regular-24a"/>
+ <use xlink:href="#Inter-Regular-29e" transform="translate(57.125 0)"/>
+ <use xlink:href="#Inter-Regular-1fb" transform="translate(116.25 0)"/>
+ <use xlink:href="#Inter-Regular-305" transform="translate(172.40625 0)"/>
+ <use xlink:href="#Inter-Regular-292" transform="translate(231.484375 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(292.8125 0)"/>
+ <use xlink:href="#Inter-Regular-255" transform="translate(351.109375 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(412.34375 0)"/>
+ <use xlink:href="#Inter-Regular-287" transform="translate(440.46875 0)"/>
+ <use xlink:href="#Inter-Regular-2b1" transform="translate(477.484375 0)"/>
+ <use xlink:href="#Inter-Regular-2e0" transform="translate(501.703125 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(525.921875 0)"/>
+ </g>
+ </g>
+ <g id="text_55">
+ <!-- 0.562 -->
+ <g style="fill: #f4f6fa" transform="translate(1209.013125 436.7496) scale(0.28 -0.28)">
+ <defs>
+ <path id="Inter-Bold-53d" d="M 2156 -63
+Q 1275 -63 784 565
+Q 294 1194 294 2325
+Q 294 3456 786 4087
+Q 1278 4719 2156 4719
+Q 3038 4719 3530 4086
+Q 4022 3453 4022 2325
+Q 4022 1194 3531 565
+Q 3041 -63 2156 -63
+z
+M 2156 728
+Q 2588 728 2819 1143
+Q 3050 1559 3050 2325
+Q 3050 3094 2819 3512
+Q 2588 3931 2156 3931
+Q 1728 3931 1497 3511
+Q 1266 3091 1266 2325
+Q 1266 1559 1495 1143
+Q 1725 728 2156 728
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Bold-5de" d="M 1069 -59
+Q 841 -59 684 95
+Q 528 250 528 478
+Q 528 706 684 861
+Q 841 1016 1069 1016
+Q 1297 1016 1453 861
+Q 1609 706 1609 478
+Q 1609 250 1453 95
+Q 1297 -59 1069 -59
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Bold-545" d="M 2138 -63
+Q 1781 -63 1451 56
+Q 1122 175 861 439
+Q 600 703 447 1140
+Q 294 1578 294 2219
+Q 294 3000 525 3561
+Q 756 4122 1178 4420
+Q 1600 4719 2172 4719
+Q 2631 4719 2984 4541
+Q 3338 4363 3553 4055
+Q 3769 3747 3816 3366
+L 2878 3366
+Q 2819 3613 2633 3755
+Q 2447 3897 2172 3897
+Q 1713 3897 1472 3497
+Q 1231 3097 1231 2409
+L 1263 2409
+Q 1419 2713 1734 2886
+Q 2050 3059 2431 3059
+Q 2841 3059 3166 2865
+Q 3491 2672 3678 2333
+Q 3866 1994 3866 1556
+Q 3866 1084 3647 718
+Q 3428 353 3039 145
+Q 2650 -63 2138 -63
+z
+M 2131 694
+Q 2475 694 2706 934
+Q 2938 1175 2938 1531
+Q 2938 1881 2711 2122
+Q 2484 2363 2138 2363
+Q 1909 2363 1725 2248
+Q 1541 2134 1434 1945
+Q 1328 1756 1328 1528
+Q 1328 1300 1433 1109
+Q 1538 919 1719 806
+Q 1900 694 2131 694
+z
+" transform="scale(0.015625)"/>
+ </defs>
+ <use xlink:href="#Inter-Bold-53d"/>
+ <use xlink:href="#Inter-Bold-5de" transform="translate(64.515625 0)"/>
+ <use xlink:href="#Inter-Bold-543" transform="translate(97.28125 0)"/>
+ <use xlink:href="#Inter-Bold-545" transform="translate(159.484375 0)"/>
+ <use xlink:href="#Inter-Bold-53f" transform="translate(224.421875 0)"/>
+ </g>
+ </g>
+ <g id="text_56">
+ <!-- 0.1.3 -->
+ <g style="fill: #c9ced8" transform="translate(1227.709375 652) scale(0.2 -0.2)">
+ <use xlink:href="#Inter-Medium-53d"/>
+ <use xlink:href="#Inter-Medium-5de" transform="translate(61.859375 0)"/>
+ <use xlink:href="#Inter-Medium-53e" transform="translate(83.40625 0)"/>
+ <use xlink:href="#Inter-Medium-5de" transform="translate(124.90625 0)"/>
+ <use xlink:href="#Inter-Medium-541" transform="translate(152.703125 0)"/>
+ </g>
+ </g>
+ <g id="text_57">
+ <!-- 0.191 -->
+ <g style="fill: #c9ced8" transform="translate(1307.58375 552.3456) scale(0.24 -0.24)">
+ <defs>
+ <path id="Inter-SemiBold-548" d="M 1953 -66
+Q 1516 -66 1175 106
+Q 834 278 625 578
+Q 416 878 366 1259
+L 1191 1259
+Q 1253 991 1450 823
+Q 1647 656 1953 656
+Q 2438 656 2700 1079
+Q 2963 1503 2963 2247
+L 2931 2247
+Q 2763 1950 2455 1776
+Q 2147 1603 1769 1603
+Q 1359 1603 1032 1798
+Q 706 1994 514 2337
+Q 322 2681 322 3119
+Q 322 3578 533 3943
+Q 744 4309 1123 4518
+Q 1503 4728 2006 4722
+Q 2334 4719 2650 4605
+Q 2966 4491 3219 4231
+Q 3472 3972 3622 3539
+Q 3772 3106 3772 2466
+Q 3772 1666 3548 1100
+Q 3325 534 2917 234
+Q 2509 -66 1953 -66
+z
+M 1991 2244
+Q 2241 2244 2439 2367
+Q 2638 2491 2755 2697
+Q 2872 2903 2872 3147
+Q 2872 3384 2759 3589
+Q 2647 3794 2450 3917
+Q 2253 4041 2003 4041
+Q 1756 4041 1559 3920
+Q 1363 3800 1248 3595
+Q 1134 3391 1134 3138
+Q 1134 2884 1245 2682
+Q 1356 2481 1550 2362
+Q 1744 2244 1991 2244
+z
+" transform="scale(0.015625)"/>
+ </defs>
+ <use xlink:href="#Inter-SemiBold-53d"/>
+ <use xlink:href="#Inter-SemiBold-5de" transform="translate(63.1875 0)"/>
+ <use xlink:href="#Inter-SemiBold-53e" transform="translate(86.1875 0)"/>
+ <use xlink:href="#Inter-SemiBold-548" transform="translate(128.46875 0)"/>
+ <use xlink:href="#Inter-SemiBold-53e" transform="translate(192.4375 0)"/>
+ </g>
+ </g>
+ <g id="text_58">
+ <!-- 0.1.2 -->
+ <g style="fill: #c9ced8" transform="translate(1314.064063 652) scale(0.2 -0.2)">
+ <use xlink:href="#Inter-Medium-53d"/>
+ <use xlink:href="#Inter-Medium-5de" transform="translate(61.859375 0)"/>
+ <use xlink:href="#Inter-Medium-53e" transform="translate(83.40625 0)"/>
+ <use xlink:href="#Inter-Medium-5de" transform="translate(124.90625 0)"/>
+ <use xlink:href="#Inter-Medium-53f" transform="translate(155.234375 0)"/>
+ </g>
+ </g>
+ <g id="text_59">
+ <!-- 0.478 -->
+ <g style="fill: #c9ced8" transform="translate(1388.42125 462.9888) scale(0.24 -0.24)">
+ <use xlink:href="#Inter-SemiBold-53d"/>
+ <use xlink:href="#Inter-SemiBold-5de" transform="translate(63.1875 0)"/>
+ <use xlink:href="#Inter-SemiBold-542" transform="translate(95.078125 0)"/>
+ <use xlink:href="#Inter-SemiBold-546" transform="translate(161.6875 0)"/>
+ <use xlink:href="#Inter-SemiBold-547" transform="translate(217.890625 0)"/>
+ </g>
+ </g>
+ <g id="text_60">
+ <!-- BM25 -->
+ <g style="fill: #c9ced8" transform="translate(1394.364063 652) scale(0.2 -0.2)">
+ <use xlink:href="#Inter-Medium-41"/>
+ <use xlink:href="#Inter-Medium-124" transform="translate(65.671875 0)"/>
+ <use xlink:href="#Inter-Medium-53f" transform="translate(156.9375 0)"/>
+ <use xlink:href="#Inter-Medium-543" transform="translate(218.5625 0)"/>
+ </g>
+ </g>
+ <g id="text_61">
+ <!-- 0.365 -->
+ <g style="fill: #c9ced8" transform="translate(1474.97375 498.0264) scale(0.24 -0.24)">
+ <use xlink:href="#Inter-SemiBold-53d"/>
+ <use xlink:href="#Inter-SemiBold-5de" transform="translate(63.1875 0)"/>
+ <use xlink:href="#Inter-SemiBold-541" transform="translate(92.640625 0)"/>
+ <use xlink:href="#Inter-SemiBold-545" transform="translate(156.265625 0)"/>
+ <use xlink:href="#Inter-SemiBold-543" transform="translate(220.234375 0)"/>
+ </g>
+ </g>
+ <g id="text_62">
+ <!-- grep -->
+ <g style="fill: #c9ced8" transform="translate(1486.821875 652) scale(0.2 -0.2)">
+ <use xlink:href="#Inter-Medium-292"/>
+ <use xlink:href="#Inter-Medium-354" transform="translate(61.96875 0)"/>
+ <use xlink:href="#Inter-Medium-266" transform="translate(98.734375 0)"/>
+ <use xlink:href="#Inter-Medium-34b" transform="translate(157.46875 0)"/>
+ </g>
+ </g>
+ <g id="text_63">
+ <!-- 1 when it comes first, 0.5 when second, -->
+ <g style="fill: #8a93a6" transform="translate(1206 696) scale(0.18 -0.18)">
+ <use xlink:href="#Inter-Regular-53e"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(40.671875 0)"/>
+ <use xlink:href="#Inter-Regular-3d8" transform="translate(68.796875 0)"/>
+ <use xlink:href="#Inter-Regular-29e" transform="translate(150.640625 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(209.765625 0)"/>
+ <use xlink:href="#Inter-Regular-305" transform="translate(268.0625 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(327.140625 0)"/>
+ <use xlink:href="#Inter-Regular-2b1" transform="translate(355.265625 0)"/>
+ <use xlink:href="#Inter-Regular-379" transform="translate(379.484375 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(412.203125 0)"/>
+ <use xlink:href="#Inter-Regular-24a" transform="translate(440.328125 0)"/>
+ <use xlink:href="#Inter-Regular-316" transform="translate(497.453125 0)"/>
+ <use xlink:href="#Inter-Regular-2fe" transform="translate(557.421875 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(645.015625 0)"/>
+ <use xlink:href="#Inter-Regular-367" transform="translate(703.3125 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(756.09375 0)"/>
+ <use xlink:href="#Inter-Regular-287" transform="translate(784.21875 0)"/>
+ <use xlink:href="#Inter-Regular-2b1" transform="translate(821.234375 0)"/>
+ <use xlink:href="#Inter-Regular-354" transform="translate(845.453125 0)"/>
+ <use xlink:href="#Inter-Regular-367" transform="translate(883.09375 0)"/>
+ <use xlink:href="#Inter-Regular-379" transform="translate(935.875 0)"/>
+ <use xlink:href="#Inter-Regular-5dd" transform="translate(968.59375 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(997.40625 0)"/>
+ <use xlink:href="#Inter-Regular-53d" transform="translate(1025.53125 0)"/>
+ <use xlink:href="#Inter-Regular-5de" transform="translate(1086.09375 0)"/>
+ <use xlink:href="#Inter-Regular-543" transform="translate(1113.484375 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(1172.8125 0)"/>
+ <use xlink:href="#Inter-Regular-3d8" transform="translate(1200.9375 0)"/>
+ <use xlink:href="#Inter-Regular-29e" transform="translate(1282.78125 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(1341.90625 0)"/>
+ <use xlink:href="#Inter-Regular-305" transform="translate(1400.203125 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(1459.28125 0)"/>
+ <use xlink:href="#Inter-Regular-367" transform="translate(1487.40625 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(1540.1875 0)"/>
+ <use xlink:href="#Inter-Regular-24a" transform="translate(1598.484375 0)"/>
+ <use xlink:href="#Inter-Regular-316" transform="translate(1655.609375 0)"/>
+ <use xlink:href="#Inter-Regular-305" transform="translate(1715.578125 0)"/>
+ <use xlink:href="#Inter-Regular-255" transform="translate(1774.65625 0)"/>
+ <use xlink:href="#Inter-Regular-5dd" transform="translate(1835.890625 0)"/>
+ </g>
+ </g>
+ <g id="text_64">
+ <!-- 0 past rank 100. -->
+ <g style="fill: #8a93a6" transform="translate(1206 720) scale(0.18 -0.18)">
+ <use xlink:href="#Inter-Regular-53d"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(63.09375 0)"/>
+ <use xlink:href="#Inter-Regular-34b" transform="translate(91.21875 0)"/>
+ <use xlink:href="#Inter-Regular-1fb" transform="translate(153.4375 0)"/>
+ <use xlink:href="#Inter-Regular-367" transform="translate(209.59375 0)"/>
+ <use xlink:href="#Inter-Regular-379" transform="translate(262.375 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(295.09375 0)"/>
+ <use xlink:href="#Inter-Regular-354" transform="translate(323.21875 0)"/>
+ <use xlink:href="#Inter-Regular-1fb" transform="translate(360.859375 0)"/>
+ <use xlink:href="#Inter-Regular-305" transform="translate(417.015625 0)"/>
+ <use xlink:href="#Inter-Regular-2d7" transform="translate(476.09375 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(530.984375 0)"/>
+ <use xlink:href="#Inter-Regular-53e" transform="translate(559.109375 0)"/>
+ <use xlink:href="#Inter-Regular-53d" transform="translate(599.78125 0)"/>
+ <use xlink:href="#Inter-Regular-53d" transform="translate(662.875 0)"/>
+ <use xlink:href="#Inter-Regular-5de" transform="translate(723.4375 0)"/>
+ </g>
+ </g>
+ </g>
+ </g>
+ <defs>
+ <clipPath id="pd3e7befa96">
+ <rect x="0" y="0" width="1600" height="900"/>
+ </clipPath>
+ </defs>
+</svg>
diff --git a/docs/assets/retrieval-light.png b/docs/assets/retrieval-light.png
new file mode 100644
index 0000000..93ed578
Binary files /dev/null and b/docs/assets/retrieval-light.png differ
diff --git a/docs/assets/retrieval-light.svg b/docs/assets/retrieval-light.svg
new file mode 100644
index 0000000..217debb
--- /dev/null
+++ b/docs/assets/retrieval-light.svg
@@ -0,0 +1,6372 @@
+<?xml version="1.0" encoding="utf-8" standalone="no"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
+ "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
+<svg xmlns:xlink="http://www.w3.org/1999/xlink" width="1600" height="900" viewBox="0 0 1600 900" xmlns="http://www.w3.org/2000/svg" version="1.1">
+ <title>Finding the files a fix changes: 100 SWE-bench Verified issues, held out from tuning. Top 1: Graphicle 0.1.3 43, Graphicle 0.1.2 13, BM25 (SWE-bench style) 35, grep for the issue&#x27;s names 20; Top 5: Graphicle 0.1.3 75, Graphicle 0.1.2 30, BM25 (SWE-bench style) 61, grep for the issue&#x27;s names 54; Top 10: Graphicle 0.1.3 82, Graphicle 0.1.2 30, BM25 (SWE-bench style) 77, grep for the issue&#x27;s names 71; MRR: Graphicle 0.1.3 0.562, Graphicle 0.1.2 0.191, BM25 (SWE-bench style) 0.478, grep for the issue&#x27;s names 0.365.</title>
+ <desc>Finding the files a fix changes: 100 SWE-bench Verified issues, held out from tuning. For each issue: is a file the fix changed among the first k files? Graphicle: the files its context packet cites, then lists. No model calls. Higher is better. Top 1 (Issues of 100 with a changed file first): Graphicle 0.1.3 43, Graphicle 0.1.2 13, BM25 (SWE-bench style) 35, grep for the issue&#x27;s names 20; 0.1.3 vs BM25, McNemar exact: +8 issues, p = 0.200, not significant. Top 5 (Issues of 100 with a changed file in the first 5): Graphicle 0.1.3 75, Graphicle 0.1.2 30, BM25 (SWE-bench style) 61, grep for the issue&#x27;s names 54; 0.1.3 vs BM25, McNemar exact: +14 issues, p = 0.013. Top 10 (Issues of 100 with a changed file in the first 10): Graphicle 0.1.3 82, Graphicle 0.1.2 30, BM25 (SWE-bench style) 77, grep for the issue&#x27;s names 71; 0.1.3 vs BM25, McNemar exact: +5 issues, p = 0.383, not significant. MRR (Mean reciprocal rank of the first changed file): Graphicle 0.1.3 0.562, Graphicle 0.1.2 0.191, BM25 (SWE-bench style) 0.478, grep for the issue&#x27;s names 0.365. Graphicle 0.1.3 and the 0.1.2 release binary run graphicle context on the issue&#x27;s prompt, with their defaults. BM25: SWE-bench style, one document per source file. grep: rg 14.1.1 for the identifiers and paths the issue names, files ranked by names matched. This measures ranking, not whether a coding agent fixes more issues. The agent test of 0.1.3 is pending. Method, task list and limits: github.com/graphicle-ai/graphicle/blob/main/docs/benchmarks/retrieval.md</desc>
+ <metadata>
+ <rdf:RDF xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://creativecommons.org/ns#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
+ <cc:Work>
+ <dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage"/>
+ <dc:format>image/svg+xml</dc:format>
+ <dc:creator>
+ <cc:Agent>
+ <dc:title>Matplotlib v3.11.2, https://matplotlib.org/</dc:title>
+ </cc:Agent>
+ </dc:creator>
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <defs>
+ <style type="text/css">*{stroke-linejoin: round; stroke-linecap: butt}</style>
+ </defs>
+ <g id="figure_1">
+ <g id="patch_1">
+ <path d="M 0 900
+L 1600 900
+L 1600 0
+L 0 0
+z
+" style="fill: #ffffff"/>
+ </g>
+ <g id="axes_1">
+ <g id="patch_2">
+ <path d="M 48 764
+L 1552 764
+L 1552 765
+L 48 765
+z
+" clip-path="url(#pd3e7befa96)" style="fill: #e3e6ec"/>
+ </g>
+ <g id="patch_3">
+ <path d="M 678.296875 46
+L 686.296875 46
+Q 690.296875 46 690.296875 50
+L 690.296875 58
+Q 690.296875 62 686.296875 62
+L 678.296875 62
+Q 674.296875 62 674.296875 58
+L 674.296875 50
+Q 674.296875 46 678.296875 46
+z
+" clip-path="url(#pd3e7befa96)" style="fill: #3f5efb"/>
+ </g>
+ <g id="patch_4">
+ <path d="M 856.40625 46
+L 864.40625 46
+Q 868.40625 46 868.40625 50
+L 868.40625 58
+Q 868.40625 62 864.40625 62
+L 856.40625 62
+Q 852.40625 62 852.40625 58
+L 852.40625 50
+Q 852.40625 46 856.40625 46
+z
+" clip-path="url(#pd3e7befa96)" style="fill: #a9b7fd"/>
+ </g>
+ <g id="patch_5">
+ <path d="M 1034.78125 46
+L 1042.78125 46
+Q 1046.78125 46 1046.78125 50
+L 1046.78125 58
+Q 1046.78125 62 1042.78125 62
+L 1034.78125 62
+Q 1030.78125 62 1030.78125 58
+L 1030.78125 50
+Q 1030.78125 46 1034.78125 46
+z
+" clip-path="url(#pd3e7befa96)" style="fill: #8a93a3"/>
+ </g>
+ <g id="patch_6">
+ <path d="M 1304 46
+L 1312 46
+Q 1316 46 1316 50
+L 1316 58
+Q 1316 62 1312 62
+L 1304 62
+Q 1300 62 1300 58
+L 1300 50
+Q 1300 46 1304 46
+z
+" clip-path="url(#pd3e7befa96)" style="fill: #c3c9d4"/>
+ </g>
+ <g id="patch_7">
+ <path d="M 65.3 624
+L 65.3 493.84
+Q 65.3 489.84 69.3 489.84
+L 113.2 489.84
+Q 117.2 489.84 117.2 493.84
+L 117.2 624
+z
+" clip-path="url(#pd3e7befa96)" style="fill: #3f5efb"/>
+ </g>
+ <g id="patch_8">
+ <path d="M 151.8 624
+L 151.8 587.44
+Q 151.8 583.44 155.8 583.44
+L 199.7 583.44
+Q 203.7 583.44 203.7 587.44
+L 203.7 624
+z
+" clip-path="url(#pd3e7befa96)" style="fill: #a9b7fd"/>
+ </g>
+ <g id="patch_9">
+ <path d="M 238.3 624
+L 238.3 518.8
+Q 238.3 514.8 242.3 514.8
+L 286.2 514.8
+Q 290.2 514.8 290.2 518.8
+L 290.2 624
+z
+" clip-path="url(#pd3e7befa96)" style="fill: #8a93a3"/>
+ </g>
+ <g id="patch_10">
+ <path d="M 324.8 624
+L 324.8 565.6
+Q 324.8 561.6 328.8 561.6
+L 372.7 561.6
+Q 376.7 561.6 376.7 565.6
+L 376.7 624
+z
+" clip-path="url(#pd3e7befa96)" style="fill: #c3c9d4"/>
+ </g>
+ <g id="patch_11">
+ <path d="M 451.3 624
+L 451.3 394
+Q 451.3 390 455.3 390
+L 499.2 390
+Q 503.2 390 503.2 394
+L 503.2 624
+z
+" clip-path="url(#pd3e7befa96)" style="fill: #3f5efb"/>
+ </g>
+ <g id="patch_12">
+ <path d="M 537.8 624
+L 537.8 534.4
+Q 537.8 530.4 541.8 530.4
+L 585.7 530.4
+Q 589.7 530.4 589.7 534.4
+L 589.7 624
+z
+" clip-path="url(#pd3e7befa96)" style="fill: #a9b7fd"/>
+ </g>
+ <g id="patch_13">
+ <path d="M 624.3 624
+L 624.3 437.68
+Q 624.3 433.68 628.3 433.68
+L 672.2 433.68
+Q 676.2 433.68 676.2 437.68
+L 676.2 624
+z
+" clip-path="url(#pd3e7befa96)" style="fill: #8a93a3"/>
+ </g>
+ <g id="patch_14">
+ <path d="M 710.8 624
+L 710.8 459.52
+Q 710.8 455.52 714.8 455.52
+L 758.7 455.52
+Q 762.7 455.52 762.7 459.52
+L 762.7 624
+z
+" clip-path="url(#pd3e7befa96)" style="fill: #c3c9d4"/>
+ </g>
+ <g id="patch_15">
+ <path d="M 837.3 624
+L 837.3 372.16
+Q 837.3 368.16 841.3 368.16
+L 885.2 368.16
+Q 889.2 368.16 889.2 372.16
+L 889.2 624
+z
+" clip-path="url(#pd3e7befa96)" style="fill: #3f5efb"/>
+ </g>
+ <g id="patch_16">
+ <path d="M 923.8 624
+L 923.8 534.4
+Q 923.8 530.4 927.8 530.4
+L 971.7 530.4
+Q 975.7 530.4 975.7 534.4
+L 975.7 624
+z
+" clip-path="url(#pd3e7befa96)" style="fill: #a9b7fd"/>
+ </g>
+ <g id="patch_17">
+ <path d="M 1010.3 624
+L 1010.3 387.76
+Q 1010.3 383.76 1014.3 383.76
+L 1058.2 383.76
+Q 1062.2 383.76 1062.2 387.76
+L 1062.2 624
+z
+" clip-path="url(#pd3e7befa96)" style="fill: #8a93a3"/>
+ </g>
+ <g id="patch_18">
+ <path d="M 1096.8 624
+L 1096.8 406.48
+Q 1096.8 402.48 1100.8 402.48
+L 1144.7 402.48
+Q 1148.7 402.48 1148.7 406.48
+L 1148.7 624
+z
+" clip-path="url(#pd3e7befa96)" style="fill: #c3c9d4"/>
+ </g>
+ <g id="patch_19">
+ <path d="M 1223.3 624
+L 1223.3 452.7496
+Q 1223.3 448.7496 1227.3 448.7496
+L 1271.2 448.7496
+Q 1275.2 448.7496 1275.2 452.7496
+L 1275.2 624
+z
+" clip-path="url(#pd3e7befa96)" style="fill: #3f5efb"/>
+ </g>
+ <g id="patch_20">
+ <path d="M 1309.8 624
+L 1309.8 568.3456
+Q 1309.8 564.3456 1313.8 564.3456
+L 1357.7 564.3456
+Q 1361.7 564.3456 1361.7 568.3456
+L 1361.7 624
+z
+" clip-path="url(#pd3e7befa96)" style="fill: #a9b7fd"/>
+ </g>
+ <g id="patch_21">
+ <path d="M 1396.3 624
+L 1396.3 478.9888
+Q 1396.3 474.9888 1400.3 474.9888
+L 1444.2 474.9888
+Q 1448.2 474.9888 1448.2 478.9888
+L 1448.2 624
+z
+" clip-path="url(#pd3e7befa96)" style="fill: #8a93a3"/>
+ </g>
+ <g id="patch_22">
+ <path d="M 1482.8 624
+L 1482.8 514.0264
+Q 1482.8 510.0264 1486.8 510.0264
+L 1530.7 510.0264
+Q 1534.7 510.0264 1534.7 514.0264
+L 1534.7 624
+z
+" clip-path="url(#pd3e7befa96)" style="fill: #c3c9d4"/>
+ </g>
+ <g id="patch_23">
+ <path d="M 48 623.25
+L 394 623.25
+L 394 624.75
+L 48 624.75
+z
+" clip-path="url(#pd3e7befa96)" style="fill: #e3e6ec"/>
+ </g>
+ <g id="patch_24">
+ <path d="M 434 623.25
+L 780 623.25
+L 780 624.75
+L 434 624.75
+z
+" clip-path="url(#pd3e7befa96)" style="fill: #e3e6ec"/>
+ </g>
+ <g id="patch_25">
+ <path d="M 820 623.25
+L 1166 623.25
+L 1166 624.75
+L 820 624.75
+z
+" clip-path="url(#pd3e7befa96)" style="fill: #e3e6ec"/>
+ </g>
+ <g id="patch_26">
+ <path d="M 1206 623.25
+L 1552 623.25
+L 1552 624.75
+L 1206 624.75
+z
+" clip-path="url(#pd3e7befa96)" style="fill: #e3e6ec"/>
+ </g>
+ <g id="patch_27">
+ <path d="M 63 712.457
+L 369.640625 712.457
+Q 384.640625 712.457 384.640625 727.457
+L 384.640625 727.457
+Q 384.640625 742.457 369.640625 742.457
+L 63 742.457
+Q 48 742.457 48 727.457
+L 48 727.457
+Q 48 712.457 63 712.457
+z
+" clip-path="url(#pd3e7befa96)" style="fill: #ebeef2"/>
+ </g>
+ <g id="patch_28">
+ <path d="M 449 712.457
+L 625.125 712.457
+Q 640.125 712.457 640.125 727.457
+L 640.125 727.457
+Q 640.125 742.457 625.125 742.457
+L 449 742.457
+Q 434 742.457 434 727.457
+L 434 727.457
+Q 434 712.457 449 712.457
+z
+" clip-path="url(#pd3e7befa96)" style="fill: #3f5efb"/>
+ </g>
+ <g id="patch_29">
+ <path d="M 835 712.457
+L 1140.265625 712.457
+Q 1155.265625 712.457 1155.265625 727.457
+L 1155.265625 727.457
+Q 1155.265625 742.457 1140.265625 742.457
+L 835 742.457
+Q 820 742.457 820 727.457
+L 820 727.457
+Q 820 712.457 835 712.457
+z
+" clip-path="url(#pd3e7befa96)" style="fill: #ebeef2"/>
+ </g>
+ <g id="text_1">
+ <!-- Graphicle -->
+ <g style="fill: #0a0b0f" transform="translate(48 60) scale(0.28 -0.28)">
+ <defs>
+ <path id="Inter-Bold-8d" d="M 2484 -63
+Q 1831 -63 1337 226
+Q 844 516 569 1050
+Q 294 1584 294 2322
+Q 294 3075 580 3612
+Q 866 4150 1358 4434
+Q 1850 4719 2463 4719
+Q 2988 4719 3413 4519
+Q 3838 4319 4109 3967
+Q 4381 3616 4447 3156
+L 3478 3156
+Q 3378 3491 3122 3681
+Q 2866 3872 2478 3872
+Q 1941 3872 1602 3472
+Q 1263 3072 1263 2331
+Q 1263 1591 1597 1187
+Q 1931 784 2491 784
+Q 2988 784 3272 1046
+Q 3556 1309 3569 1756
+L 2556 1756
+L 2556 2481
+L 4494 2481
+L 4494 1900
+Q 4494 1288 4234 848
+Q 3975 409 3522 173
+Q 3069 -63 2484 -63
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Bold-354" d="M 400 0
+L 400 3494
+L 1306 3494
+L 1306 2884
+L 1344 2884
+Q 1441 3206 1667 3373
+Q 1894 3541 2188 3541
+Q 2347 3541 2491 3509
+L 2491 2672
+Q 2428 2691 2308 2705
+Q 2188 2719 2084 2719
+Q 1759 2719 1548 2516
+Q 1338 2313 1338 1988
+L 1338 0
+L 400 0
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Bold-1fb" d="M 1375 -69
+Q 875 -69 544 195
+Q 213 459 213 978
+Q 213 1369 400 1591
+Q 588 1813 888 1916
+Q 1188 2019 1531 2050
+Q 1981 2094 2179 2142
+Q 2378 2191 2378 2363
+L 2378 2378
+Q 2378 2600 2236 2722
+Q 2094 2844 1831 2844
+Q 1559 2844 1393 2726
+Q 1228 2609 1172 2441
+L 313 2584
+Q 447 3038 848 3288
+Q 1250 3538 1834 3538
+Q 2209 3538 2548 3419
+Q 2888 3300 3102 3039
+Q 3316 2778 3316 2353
+L 3316 0
+L 2428 0
+L 2428 484
+L 2397 484
+Q 2269 241 2016 86
+Q 1763 -69 1375 -69
+z
+M 1641 591
+Q 1969 591 2176 781
+Q 2384 972 2384 1250
+L 2384 1628
+Q 2328 1588 2201 1558
+Q 2075 1528 1934 1504
+Q 1794 1481 1691 1469
+Q 1431 1431 1272 1322
+Q 1113 1213 1113 1003
+Q 1113 800 1261 695
+Q 1409 591 1641 591
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Bold-34b" d="M 400 -1306
+L 400 3494
+L 1322 3494
+L 1322 2906
+L 1366 2906
+Q 1428 3044 1548 3191
+Q 1669 3338 1867 3438
+Q 2066 3538 2363 3538
+Q 2750 3538 3072 3338
+Q 3394 3138 3586 2738
+Q 3778 2338 3778 1741
+Q 3778 1159 3590 757
+Q 3403 356 3081 148
+Q 2759 -59 2356 -59
+Q 2072 -59 1875 37
+Q 1678 134 1554 276
+Q 1431 419 1366 559
+L 1338 559
+L 1338 -1306
+L 400 -1306
+z
+M 2069 694
+Q 2434 694 2626 987
+Q 2819 1281 2819 1744
+Q 2819 2203 2628 2495
+Q 2438 2788 2069 2788
+Q 1706 2788 1511 2503
+Q 1316 2219 1316 1744
+Q 1316 1269 1512 981
+Q 1709 694 2069 694
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Bold-29e" d="M 1338 2022
+L 1338 0
+L 400 0
+L 400 4656
+L 1319 4656
+L 1319 2825
+Q 1472 3166 1734 3352
+Q 1997 3538 2384 3538
+Q 2928 3538 3258 3188
+Q 3588 2838 3588 2222
+L 3588 0
+L 2647 0
+L 2647 2059
+Q 2647 2384 2480 2568
+Q 2313 2753 2016 2753
+Q 1716 2753 1527 2561
+Q 1338 2369 1338 2022
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Bold-2b1" d="M 400 0
+L 400 3494
+L 1338 3494
+L 1338 0
+L 400 0
+z
+M 869 3950
+Q 656 3950 506 4090
+Q 356 4231 356 4431
+Q 356 4631 506 4772
+Q 656 4913 869 4913
+Q 1081 4913 1232 4772
+Q 1384 4631 1384 4431
+Q 1384 4231 1232 4090
+Q 1081 3950 869 3950
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Bold-24a" d="M 1963 -69
+Q 1434 -69 1051 157
+Q 669 384 461 789
+Q 253 1194 253 1731
+Q 253 2272 461 2678
+Q 669 3084 1051 3311
+Q 1434 3538 1963 3538
+Q 2584 3538 3000 3227
+Q 3416 2916 3516 2375
+L 2644 2213
+Q 2584 2484 2414 2642
+Q 2244 2800 1972 2800
+Q 1597 2800 1403 2504
+Q 1209 2209 1209 1734
+Q 1209 1266 1403 967
+Q 1597 669 1972 669
+Q 2244 669 2419 833
+Q 2594 997 2650 1278
+L 3522 1119
+Q 3422 566 3006 248
+Q 2591 -69 1963 -69
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Bold-2e0" d="M 1338 4656
+L 1338 0
+L 400 0
+L 400 4656
+L 1338 4656
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Bold-266" d="M 1978 -69
+Q 1444 -69 1056 150
+Q 669 369 461 772
+Q 253 1175 253 1728
+Q 253 2269 461 2675
+Q 669 3081 1045 3309
+Q 1422 3538 1931 3538
+Q 2388 3538 2759 3344
+Q 3131 3150 3351 2756
+Q 3572 2363 3572 1766
+L 3572 1503
+L 1181 1503
+Q 1197 1075 1419 856
+Q 1641 638 1994 638
+Q 2241 638 2417 742
+Q 2594 847 2669 1050
+L 3519 891
+Q 3391 456 2989 193
+Q 2588 -69 1978 -69
+z
+M 1188 2091
+L 2669 2091
+Q 2634 2431 2450 2631
+Q 2266 2831 1941 2831
+Q 1603 2831 1409 2623
+Q 1216 2416 1188 2091
+z
+" transform="scale(0.015625)"/>
+ </defs>
+ <use xlink:href="#Inter-Bold-8d"/>
+ <use xlink:href="#Inter-Bold-354" transform="translate(75.046875 0)"/>
+ <use xlink:href="#Inter-Bold-1fb" transform="translate(114.40625 0)"/>
+ <use xlink:href="#Inter-Bold-34b" transform="translate(172.46875 0)"/>
+ <use xlink:href="#Inter-Bold-29e" transform="translate(235.5 0)"/>
+ <use xlink:href="#Inter-Bold-2b1" transform="translate(297.75 0)"/>
+ <use xlink:href="#Inter-Bold-24a" transform="translate(324.84375 0)"/>
+ <use xlink:href="#Inter-Bold-2e0" transform="translate(383.6875 0)"/>
+ <use xlink:href="#Inter-Bold-266" transform="translate(410.78125 0)"/>
+ </g>
+ </g>
+ <g id="text_2">
+ <!-- Offline retrieval benchmark, 21 October 2026 -->
+ <g style="fill: #5b6474" transform="translate(195.734375 60) scale(0.2 -0.2)">
+ <defs>
+ <path id="Inter-Regular-141" d="M 2450 -63
+Q 1853 -63 1386 226
+Q 919 516 650 1052
+Q 381 1588 381 2325
+Q 381 3066 650 3602
+Q 919 4138 1386 4428
+Q 1853 4719 2450 4719
+Q 3047 4719 3512 4428
+Q 3978 4138 4245 3602
+Q 4513 3066 4513 2325
+Q 4513 1588 4245 1052
+Q 3978 516 3512 226
+Q 3047 -63 2450 -63
+z
+M 2450 488
+Q 2866 488 3202 698
+Q 3538 909 3736 1320
+Q 3934 1731 3934 2325
+Q 3934 2925 3736 3336
+Q 3538 3747 3202 3958
+Q 2866 4169 2450 4169
+Q 2031 4169 1693 3956
+Q 1356 3744 1157 3333
+Q 959 2922 959 2325
+Q 959 1731 1157 1322
+Q 1356 913 1693 700
+Q 2031 488 2450 488
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Regular-287" d="M 2119 3494
+L 2119 3013
+L 1313 3013
+L 1313 0
+L 750 0
+L 750 3013
+L 63 3013
+L 63 3494
+L 750 3494
+L 750 3959
+Q 750 4263 892 4466
+Q 1034 4669 1262 4772
+Q 1491 4875 1744 4875
+Q 1944 4875 2075 4842
+Q 2206 4809 2269 4781
+L 2113 4300
+Q 2069 4316 1998 4334
+Q 1928 4353 1809 4353
+Q 1550 4353 1431 4220
+Q 1313 4088 1313 3834
+L 1313 3494
+L 2119 3494
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Regular-2e0" d="M 1056 4656
+L 1056 0
+L 494 0
+L 494 4656
+L 1056 4656
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Regular-2b1" d="M 494 0
+L 494 3494
+L 1056 3494
+L 1056 0
+L 494 0
+z
+M 778 4066
+Q 619 4066 503 4175
+Q 387 4284 387 4438
+Q 387 4594 503 4701
+Q 619 4809 778 4809
+Q 940 4809 1056 4701
+Q 1172 4594 1172 4438
+Q 1172 4284 1056 4175
+Q 940 4066 778 4066
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Regular-305" d="M 1056 2094
+L 1056 0
+L 494 0
+L 494 3494
+L 1034 3494
+L 1038 2847
+Q 1206 3219 1479 3378
+Q 1753 3538 2106 3538
+Q 2638 3538 2963 3209
+Q 3288 2881 3288 2219
+L 3288 0
+L 2725 0
+L 2725 2172
+Q 2725 2575 2514 2803
+Q 2303 3031 1938 3031
+Q 1559 3031 1307 2786
+Q 1056 2541 1056 2094
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Regular-266" d="M 1963 -75
+Q 1456 -75 1089 150
+Q 722 375 523 778
+Q 325 1181 325 1719
+Q 325 2256 519 2665
+Q 713 3075 1067 3306
+Q 1422 3538 1897 3538
+Q 2175 3538 2445 3445
+Q 2716 3353 2936 3148
+Q 3156 2944 3287 2609
+Q 3419 2275 3419 1791
+L 3419 1556
+L 894 1556
+Q 916 1009 1208 717
+Q 1500 425 1966 425
+Q 2275 425 2498 561
+Q 2722 697 2819 963
+L 3363 813
+Q 3241 416 2870 170
+Q 2500 -75 1963 -75
+z
+M 897 2031
+L 2847 2031
+Q 2806 2478 2567 2758
+Q 2328 3038 1897 3038
+Q 1597 3038 1380 2897
+Q 1163 2756 1038 2528
+Q 913 2300 897 2031
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Regular-6f1" transform="scale(0.015625)"/>
+ <path id="Inter-Regular-354" d="M 494 0
+L 494 3494
+L 1038 3494
+L 1038 2956
+L 1075 2956
+Q 1172 3222 1420 3383
+Q 1669 3544 1981 3544
+Q 2044 3544 2130 3541
+Q 2216 3538 2266 3534
+L 2266 2969
+Q 2241 2975 2141 2987
+Q 2041 3000 1928 3000
+Q 1550 3000 1303 2770
+Q 1056 2541 1056 2188
+L 1056 0
+L 494 0
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Regular-379" d="M 1869 3494
+L 1869 3013
+L 1150 3013
+L 1150 906
+Q 1150 672 1245 564
+Q 1341 456 1563 456
+Q 1616 456 1698 468
+Q 1781 481 1850 494
+L 1966 19
+Q 1878 -13 1767 -28
+Q 1656 -44 1547 -44
+Q 1094 -44 841 195
+Q 588 434 588 863
+L 588 3013
+L 63 3013
+L 63 3494
+L 588 3494
+L 588 4325
+L 1150 4325
+L 1150 3494
+L 1869 3494
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Regular-3d4" d="M 1503 0
+L 169 3494
+L 784 3494
+L 1528 1422
+Q 1609 1194 1675 967
+Q 1741 741 1800 522
+Q 1859 741 1923 967
+Q 1988 1194 2069 1422
+L 2813 3494
+L 3428 3494
+L 2094 0
+L 1503 0
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Regular-1fb" d="M 1472 -81
+Q 1141 -81 870 44
+Q 600 169 440 409
+Q 281 650 281 994
+Q 281 1294 400 1481
+Q 519 1669 717 1776
+Q 916 1884 1156 1937
+Q 1397 1991 1641 2022
+Q 1953 2063 2150 2084
+Q 2347 2106 2442 2159
+Q 2538 2213 2538 2341
+L 2538 2359
+Q 2538 2684 2353 2864
+Q 2169 3044 1806 3044
+Q 1428 3044 1215 2880
+Q 1003 2716 922 2531
+L 381 2709
+Q 516 3028 744 3208
+Q 972 3388 1247 3463
+Q 1522 3538 1791 3538
+Q 1966 3538 2189 3495
+Q 2413 3453 2620 3328
+Q 2828 3203 2964 2958
+Q 3100 2713 3100 2303
+L 3100 0
+L 2547 0
+L 2547 475
+L 2509 475
+Q 2450 353 2319 223
+Q 2188 94 1978 6
+Q 1769 -81 1472 -81
+z
+M 1569 416
+Q 1881 416 2097 537
+Q 2313 659 2425 854
+Q 2538 1050 2538 1263
+L 2538 1747
+Q 2503 1706 2387 1673
+Q 2272 1641 2123 1616
+Q 1975 1591 1836 1573
+Q 1697 1556 1616 1547
+Q 1413 1522 1236 1461
+Q 1059 1400 953 1283
+Q 847 1166 847 966
+Q 847 694 1051 555
+Q 1256 416 1569 416
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Regular-242" d="M 2116 -75
+Q 1784 -75 1581 39
+Q 1378 153 1268 298
+Q 1159 444 1100 541
+L 1038 541
+L 1038 0
+L 494 0
+L 494 4656
+L 1056 4656
+L 1056 2934
+L 1100 2934
+Q 1159 3028 1265 3170
+Q 1372 3313 1572 3425
+Q 1772 3538 2113 3538
+Q 2550 3538 2883 3319
+Q 3216 3100 3405 2695
+Q 3594 2291 3594 1738
+Q 3594 1181 3406 775
+Q 3219 369 2886 147
+Q 2553 -75 2116 -75
+z
+M 2031 428
+Q 2359 428 2579 604
+Q 2800 781 2911 1079
+Q 3022 1378 3022 1744
+Q 3022 2106 2912 2398
+Q 2803 2691 2583 2862
+Q 2363 3034 2031 3034
+Q 1550 3034 1300 2678
+Q 1050 2322 1050 1744
+Q 1050 1159 1303 793
+Q 1556 428 2031 428
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Regular-24a" d="M 1916 -75
+Q 1441 -75 1083 150
+Q 725 375 525 781
+Q 325 1188 325 1725
+Q 325 2272 525 2680
+Q 725 3088 1083 3313
+Q 1441 3538 1916 3538
+Q 2422 3538 2805 3283
+Q 3188 3028 3331 2572
+L 2791 2419
+Q 2713 2688 2486 2861
+Q 2259 3034 1916 3034
+Q 1566 3034 1341 2851
+Q 1116 2669 1006 2372
+Q 897 2075 897 1725
+Q 897 1381 1006 1086
+Q 1116 791 1341 609
+Q 1566 428 1916 428
+Q 2269 428 2498 608
+Q 2728 788 2806 1072
+L 3344 919
+Q 3203 453 2815 189
+Q 2428 -75 1916 -75
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Regular-29e" d="M 1056 2094
+L 1056 0
+L 494 0
+L 494 4656
+L 1056 4656
+L 1056 2888
+Q 1228 3238 1495 3388
+Q 1763 3538 2106 3538
+Q 2638 3538 2964 3209
+Q 3291 2881 3291 2219
+L 3291 0
+L 2725 0
+L 2725 2172
+Q 2725 2575 2514 2803
+Q 2303 3031 1938 3031
+Q 1559 3031 1307 2786
+Q 1056 2541 1056 2094
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Regular-2fe" d="M 494 0
+L 494 3494
+L 1041 3494
+L 1044 2853
+Q 1172 3206 1442 3381
+Q 1713 3556 2022 3556
+Q 2366 3556 2592 3361
+Q 2819 3166 2913 2844
+Q 3038 3175 3336 3365
+Q 3634 3556 4013 3556
+Q 4316 3556 4566 3425
+Q 4816 3294 4964 3028
+Q 5113 2763 5113 2356
+L 5113 0
+L 4550 0
+L 4550 2341
+Q 4550 2719 4337 2881
+Q 4125 3044 3844 3044
+Q 3491 3044 3287 2828
+Q 3084 2613 3084 2281
+L 3084 0
+L 2522 0
+L 2522 2397
+Q 2522 2688 2328 2866
+Q 2134 3044 1838 3044
+Q 1531 3044 1293 2831
+Q 1056 2619 1056 2200
+L 1056 0
+L 494 0
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Regular-2d7" d="M 494 0
+L 494 4656
+L 1056 4656
+L 1056 1953
+L 1125 1953
+L 2619 3494
+L 3316 3494
+L 1853 1994
+L 3425 0
+L 2703 0
+L 1425 1634
+L 1056 1288
+L 1056 0
+L 494 0
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Regular-5dd" d="M 400 -1122
+L 675 650
+L 1319 650
+L 831 -1122
+L 400 -1122
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Regular-53f" d="M 481 0
+L 481 428
+L 2028 2106
+Q 2288 2388 2459 2600
+Q 2631 2813 2718 3005
+Q 2806 3197 2806 3413
+Q 2806 3778 2554 3990
+Q 2303 4203 1931 4203
+Q 1534 4203 1298 3965
+Q 1063 3728 1063 3334
+L 494 3334
+Q 494 3747 684 4059
+Q 875 4372 1203 4545
+Q 1531 4719 1947 4719
+Q 2363 4719 2683 4545
+Q 3003 4372 3186 4078
+Q 3369 3784 3369 3419
+Q 3369 3166 3278 2927
+Q 3188 2688 2959 2384
+Q 2731 2081 2319 1644
+L 1300 559
+L 1300 522
+L 3447 522
+L 3447 0
+L 481 0
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Regular-53e" d="M 2041 4656
+L 2041 0
+L 1456 0
+L 1456 4106
+L 1425 4106
+L 300 3272
+L 300 3909
+L 1313 4656
+L 2041 4656
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Regular-316" d="M 1916 -75
+Q 1441 -75 1083 150
+Q 725 375 525 781
+Q 325 1188 325 1725
+Q 325 2272 525 2680
+Q 725 3088 1083 3313
+Q 1441 3538 1916 3538
+Q 2394 3538 2753 3313
+Q 3113 3088 3313 2680
+Q 3513 2272 3513 1725
+Q 3513 1188 3313 781
+Q 3113 375 2753 150
+Q 2394 -75 1916 -75
+z
+M 1916 428
+Q 2269 428 2497 609
+Q 2725 791 2834 1086
+Q 2944 1381 2944 1725
+Q 2944 2072 2834 2370
+Q 2725 2669 2497 2851
+Q 2269 3034 1916 3034
+Q 1566 3034 1341 2851
+Q 1116 2669 1006 2372
+Q 897 2075 897 1725
+Q 897 1381 1006 1086
+Q 1116 791 1341 609
+Q 1566 428 1916 428
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Regular-53d" d="M 2019 -63
+Q 1241 -63 811 562
+Q 381 1188 381 2325
+Q 381 3456 814 4087
+Q 1247 4719 2019 4719
+Q 2794 4719 3225 4087
+Q 3656 3456 3656 2325
+Q 3656 1188 3228 562
+Q 2800 -63 2019 -63
+z
+M 2019 456
+Q 2531 456 2807 948
+Q 3084 1441 3084 2325
+Q 3084 3216 2807 3709
+Q 2531 4203 2019 4203
+Q 1509 4203 1231 3708
+Q 953 3213 953 2325
+Q 953 1441 1231 948
+Q 1509 456 2019 456
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Regular-545" d="M 2019 -63
+Q 1728 -63 1437 43
+Q 1147 150 908 400
+Q 669 650 525 1078
+Q 381 1506 381 2150
+Q 381 3378 840 4048
+Q 1300 4719 2091 4719
+Q 2481 4719 2790 4562
+Q 3100 4406 3297 4128
+Q 3494 3850 3550 3484
+L 2969 3484
+Q 2891 3788 2672 3991
+Q 2453 4194 2091 4194
+Q 1553 4194 1248 3730
+Q 944 3266 944 2425
+L 981 2425
+Q 1169 2716 1467 2880
+Q 1766 3044 2128 3044
+Q 2528 3044 2859 2847
+Q 3191 2650 3389 2301
+Q 3588 1953 3588 1503
+Q 3588 1069 3394 714
+Q 3200 359 2847 148
+Q 2494 -63 2019 -63
+z
+M 2019 459
+Q 2300 459 2525 600
+Q 2750 741 2881 977
+Q 3013 1213 3013 1503
+Q 3013 1788 2886 2020
+Q 2759 2253 2537 2390
+Q 2316 2528 2034 2528
+Q 1753 2528 1525 2384
+Q 1297 2241 1162 2005
+Q 1028 1769 1028 1497
+Q 1028 1222 1156 986
+Q 1284 750 1509 604
+Q 1734 459 2019 459
+z
+" transform="scale(0.015625)"/>
+ </defs>
+ <use xlink:href="#Inter-Regular-141"/>
+ <use xlink:href="#Inter-Regular-287" transform="translate(76.46875 0)"/>
+ <use xlink:href="#Inter-Regular-287" transform="translate(109.578125 0)"/>
+ <use xlink:href="#Inter-Regular-2e0" transform="translate(146.59375 0)"/>
+ <use xlink:href="#Inter-Regular-2b1" transform="translate(170.8125 0)"/>
+ <use xlink:href="#Inter-Regular-305" transform="translate(195.03125 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(254.109375 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(312.40625 0)"/>
+ <use xlink:href="#Inter-Regular-354" transform="translate(340.53125 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(376.515625 0)"/>
+ <use xlink:href="#Inter-Regular-379" transform="translate(434.8125 0)"/>
+ <use xlink:href="#Inter-Regular-354" transform="translate(467.53125 0)"/>
+ <use xlink:href="#Inter-Regular-2b1" transform="translate(506.15625 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(530.375 0)"/>
+ <use xlink:href="#Inter-Regular-3d4" transform="translate(586.71875 0)"/>
+ <use xlink:href="#Inter-Regular-1fb" transform="translate(642.4375 0)"/>
+ <use xlink:href="#Inter-Regular-2e0" transform="translate(698.59375 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(722.8125 0)"/>
+ <use xlink:href="#Inter-Regular-242" transform="translate(750.9375 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(812.171875 0)"/>
+ <use xlink:href="#Inter-Regular-305" transform="translate(870.46875 0)"/>
+ <use xlink:href="#Inter-Regular-24a" transform="translate(929.546875 0)"/>
+ <use xlink:href="#Inter-Regular-29e" transform="translate(986.671875 0)"/>
+ <use xlink:href="#Inter-Regular-2fe" transform="translate(1045.796875 0)"/>
+ <use xlink:href="#Inter-Regular-1fb" transform="translate(1133.390625 0)"/>
+ <use xlink:href="#Inter-Regular-354" transform="translate(1189.546875 0)"/>
+ <use xlink:href="#Inter-Regular-2d7" transform="translate(1228.75 0)"/>
+ <use xlink:href="#Inter-Regular-5dd" transform="translate(1283.640625 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(1312.453125 0)"/>
+ <use xlink:href="#Inter-Regular-53f" transform="translate(1340.578125 0)"/>
+ <use xlink:href="#Inter-Regular-53e" transform="translate(1401.5625 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(1442.234375 0)"/>
+ <use xlink:href="#Inter-Regular-141" transform="translate(1470.359375 0)"/>
+ <use xlink:href="#Inter-Regular-24a" transform="translate(1546.828125 0)"/>
+ <use xlink:href="#Inter-Regular-379" transform="translate(1603.953125 0)"/>
+ <use xlink:href="#Inter-Regular-316" transform="translate(1635.703125 0)"/>
+ <use xlink:href="#Inter-Regular-242" transform="translate(1695.671875 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(1756.90625 0)"/>
+ <use xlink:href="#Inter-Regular-354" transform="translate(1815.203125 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(1852.84375 0)"/>
+ <use xlink:href="#Inter-Regular-53f" transform="translate(1880.96875 0)"/>
+ <use xlink:href="#Inter-Regular-53d" transform="translate(1941.953125 0)"/>
+ <use xlink:href="#Inter-Regular-53f" transform="translate(2005.046875 0)"/>
+ <use xlink:href="#Inter-Regular-545" transform="translate(2066.03125 0)"/>
+ </g>
+ </g>
+ <g id="text_3">
+ <!-- Graphicle 0.1.3 -->
+ <g style="fill: #2e3440" transform="translate(698.296875 60) scale(0.18 -0.18)">
+ <defs>
+ <path id="Inter-Medium-8d" d="M 2472 -63
+Q 1841 -63 1362 228
+Q 884 519 618 1053
+Q 353 1588 353 2325
+Q 353 3069 623 3605
+Q 894 4141 1366 4430
+Q 1838 4719 2441 4719
+Q 2944 4719 3353 4523
+Q 3763 4328 4030 3983
+Q 4297 3638 4375 3184
+L 3644 3184
+Q 3516 3594 3211 3831
+Q 2906 4069 2447 4069
+Q 2053 4069 1739 3869
+Q 1425 3669 1242 3280
+Q 1059 2891 1059 2328
+Q 1059 1766 1242 1378
+Q 1425 991 1744 789
+Q 2063 588 2475 588
+Q 3028 588 3367 914
+Q 3706 1241 3719 1800
+L 2578 1800
+L 2578 2388
+L 4416 2388
+L 4416 1853
+Q 4416 1266 4164 836
+Q 3913 406 3475 171
+Q 3038 -63 2472 -63
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Medium-354" d="M 463 0
+L 463 3494
+L 1128 3494
+L 1128 2931
+L 1166 2931
+Q 1259 3216 1501 3380
+Q 1744 3544 2050 3544
+Q 2116 3544 2202 3537
+Q 2288 3531 2341 3525
+L 2341 2869
+Q 2303 2878 2197 2892
+Q 2091 2906 1981 2906
+Q 1622 2906 1386 2686
+Q 1150 2466 1150 2122
+L 1150 0
+L 463 0
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Medium-1fb" d="M 1441 -78
+Q 1106 -78 839 45
+Q 572 169 415 406
+Q 259 644 259 988
+Q 259 1284 375 1476
+Q 491 1669 684 1780
+Q 878 1891 1117 1947
+Q 1356 2003 1603 2031
+Q 2066 2084 2275 2123
+Q 2484 2163 2484 2347
+L 2484 2366
+Q 2484 2656 2314 2817
+Q 2144 2978 1816 2978
+Q 1472 2978 1275 2828
+Q 1078 2678 1006 2500
+L 359 2669
+Q 478 2981 700 3172
+Q 922 3363 1208 3450
+Q 1494 3538 1806 3538
+Q 2016 3538 2253 3488
+Q 2491 3438 2700 3308
+Q 2909 3178 3040 2937
+Q 3172 2697 3172 2319
+L 3172 0
+L 2506 0
+L 2506 478
+L 2472 478
+Q 2369 272 2117 97
+Q 1866 -78 1441 -78
+z
+M 1594 475
+Q 1872 475 2072 586
+Q 2272 697 2380 875
+Q 2488 1053 2488 1259
+L 2488 1706
+Q 2438 1656 2273 1620
+Q 2109 1584 1928 1559
+Q 1747 1534 1641 1522
+Q 1350 1481 1142 1364
+Q 934 1247 934 978
+Q 934 728 1120 601
+Q 1306 475 1594 475
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Medium-34b" d="M 463 -1306
+L 463 3494
+L 1131 3494
+L 1131 2925
+L 1188 2925
+Q 1247 3031 1358 3176
+Q 1469 3322 1669 3430
+Q 1869 3538 2197 3538
+Q 2616 3538 2945 3325
+Q 3275 3113 3465 2709
+Q 3656 2306 3656 1738
+Q 3656 1175 3468 769
+Q 3281 363 2951 147
+Q 2622 -69 2197 -69
+Q 1878 -69 1678 39
+Q 1478 147 1364 290
+Q 1250 434 1188 547
+L 1150 547
+L 1150 -1306
+L 463 -1306
+z
+M 2044 516
+Q 2344 516 2545 678
+Q 2747 841 2850 1119
+Q 2953 1397 2953 1744
+Q 2953 2088 2851 2361
+Q 2750 2634 2548 2793
+Q 2347 2953 2044 2953
+Q 1600 2953 1369 2620
+Q 1138 2288 1138 1744
+Q 1138 1197 1372 856
+Q 1606 516 2044 516
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Medium-29e" d="M 1150 2069
+L 1150 0
+L 463 0
+L 463 4656
+L 1144 4656
+L 1144 2866
+Q 1309 3213 1575 3375
+Q 1841 3538 2200 3538
+Q 2734 3538 3062 3202
+Q 3391 2866 3391 2219
+L 3391 0
+L 2700 0
+L 2700 2134
+Q 2700 2513 2503 2725
+Q 2306 2938 1963 2938
+Q 1613 2938 1381 2711
+Q 1150 2484 1150 2069
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Medium-2b1" d="M 463 0
+L 463 3494
+L 1150 3494
+L 1150 0
+L 463 0
+z
+M 809 4028
+Q 631 4028 504 4147
+Q 378 4266 378 4434
+Q 378 4606 504 4725
+Q 631 4844 809 4844
+Q 987 4844 1115 4725
+Q 1243 4606 1243 4434
+Q 1243 4266 1115 4147
+Q 987 4028 809 4028
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Medium-24a" d="M 1931 -72
+Q 1438 -72 1072 153
+Q 706 378 503 783
+Q 300 1188 300 1728
+Q 300 2272 503 2680
+Q 706 3088 1072 3313
+Q 1438 3538 1931 3538
+Q 2475 3538 2870 3264
+Q 3266 2991 3394 2506
+L 2741 2350
+Q 2669 2622 2461 2789
+Q 2253 2956 1934 2956
+Q 1619 2956 1411 2790
+Q 1203 2625 1101 2345
+Q 1000 2066 1000 1728
+Q 1000 1394 1101 1117
+Q 1203 841 1411 675
+Q 1619 509 1934 509
+Q 2259 509 2471 682
+Q 2684 856 2753 1141
+L 3403 984
+Q 3275 491 2878 209
+Q 2481 -72 1931 -72
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Medium-2e0" d="M 1150 4656
+L 1150 0
+L 463 0
+L 463 4656
+L 1150 4656
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Medium-266" d="M 1969 -72
+Q 1453 -72 1078 150
+Q 703 372 501 775
+Q 300 1178 300 1722
+Q 300 2259 498 2668
+Q 697 3078 1059 3308
+Q 1422 3538 1909 3538
+Q 2306 3538 2664 3361
+Q 3022 3184 3245 2798
+Q 3469 2413 3469 1781
+L 3469 1538
+L 991 1538
+Q 1009 1031 1278 764
+Q 1547 497 1975 497
+Q 2263 497 2470 622
+Q 2678 747 2769 991
+L 3416 838
+Q 3291 428 2909 178
+Q 2528 -72 1969 -72
+z
+M 994 2050
+L 2788 2050
+Q 2750 2463 2529 2716
+Q 2309 2969 1913 2969
+Q 1500 2969 1261 2698
+Q 1022 2428 994 2050
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Medium-6f1" transform="scale(0.015625)"/>
+ <path id="Inter-Medium-53d" d="M 2066 -63
+Q 1253 -63 803 562
+Q 353 1188 353 2325
+Q 353 3456 804 4087
+Q 1256 4719 2066 4719
+Q 2875 4719 3326 4087
+Q 3778 3456 3778 2325
+Q 3778 1191 3329 564
+Q 2881 -63 2066 -63
+z
+M 2066 547
+Q 2550 547 2811 1012
+Q 3072 1478 3072 2325
+Q 3072 3175 2811 3644
+Q 2550 4113 2066 4113
+Q 1581 4113 1318 3642
+Q 1056 3172 1056 2325
+Q 1056 1478 1318 1012
+Q 1581 547 2066 547
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Medium-5de" d="M 972 -47
+Q 778 -47 643 86
+Q 509 219 509 413
+Q 509 606 643 740
+Q 778 875 972 875
+Q 1166 875 1298 740
+Q 1431 606 1431 413
+Q 1431 219 1298 86
+Q 1166 -47 972 -47
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Medium-53e" d="M 2141 4656
+L 2141 0
+L 1434 0
+L 1434 4009
+L 1403 4009
+L 297 3203
+L 297 3919
+L 1316 4656
+L 2141 4656
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Medium-541" d="M 2009 -63
+Q 1538 -63 1170 100
+Q 803 263 589 550
+Q 375 838 363 1219
+L 1084 1219
+Q 1103 909 1365 729
+Q 1628 550 2003 550
+Q 2409 550 2673 758
+Q 2938 966 2938 1303
+Q 2938 1650 2672 1870
+Q 2406 2091 1928 2091
+L 1531 2091
+L 1531 2672
+L 1928 2672
+Q 2313 2672 2555 2873
+Q 2797 3075 2797 3409
+Q 2797 3731 2584 3926
+Q 2372 4122 2016 4122
+Q 1678 4122 1418 3942
+Q 1159 3763 1147 3444
+L 459 3444
+Q 472 3822 683 4109
+Q 894 4397 1245 4558
+Q 1597 4719 2028 4719
+Q 2475 4719 2804 4544
+Q 3134 4369 3312 4080
+Q 3491 3791 3491 3450
+Q 3491 3056 3272 2786
+Q 3053 2516 2688 2419
+L 2688 2384
+Q 3153 2313 3406 2014
+Q 3659 1716 3659 1278
+Q 3659 891 3445 587
+Q 3231 284 2859 110
+Q 2488 -63 2009 -63
+z
+" transform="scale(0.015625)"/>
+ </defs>
+ <use xlink:href="#Inter-Medium-8d"/>
+ <use xlink:href="#Inter-Medium-354" transform="translate(74.75 0)"/>
+ <use xlink:href="#Inter-Medium-1fb" transform="translate(112.984375 0)"/>
+ <use xlink:href="#Inter-Medium-34b" transform="translate(169.765625 0)"/>
+ <use xlink:href="#Inter-Medium-29e" transform="translate(231.578125 0)"/>
+ <use xlink:href="#Inter-Medium-2b1" transform="translate(291.734375 0)"/>
+ <use xlink:href="#Inter-Medium-24a" transform="translate(316.9375 0)"/>
+ <use xlink:href="#Inter-Medium-2e0" transform="translate(374.65625 0)"/>
+ <use xlink:href="#Inter-Medium-266" transform="translate(399.859375 0)"/>
+ <use xlink:href="#Inter-Medium-6f1" transform="translate(458.59375 0)"/>
+ <use xlink:href="#Inter-Medium-53d" transform="translate(485.25 0)"/>
+ <use xlink:href="#Inter-Medium-5de" transform="translate(547.109375 0)"/>
+ <use xlink:href="#Inter-Medium-53e" transform="translate(568.65625 0)"/>
+ <use xlink:href="#Inter-Medium-5de" transform="translate(610.15625 0)"/>
+ <use xlink:href="#Inter-Medium-541" transform="translate(637.953125 0)"/>
+ </g>
+ </g>
+ <g id="text_4">
+ <!-- Graphicle 0.1.2 -->
+ <g style="fill: #2e3440" transform="translate(876.40625 60) scale(0.18 -0.18)">
+ <defs>
+ <path id="Inter-Medium-53f" d="M 450 0
+L 450 516
+L 2031 2150
+Q 2394 2531 2581 2797
+Q 2769 3063 2769 3369
+Q 2769 3719 2533 3920
+Q 2297 4122 1944 4122
+Q 1572 4122 1350 3898
+Q 1128 3675 1128 3300
+L 444 3300
+Q 444 3725 641 4045
+Q 838 4366 1180 4542
+Q 1522 4719 1956 4719
+Q 2400 4719 2736 4544
+Q 3072 4369 3262 4070
+Q 3453 3772 3453 3394
+Q 3453 3141 3358 2895
+Q 3263 2650 3023 2344
+Q 2784 2038 2350 1600
+L 1438 647
+L 1438 609
+L 3525 609
+L 3525 0
+L 450 0
+z
+" transform="scale(0.015625)"/>
+ </defs>
+ <use xlink:href="#Inter-Medium-8d"/>
+ <use xlink:href="#Inter-Medium-354" transform="translate(74.75 0)"/>
+ <use xlink:href="#Inter-Medium-1fb" transform="translate(112.984375 0)"/>
+ <use xlink:href="#Inter-Medium-34b" transform="translate(169.765625 0)"/>
+ <use xlink:href="#Inter-Medium-29e" transform="translate(231.578125 0)"/>
+ <use xlink:href="#Inter-Medium-2b1" transform="translate(291.734375 0)"/>
+ <use xlink:href="#Inter-Medium-24a" transform="translate(316.9375 0)"/>
+ <use xlink:href="#Inter-Medium-2e0" transform="translate(374.65625 0)"/>
+ <use xlink:href="#Inter-Medium-266" transform="translate(399.859375 0)"/>
+ <use xlink:href="#Inter-Medium-6f1" transform="translate(458.59375 0)"/>
+ <use xlink:href="#Inter-Medium-53d" transform="translate(485.25 0)"/>
+ <use xlink:href="#Inter-Medium-5de" transform="translate(547.109375 0)"/>
+ <use xlink:href="#Inter-Medium-53e" transform="translate(568.65625 0)"/>
+ <use xlink:href="#Inter-Medium-5de" transform="translate(610.15625 0)"/>
+ <use xlink:href="#Inter-Medium-53f" transform="translate(640.484375 0)"/>
+ </g>
+ </g>
+ <g id="text_5">
+ <!-- BM25 (SWE-bench style) -->
+ <g style="fill: #2e3440" transform="translate(1054.78125 60) scale(0.18 -0.18)">
+ <defs>
+ <path id="Inter-Medium-41" d="M 516 0
+L 516 4656
+L 2231 4656
+Q 2725 4656 3050 4493
+Q 3375 4331 3536 4054
+Q 3697 3778 3697 3434
+Q 3697 2997 3465 2764
+Q 3234 2531 2909 2450
+L 2909 2403
+Q 3144 2391 3366 2255
+Q 3588 2119 3733 1866
+Q 3878 1613 3878 1256
+Q 3878 897 3711 612
+Q 3544 328 3195 164
+Q 2847 0 2306 0
+L 516 0
+z
+M 1228 613
+L 2234 613
+Q 2738 613 2955 806
+Q 3172 1000 3172 1291
+Q 3172 1619 2926 1855
+Q 2681 2091 2263 2091
+L 1228 2091
+L 1228 613
+z
+M 1228 2641
+L 2163 2641
+Q 2516 2641 2756 2841
+Q 2997 3041 2997 3375
+Q 2997 3663 2795 3855
+Q 2594 4047 2181 4047
+L 1228 4047
+L 1228 2641
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Medium-124" d="M 516 0
+L 516 4656
+L 1566 4656
+L 2581 1984
+Q 2628 1859 2687 1661
+Q 2747 1463 2809 1234
+Q 2872 1006 2925 794
+Q 2981 1000 3043 1228
+Q 3106 1456 3165 1656
+Q 3225 1856 3272 1984
+L 4272 4656
+L 5328 4656
+L 5328 0
+L 4619 0
+L 4619 2506
+Q 4619 2763 4626 3167
+Q 4634 3572 4644 3963
+Q 4563 3678 4475 3400
+Q 4388 3122 4309 2886
+Q 4231 2650 4178 2506
+L 3225 0
+L 2616 0
+L 1650 2506
+Q 1569 2716 1442 3116
+Q 1316 3516 1181 3947
+Q 1188 3703 1194 3437
+Q 1200 3172 1204 2928
+Q 1209 2684 1209 2506
+L 1209 0
+L 516 0
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Medium-543" d="M 1897 -63
+Q 1463 -63 1122 103
+Q 781 269 579 559
+Q 378 850 363 1219
+L 1056 1219
+Q 1081 919 1322 728
+Q 1563 538 1897 538
+Q 2294 538 2551 806
+Q 2809 1075 2809 1494
+Q 2809 1775 2687 1997
+Q 2566 2219 2353 2345
+Q 2141 2472 1866 2472
+Q 1653 2472 1440 2398
+Q 1228 2325 1100 2209
+L 444 2303
+L 703 4656
+L 3275 4656
+L 3275 4047
+L 1300 4047
+L 1153 2747
+L 1178 2747
+Q 1316 2884 1542 2970
+Q 1769 3056 2031 3056
+Q 2456 3056 2789 2856
+Q 3122 2656 3314 2306
+Q 3506 1956 3506 1506
+Q 3506 1053 3300 698
+Q 3094 344 2730 140
+Q 2366 -63 1897 -63
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Medium-5a6" d="M 631 2191
+Q 631 2700 734 3259
+Q 838 3819 1020 4334
+Q 1203 4850 1438 5235
+L 2091 5235
+Q 1853 4744 1683 4216
+Q 1513 3688 1422 3169
+Q 1331 2650 1331 2191
+Q 1331 1572 1512 920
+Q 1694 269 2091 -578
+L 1438 -578
+Q 1038 94 834 797
+Q 631 1500 631 2191
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Medium-18d" d="M 2078 -78
+Q 1294 -78 828 289
+Q 363 656 331 1294
+L 1047 1294
+Q 1078 913 1375 730
+Q 1672 547 2075 547
+Q 2519 547 2809 753
+Q 3100 959 3100 1297
+Q 3100 1600 2845 1748
+Q 2591 1897 2216 1997
+L 1672 2147
+Q 1100 2300 779 2600
+Q 459 2900 459 3378
+Q 459 3781 676 4082
+Q 894 4384 1267 4551
+Q 1641 4719 2109 4719
+Q 2588 4719 2952 4551
+Q 3316 4384 3523 4092
+Q 3731 3800 3741 3431
+L 3047 3431
+Q 3013 3750 2752 3925
+Q 2491 4100 2094 4100
+Q 1672 4100 1422 3908
+Q 1172 3716 1172 3419
+Q 1172 3197 1306 3061
+Q 1441 2925 1636 2845
+Q 1831 2766 2009 2719
+L 2463 2600
+Q 2684 2544 2920 2448
+Q 3156 2353 3356 2201
+Q 3556 2050 3679 1826
+Q 3803 1603 3803 1288
+Q 3803 894 3600 584
+Q 3397 275 3011 98
+Q 2625 -78 2078 -78
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Medium-1cb" d="M 1422 0
+L 159 4656
+L 909 4656
+L 1581 1988
+Q 1656 1681 1722 1348
+Q 1788 1016 1847 678
+Q 1913 1016 1980 1348
+Q 2047 1681 2128 1988
+L 2819 4656
+L 3600 4656
+L 4284 1988
+Q 4363 1684 4431 1356
+Q 4500 1028 4566 697
+Q 4625 1028 4692 1356
+Q 4759 1684 4831 1988
+L 5503 4656
+L 6259 4656
+L 4991 0
+L 4169 0
+L 3428 2759
+Q 3366 2994 3311 3259
+Q 3256 3525 3206 3828
+Q 3156 3541 3104 3280
+Q 3053 3019 2984 2759
+L 2247 0
+L 1422 0
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Medium-5f" d="M 516 0
+L 516 4656
+L 3447 4656
+L 3447 4044
+L 1228 4044
+L 1228 2656
+L 3291 2656
+L 3291 2047
+L 1228 2047
+L 1228 613
+L 3466 613
+L 3466 0
+L 516 0
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Medium-5b3" d="M 2516 2263
+L 2516 1666
+L 447 1666
+L 447 2263
+L 2516 2263
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Medium-242" d="M 2197 -69
+Q 1878 -69 1678 39
+Q 1478 147 1364 290
+Q 1250 434 1188 547
+L 1131 547
+L 1131 0
+L 463 0
+L 463 4656
+L 1150 4656
+L 1150 2925
+L 1188 2925
+Q 1247 3031 1358 3176
+Q 1469 3322 1669 3430
+Q 1869 3538 2197 3538
+Q 2616 3538 2945 3325
+Q 3275 3113 3465 2709
+Q 3656 2306 3656 1738
+Q 3656 1175 3468 769
+Q 3281 363 2951 147
+Q 2622 -69 2197 -69
+z
+M 2044 516
+Q 2344 516 2545 678
+Q 2747 841 2850 1119
+Q 2953 1397 2953 1744
+Q 2953 2088 2851 2361
+Q 2750 2634 2548 2793
+Q 2347 2953 2044 2953
+Q 1600 2953 1369 2620
+Q 1138 2288 1138 1744
+Q 1138 1197 1372 856
+Q 1606 516 2044 516
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Medium-305" d="M 1150 2069
+L 1150 0
+L 463 0
+L 463 3494
+L 1119 3494
+L 1122 2822
+Q 1284 3191 1557 3364
+Q 1831 3538 2200 3538
+Q 2734 3538 3061 3202
+Q 3388 2866 3388 2219
+L 3388 0
+L 2700 0
+L 2700 2134
+Q 2700 2513 2503 2725
+Q 2306 2938 1963 2938
+Q 1613 2938 1381 2711
+Q 1150 2484 1150 2069
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Medium-367" d="M 1716 -72
+Q 1147 -72 773 173
+Q 400 419 306 884
+L 953 1019
+Q 1094 484 1722 484
+Q 2056 484 2251 623
+Q 2447 763 2447 956
+Q 2447 1288 1956 1397
+L 1369 1531
+Q 406 1747 406 2497
+Q 406 2809 579 3043
+Q 753 3278 1058 3408
+Q 1363 3538 1759 3538
+Q 2325 3538 2647 3295
+Q 2969 3053 3081 2666
+L 2466 2531
+Q 2400 2716 2237 2855
+Q 2075 2994 1766 2994
+Q 1481 2994 1290 2866
+Q 1100 2738 1100 2541
+Q 1100 2366 1226 2258
+Q 1353 2150 1641 2084
+L 2203 1959
+Q 3156 1744 3156 1016
+Q 3156 697 2973 451
+Q 2791 206 2466 67
+Q 2141 -72 1716 -72
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Medium-379" d="M 1956 3494
+L 1956 2934
+L 1259 2934
+L 1259 944
+Q 1259 734 1348 636
+Q 1438 538 1641 538
+Q 1697 538 1783 550
+Q 1869 563 1931 575
+L 2053 25
+Q 1944 -13 1817 -30
+Q 1691 -47 1572 -47
+Q 1097 -47 834 198
+Q 572 444 572 888
+L 572 2934
+L 63 2934
+L 63 3494
+L 572 3494
+L 572 4325
+L 1259 4325
+L 1259 3494
+L 1956 3494
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Medium-3e6" d="M 416 -1256
+L 584 -697
+L 663 -716
+Q 928 -788 1114 -698
+Q 1300 -609 1397 -272
+L 1472 -16
+L 144 3494
+L 888 3494
+L 1578 1509
+Q 1656 1278 1715 1053
+Q 1775 828 1831 603
+Q 1891 828 1953 1054
+Q 2016 1281 2097 1509
+L 2800 3494
+L 3538 3494
+L 2019 -484
+Q 1859 -903 1589 -1117
+Q 1319 -1331 897 -1331
+Q 734 -1331 607 -1307
+Q 481 -1284 416 -1256
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Medium-59e" d="M 269 -872
+Q 541 -294 708 182
+Q 875 659 953 1076
+Q 1031 1494 1031 1897
+Q 1031 2356 939 2875
+Q 847 3394 676 3922
+Q 506 4450 269 4941
+L 925 4941
+Q 1159 4559 1340 4042
+Q 1522 3525 1626 2965
+Q 1731 2406 1731 1897
+Q 1731 1197 1523 494
+Q 1316 -209 925 -872
+L 269 -872
+z
+" transform="scale(0.015625)"/>
+ </defs>
+ <use xlink:href="#Inter-Medium-41"/>
+ <use xlink:href="#Inter-Medium-124" transform="translate(65.671875 0)"/>
+ <use xlink:href="#Inter-Medium-53f" transform="translate(156.9375 0)"/>
+ <use xlink:href="#Inter-Medium-543" transform="translate(218.5625 0)"/>
+ <use xlink:href="#Inter-Medium-6f1" transform="translate(278.859375 0)"/>
+ <use xlink:href="#Inter-Medium-5a6" transform="translate(305.515625 0)"/>
+ <use xlink:href="#Inter-Medium-18d" transform="translate(342.375 0)"/>
+ <use xlink:href="#Inter-Medium-1cb" transform="translate(406.96875 0)"/>
+ <use xlink:href="#Inter-Medium-5f" transform="translate(507.265625 0)"/>
+ <use xlink:href="#Inter-Medium-5b3" transform="translate(567.5625 0)"/>
+ <use xlink:href="#Inter-Medium-242" transform="translate(613.796875 0)"/>
+ <use xlink:href="#Inter-Medium-266" transform="translate(675.609375 0)"/>
+ <use xlink:href="#Inter-Medium-305" transform="translate(734.34375 0)"/>
+ <use xlink:href="#Inter-Medium-24a" transform="translate(794.5 0)"/>
+ <use xlink:href="#Inter-Medium-29e" transform="translate(852.21875 0)"/>
+ <use xlink:href="#Inter-Medium-6f1" transform="translate(912.375 0)"/>
+ <use xlink:href="#Inter-Medium-367" transform="translate(939.03125 0)"/>
+ <use xlink:href="#Inter-Medium-379" transform="translate(992.890625 0)"/>
+ <use xlink:href="#Inter-Medium-3e6" transform="translate(1028.96875 0)"/>
+ <use xlink:href="#Inter-Medium-2e0" transform="translate(1086.875 0)"/>
+ <use xlink:href="#Inter-Medium-266" transform="translate(1112.078125 0)"/>
+ <use xlink:href="#Inter-Medium-59e" transform="translate(1169.640625 0)"/>
+ </g>
+ </g>
+ <g id="text_6">
+ <!-- grep for the issue's names -->
+ <g style="fill: #2e3440" transform="translate(1324 60) scale(0.18 -0.18)">
+ <defs>
+ <path id="Inter-Medium-292" d="M 1925 -1381
+Q 1319 -1381 953 -1159
+Q 588 -938 441 -622
+L 1016 -350
+Q 1078 -450 1183 -561
+Q 1288 -672 1464 -750
+Q 1641 -828 1922 -828
+Q 2319 -828 2569 -639
+Q 2819 -450 2819 -47
+L 2819 634
+L 2759 634
+Q 2697 519 2586 384
+Q 2475 250 2276 151
+Q 2078 53 1759 53
+Q 1347 53 1017 247
+Q 688 441 494 820
+Q 300 1200 300 1759
+Q 300 2316 492 2714
+Q 684 3113 1015 3325
+Q 1347 3538 1769 3538
+Q 2091 3538 2292 3430
+Q 2494 3322 2608 3178
+Q 2722 3034 2781 2925
+L 2831 2925
+L 2831 3494
+L 3503 3494
+L 3503 -50
+Q 3503 -509 3293 -803
+Q 3084 -1097 2728 -1239
+Q 2372 -1381 1925 -1381
+z
+M 1919 625
+Q 2356 625 2589 928
+Q 2822 1231 2822 1769
+Q 2822 2294 2592 2623
+Q 2363 2953 1919 2953
+Q 1616 2953 1411 2795
+Q 1206 2638 1104 2370
+Q 1003 2103 1003 1769
+Q 1003 1256 1236 940
+Q 1469 625 1919 625
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Medium-287" d="M 2194 3494
+L 2194 2934
+L 1413 2934
+L 1413 0
+L 725 0
+L 725 2934
+L 63 2934
+L 63 3494
+L 725 3494
+L 725 3894
+Q 725 4219 870 4437
+Q 1016 4656 1252 4765
+Q 1488 4875 1766 4875
+Q 1972 4875 2120 4842
+Q 2269 4809 2341 4781
+L 2181 4225
+Q 2131 4238 2056 4256
+Q 1981 4275 1875 4275
+Q 1628 4275 1520 4153
+Q 1413 4031 1413 3800
+L 1413 3494
+L 2194 3494
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Medium-316" d="M 1931 -72
+Q 1441 -72 1073 153
+Q 706 378 503 783
+Q 300 1188 300 1728
+Q 300 2272 503 2680
+Q 706 3088 1073 3313
+Q 1441 3538 1931 3538
+Q 2425 3538 2792 3313
+Q 3159 3088 3362 2680
+Q 3566 2272 3566 1728
+Q 3566 1188 3362 783
+Q 3159 378 2792 153
+Q 2425 -72 1931 -72
+z
+M 1931 509
+Q 2250 509 2458 676
+Q 2666 844 2767 1120
+Q 2869 1397 2869 1728
+Q 2869 2063 2767 2342
+Q 2666 2622 2458 2789
+Q 2250 2956 1931 2956
+Q 1616 2956 1409 2789
+Q 1203 2622 1101 2342
+Q 1000 2063 1000 1728
+Q 1000 1397 1101 1120
+Q 1203 844 1409 676
+Q 1616 509 1931 509
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Medium-393" d="M 1653 -44
+Q 1119 -44 791 292
+Q 463 628 463 1275
+L 463 3494
+L 1150 3494
+L 1150 1359
+Q 1150 981 1348 768
+Q 1547 556 1888 556
+Q 2238 556 2469 782
+Q 2700 1009 2700 1425
+L 2700 3494
+L 3391 3494
+L 3391 0
+L 2731 0
+L 2728 678
+Q 2563 297 2289 126
+Q 2016 -44 1653 -44
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Medium-5cc" d="M 725 2828
+L 647 4656
+L 1353 4656
+L 1275 2828
+L 725 2828
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Medium-2fe" d="M 463 0
+L 463 3494
+L 1116 3494
+L 1131 2841
+Q 1266 3203 1534 3378
+Q 1803 3553 2116 3553
+Q 2456 3553 2681 3359
+Q 2906 3166 3009 2819
+Q 3141 3172 3442 3362
+Q 3744 3553 4116 3553
+Q 4425 3553 4675 3418
+Q 4925 3284 5073 3018
+Q 5222 2753 5222 2356
+L 5222 0
+L 4534 0
+L 4534 2288
+Q 4534 2638 4339 2794
+Q 4144 2950 3878 2950
+Q 3553 2950 3367 2750
+Q 3181 2550 3181 2238
+L 3181 0
+L 2503 0
+L 2503 2331
+Q 2503 2613 2323 2781
+Q 2144 2950 1866 2950
+Q 1578 2950 1364 2751
+Q 1150 2553 1150 2172
+L 1150 0
+L 463 0
+z
+" transform="scale(0.015625)"/>
+ </defs>
+ <use xlink:href="#Inter-Medium-292"/>
+ <use xlink:href="#Inter-Medium-354" transform="translate(61.96875 0)"/>
+ <use xlink:href="#Inter-Medium-266" transform="translate(98.734375 0)"/>
+ <use xlink:href="#Inter-Medium-34b" transform="translate(157.46875 0)"/>
+ <use xlink:href="#Inter-Medium-6f1" transform="translate(219.28125 0)"/>
+ <use xlink:href="#Inter-Medium-287" transform="translate(245.9375 0)"/>
+ <use xlink:href="#Inter-Medium-316" transform="translate(281.1875 0)"/>
+ <use xlink:href="#Inter-Medium-354" transform="translate(341.59375 0)"/>
+ <use xlink:href="#Inter-Medium-6f1" transform="translate(380.265625 0)"/>
+ <use xlink:href="#Inter-Medium-379" transform="translate(406.921875 0)"/>
+ <use xlink:href="#Inter-Medium-29e" transform="translate(441.046875 0)"/>
+ <use xlink:href="#Inter-Medium-266" transform="translate(501.203125 0)"/>
+ <use xlink:href="#Inter-Medium-6f1" transform="translate(559.9375 0)"/>
+ <use xlink:href="#Inter-Medium-2b1" transform="translate(586.59375 0)"/>
+ <use xlink:href="#Inter-Medium-367" transform="translate(611.796875 0)"/>
+ <use xlink:href="#Inter-Medium-367" transform="translate(665.65625 0)"/>
+ <use xlink:href="#Inter-Medium-393" transform="translate(719.515625 0)"/>
+ <use xlink:href="#Inter-Medium-266" transform="translate(779.671875 0)"/>
+ <use xlink:href="#Inter-Medium-5cc" transform="translate(836.75 0)"/>
+ <use xlink:href="#Inter-Medium-367" transform="translate(867.796875 0)"/>
+ <use xlink:href="#Inter-Medium-6f1" transform="translate(921.65625 0)"/>
+ <use xlink:href="#Inter-Medium-305" transform="translate(948.3125 0)"/>
+ <use xlink:href="#Inter-Medium-1fb" transform="translate(1008.46875 0)"/>
+ <use xlink:href="#Inter-Medium-2fe" transform="translate(1065.25 0)"/>
+ <use xlink:href="#Inter-Medium-266" transform="translate(1154.0625 0)"/>
+ <use xlink:href="#Inter-Medium-367" transform="translate(1212.796875 0)"/>
+ </g>
+ </g>
+ <g id="text_7">
+ <!-- Finding the files a fix changes: 100 SWE-bench Verified issues, held out from tuning -->
+ <g style="fill: #0a0b0f" transform="translate(48 112) scale(0.34 -0.34)">
+ <defs>
+ <path id="InterDisplay-SemiBold-89" d="M 388 0
+L 388 4656
+L 3519 4656
+L 3519 3941
+L 1213 3941
+L 1213 2669
+L 3353 2669
+L 3353 1969
+L 1213 1969
+L 1213 0
+L 388 0
+z
+" transform="scale(0.015625)"/>
+ <path id="InterDisplay-SemiBold-2b1" d="M 350 0
+L 350 3300
+L 1138 3300
+L 1138 0
+L 350 0
+z
+M 743 3791
+Q 540 3791 406 3920
+Q 272 4050 272 4241
+Q 272 4431 406 4559
+Q 540 4688 743 4688
+Q 943 4688 1077 4559
+Q 1212 4431 1212 4241
+Q 1212 4050 1077 3920
+Q 943 3791 743 3791
+z
+" transform="scale(0.015625)"/>
+ <path id="InterDisplay-SemiBold-305" d="M 1138 1866
+L 1138 0
+L 350 0
+L 350 3300
+L 1125 3300
+L 1125 2794
+Q 1469 3366 2138 3366
+Q 2656 3366 2986 3031
+Q 3316 2697 3316 2063
+L 3316 0
+L 2525 0
+L 2525 1938
+Q 2525 2300 2350 2487
+Q 2175 2675 1859 2675
+Q 1550 2675 1344 2481
+Q 1138 2288 1138 1866
+z
+" transform="scale(0.015625)"/>
+ <path id="InterDisplay-SemiBold-255" d="M 1625 -66
+Q 1194 -66 872 150
+Q 550 366 373 752
+Q 197 1138 197 1653
+Q 197 2159 375 2545
+Q 553 2931 875 3148
+Q 1197 3366 1619 3366
+Q 1941 3366 2197 3234
+Q 2453 3103 2613 2831
+L 2619 2831
+L 2619 4656
+L 3406 4656
+L 3406 0
+L 2631 0
+L 2631 503
+L 2625 503
+Q 2469 216 2208 75
+Q 1947 -66 1625 -66
+z
+M 1809 594
+Q 2197 594 2430 883
+Q 2663 1172 2663 1653
+Q 2663 2134 2430 2423
+Q 2197 2713 1809 2713
+Q 1444 2713 1219 2438
+Q 994 2163 994 1653
+Q 994 1141 1219 867
+Q 1444 594 1809 594
+z
+" transform="scale(0.015625)"/>
+ <path id="InterDisplay-SemiBold-292" d="M 1847 -1350
+Q 1194 -1350 809 -1069
+Q 425 -788 359 -306
+L 1131 -306
+Q 1188 -519 1378 -630
+Q 1569 -741 1847 -741
+Q 2216 -741 2420 -541
+Q 2625 -341 2625 38
+L 2625 541
+L 2622 541
+Q 2463 250 2206 114
+Q 1950 -22 1625 -22
+Q 1194 -22 872 193
+Q 550 409 373 789
+Q 197 1169 197 1666
+Q 197 2166 375 2550
+Q 553 2934 875 3150
+Q 1197 3366 1619 3366
+Q 1941 3366 2202 3230
+Q 2463 3094 2625 2809
+L 2628 2809
+L 2628 3300
+L 3406 3300
+L 3406 84
+Q 3406 -425 3203 -742
+Q 3000 -1059 2647 -1204
+Q 2294 -1350 1847 -1350
+z
+M 1809 628
+Q 2197 628 2430 914
+Q 2663 1200 2663 1675
+Q 2663 2150 2430 2436
+Q 2197 2722 1809 2722
+Q 1444 2722 1219 2450
+Q 994 2178 994 1675
+Q 994 1169 1219 898
+Q 1444 628 1809 628
+z
+" transform="scale(0.015625)"/>
+ <path id="InterDisplay-SemiBold-6f1" transform="scale(0.015625)"/>
+ <path id="InterDisplay-SemiBold-379" d="M 2091 3300
+L 2091 2666
+L 1419 2666
+L 1419 947
+Q 1419 769 1491 701
+Q 1563 634 1753 634
+L 2091 634
+L 2091 0
+L 1616 0
+Q 1113 0 870 203
+Q 628 406 628 831
+L 628 2666
+L 53 2666
+L 53 3300
+L 628 3300
+L 628 4200
+L 1419 4200
+L 1419 3300
+L 2091 3300
+z
+" transform="scale(0.015625)"/>
+ <path id="InterDisplay-SemiBold-29e" d="M 1138 1866
+L 1138 0
+L 350 0
+L 350 4656
+L 1138 4656
+L 1138 2816
+Q 1481 3366 2138 3366
+Q 2656 3366 2986 3031
+Q 3316 2697 3316 2063
+L 3316 0
+L 2525 0
+L 2525 1938
+Q 2525 2300 2350 2487
+Q 2175 2675 1859 2675
+Q 1550 2675 1344 2481
+Q 1138 2288 1138 1866
+z
+" transform="scale(0.015625)"/>
+ <path id="InterDisplay-SemiBold-266" d="M 1806 -75
+Q 1313 -75 950 147
+Q 588 369 392 758
+Q 197 1147 197 1647
+Q 197 2150 398 2539
+Q 600 2928 956 3151
+Q 1313 3375 1775 3375
+Q 2250 3375 2606 3156
+Q 2963 2938 3159 2552
+Q 3356 2166 3356 1659
+L 3356 1444
+L 969 1444
+Q 984 1041 1206 794
+Q 1428 547 1825 547
+Q 2122 547 2315 676
+Q 2509 806 2578 1019
+L 3316 1019
+Q 3253 697 3042 450
+Q 2831 203 2512 64
+Q 2194 -75 1806 -75
+z
+M 975 1988
+L 2600 1988
+Q 2563 2341 2345 2545
+Q 2128 2750 1788 2750
+Q 1444 2750 1230 2545
+Q 1016 2341 975 1988
+z
+" transform="scale(0.015625)"/>
+ <path id="InterDisplay-SemiBold-287" d="M 2109 3300
+L 2109 2666
+L 1438 2666
+L 1438 0
+L 647 0
+L 647 2666
+L 53 2666
+L 53 3300
+L 647 3300
+L 647 3781
+Q 647 4206 905 4431
+Q 1163 4656 1650 4656
+L 2109 4656
+L 2109 4022
+L 1806 4022
+Q 1603 4022 1520 3937
+Q 1438 3853 1438 3650
+L 1438 3300
+L 2109 3300
+z
+" transform="scale(0.015625)"/>
+ <path id="InterDisplay-SemiBold-2e0" d="M 1138 4656
+L 1138 0
+L 350 0
+L 350 4656
+L 1138 4656
+z
+" transform="scale(0.015625)"/>
+ <path id="InterDisplay-SemiBold-367" d="M 1644 -78
+Q 1041 -78 636 205
+Q 231 488 194 1019
+L 972 1019
+Q 997 778 1165 645
+Q 1334 513 1631 513
+Q 1916 513 2080 625
+Q 2244 738 2244 913
+Q 2244 1063 2122 1153
+Q 2000 1244 1794 1288
+L 1231 1403
+Q 269 1603 269 2356
+Q 269 2813 631 3092
+Q 994 3372 1597 3372
+Q 2197 3372 2573 3076
+Q 2950 2781 2963 2272
+L 2222 2272
+Q 2216 2494 2050 2637
+Q 1884 2781 1616 2781
+Q 1356 2781 1206 2665
+Q 1056 2550 1056 2381
+Q 1056 2234 1172 2142
+Q 1288 2050 1494 2003
+L 2088 1881
+Q 2578 1778 2811 1556
+Q 3044 1334 3044 972
+Q 3044 650 2864 414
+Q 2684 178 2368 50
+Q 2053 -78 1644 -78
+z
+" transform="scale(0.015625)"/>
+ <path id="InterDisplay-SemiBold-1fb" d="M 1356 -53
+Q 863 -53 539 195
+Q 216 444 216 938
+Q 216 1313 398 1517
+Q 581 1722 876 1815
+Q 1172 1909 1513 1944
+Q 1972 1997 2153 2037
+Q 2334 2078 2334 2247
+L 2334 2272
+Q 2334 2484 2173 2618
+Q 2013 2753 1731 2753
+Q 1444 2753 1264 2618
+Q 1084 2484 1069 2275
+L 309 2275
+Q 338 2766 719 3066
+Q 1100 3366 1747 3366
+Q 2391 3366 2753 3066
+Q 3116 2766 3116 2250
+L 3116 0
+L 2341 0
+L 2341 466
+L 2328 466
+Q 2209 247 1984 97
+Q 1759 -53 1356 -53
+z
+M 1550 531
+Q 1938 531 2138 732
+Q 2338 934 2338 1222
+L 2338 1578
+Q 2266 1531 2059 1492
+Q 1853 1453 1609 1416
+Q 1356 1378 1170 1273
+Q 984 1169 984 944
+Q 984 750 1137 640
+Q 1291 531 1550 531
+z
+" transform="scale(0.015625)"/>
+ <path id="InterDisplay-SemiBold-3e1" d="M 56 0
+L 1253 1681
+L 134 3300
+L 1013 3300
+L 1356 2775
+Q 1447 2631 1531 2492
+Q 1616 2353 1700 2216
+Q 1784 2353 1870 2492
+Q 1956 2631 2047 2775
+L 2397 3300
+L 3263 3300
+L 2134 1697
+L 3316 0
+L 2434 0
+L 2041 588
+Q 1950 734 1862 871
+Q 1775 1009 1691 1147
+Q 1603 1009 1515 871
+Q 1428 734 1334 588
+L 934 0
+L 56 0
+z
+" transform="scale(0.015625)"/>
+ <path id="InterDisplay-SemiBold-24a" d="M 1809 -75
+Q 1328 -75 964 144
+Q 600 363 398 750
+Q 197 1138 197 1647
+Q 197 2156 398 2545
+Q 600 2934 964 3154
+Q 1328 3375 1809 3375
+Q 2225 3375 2550 3214
+Q 2875 3053 3073 2770
+Q 3272 2488 3306 2119
+L 2534 2119
+Q 2491 2384 2308 2551
+Q 2125 2719 1819 2719
+Q 1431 2719 1212 2428
+Q 994 2138 994 1647
+Q 994 1159 1212 870
+Q 1431 581 1819 581
+Q 2128 581 2300 745
+Q 2472 909 2528 1184
+L 3306 1184
+Q 3278 822 3079 537
+Q 2881 253 2554 89
+Q 2228 -75 1809 -75
+z
+" transform="scale(0.015625)"/>
+ <path id="InterDisplay-SemiBold-5e1" d="M 756 -56
+Q 553 -56 412 86
+Q 272 228 272 428
+Q 272 631 412 772
+Q 553 913 756 913
+Q 959 913 1100 772
+Q 1241 631 1241 428
+Q 1241 228 1100 86
+Q 959 -56 756 -56
+z
+M 756 2216
+Q 553 2216 412 2358
+Q 272 2500 272 2700
+Q 272 2903 412 3044
+Q 553 3185 756 3185
+Q 959 3185 1100 3044
+Q 1241 2903 1241 2700
+Q 1241 2500 1100 2358
+Q 959 2216 756 2216
+z
+" transform="scale(0.015625)"/>
+ <path id="InterDisplay-SemiBold-53e" d="M 2050 4656
+L 2050 0
+L 1253 0
+L 1253 3875
+L 1247 3875
+L 131 3153
+L 131 3909
+L 1288 4656
+L 2050 4656
+z
+" transform="scale(0.015625)"/>
+ <path id="InterDisplay-SemiBold-53d" d="M 2041 -75
+Q 1478 -75 1072 219
+Q 666 513 445 1050
+Q 225 1588 225 2325
+Q 225 3066 445 3605
+Q 666 4144 1072 4437
+Q 1478 4731 2041 4731
+Q 2603 4731 3011 4437
+Q 3419 4144 3637 3605
+Q 3856 3066 3856 2325
+Q 3856 1588 3637 1048
+Q 3419 509 3011 217
+Q 2603 -75 2041 -75
+z
+M 2041 606
+Q 2522 606 2798 1065
+Q 3075 1525 3075 2325
+Q 3075 3131 2798 3590
+Q 2522 4050 2041 4050
+Q 1559 4050 1282 3590
+Q 1006 3131 1006 2325
+Q 1006 1525 1282 1065
+Q 1559 606 2041 606
+z
+" transform="scale(0.015625)"/>
+ <path id="InterDisplay-SemiBold-18d" d="M 2072 -75
+Q 1206 -75 717 348
+Q 228 772 228 1519
+L 1038 1519
+Q 1044 1097 1317 859
+Q 1591 622 2078 622
+Q 2513 622 2778 805
+Q 3044 988 3044 1294
+Q 3044 1541 2844 1695
+Q 2644 1850 2178 1956
+L 1678 2069
+Q 981 2228 650 2540
+Q 319 2853 319 3344
+Q 319 3759 533 4071
+Q 747 4384 1133 4557
+Q 1519 4731 2031 4731
+Q 2813 4731 3270 4334
+Q 3728 3938 3747 3244
+L 2963 3244
+Q 2938 3613 2688 3822
+Q 2438 4031 2028 4031
+Q 1641 4031 1394 3850
+Q 1147 3669 1147 3384
+Q 1147 3150 1342 3004
+Q 1538 2859 1994 2756
+L 2466 2647
+Q 3191 2488 3528 2172
+Q 3866 1856 3866 1344
+Q 3866 909 3647 590
+Q 3428 272 3025 98
+Q 2622 -75 2072 -75
+z
+" transform="scale(0.015625)"/>
+ <path id="InterDisplay-SemiBold-1cb" d="M 1297 0
+L 41 4656
+L 913 4656
+L 1528 2147
+Q 1600 1841 1664 1536
+Q 1728 1231 1788 925
+Q 1850 1231 1919 1536
+Q 1988 1841 2063 2147
+L 2703 4656
+L 3575 4656
+L 4209 2147
+Q 4284 1844 4353 1542
+Q 4422 1241 4484 941
+Q 4603 1531 4747 2147
+L 5363 4656
+L 6238 4656
+L 4978 0
+L 4044 0
+L 3331 2694
+Q 3281 2884 3234 3095
+Q 3188 3306 3138 3538
+Q 3088 3306 3041 3095
+Q 2994 2884 2944 2694
+L 2234 0
+L 1297 0
+z
+" transform="scale(0.015625)"/>
+ <path id="InterDisplay-SemiBold-5f" d="M 388 0
+L 388 4656
+L 3622 4656
+L 3622 3941
+L 1213 3941
+L 1213 2716
+L 3441 2716
+L 3441 2013
+L 1213 2013
+L 1213 716
+L 3622 716
+L 3622 0
+L 388 0
+z
+" transform="scale(0.015625)"/>
+ <path id="InterDisplay-SemiBold-5b3" d="M 2450 2188
+L 2450 1525
+L 363 1525
+L 363 2188
+L 2450 2188
+z
+" transform="scale(0.015625)"/>
+ <path id="InterDisplay-SemiBold-242" d="M 2131 -66
+Q 1806 -66 1545 75
+Q 1284 216 1131 503
+L 1125 503
+L 1125 0
+L 350 0
+L 350 4656
+L 1138 4656
+L 1138 2831
+L 1144 2831
+Q 1303 3103 1559 3234
+Q 1816 3366 2134 3366
+Q 2559 3366 2879 3148
+Q 3200 2931 3379 2545
+Q 3559 2159 3559 1653
+Q 3559 1138 3382 752
+Q 3206 366 2884 150
+Q 2563 -66 2131 -66
+z
+M 1947 594
+Q 2313 594 2538 867
+Q 2763 1141 2763 1653
+Q 2763 2163 2538 2438
+Q 2313 2713 1947 2713
+Q 1559 2713 1326 2423
+Q 1094 2134 1094 1653
+Q 1094 1172 1326 883
+Q 1559 594 1947 594
+z
+" transform="scale(0.015625)"/>
+ <path id="InterDisplay-SemiBold-1c8" d="M 1703 0
+L 41 4656
+L 934 4656
+L 1775 2209
+Q 1869 1916 1980 1555
+Q 2091 1194 2225 750
+Q 2356 1194 2465 1555
+Q 2575 1916 2666 2209
+L 3478 4656
+L 4363 4656
+L 2731 0
+L 1703 0
+z
+" transform="scale(0.015625)"/>
+ <path id="InterDisplay-SemiBold-354" d="M 350 0
+L 350 3300
+L 1109 3300
+L 1109 2753
+L 1119 2753
+Q 1209 3034 1404 3182
+Q 1600 3331 1919 3331
+Q 2000 3331 2064 3326
+Q 2128 3322 2175 3319
+L 2175 2619
+Q 2131 2625 2025 2634
+Q 1919 2644 1803 2644
+Q 1522 2644 1330 2450
+Q 1138 2256 1138 1869
+L 1138 0
+L 350 0
+z
+" transform="scale(0.015625)"/>
+ <path id="InterDisplay-SemiBold-393" d="M 1525 -66
+Q 1006 -66 678 268
+Q 350 603 350 1238
+L 350 3300
+L 1138 3300
+L 1138 1363
+Q 1138 1000 1313 812
+Q 1488 625 1803 625
+Q 2116 625 2320 819
+Q 2525 1013 2525 1434
+L 2525 3300
+L 3316 3300
+L 3316 0
+L 2541 0
+L 2541 506
+Q 2194 -66 1525 -66
+z
+" transform="scale(0.015625)"/>
+ <path id="InterDisplay-SemiBold-5dd" d="M 156 -943
+L 403 722
+L 1181 722
+L 716 -943
+L 156 -943
+z
+" transform="scale(0.015625)"/>
+ <path id="InterDisplay-SemiBold-316" d="M 1825 -75
+Q 1338 -75 972 142
+Q 606 359 401 746
+Q 197 1134 197 1647
+Q 197 2159 401 2548
+Q 606 2938 972 3156
+Q 1338 3375 1825 3375
+Q 2309 3375 2676 3156
+Q 3044 2938 3248 2548
+Q 3453 2159 3453 1647
+Q 3453 1134 3248 746
+Q 3044 359 2676 142
+Q 2309 -75 1825 -75
+z
+M 1825 584
+Q 2203 584 2428 868
+Q 2653 1153 2653 1647
+Q 2653 2141 2428 2428
+Q 2203 2716 1825 2716
+Q 1444 2716 1219 2430
+Q 994 2144 994 1647
+Q 994 1153 1219 868
+Q 1444 584 1825 584
+z
+" transform="scale(0.015625)"/>
+ <path id="InterDisplay-SemiBold-2fe" d="M 350 0
+L 350 3300
+L 1113 3300
+L 1113 2728
+Q 1263 3047 1528 3206
+Q 1794 3366 2106 3366
+Q 2441 3366 2697 3195
+Q 2953 3025 3056 2741
+Q 3188 3025 3466 3195
+Q 3744 3366 4106 3366
+Q 4575 3366 4894 3062
+Q 5213 2759 5213 2178
+L 5213 0
+L 4422 0
+L 4422 2066
+Q 4422 2394 4242 2545
+Q 4063 2697 3809 2697
+Q 3509 2697 3336 2509
+Q 3163 2322 3163 2025
+L 3163 0
+L 2397 0
+L 2397 2103
+Q 2397 2372 2228 2534
+Q 2059 2697 1797 2697
+Q 1531 2697 1334 2511
+Q 1138 2325 1138 1969
+L 1138 0
+L 350 0
+z
+" transform="scale(0.015625)"/>
+ </defs>
+ <use xlink:href="#InterDisplay-SemiBold-89"/>
+ <use xlink:href="#InterDisplay-SemiBold-2b1" transform="translate(57.234375 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-305" transform="translate(80.484375 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-255" transform="translate(137.765625 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-2b1" transform="translate(196.453125 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-305" transform="translate(219.703125 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-292" transform="translate(276.984375 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-6f1" transform="translate(335.671875 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-379" transform="translate(358.28125 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-29e" transform="translate(393.25 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-266" transform="translate(450.53125 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-6f1" transform="translate(505.859375 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-287" transform="translate(528.46875 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-2b1" transform="translate(563.375 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-2e0" transform="translate(586.625 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-266" transform="translate(609.875 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-367" transform="translate(665.203125 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-6f1" transform="translate(715.6875 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-1fb" transform="translate(738.296875 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-6f1" transform="translate(792.40625 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-287" transform="translate(815.015625 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-2b1" transform="translate(849.921875 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-3e1" transform="translate(873.171875 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-6f1" transform="translate(925.859375 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-24a" transform="translate(948.46875 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-29e" transform="translate(1002.90625 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-1fb" transform="translate(1060.1875 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-305" transform="translate(1114.296875 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-292" transform="translate(1171.578125 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-266" transform="translate(1230.265625 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-367" transform="translate(1285.59375 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-5e1" transform="translate(1336.078125 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-6f1" transform="translate(1359.71875 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-53e" transform="translate(1382.328125 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-53d" transform="translate(1420.359375 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-53d" transform="translate(1484.125 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-6f1" transform="translate(1547.890625 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-18d" transform="translate(1570.5 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-1cb" transform="translate(1634.46875 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-5f" transform="translate(1732.5625 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-5b3" transform="translate(1792.421875 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-242" transform="translate(1836.375 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-266" transform="translate(1895.0625 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-305" transform="translate(1950.390625 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-24a" transform="translate(2007.671875 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-29e" transform="translate(2062.109375 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-6f1" transform="translate(2119.390625 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-1c8" transform="translate(2142 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-266" transform="translate(2203.28125 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-354" transform="translate(2258.609375 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-2b1" transform="translate(2294.546875 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-287" transform="translate(2317.796875 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-2b1" transform="translate(2352.703125 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-266" transform="translate(2375.953125 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-255" transform="translate(2431.28125 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-6f1" transform="translate(2489.96875 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-2b1" transform="translate(2512.578125 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-367" transform="translate(2535.828125 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-367" transform="translate(2586.3125 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-393" transform="translate(2636.796875 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-266" transform="translate(2694.078125 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-367" transform="translate(2749.40625 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-5dd" transform="translate(2799.890625 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-6f1" transform="translate(2821.484375 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-29e" transform="translate(2844.09375 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-266" transform="translate(2901.375 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-2e0" transform="translate(2956.703125 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-255" transform="translate(2979.953125 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-6f1" transform="translate(3038.640625 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-316" transform="translate(3061.25 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-393" transform="translate(3118.234375 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-379" transform="translate(3175.515625 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-6f1" transform="translate(3210.484375 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-287" transform="translate(3233.09375 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-354" transform="translate(3268 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-316" transform="translate(3302.953125 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-2fe" transform="translate(3359.9375 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-6f1" transform="translate(3446.796875 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-379" transform="translate(3469.40625 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-393" transform="translate(3504.375 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-305" transform="translate(3561.65625 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-2b1" transform="translate(3618.9375 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-305" transform="translate(3642.1875 0)"/>
+ <use xlink:href="#InterDisplay-SemiBold-292" transform="translate(3699.46875 0)"/>
+ </g>
+ </g>
+ <g id="text_8">
+ <!-- For each issue: is a file the fix changed among the first k files? Graphicle: the files its context packet cites, then lists. No model calls. Higher is better. -->
+ <g style="fill: #5b6474" transform="translate(48 146) scale(0.2 -0.2)">
+ <defs>
+ <path id="Inter-Regular-89" d="M 563 0
+L 563 4656
+L 3378 4656
+L 3378 4131
+L 1156 4131
+L 1156 2538
+L 3166 2538
+L 3166 2013
+L 1156 2013
+L 1156 0
+L 563 0
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Regular-367" d="M 1681 -75
+Q 1144 -75 787 159
+Q 431 394 338 847
+L 872 975
+Q 947 688 1155 553
+Q 1363 419 1675 419
+Q 2041 419 2258 575
+Q 2475 731 2475 947
+Q 2475 1306 1963 1428
+L 1381 1566
+Q 444 1788 444 2519
+Q 444 2819 612 3048
+Q 781 3278 1073 3408
+Q 1366 3538 1738 3538
+Q 2278 3538 2576 3302
+Q 2875 3066 2994 2697
+L 2484 2566
+Q 2413 2753 2245 2906
+Q 2078 3059 1741 3059
+Q 1428 3059 1220 2915
+Q 1013 2772 1013 2553
+Q 1013 2359 1153 2242
+Q 1294 2125 1600 2053
+L 2128 1928
+Q 2603 1816 2831 1580
+Q 3059 1344 3059 984
+Q 3059 678 2886 439
+Q 2713 200 2402 62
+Q 2091 -75 1681 -75
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Regular-393" d="M 1678 -44
+Q 1150 -44 822 284
+Q 494 613 494 1275
+L 494 3494
+L 1056 3494
+L 1056 1322
+Q 1056 919 1268 691
+Q 1481 463 1847 463
+Q 2222 463 2473 708
+Q 2725 953 2725 1400
+L 2725 3494
+L 3291 3494
+L 3291 0
+L 2747 0
+L 2747 653
+Q 2575 272 2298 114
+Q 2022 -44 1678 -44
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Regular-5e1" d="M 922 -41
+Q 747 -41 623 82
+Q 500 206 500 381
+Q 500 556 623 679
+Q 747 803 922 803
+Q 1097 803 1220 679
+Q 1344 556 1344 381
+Q 1344 206 1220 82
+Q 1097 -41 922 -41
+z
+M 922 2487
+Q 747 2487 623 2610
+Q 500 2734 500 2909
+Q 500 3084 623 3207
+Q 747 3331 922 3331
+Q 1097 3331 1220 3207
+Q 1344 3084 1344 2909
+Q 1344 2734 1220 2610
+Q 1097 2487 922 2487
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Regular-3e1" d="M 203 0
+L 1431 1794
+L 275 3494
+L 931 3494
+L 1366 2816
+Q 1484 2628 1579 2461
+Q 1675 2294 1766 2134
+Q 1850 2294 1937 2461
+Q 2025 2628 2147 2816
+L 2591 3494
+L 3234 3494
+L 2066 1763
+L 3291 0
+L 2638 0
+L 2125 784
+Q 2009 963 1918 1123
+Q 1828 1284 1741 1431
+Q 1659 1284 1575 1123
+Q 1491 963 1372 784
+L 853 0
+L 203 0
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Regular-292" d="M 1909 -1381
+Q 1328 -1381 981 -1168
+Q 634 -956 472 -669
+L 928 -375
+Q 1003 -475 1114 -597
+Q 1225 -719 1414 -805
+Q 1603 -891 1909 -891
+Q 2328 -891 2598 -691
+Q 2869 -491 2869 -59
+L 2869 641
+L 2816 641
+Q 2756 541 2648 403
+Q 2541 266 2339 161
+Q 2138 56 1800 56
+Q 1381 56 1047 254
+Q 713 453 519 834
+Q 325 1216 325 1763
+Q 325 2303 515 2701
+Q 706 3100 1042 3319
+Q 1378 3538 1813 3538
+Q 2150 3538 2351 3427
+Q 2553 3316 2662 3172
+Q 2772 3028 2831 2934
+L 2884 2934
+L 2884 3494
+L 3431 3494
+L 3431 -91
+Q 3431 -541 3228 -827
+Q 3025 -1113 2679 -1247
+Q 2334 -1381 1909 -1381
+z
+M 1894 556
+Q 2369 556 2622 879
+Q 2875 1203 2875 1775
+Q 2875 2331 2626 2682
+Q 2378 3034 1894 3034
+Q 1563 3034 1341 2864
+Q 1119 2694 1008 2409
+Q 897 2125 897 1775
+Q 897 1238 1150 897
+Q 1403 556 1894 556
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Regular-255" d="M 1803 -75
+Q 1369 -75 1034 147
+Q 700 369 512 775
+Q 325 1181 325 1738
+Q 325 2291 514 2695
+Q 703 3100 1037 3319
+Q 1372 3538 1806 3538
+Q 2147 3538 2347 3425
+Q 2547 3313 2655 3170
+Q 2763 3028 2819 2934
+L 2863 2934
+L 2863 4656
+L 3425 4656
+L 3425 0
+L 2881 0
+L 2881 541
+L 2819 541
+Q 2763 444 2652 298
+Q 2541 153 2339 39
+Q 2138 -75 1803 -75
+z
+M 1888 428
+Q 2363 428 2616 793
+Q 2869 1159 2869 1744
+Q 2869 2322 2620 2678
+Q 2372 3034 1888 3034
+Q 1556 3034 1336 2862
+Q 1116 2691 1006 2398
+Q 897 2106 897 1744
+Q 897 1378 1008 1079
+Q 1119 781 1341 604
+Q 1563 428 1888 428
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Regular-597" d="M 1197 1403
+L 1197 1438
+Q 1197 1866 1280 2098
+Q 1363 2331 1519 2467
+Q 1675 2603 1891 2731
+Q 2097 2856 2237 3048
+Q 2378 3241 2378 3513
+Q 2378 3838 2156 4030
+Q 1934 4222 1619 4222
+Q 1344 4222 1109 4048
+Q 875 3875 850 3484
+L 256 3484
+Q 272 3878 458 4153
+Q 644 4428 947 4573
+Q 1250 4719 1619 4719
+Q 2025 4719 2323 4561
+Q 2622 4403 2787 4125
+Q 2953 3847 2953 3491
+Q 2953 3113 2787 2844
+Q 2622 2575 2319 2391
+Q 2119 2269 1995 2155
+Q 1872 2041 1817 1878
+Q 1763 1716 1763 1438
+L 1763 1403
+L 1197 1403
+z
+M 1488 -41
+Q 1313 -41 1189 82
+Q 1066 206 1066 378
+Q 1066 553 1189 676
+Q 1313 800 1488 800
+Q 1663 800 1784 676
+Q 1906 553 1906 378
+Q 1906 206 1784 82
+Q 1663 -41 1488 -41
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Regular-8d" d="M 2466 -63
+Q 1844 -63 1375 228
+Q 906 519 643 1055
+Q 381 1591 381 2325
+Q 381 3066 643 3602
+Q 906 4138 1368 4428
+Q 1831 4719 2428 4719
+Q 2922 4719 3323 4526
+Q 3725 4334 3990 3992
+Q 4256 3650 4341 3197
+L 3728 3197
+Q 3584 3644 3254 3906
+Q 2925 4169 2431 4169
+Q 2022 4169 1687 3958
+Q 1353 3747 1156 3336
+Q 959 2925 959 2325
+Q 959 1731 1157 1322
+Q 1356 913 1697 700
+Q 2038 488 2466 488
+Q 2853 488 3150 650
+Q 3447 813 3617 1113
+Q 3788 1413 3794 1822
+L 2588 1822
+L 2588 2341
+L 4375 2341
+L 4375 1831
+Q 4375 1253 4128 828
+Q 3881 403 3451 170
+Q 3022 -63 2466 -63
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Regular-34b" d="M 494 -1306
+L 494 3494
+L 1038 3494
+L 1038 2934
+L 1100 2934
+Q 1159 3028 1265 3170
+Q 1372 3313 1572 3425
+Q 1772 3538 2113 3538
+Q 2550 3538 2883 3319
+Q 3216 3100 3405 2695
+Q 3594 2291 3594 1738
+Q 3594 1181 3406 775
+Q 3219 369 2886 147
+Q 2553 -75 2116 -75
+Q 1784 -75 1581 39
+Q 1378 153 1268 298
+Q 1159 444 1100 541
+L 1056 541
+L 1056 -1306
+L 494 -1306
+z
+M 2031 428
+Q 2359 428 2579 604
+Q 2800 781 2911 1079
+Q 3022 1378 3022 1744
+Q 3022 2106 2912 2398
+Q 2803 2691 2583 2862
+Q 2363 3034 2031 3034
+Q 1550 3034 1300 2678
+Q 1050 2322 1050 1744
+Q 1050 1159 1303 793
+Q 1556 428 2031 428
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Regular-5de" d="M 922 -41
+Q 747 -41 623 82
+Q 500 206 500 381
+Q 500 556 623 679
+Q 747 803 922 803
+Q 1097 803 1220 679
+Q 1344 556 1344 381
+Q 1344 206 1220 82
+Q 1097 -41 922 -41
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Regular-12c" d="M 563 0
+L 563 4656
+L 1263 4656
+L 3156 1678
+Q 3250 1528 3398 1273
+Q 3547 1019 3706 703
+Q 3678 1041 3672 1327
+Q 3666 1613 3666 1800
+L 3666 4656
+L 4259 4656
+L 4259 0
+L 3553 0
+L 1866 2650
+Q 1759 2816 1654 2991
+Q 1550 3166 1422 3394
+Q 1294 3622 1113 3944
+Q 1131 3497 1145 3161
+Q 1159 2825 1159 2656
+L 1159 0
+L 563 0
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Regular-a1" d="M 563 0
+L 563 4656
+L 1156 4656
+L 1156 2644
+L 3600 2644
+L 3600 4656
+L 4194 4656
+L 4194 0
+L 3600 0
+L 3600 2119
+L 1156 2119
+L 1156 0
+L 563 0
+z
+" transform="scale(0.015625)"/>
+ </defs>
+ <use xlink:href="#Inter-Regular-89"/>
+ <use xlink:href="#Inter-Regular-316" transform="translate(55.078125 0)"/>
+ <use xlink:href="#Inter-Regular-354" transform="translate(115.046875 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(152.6875 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(180.8125 0)"/>
+ <use xlink:href="#Inter-Regular-1fb" transform="translate(240.09375 0)"/>
+ <use xlink:href="#Inter-Regular-24a" transform="translate(296.25 0)"/>
+ <use xlink:href="#Inter-Regular-29e" transform="translate(353.375 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(412.5 0)"/>
+ <use xlink:href="#Inter-Regular-2b1" transform="translate(440.625 0)"/>
+ <use xlink:href="#Inter-Regular-367" transform="translate(464.84375 0)"/>
+ <use xlink:href="#Inter-Regular-367" transform="translate(517.625 0)"/>
+ <use xlink:href="#Inter-Regular-393" transform="translate(570.40625 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(629.53125 0)"/>
+ <use xlink:href="#Inter-Regular-5e1" transform="translate(687.828125 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(716.640625 0)"/>
+ <use xlink:href="#Inter-Regular-2b1" transform="translate(744.765625 0)"/>
+ <use xlink:href="#Inter-Regular-367" transform="translate(768.984375 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(821.765625 0)"/>
+ <use xlink:href="#Inter-Regular-1fb" transform="translate(849.890625 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(906.046875 0)"/>
+ <use xlink:href="#Inter-Regular-287" transform="translate(934.171875 0)"/>
+ <use xlink:href="#Inter-Regular-2b1" transform="translate(971.1875 0)"/>
+ <use xlink:href="#Inter-Regular-2e0" transform="translate(995.40625 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(1019.625 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(1077.921875 0)"/>
+ <use xlink:href="#Inter-Regular-379" transform="translate(1106.046875 0)"/>
+ <use xlink:href="#Inter-Regular-29e" transform="translate(1138.765625 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(1197.890625 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(1256.1875 0)"/>
+ <use xlink:href="#Inter-Regular-287" transform="translate(1284.3125 0)"/>
+ <use xlink:href="#Inter-Regular-2b1" transform="translate(1321.328125 0)"/>
+ <use xlink:href="#Inter-Regular-3e1" transform="translate(1345.546875 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(1400.140625 0)"/>
+ <use xlink:href="#Inter-Regular-24a" transform="translate(1428.265625 0)"/>
+ <use xlink:href="#Inter-Regular-29e" transform="translate(1485.390625 0)"/>
+ <use xlink:href="#Inter-Regular-1fb" transform="translate(1544.515625 0)"/>
+ <use xlink:href="#Inter-Regular-305" transform="translate(1600.671875 0)"/>
+ <use xlink:href="#Inter-Regular-292" transform="translate(1659.75 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(1721.078125 0)"/>
+ <use xlink:href="#Inter-Regular-255" transform="translate(1779.375 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(1840.609375 0)"/>
+ <use xlink:href="#Inter-Regular-1fb" transform="translate(1868.734375 0)"/>
+ <use xlink:href="#Inter-Regular-2fe" transform="translate(1924.890625 0)"/>
+ <use xlink:href="#Inter-Regular-316" transform="translate(2012.484375 0)"/>
+ <use xlink:href="#Inter-Regular-305" transform="translate(2072.453125 0)"/>
+ <use xlink:href="#Inter-Regular-292" transform="translate(2131.53125 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(2192.859375 0)"/>
+ <use xlink:href="#Inter-Regular-379" transform="translate(2220.984375 0)"/>
+ <use xlink:href="#Inter-Regular-29e" transform="translate(2253.703125 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(2312.828125 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(2371.125 0)"/>
+ <use xlink:href="#Inter-Regular-287" transform="translate(2399.25 0)"/>
+ <use xlink:href="#Inter-Regular-2b1" transform="translate(2436.265625 0)"/>
+ <use xlink:href="#Inter-Regular-354" transform="translate(2460.484375 0)"/>
+ <use xlink:href="#Inter-Regular-367" transform="translate(2498.125 0)"/>
+ <use xlink:href="#Inter-Regular-379" transform="translate(2550.90625 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(2583.625 0)"/>
+ <use xlink:href="#Inter-Regular-2d7" transform="translate(2611.75 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(2666.640625 0)"/>
+ <use xlink:href="#Inter-Regular-287" transform="translate(2694.765625 0)"/>
+ <use xlink:href="#Inter-Regular-2b1" transform="translate(2731.78125 0)"/>
+ <use xlink:href="#Inter-Regular-2e0" transform="translate(2756 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(2780.21875 0)"/>
+ <use xlink:href="#Inter-Regular-367" transform="translate(2838.515625 0)"/>
+ <use xlink:href="#Inter-Regular-597" transform="translate(2891.296875 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(2942.421875 0)"/>
+ <use xlink:href="#Inter-Regular-8d" transform="translate(2970.546875 0)"/>
+ <use xlink:href="#Inter-Regular-354" transform="translate(3045.15625 0)"/>
+ <use xlink:href="#Inter-Regular-1fb" transform="translate(3082.796875 0)"/>
+ <use xlink:href="#Inter-Regular-34b" transform="translate(3138.953125 0)"/>
+ <use xlink:href="#Inter-Regular-29e" transform="translate(3200.1875 0)"/>
+ <use xlink:href="#Inter-Regular-2b1" transform="translate(3259.3125 0)"/>
+ <use xlink:href="#Inter-Regular-24a" transform="translate(3283.53125 0)"/>
+ <use xlink:href="#Inter-Regular-2e0" transform="translate(3340.65625 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(3364.875 0)"/>
+ <use xlink:href="#Inter-Regular-5e1" transform="translate(3423.171875 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(3451.984375 0)"/>
+ <use xlink:href="#Inter-Regular-379" transform="translate(3480.109375 0)"/>
+ <use xlink:href="#Inter-Regular-29e" transform="translate(3512.828125 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(3571.953125 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(3630.25 0)"/>
+ <use xlink:href="#Inter-Regular-287" transform="translate(3658.375 0)"/>
+ <use xlink:href="#Inter-Regular-2b1" transform="translate(3695.390625 0)"/>
+ <use xlink:href="#Inter-Regular-2e0" transform="translate(3719.609375 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(3743.828125 0)"/>
+ <use xlink:href="#Inter-Regular-367" transform="translate(3802.125 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(3854.90625 0)"/>
+ <use xlink:href="#Inter-Regular-2b1" transform="translate(3883.03125 0)"/>
+ <use xlink:href="#Inter-Regular-379" transform="translate(3907.25 0)"/>
+ <use xlink:href="#Inter-Regular-367" transform="translate(3939 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(3991.78125 0)"/>
+ <use xlink:href="#Inter-Regular-24a" transform="translate(4019.90625 0)"/>
+ <use xlink:href="#Inter-Regular-316" transform="translate(4077.03125 0)"/>
+ <use xlink:href="#Inter-Regular-305" transform="translate(4137 0)"/>
+ <use xlink:href="#Inter-Regular-379" transform="translate(4196.078125 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(4227.828125 0)"/>
+ <use xlink:href="#Inter-Regular-3e1" transform="translate(4283.875 0)"/>
+ <use xlink:href="#Inter-Regular-379" transform="translate(4340.421875 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(4373.140625 0)"/>
+ <use xlink:href="#Inter-Regular-34b" transform="translate(4401.265625 0)"/>
+ <use xlink:href="#Inter-Regular-1fb" transform="translate(4463.484375 0)"/>
+ <use xlink:href="#Inter-Regular-24a" transform="translate(4519.640625 0)"/>
+ <use xlink:href="#Inter-Regular-2d7" transform="translate(4576.765625 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(4629.40625 0)"/>
+ <use xlink:href="#Inter-Regular-379" transform="translate(4687.703125 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(4720.421875 0)"/>
+ <use xlink:href="#Inter-Regular-24a" transform="translate(4748.546875 0)"/>
+ <use xlink:href="#Inter-Regular-2b1" transform="translate(4805.671875 0)"/>
+ <use xlink:href="#Inter-Regular-379" transform="translate(4829.890625 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(4861.640625 0)"/>
+ <use xlink:href="#Inter-Regular-367" transform="translate(4919.9375 0)"/>
+ <use xlink:href="#Inter-Regular-5dd" transform="translate(4972.71875 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(5001.53125 0)"/>
+ <use xlink:href="#Inter-Regular-379" transform="translate(5029.65625 0)"/>
+ <use xlink:href="#Inter-Regular-29e" transform="translate(5062.375 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(5121.5 0)"/>
+ <use xlink:href="#Inter-Regular-305" transform="translate(5179.796875 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(5238.875 0)"/>
+ <use xlink:href="#Inter-Regular-2e0" transform="translate(5267 0)"/>
+ <use xlink:href="#Inter-Regular-2b1" transform="translate(5291.21875 0)"/>
+ <use xlink:href="#Inter-Regular-367" transform="translate(5315.4375 0)"/>
+ <use xlink:href="#Inter-Regular-379" transform="translate(5368.21875 0)"/>
+ <use xlink:href="#Inter-Regular-367" transform="translate(5399.96875 0)"/>
+ <use xlink:href="#Inter-Regular-5de" transform="translate(5452.75 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(5481.5625 0)"/>
+ <use xlink:href="#Inter-Regular-12c" transform="translate(5509.6875 0)"/>
+ <use xlink:href="#Inter-Regular-316" transform="translate(5585.03125 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(5645 0)"/>
+ <use xlink:href="#Inter-Regular-2fe" transform="translate(5673.125 0)"/>
+ <use xlink:href="#Inter-Regular-316" transform="translate(5760.71875 0)"/>
+ <use xlink:href="#Inter-Regular-255" transform="translate(5820.6875 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(5881.921875 0)"/>
+ <use xlink:href="#Inter-Regular-2e0" transform="translate(5940.21875 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(5964.4375 0)"/>
+ <use xlink:href="#Inter-Regular-24a" transform="translate(5992.5625 0)"/>
+ <use xlink:href="#Inter-Regular-1fb" transform="translate(6050.671875 0)"/>
+ <use xlink:href="#Inter-Regular-2e0" transform="translate(6106.828125 0)"/>
+ <use xlink:href="#Inter-Regular-2e0" transform="translate(6131.046875 0)"/>
+ <use xlink:href="#Inter-Regular-367" transform="translate(6155.265625 0)"/>
+ <use xlink:href="#Inter-Regular-5de" transform="translate(6208.046875 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(6236.859375 0)"/>
+ <use xlink:href="#Inter-Regular-a1" transform="translate(6264.984375 0)"/>
+ <use xlink:href="#Inter-Regular-2b1" transform="translate(6339.296875 0)"/>
+ <use xlink:href="#Inter-Regular-292" transform="translate(6363.515625 0)"/>
+ <use xlink:href="#Inter-Regular-29e" transform="translate(6424.84375 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(6483.96875 0)"/>
+ <use xlink:href="#Inter-Regular-354" transform="translate(6542.265625 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(6579.90625 0)"/>
+ <use xlink:href="#Inter-Regular-2b1" transform="translate(6608.03125 0)"/>
+ <use xlink:href="#Inter-Regular-367" transform="translate(6632.25 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(6685.03125 0)"/>
+ <use xlink:href="#Inter-Regular-242" transform="translate(6713.15625 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(6774.390625 0)"/>
+ <use xlink:href="#Inter-Regular-379" transform="translate(6832.6875 0)"/>
+ <use xlink:href="#Inter-Regular-379" transform="translate(6865.40625 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(6897.15625 0)"/>
+ <use xlink:href="#Inter-Regular-354" transform="translate(6955.453125 0)"/>
+ <use xlink:href="#Inter-Regular-5de" transform="translate(6986.84375 0)"/>
+ </g>
+ </g>
+ <g id="text_9">
+ <!-- Graphicle 0.1.3 and the 0.1.2 release binary run graphicle context on the issue's prompt, with their defaults. BM25: SWE-bench style, one document per source file. grep: rg 14.1.1 -->
+ <g style="fill: #5b6474" transform="translate(48 796) scale(0.18 -0.18)">
+ <defs>
+ <path id="Inter-Regular-541" d="M 1984 -63
+Q 1528 -63 1175 93
+Q 822 250 614 528
+Q 406 806 391 1175
+L 991 1175
+Q 1016 844 1297 651
+Q 1578 459 1975 459
+Q 2413 459 2698 684
+Q 2984 909 2984 1272
+Q 2984 1650 2703 1889
+Q 2422 2128 1903 2128
+L 1525 2128
+L 1525 2644
+L 1903 2644
+Q 2313 2644 2567 2861
+Q 2822 3078 2822 3438
+Q 2822 3784 2597 3993
+Q 2372 4203 1991 4203
+Q 1753 4203 1545 4117
+Q 1338 4031 1205 3872
+Q 1072 3713 1063 3484
+L 491 3484
+Q 503 3850 709 4128
+Q 916 4406 1255 4562
+Q 1594 4719 2003 4719
+Q 2438 4719 2752 4544
+Q 3066 4369 3234 4084
+Q 3403 3800 3403 3469
+Q 3403 3075 3195 2800
+Q 2988 2525 2631 2419
+L 2631 2381
+Q 3078 2309 3325 2007
+Q 3572 1706 3572 1266
+Q 3572 884 3365 584
+Q 3159 284 2800 110
+Q 2441 -63 1984 -63
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Regular-3e6" d="M 438 -1266
+L 581 -778
+L 641 -794
+Q 900 -863 1087 -773
+Q 1275 -684 1403 -309
+L 1503 -19
+L 169 3494
+L 784 3494
+L 1528 1422
+Q 1609 1194 1673 969
+Q 1738 744 1797 525
+Q 1856 744 1920 969
+Q 1984 1194 2066 1422
+L 2816 3494
+L 3428 3494
+L 1894 -522
+Q 1734 -938 1478 -1134
+Q 1222 -1331 850 -1331
+Q 700 -1331 590 -1309
+Q 481 -1288 438 -1266
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Regular-5cc" d="M 725 2884
+L 656 4656
+L 1263 4656
+L 1194 2884
+L 725 2884
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Regular-3d8" d="M 1278 0
+L 219 3494
+L 816 3494
+L 1241 1969
+Q 1316 1697 1403 1358
+Q 1491 1019 1575 603
+Q 1659 1003 1742 1340
+Q 1825 1678 1906 1969
+L 2325 3494
+L 2925 3494
+L 3338 1969
+Q 3413 1688 3495 1352
+Q 3578 1016 3659 613
+Q 3747 1013 3833 1348
+Q 3919 1684 3997 1969
+L 4422 3494
+L 5019 3494
+L 3959 0
+L 3400 0
+L 2947 1581
+Q 2859 1881 2779 2200
+Q 2700 2519 2619 2853
+Q 2541 2519 2458 2197
+Q 2375 1875 2291 1581
+L 1838 0
+L 1278 0
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Regular-41" d="M 563 0
+L 563 4656
+L 2213 4656
+Q 2700 4656 3017 4489
+Q 3334 4322 3489 4042
+Q 3644 3763 3644 3422
+Q 3644 3122 3537 2926
+Q 3431 2731 3257 2615
+Q 3084 2500 2881 2444
+L 2881 2400
+Q 3100 2388 3317 2250
+Q 3534 2113 3679 1859
+Q 3825 1606 3825 1241
+Q 3825 891 3664 609
+Q 3503 328 3159 164
+Q 2816 0 2266 0
+L 563 0
+z
+M 1156 525
+L 2250 525
+Q 2794 525 3023 734
+Q 3253 944 3253 1247
+Q 3253 1481 3134 1678
+Q 3016 1875 2798 1994
+Q 2581 2113 2281 2113
+L 1156 2113
+L 1156 525
+z
+M 1156 2613
+L 2181 2613
+Q 2556 2613 2815 2831
+Q 3075 3050 3075 3409
+Q 3075 3713 2864 3922
+Q 2653 4131 2200 4131
+L 1156 4131
+L 1156 2613
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Regular-124" d="M 563 0
+L 563 4656
+L 1406 4656
+L 2553 1719
+Q 2619 1550 2716 1247
+Q 2813 944 2897 659
+Q 2978 934 3075 1239
+Q 3172 1544 3241 1719
+L 4372 4656
+L 5219 4656
+L 5219 0
+L 4634 0
+L 4634 2659
+Q 4634 2916 4640 3287
+Q 4647 3659 4656 4022
+Q 4528 3622 4398 3244
+Q 4269 2866 4188 2659
+L 3147 0
+L 2631 0
+L 1575 2659
+Q 1497 2856 1370 3229
+Q 1244 3603 1106 4013
+Q 1113 3681 1120 3304
+Q 1128 2928 1128 2659
+L 1128 0
+L 563 0
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Regular-543" d="M 1863 -63
+Q 1453 -63 1128 98
+Q 803 259 609 539
+Q 416 819 400 1175
+L 975 1175
+Q 1003 863 1258 661
+Q 1513 459 1863 459
+Q 2144 459 2364 590
+Q 2584 722 2709 953
+Q 2834 1184 2834 1478
+Q 2834 1778 2703 2015
+Q 2572 2253 2345 2389
+Q 2119 2525 1825 2525
+Q 1609 2525 1387 2456
+Q 1166 2388 1028 2281
+L 472 2350
+L 747 4656
+L 3197 4656
+L 3197 4134
+L 1247 4134
+L 1088 2775
+L 1113 2775
+Q 1256 2894 1475 2970
+Q 1694 3047 1934 3047
+Q 2363 3047 2697 2845
+Q 3031 2644 3223 2291
+Q 3416 1938 3416 1488
+Q 3416 1041 3214 691
+Q 3013 341 2663 139
+Q 2313 -63 1863 -63
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Regular-5e2" d="M 922 640
+Q 747 640 623 763
+Q 500 887 500 1062
+Q 500 1237 623 1360
+Q 747 1484 922 1484
+Q 1097 1484 1220 1360
+Q 1344 1237 1344 1062
+Q 1344 887 1220 763
+Q 1097 640 922 640
+z
+M 922 3168
+Q 747 3168 623 3291
+Q 500 3415 500 3590
+Q 500 3765 623 3888
+Q 747 4012 922 4012
+Q 1097 4012 1220 3888
+Q 1344 3765 1344 3590
+Q 1344 3415 1220 3291
+Q 1097 3168 922 3168
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Regular-18d" d="M 2053 -81
+Q 1297 -81 850 276
+Q 403 634 363 1219
+L 972 1219
+Q 997 956 1150 786
+Q 1303 616 1542 533
+Q 1781 450 2053 450
+Q 2369 450 2620 553
+Q 2872 656 3019 843
+Q 3166 1031 3166 1278
+Q 3166 1503 3039 1643
+Q 2913 1784 2703 1875
+Q 2494 1966 2244 2034
+L 1681 2194
+Q 1119 2353 806 2650
+Q 494 2947 494 3409
+Q 494 3803 706 4098
+Q 919 4394 1281 4556
+Q 1644 4719 2094 4719
+Q 2553 4719 2906 4556
+Q 3259 4394 3464 4114
+Q 3669 3834 3681 3481
+L 3100 3481
+Q 3059 3822 2775 4008
+Q 2491 4194 2075 4194
+Q 1622 4194 1347 3980
+Q 1072 3766 1072 3438
+Q 1072 3194 1223 3045
+Q 1375 2897 1583 2814
+Q 1791 2731 1959 2684
+L 2425 2556
+Q 2613 2506 2839 2418
+Q 3066 2331 3272 2186
+Q 3478 2041 3611 1817
+Q 3744 1594 3744 1269
+Q 3744 888 3545 581
+Q 3347 275 2969 97
+Q 2591 -81 2053 -81
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Regular-1cb" d="M 1431 0
+L 163 4656
+L 769 4656
+L 1506 1800
+Q 1581 1500 1650 1190
+Q 1719 881 1781 553
+Q 1844 881 1912 1190
+Q 1981 1500 2063 1800
+L 2816 4656
+L 3491 4656
+L 4238 1800
+Q 4394 1216 4522 572
+Q 4581 894 4651 1198
+Q 4722 1503 4797 1800
+L 5531 4656
+L 6144 4656
+L 4869 0
+L 4178 0
+L 3378 2950
+Q 3319 3172 3261 3425
+Q 3203 3678 3150 3984
+Q 3097 3700 3044 3451
+Q 2991 3203 2922 2950
+L 2125 0
+L 1431 0
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Regular-5f" d="M 563 0
+L 563 4656
+L 3400 4656
+L 3400 4131
+L 1156 4131
+L 1156 2613
+L 3247 2613
+L 3247 2088
+L 1156 2088
+L 1156 525
+L 3428 525
+L 3428 0
+L 563 0
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Regular-5b3" d="M 2494 2247
+L 2494 1728
+L 450 1728
+L 450 2247
+L 2494 2247
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Regular-542" d="M 375 947
+L 375 1431
+L 2413 4656
+L 3134 4656
+L 3134 1469
+L 3766 1469
+L 3766 947
+L 3134 947
+L 3134 0
+L 2566 0
+L 2566 947
+L 375 947
+z
+M 2569 1469
+L 2569 3913
+L 2531 3913
+L 1009 1506
+L 1009 1469
+L 2569 1469
+z
+" transform="scale(0.015625)"/>
+ </defs>
+ <use xlink:href="#Inter-Regular-8d"/>
+ <use xlink:href="#Inter-Regular-354" transform="translate(74.609375 0)"/>
+ <use xlink:href="#Inter-Regular-1fb" transform="translate(112.25 0)"/>
+ <use xlink:href="#Inter-Regular-34b" transform="translate(168.40625 0)"/>
+ <use xlink:href="#Inter-Regular-29e" transform="translate(229.640625 0)"/>
+ <use xlink:href="#Inter-Regular-2b1" transform="translate(288.765625 0)"/>
+ <use xlink:href="#Inter-Regular-24a" transform="translate(312.984375 0)"/>
+ <use xlink:href="#Inter-Regular-2e0" transform="translate(370.109375 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(394.328125 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(452.625 0)"/>
+ <use xlink:href="#Inter-Regular-53d" transform="translate(480.75 0)"/>
+ <use xlink:href="#Inter-Regular-5de" transform="translate(541.3125 0)"/>
+ <use xlink:href="#Inter-Regular-53e" transform="translate(561.484375 0)"/>
+ <use xlink:href="#Inter-Regular-5de" transform="translate(602.15625 0)"/>
+ <use xlink:href="#Inter-Regular-541" transform="translate(628.28125 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(690.046875 0)"/>
+ <use xlink:href="#Inter-Regular-1fb" transform="translate(718.171875 0)"/>
+ <use xlink:href="#Inter-Regular-305" transform="translate(774.328125 0)"/>
+ <use xlink:href="#Inter-Regular-255" transform="translate(833.40625 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(894.640625 0)"/>
+ <use xlink:href="#Inter-Regular-379" transform="translate(922.765625 0)"/>
+ <use xlink:href="#Inter-Regular-29e" transform="translate(955.484375 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(1014.609375 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(1072.90625 0)"/>
+ <use xlink:href="#Inter-Regular-53d" transform="translate(1101.03125 0)"/>
+ <use xlink:href="#Inter-Regular-5de" transform="translate(1161.59375 0)"/>
+ <use xlink:href="#Inter-Regular-53e" transform="translate(1181.765625 0)"/>
+ <use xlink:href="#Inter-Regular-5de" transform="translate(1222.4375 0)"/>
+ <use xlink:href="#Inter-Regular-53f" transform="translate(1251.25 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(1312.234375 0)"/>
+ <use xlink:href="#Inter-Regular-354" transform="translate(1340.359375 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(1376.34375 0)"/>
+ <use xlink:href="#Inter-Regular-2e0" transform="translate(1434.640625 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(1458.859375 0)"/>
+ <use xlink:href="#Inter-Regular-1fb" transform="translate(1518.140625 0)"/>
+ <use xlink:href="#Inter-Regular-367" transform="translate(1574.296875 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(1627.078125 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(1685.375 0)"/>
+ <use xlink:href="#Inter-Regular-242" transform="translate(1713.5 0)"/>
+ <use xlink:href="#Inter-Regular-2b1" transform="translate(1774.734375 0)"/>
+ <use xlink:href="#Inter-Regular-305" transform="translate(1798.953125 0)"/>
+ <use xlink:href="#Inter-Regular-1fb" transform="translate(1858.03125 0)"/>
+ <use xlink:href="#Inter-Regular-354" transform="translate(1914.1875 0)"/>
+ <use xlink:href="#Inter-Regular-3e6" transform="translate(1953.390625 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(2009.59375 0)"/>
+ <use xlink:href="#Inter-Regular-354" transform="translate(2037.71875 0)"/>
+ <use xlink:href="#Inter-Regular-393" transform="translate(2075.359375 0)"/>
+ <use xlink:href="#Inter-Regular-305" transform="translate(2134.484375 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(2193.5625 0)"/>
+ <use xlink:href="#Inter-Regular-292" transform="translate(2221.6875 0)"/>
+ <use xlink:href="#Inter-Regular-354" transform="translate(2283.015625 0)"/>
+ <use xlink:href="#Inter-Regular-1fb" transform="translate(2320.65625 0)"/>
+ <use xlink:href="#Inter-Regular-34b" transform="translate(2376.8125 0)"/>
+ <use xlink:href="#Inter-Regular-29e" transform="translate(2438.046875 0)"/>
+ <use xlink:href="#Inter-Regular-2b1" transform="translate(2497.171875 0)"/>
+ <use xlink:href="#Inter-Regular-24a" transform="translate(2521.390625 0)"/>
+ <use xlink:href="#Inter-Regular-2e0" transform="translate(2578.515625 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(2602.734375 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(2661.03125 0)"/>
+ <use xlink:href="#Inter-Regular-24a" transform="translate(2689.15625 0)"/>
+ <use xlink:href="#Inter-Regular-316" transform="translate(2746.28125 0)"/>
+ <use xlink:href="#Inter-Regular-305" transform="translate(2806.25 0)"/>
+ <use xlink:href="#Inter-Regular-379" transform="translate(2865.328125 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(2897.078125 0)"/>
+ <use xlink:href="#Inter-Regular-3e1" transform="translate(2953.125 0)"/>
+ <use xlink:href="#Inter-Regular-379" transform="translate(3009.671875 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(3042.390625 0)"/>
+ <use xlink:href="#Inter-Regular-316" transform="translate(3070.515625 0)"/>
+ <use xlink:href="#Inter-Regular-305" transform="translate(3130.484375 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(3189.5625 0)"/>
+ <use xlink:href="#Inter-Regular-379" transform="translate(3217.6875 0)"/>
+ <use xlink:href="#Inter-Regular-29e" transform="translate(3250.40625 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(3309.53125 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(3367.828125 0)"/>
+ <use xlink:href="#Inter-Regular-2b1" transform="translate(3395.953125 0)"/>
+ <use xlink:href="#Inter-Regular-367" transform="translate(3420.171875 0)"/>
+ <use xlink:href="#Inter-Regular-367" transform="translate(3472.953125 0)"/>
+ <use xlink:href="#Inter-Regular-393" transform="translate(3525.734375 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(3584.859375 0)"/>
+ <use xlink:href="#Inter-Regular-5cc" transform="translate(3641.6875 0)"/>
+ <use xlink:href="#Inter-Regular-367" transform="translate(3671.671875 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(3724.453125 0)"/>
+ <use xlink:href="#Inter-Regular-34b" transform="translate(3752.578125 0)"/>
+ <use xlink:href="#Inter-Regular-354" transform="translate(3813.8125 0)"/>
+ <use xlink:href="#Inter-Regular-316" transform="translate(3849.796875 0)"/>
+ <use xlink:href="#Inter-Regular-2fe" transform="translate(3909.765625 0)"/>
+ <use xlink:href="#Inter-Regular-34b" transform="translate(3997.359375 0)"/>
+ <use xlink:href="#Inter-Regular-379" transform="translate(4058.59375 0)"/>
+ <use xlink:href="#Inter-Regular-5dd" transform="translate(4091.3125 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(4120.125 0)"/>
+ <use xlink:href="#Inter-Regular-3d8" transform="translate(4148.25 0)"/>
+ <use xlink:href="#Inter-Regular-2b1" transform="translate(4230.09375 0)"/>
+ <use xlink:href="#Inter-Regular-379" transform="translate(4254.3125 0)"/>
+ <use xlink:href="#Inter-Regular-29e" transform="translate(4287.03125 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(4346.15625 0)"/>
+ <use xlink:href="#Inter-Regular-379" transform="translate(4374.28125 0)"/>
+ <use xlink:href="#Inter-Regular-29e" transform="translate(4407 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(4466.125 0)"/>
+ <use xlink:href="#Inter-Regular-2b1" transform="translate(4524.421875 0)"/>
+ <use xlink:href="#Inter-Regular-354" transform="translate(4548.640625 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(4586.28125 0)"/>
+ <use xlink:href="#Inter-Regular-255" transform="translate(4614.40625 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(4675.640625 0)"/>
+ <use xlink:href="#Inter-Regular-287" transform="translate(4733.9375 0)"/>
+ <use xlink:href="#Inter-Regular-1fb" transform="translate(4769.390625 0)"/>
+ <use xlink:href="#Inter-Regular-393" transform="translate(4825.546875 0)"/>
+ <use xlink:href="#Inter-Regular-2e0" transform="translate(4884.671875 0)"/>
+ <use xlink:href="#Inter-Regular-379" transform="translate(4910.359375 0)"/>
+ <use xlink:href="#Inter-Regular-367" transform="translate(4942.109375 0)"/>
+ <use xlink:href="#Inter-Regular-5de" transform="translate(4994.890625 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(5023.703125 0)"/>
+ <use xlink:href="#Inter-Regular-41" transform="translate(5051.828125 0)"/>
+ <use xlink:href="#Inter-Regular-124" transform="translate(5117.265625 0)"/>
+ <use xlink:href="#Inter-Regular-53f" transform="translate(5207.59375 0)"/>
+ <use xlink:href="#Inter-Regular-543" transform="translate(5268.578125 0)"/>
+ <use xlink:href="#Inter-Regular-5e2" transform="translate(5327.90625 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(5356.71875 0)"/>
+ <use xlink:href="#Inter-Regular-18d" transform="translate(5384.84375 0)"/>
+ <use xlink:href="#Inter-Regular-1cb" transform="translate(5449 0)"/>
+ <use xlink:href="#Inter-Regular-5f" transform="translate(5547.53125 0)"/>
+ <use xlink:href="#Inter-Regular-5b3" transform="translate(5607.640625 0)"/>
+ <use xlink:href="#Inter-Regular-242" transform="translate(5653.640625 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(5714.875 0)"/>
+ <use xlink:href="#Inter-Regular-305" transform="translate(5773.171875 0)"/>
+ <use xlink:href="#Inter-Regular-24a" transform="translate(5832.25 0)"/>
+ <use xlink:href="#Inter-Regular-29e" transform="translate(5889.375 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(5948.5 0)"/>
+ <use xlink:href="#Inter-Regular-367" transform="translate(5976.625 0)"/>
+ <use xlink:href="#Inter-Regular-379" transform="translate(6029.40625 0)"/>
+ <use xlink:href="#Inter-Regular-3e6" transform="translate(6064.078125 0)"/>
+ <use xlink:href="#Inter-Regular-2e0" transform="translate(6120.765625 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(6144.984375 0)"/>
+ <use xlink:href="#Inter-Regular-5dd" transform="translate(6203.28125 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(6232.09375 0)"/>
+ <use xlink:href="#Inter-Regular-316" transform="translate(6260.21875 0)"/>
+ <use xlink:href="#Inter-Regular-305" transform="translate(6320.1875 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(6379.265625 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(6437.5625 0)"/>
+ <use xlink:href="#Inter-Regular-255" transform="translate(6465.6875 0)"/>
+ <use xlink:href="#Inter-Regular-316" transform="translate(6526.921875 0)"/>
+ <use xlink:href="#Inter-Regular-24a" transform="translate(6586.890625 0)"/>
+ <use xlink:href="#Inter-Regular-393" transform="translate(6644.015625 0)"/>
+ <use xlink:href="#Inter-Regular-2fe" transform="translate(6703.140625 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(6790.734375 0)"/>
+ <use xlink:href="#Inter-Regular-305" transform="translate(6849.03125 0)"/>
+ <use xlink:href="#Inter-Regular-379" transform="translate(6908.109375 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(6940.828125 0)"/>
+ <use xlink:href="#Inter-Regular-34b" transform="translate(6968.953125 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(7030.1875 0)"/>
+ <use xlink:href="#Inter-Regular-354" transform="translate(7088.484375 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(7126.125 0)"/>
+ <use xlink:href="#Inter-Regular-367" transform="translate(7154.25 0)"/>
+ <use xlink:href="#Inter-Regular-316" transform="translate(7207.03125 0)"/>
+ <use xlink:href="#Inter-Regular-393" transform="translate(7267 0)"/>
+ <use xlink:href="#Inter-Regular-354" transform="translate(7326.125 0)"/>
+ <use xlink:href="#Inter-Regular-24a" transform="translate(7362.109375 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(7419.234375 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(7477.53125 0)"/>
+ <use xlink:href="#Inter-Regular-287" transform="translate(7505.65625 0)"/>
+ <use xlink:href="#Inter-Regular-2b1" transform="translate(7542.671875 0)"/>
+ <use xlink:href="#Inter-Regular-2e0" transform="translate(7566.890625 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(7591.109375 0)"/>
+ <use xlink:href="#Inter-Regular-5de" transform="translate(7649.40625 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(7678.21875 0)"/>
+ <use xlink:href="#Inter-Regular-292" transform="translate(7706.34375 0)"/>
+ <use xlink:href="#Inter-Regular-354" transform="translate(7767.671875 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(7803.65625 0)"/>
+ <use xlink:href="#Inter-Regular-34b" transform="translate(7861.953125 0)"/>
+ <use xlink:href="#Inter-Regular-5e1" transform="translate(7923.1875 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(7952 0)"/>
+ <use xlink:href="#Inter-Regular-354" transform="translate(7980.125 0)"/>
+ <use xlink:href="#Inter-Regular-292" transform="translate(8016.109375 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(8077.4375 0)"/>
+ <use xlink:href="#Inter-Regular-53e" transform="translate(8105.5625 0)"/>
+ <use xlink:href="#Inter-Regular-542" transform="translate(8146.234375 0)"/>
+ <use xlink:href="#Inter-Regular-5de" transform="translate(8207.453125 0)"/>
+ <use xlink:href="#Inter-Regular-53e" transform="translate(8227.625 0)"/>
+ <use xlink:href="#Inter-Regular-5de" transform="translate(8268.296875 0)"/>
+ <use xlink:href="#Inter-Regular-53e" transform="translate(8288.46875 0)"/>
+ </g>
+ </g>
+ <g id="text_10">
+ <!-- for the identifiers and paths the issue names, files ranked by names matched. -->
+ <g style="fill: #5b6474" transform="translate(48 821) scale(0.18 -0.18)">
+ <use xlink:href="#Inter-Regular-287"/>
+ <use xlink:href="#Inter-Regular-316" transform="translate(34.09375 0)"/>
+ <use xlink:href="#Inter-Regular-354" transform="translate(94.0625 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(131.703125 0)"/>
+ <use xlink:href="#Inter-Regular-379" transform="translate(159.828125 0)"/>
+ <use xlink:href="#Inter-Regular-29e" transform="translate(192.546875 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(251.671875 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(309.96875 0)"/>
+ <use xlink:href="#Inter-Regular-2b1" transform="translate(338.09375 0)"/>
+ <use xlink:href="#Inter-Regular-255" transform="translate(362.3125 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(423.546875 0)"/>
+ <use xlink:href="#Inter-Regular-305" transform="translate(481.84375 0)"/>
+ <use xlink:href="#Inter-Regular-379" transform="translate(540.921875 0)"/>
+ <use xlink:href="#Inter-Regular-2b1" transform="translate(573.640625 0)"/>
+ <use xlink:href="#Inter-Regular-287" transform="translate(597.859375 0)"/>
+ <use xlink:href="#Inter-Regular-2b1" transform="translate(634.875 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(659.09375 0)"/>
+ <use xlink:href="#Inter-Regular-354" transform="translate(717.390625 0)"/>
+ <use xlink:href="#Inter-Regular-367" transform="translate(755.03125 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(807.8125 0)"/>
+ <use xlink:href="#Inter-Regular-1fb" transform="translate(835.9375 0)"/>
+ <use xlink:href="#Inter-Regular-305" transform="translate(892.09375 0)"/>
+ <use xlink:href="#Inter-Regular-255" transform="translate(951.171875 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(1012.40625 0)"/>
+ <use xlink:href="#Inter-Regular-34b" transform="translate(1040.53125 0)"/>
+ <use xlink:href="#Inter-Regular-1fb" transform="translate(1102.75 0)"/>
+ <use xlink:href="#Inter-Regular-379" transform="translate(1158.90625 0)"/>
+ <use xlink:href="#Inter-Regular-29e" transform="translate(1191.625 0)"/>
+ <use xlink:href="#Inter-Regular-367" transform="translate(1250.75 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(1303.53125 0)"/>
+ <use xlink:href="#Inter-Regular-379" transform="translate(1331.65625 0)"/>
+ <use xlink:href="#Inter-Regular-29e" transform="translate(1364.375 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(1423.5 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(1481.796875 0)"/>
+ <use xlink:href="#Inter-Regular-2b1" transform="translate(1509.921875 0)"/>
+ <use xlink:href="#Inter-Regular-367" transform="translate(1534.140625 0)"/>
+ <use xlink:href="#Inter-Regular-367" transform="translate(1586.921875 0)"/>
+ <use xlink:href="#Inter-Regular-393" transform="translate(1639.703125 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(1698.828125 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(1757.125 0)"/>
+ <use xlink:href="#Inter-Regular-305" transform="translate(1785.25 0)"/>
+ <use xlink:href="#Inter-Regular-1fb" transform="translate(1844.328125 0)"/>
+ <use xlink:href="#Inter-Regular-2fe" transform="translate(1900.484375 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(1988.078125 0)"/>
+ <use xlink:href="#Inter-Regular-367" transform="translate(2046.375 0)"/>
+ <use xlink:href="#Inter-Regular-5dd" transform="translate(2099.15625 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(2127.96875 0)"/>
+ <use xlink:href="#Inter-Regular-287" transform="translate(2156.09375 0)"/>
+ <use xlink:href="#Inter-Regular-2b1" transform="translate(2193.109375 0)"/>
+ <use xlink:href="#Inter-Regular-2e0" transform="translate(2217.328125 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(2241.546875 0)"/>
+ <use xlink:href="#Inter-Regular-367" transform="translate(2299.84375 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(2352.625 0)"/>
+ <use xlink:href="#Inter-Regular-354" transform="translate(2380.75 0)"/>
+ <use xlink:href="#Inter-Regular-1fb" transform="translate(2418.390625 0)"/>
+ <use xlink:href="#Inter-Regular-305" transform="translate(2474.546875 0)"/>
+ <use xlink:href="#Inter-Regular-2d7" transform="translate(2533.625 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(2586.265625 0)"/>
+ <use xlink:href="#Inter-Regular-255" transform="translate(2644.5625 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(2705.796875 0)"/>
+ <use xlink:href="#Inter-Regular-242" transform="translate(2733.921875 0)"/>
+ <use xlink:href="#Inter-Regular-3e6" transform="translate(2793.203125 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(2849.40625 0)"/>
+ <use xlink:href="#Inter-Regular-305" transform="translate(2877.53125 0)"/>
+ <use xlink:href="#Inter-Regular-1fb" transform="translate(2936.609375 0)"/>
+ <use xlink:href="#Inter-Regular-2fe" transform="translate(2992.765625 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(3080.359375 0)"/>
+ <use xlink:href="#Inter-Regular-367" transform="translate(3138.65625 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(3191.4375 0)"/>
+ <use xlink:href="#Inter-Regular-2fe" transform="translate(3219.5625 0)"/>
+ <use xlink:href="#Inter-Regular-1fb" transform="translate(3307.15625 0)"/>
+ <use xlink:href="#Inter-Regular-379" transform="translate(3363.3125 0)"/>
+ <use xlink:href="#Inter-Regular-24a" transform="translate(3395.0625 0)"/>
+ <use xlink:href="#Inter-Regular-29e" transform="translate(3452.1875 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(3511.3125 0)"/>
+ <use xlink:href="#Inter-Regular-255" transform="translate(3569.609375 0)"/>
+ <use xlink:href="#Inter-Regular-5de" transform="translate(3630.84375 0)"/>
+ </g>
+ </g>
+ <g id="text_11">
+ <!-- This measures ranking, not whether a coding agent fixes more issues. The agent test of 0.1.3 is pending. -->
+ <g style="fill: #5b6474" transform="translate(48 846) scale(0.18 -0.18)">
+ <defs>
+ <path id="Inter-Regular-19b" d="M 306 4131
+L 306 4656
+L 3825 4656
+L 3825 4131
+L 2366 4131
+L 2366 0
+L 1772 0
+L 1772 4131
+L 306 4131
+z
+" transform="scale(0.015625)"/>
+ </defs>
+ <use xlink:href="#Inter-Regular-19b"/>
+ <use xlink:href="#Inter-Regular-29e" transform="translate(64.546875 0)"/>
+ <use xlink:href="#Inter-Regular-2b1" transform="translate(123.671875 0)"/>
+ <use xlink:href="#Inter-Regular-367" transform="translate(147.890625 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(200.671875 0)"/>
+ <use xlink:href="#Inter-Regular-2fe" transform="translate(228.796875 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(316.390625 0)"/>
+ <use xlink:href="#Inter-Regular-1fb" transform="translate(375.671875 0)"/>
+ <use xlink:href="#Inter-Regular-367" transform="translate(431.828125 0)"/>
+ <use xlink:href="#Inter-Regular-393" transform="translate(484.609375 0)"/>
+ <use xlink:href="#Inter-Regular-354" transform="translate(543.734375 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(579.71875 0)"/>
+ <use xlink:href="#Inter-Regular-367" transform="translate(638.015625 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(690.796875 0)"/>
+ <use xlink:href="#Inter-Regular-354" transform="translate(718.921875 0)"/>
+ <use xlink:href="#Inter-Regular-1fb" transform="translate(756.5625 0)"/>
+ <use xlink:href="#Inter-Regular-305" transform="translate(812.71875 0)"/>
+ <use xlink:href="#Inter-Regular-2d7" transform="translate(871.796875 0)"/>
+ <use xlink:href="#Inter-Regular-2b1" transform="translate(926.6875 0)"/>
+ <use xlink:href="#Inter-Regular-305" transform="translate(950.90625 0)"/>
+ <use xlink:href="#Inter-Regular-292" transform="translate(1009.984375 0)"/>
+ <use xlink:href="#Inter-Regular-5dd" transform="translate(1071.3125 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(1100.125 0)"/>
+ <use xlink:href="#Inter-Regular-305" transform="translate(1128.25 0)"/>
+ <use xlink:href="#Inter-Regular-316" transform="translate(1187.328125 0)"/>
+ <use xlink:href="#Inter-Regular-379" transform="translate(1247.296875 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(1280.015625 0)"/>
+ <use xlink:href="#Inter-Regular-3d8" transform="translate(1308.140625 0)"/>
+ <use xlink:href="#Inter-Regular-29e" transform="translate(1389.984375 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(1449.109375 0)"/>
+ <use xlink:href="#Inter-Regular-379" transform="translate(1507.40625 0)"/>
+ <use xlink:href="#Inter-Regular-29e" transform="translate(1540.125 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(1599.25 0)"/>
+ <use xlink:href="#Inter-Regular-354" transform="translate(1657.546875 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(1695.1875 0)"/>
+ <use xlink:href="#Inter-Regular-1fb" transform="translate(1723.3125 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(1779.46875 0)"/>
+ <use xlink:href="#Inter-Regular-24a" transform="translate(1807.59375 0)"/>
+ <use xlink:href="#Inter-Regular-316" transform="translate(1864.71875 0)"/>
+ <use xlink:href="#Inter-Regular-255" transform="translate(1924.6875 0)"/>
+ <use xlink:href="#Inter-Regular-2b1" transform="translate(1985.921875 0)"/>
+ <use xlink:href="#Inter-Regular-305" transform="translate(2010.140625 0)"/>
+ <use xlink:href="#Inter-Regular-292" transform="translate(2069.21875 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(2130.546875 0)"/>
+ <use xlink:href="#Inter-Regular-1fb" transform="translate(2158.671875 0)"/>
+ <use xlink:href="#Inter-Regular-292" transform="translate(2214.828125 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(2276.15625 0)"/>
+ <use xlink:href="#Inter-Regular-305" transform="translate(2334.453125 0)"/>
+ <use xlink:href="#Inter-Regular-379" transform="translate(2393.53125 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(2426.25 0)"/>
+ <use xlink:href="#Inter-Regular-287" transform="translate(2454.375 0)"/>
+ <use xlink:href="#Inter-Regular-2b1" transform="translate(2491.390625 0)"/>
+ <use xlink:href="#Inter-Regular-3e1" transform="translate(2515.609375 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(2567.953125 0)"/>
+ <use xlink:href="#Inter-Regular-367" transform="translate(2626.25 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(2679.03125 0)"/>
+ <use xlink:href="#Inter-Regular-2fe" transform="translate(2707.15625 0)"/>
+ <use xlink:href="#Inter-Regular-316" transform="translate(2794.75 0)"/>
+ <use xlink:href="#Inter-Regular-354" transform="translate(2854.71875 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(2890.703125 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(2949 0)"/>
+ <use xlink:href="#Inter-Regular-2b1" transform="translate(2977.125 0)"/>
+ <use xlink:href="#Inter-Regular-367" transform="translate(3001.34375 0)"/>
+ <use xlink:href="#Inter-Regular-367" transform="translate(3054.125 0)"/>
+ <use xlink:href="#Inter-Regular-393" transform="translate(3106.90625 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(3166.03125 0)"/>
+ <use xlink:href="#Inter-Regular-367" transform="translate(3224.328125 0)"/>
+ <use xlink:href="#Inter-Regular-5de" transform="translate(3277.109375 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(3305.921875 0)"/>
+ <use xlink:href="#Inter-Regular-19b" transform="translate(3334.046875 0)"/>
+ <use xlink:href="#Inter-Regular-29e" transform="translate(3398.59375 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(3457.71875 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(3516.015625 0)"/>
+ <use xlink:href="#Inter-Regular-1fb" transform="translate(3544.140625 0)"/>
+ <use xlink:href="#Inter-Regular-292" transform="translate(3600.296875 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(3661.625 0)"/>
+ <use xlink:href="#Inter-Regular-305" transform="translate(3719.921875 0)"/>
+ <use xlink:href="#Inter-Regular-379" transform="translate(3779 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(3811.71875 0)"/>
+ <use xlink:href="#Inter-Regular-379" transform="translate(3839.84375 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(3871.59375 0)"/>
+ <use xlink:href="#Inter-Regular-367" transform="translate(3929.890625 0)"/>
+ <use xlink:href="#Inter-Regular-379" transform="translate(3982.671875 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(4015.390625 0)"/>
+ <use xlink:href="#Inter-Regular-316" transform="translate(4043.515625 0)"/>
+ <use xlink:href="#Inter-Regular-287" transform="translate(4103.484375 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(4140.5 0)"/>
+ <use xlink:href="#Inter-Regular-53d" transform="translate(4168.625 0)"/>
+ <use xlink:href="#Inter-Regular-5de" transform="translate(4229.1875 0)"/>
+ <use xlink:href="#Inter-Regular-53e" transform="translate(4249.359375 0)"/>
+ <use xlink:href="#Inter-Regular-5de" transform="translate(4290.03125 0)"/>
+ <use xlink:href="#Inter-Regular-541" transform="translate(4316.15625 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(4377.921875 0)"/>
+ <use xlink:href="#Inter-Regular-2b1" transform="translate(4406.046875 0)"/>
+ <use xlink:href="#Inter-Regular-367" transform="translate(4430.265625 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(4483.046875 0)"/>
+ <use xlink:href="#Inter-Regular-34b" transform="translate(4511.171875 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(4572.40625 0)"/>
+ <use xlink:href="#Inter-Regular-305" transform="translate(4630.703125 0)"/>
+ <use xlink:href="#Inter-Regular-255" transform="translate(4689.78125 0)"/>
+ <use xlink:href="#Inter-Regular-2b1" transform="translate(4751.015625 0)"/>
+ <use xlink:href="#Inter-Regular-305" transform="translate(4775.234375 0)"/>
+ <use xlink:href="#Inter-Regular-292" transform="translate(4834.3125 0)"/>
+ <use xlink:href="#Inter-Regular-5de" transform="translate(4895.640625 0)"/>
+ </g>
+ </g>
+ <g id="text_12">
+ <!-- Method, task list and limits: -->
+ <g style="fill: #5b6474" transform="translate(48 871) scale(0.18 -0.18)">
+ <use xlink:href="#Inter-Regular-124"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(90.328125 0)"/>
+ <use xlink:href="#Inter-Regular-379" transform="translate(148.625 0)"/>
+ <use xlink:href="#Inter-Regular-29e" transform="translate(181.34375 0)"/>
+ <use xlink:href="#Inter-Regular-316" transform="translate(240.46875 0)"/>
+ <use xlink:href="#Inter-Regular-255" transform="translate(300.4375 0)"/>
+ <use xlink:href="#Inter-Regular-5dd" transform="translate(361.671875 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(390.484375 0)"/>
+ <use xlink:href="#Inter-Regular-379" transform="translate(418.609375 0)"/>
+ <use xlink:href="#Inter-Regular-1fb" transform="translate(451.8125 0)"/>
+ <use xlink:href="#Inter-Regular-367" transform="translate(507.96875 0)"/>
+ <use xlink:href="#Inter-Regular-2d7" transform="translate(560.75 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(615.640625 0)"/>
+ <use xlink:href="#Inter-Regular-2e0" transform="translate(643.765625 0)"/>
+ <use xlink:href="#Inter-Regular-2b1" transform="translate(667.984375 0)"/>
+ <use xlink:href="#Inter-Regular-367" transform="translate(692.203125 0)"/>
+ <use xlink:href="#Inter-Regular-379" transform="translate(744.984375 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(777.703125 0)"/>
+ <use xlink:href="#Inter-Regular-1fb" transform="translate(805.828125 0)"/>
+ <use xlink:href="#Inter-Regular-305" transform="translate(861.984375 0)"/>
+ <use xlink:href="#Inter-Regular-255" transform="translate(921.0625 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(982.296875 0)"/>
+ <use xlink:href="#Inter-Regular-2e0" transform="translate(1010.421875 0)"/>
+ <use xlink:href="#Inter-Regular-2b1" transform="translate(1034.640625 0)"/>
+ <use xlink:href="#Inter-Regular-2fe" transform="translate(1058.859375 0)"/>
+ <use xlink:href="#Inter-Regular-2b1" transform="translate(1146.453125 0)"/>
+ <use xlink:href="#Inter-Regular-379" transform="translate(1170.671875 0)"/>
+ <use xlink:href="#Inter-Regular-367" transform="translate(1202.421875 0)"/>
+ <use xlink:href="#Inter-Regular-5e1" transform="translate(1255.203125 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(1284.015625 0)"/>
+ </g>
+ </g>
+ <g id="text_13">
+ <!-- github.com/graphicle-ai/graphicle/blob/main/docs/benchmarks/retrieval.md -->
+ <g style="fill: #5b6474" transform="translate(284.203125 871) scale(0.17 -0.17)">
+ <defs>
+ <path id="JetBrainsMono-Regular-f5" d="M 1030 -1152
+L 1030 -627
+L 2022 -627
+Q 2323 -627 2496 -457
+Q 2669 -288 2669 0
+L 2669 320
+L 2682 896
+L 2662 896
+Q 2611 582 2361 412
+Q 2112 243 1734 243
+Q 1190 243 876 588
+Q 563 934 563 1536
+L 563 2278
+Q 563 2880 876 3232
+Q 1190 3584 1734 3584
+Q 2112 3584 2361 3405
+Q 2611 3226 2662 2912
+L 2675 2912
+L 2675 3520
+L 3245 3520
+L 3245 0
+Q 3245 -531 2915 -841
+Q 2586 -1152 2016 -1152
+L 1030 -1152
+z
+M 1907 723
+Q 2266 723 2470 947
+Q 2675 1171 2675 1568
+L 2675 2240
+Q 2675 2637 2470 2861
+Q 2266 3085 1907 3085
+Q 1542 3085 1340 2873
+Q 1139 2662 1139 2304
+L 1139 1504
+Q 1139 1146 1340 934
+Q 1542 723 1907 723
+z
+" transform="scale(0.015625)"/>
+ <path id="JetBrainsMono-Regular-ff" d="M 544 0
+L 544 525
+L 1792 525
+L 1792 2995
+L 672 2995
+L 672 3520
+L 2368 3520
+L 2368 525
+L 3552 525
+L 3552 0
+L 544 0
+z
+M 2016 4154
+Q 1805 4154 1683 4262
+Q 1562 4371 1562 4557
+Q 1562 4749 1683 4861
+Q 1805 4973 2016 4973
+Q 2227 4973 2348 4861
+Q 2470 4749 2470 4557
+Q 2470 4371 2348 4262
+Q 2227 4154 2016 4154
+z
+" transform="scale(0.015625)"/>
+ <path id="JetBrainsMono-Regular-14c" d="M 2272 0
+Q 1837 0 1574 253
+Q 1312 506 1312 928
+L 1312 2995
+L 301 2995
+L 301 3520
+L 1312 3520
+L 1312 4512
+L 1888 4512
+L 1888 3520
+L 3328 3520
+L 3328 2995
+L 1888 2995
+L 1888 928
+Q 1888 749 1993 637
+Q 2099 525 2272 525
+L 3296 525
+L 3296 0
+L 2272 0
+z
+" transform="scale(0.015625)"/>
+ <path id="JetBrainsMono-Regular-fc" d="M 589 0
+L 589 4672
+L 1165 4672
+L 1165 2848
+L 1171 2848
+Q 1216 3200 1459 3392
+Q 1702 3584 2106 3584
+Q 2637 3584 2950 3257
+Q 3264 2931 3264 2368
+L 3264 0
+L 2688 0
+L 2688 2272
+Q 2688 2669 2486 2883
+Q 2285 3098 1939 3098
+Q 1581 3098 1373 2874
+Q 1165 2650 1165 2240
+L 1165 0
+L 589 0
+z
+" transform="scale(0.015625)"/>
+ <path id="JetBrainsMono-Regular-151" d="M 1914 -64
+Q 1306 -64 941 297
+Q 576 659 576 1280
+L 576 3520
+L 1152 3520
+L 1152 1280
+Q 1152 896 1357 669
+Q 1562 442 1914 442
+Q 2272 442 2480 669
+Q 2688 896 2688 1280
+L 2688 3520
+L 3264 3520
+L 3264 1280
+Q 3264 659 2893 297
+Q 2522 -64 1914 -64
+z
+" transform="scale(0.015625)"/>
+ <path id="JetBrainsMono-Regular-d6" d="M 2125 -64
+Q 1728 -64 1472 131
+Q 1216 326 1171 672
+L 1165 672
+L 1165 0
+L 589 0
+L 589 4672
+L 1165 4672
+L 1165 3648
+L 1152 2848
+L 1158 2848
+Q 1210 3187 1469 3385
+Q 1728 3584 2125 3584
+Q 2656 3584 2969 3232
+Q 3283 2880 3283 2272
+L 3283 1242
+Q 3283 640 2969 288
+Q 2656 -64 2125 -64
+z
+M 1933 435
+Q 2298 435 2502 627
+Q 2707 819 2707 1248
+L 2707 2272
+Q 2707 2707 2502 2896
+Q 2298 3085 1933 3085
+Q 1581 3085 1373 2861
+Q 1165 2637 1165 2240
+L 1165 1280
+Q 1165 883 1373 659
+Q 1581 435 1933 435
+z
+" transform="scale(0.015625)"/>
+ <path id="JetBrainsMono-Regular-329" d="M 1920 -64
+Q 1683 -64 1539 77
+Q 1395 218 1395 442
+Q 1395 678 1539 825
+Q 1683 973 1920 973
+Q 2157 973 2301 825
+Q 2445 678 2445 442
+Q 2445 218 2301 77
+Q 2157 -64 1920 -64
+z
+" transform="scale(0.015625)"/>
+ <path id="JetBrainsMono-Regular-d7" d="M 1971 -64
+Q 1331 -64 947 294
+Q 563 653 563 1280
+L 563 2240
+Q 563 2867 947 3225
+Q 1331 3584 1971 3584
+Q 2579 3584 2953 3257
+Q 3328 2931 3347 2368
+L 2771 2368
+Q 2752 2707 2541 2889
+Q 2330 3072 1971 3072
+Q 1594 3072 1366 2857
+Q 1139 2643 1139 2246
+L 1139 1280
+Q 1139 883 1366 665
+Q 1594 448 1971 448
+Q 2330 448 2541 633
+Q 2752 819 2771 1152
+L 3347 1152
+Q 3328 589 2953 262
+Q 2579 -64 1971 -64
+z
+" transform="scale(0.015625)"/>
+ <path id="JetBrainsMono-Regular-122" d="M 1920 -51
+Q 1286 -51 912 320
+Q 538 691 538 1357
+L 538 2163
+Q 538 2835 909 3203
+Q 1280 3571 1920 3571
+Q 2560 3571 2931 3203
+Q 3302 2835 3302 2163
+L 3302 1357
+Q 3302 691 2928 320
+Q 2554 -51 1920 -51
+z
+M 1920 461
+Q 2298 461 2512 672
+Q 2726 883 2726 1293
+L 2726 2227
+Q 2726 2637 2512 2848
+Q 2298 3059 1920 3059
+Q 1549 3059 1331 2848
+Q 1114 2637 1114 2227
+L 1114 1293
+Q 1114 883 1331 672
+Q 1549 461 1920 461
+z
+" transform="scale(0.015625)"/>
+ <path id="JetBrainsMono-Regular-11a" d="M 384 0
+L 384 3520
+L 883 3520
+L 883 3053
+L 896 3053
+Q 928 3290 1085 3437
+Q 1242 3584 1485 3584
+Q 1715 3584 1875 3449
+Q 2035 3315 2106 3085
+L 2112 3085
+Q 2157 3315 2313 3449
+Q 2470 3584 2714 3584
+Q 3053 3584 3254 3331
+Q 3456 3078 3456 2675
+L 3456 0
+L 2918 0
+L 2918 2682
+Q 2918 2893 2816 3017
+Q 2714 3142 2534 3142
+Q 2362 3142 2259 3020
+Q 2157 2899 2157 2688
+L 2157 0
+L 1683 0
+L 1683 2682
+Q 1683 2893 1580 3017
+Q 1478 3142 1306 3142
+Q 1126 3142 1024 3020
+Q 922 2899 922 2688
+L 922 0
+L 384 0
+z
+" transform="scale(0.015625)"/>
+ <path id="JetBrainsMono-Regular-33d" d="M 480 -704
+L 2752 5312
+L 3360 5312
+L 1088 -704
+L 480 -704
+z
+" transform="scale(0.015625)"/>
+ <path id="JetBrainsMono-Regular-140" d="M 717 0
+L 717 3520
+L 1293 3520
+L 1293 2848
+L 1306 2848
+Q 1350 3187 1593 3385
+Q 1837 3584 2246 3584
+Q 2797 3584 3094 3254
+Q 3392 2925 3392 2317
+L 3392 2016
+L 2816 2016
+L 2816 2317
+Q 2816 3085 2067 3085
+Q 1690 3085 1491 2867
+Q 1293 2650 1293 2240
+L 1293 0
+L 717 0
+z
+" transform="scale(0.015625)"/>
+ <path id="JetBrainsMono-Regular-bd" d="M 1613 -64
+Q 1069 -64 749 240
+Q 429 544 429 1037
+Q 429 1363 576 1606
+Q 723 1850 985 1987
+Q 1248 2125 1587 2125
+L 2675 2125
+L 2675 2400
+Q 2675 3085 1926 3085
+Q 1594 3085 1389 2963
+Q 1184 2842 1171 2624
+L 595 2624
+Q 627 3040 982 3312
+Q 1338 3584 1926 3584
+Q 2566 3584 2908 3277
+Q 3251 2970 3251 2419
+L 3251 0
+L 2682 0
+L 2682 640
+L 2669 640
+Q 2618 314 2342 125
+Q 2067 -64 1613 -64
+z
+M 1754 422
+Q 2176 422 2425 627
+Q 2675 832 2675 1184
+L 2675 1677
+L 1651 1677
+Q 1370 1677 1194 1507
+Q 1018 1338 1018 1056
+Q 1018 762 1213 592
+Q 1408 422 1754 422
+z
+" transform="scale(0.015625)"/>
+ <path id="JetBrainsMono-Regular-13d" d="M 589 -1152
+L 589 3520
+L 1165 3520
+L 1165 2848
+L 1171 2848
+Q 1216 3194 1472 3389
+Q 1728 3584 2125 3584
+Q 2656 3584 2969 3235
+Q 3283 2886 3283 2278
+L 3283 1248
+Q 3283 640 2969 288
+Q 2656 -64 2125 -64
+Q 1728 -64 1472 134
+Q 1216 333 1171 672
+L 1152 672
+L 1165 -128
+L 1165 -1152
+L 589 -1152
+z
+M 1933 435
+Q 2298 435 2502 627
+Q 2707 819 2707 1248
+L 2707 2272
+Q 2707 2707 2502 2896
+Q 2298 3085 1933 3085
+Q 1581 3085 1373 2861
+Q 1165 2637 1165 2240
+L 1165 1280
+Q 1165 883 1373 659
+Q 1581 435 1933 435
+z
+" transform="scale(0.015625)"/>
+ <path id="JetBrainsMono-Regular-113" d="M 2432 0
+Q 1965 0 1686 272
+Q 1408 544 1408 992
+L 1408 4147
+L 192 4147
+L 192 4672
+L 1984 4672
+L 1984 992
+Q 1984 774 2105 649
+Q 2227 525 2432 525
+L 3520 525
+L 3520 0
+L 2432 0
+z
+" transform="scale(0.015625)"/>
+ <path id="JetBrainsMono-Regular-e1" d="M 1920 -64
+Q 1299 -64 918 310
+Q 538 685 538 1344
+L 538 2176
+Q 538 2835 918 3209
+Q 1299 3584 1920 3584
+Q 2336 3584 2646 3417
+Q 2957 3251 3129 2950
+Q 3302 2650 3302 2240
+L 3302 1613
+L 1101 1613
+L 1101 1280
+Q 1101 890 1325 662
+Q 1549 435 1920 435
+Q 2240 435 2448 560
+Q 2656 685 2701 896
+L 3277 896
+Q 3219 454 2848 195
+Q 2477 -64 1920 -64
+z
+M 1101 2061
+L 2739 2061
+L 2739 2240
+Q 2739 2656 2524 2883
+Q 2310 3110 1920 3110
+Q 1530 3110 1315 2883
+Q 1101 2656 1101 2240
+L 1101 2061
+z
+" transform="scale(0.015625)"/>
+ <path id="JetBrainsMono-Regular-357" d="M 896 1856
+L 896 2368
+L 2944 2368
+L 2944 1856
+L 896 1856
+z
+" transform="scale(0.015625)"/>
+ <path id="JetBrainsMono-Regular-11b" d="M 589 0
+L 589 3520
+L 1165 3520
+L 1165 2848
+L 1171 2848
+Q 1216 3200 1459 3392
+Q 1702 3584 2106 3584
+Q 2637 3584 2950 3257
+Q 3264 2931 3264 2368
+L 3264 0
+L 2688 0
+L 2688 2266
+Q 2688 2669 2486 2883
+Q 2285 3098 1939 3098
+Q 1581 3098 1373 2874
+Q 1165 2650 1165 2240
+L 1165 0
+L 589 0
+z
+" transform="scale(0.015625)"/>
+ <path id="JetBrainsMono-Regular-dd" d="M 1715 -64
+Q 1190 -64 873 288
+Q 557 640 557 1242
+L 557 2272
+Q 557 2880 870 3232
+Q 1184 3584 1715 3584
+Q 2112 3584 2371 3385
+Q 2630 3187 2682 2848
+L 2688 2848
+L 2675 3648
+L 2675 4672
+L 3251 4672
+L 3251 0
+L 2675 0
+L 2675 672
+L 2669 672
+Q 2624 326 2368 131
+Q 2112 -64 1715 -64
+z
+M 1907 435
+Q 2266 435 2470 659
+Q 2675 883 2675 1280
+L 2675 2240
+Q 2675 2637 2470 2861
+Q 2266 3085 1907 3085
+Q 1542 3085 1337 2896
+Q 1133 2707 1133 2272
+L 1133 1248
+Q 1133 819 1337 627
+Q 1542 435 1907 435
+z
+" transform="scale(0.015625)"/>
+ <path id="JetBrainsMono-Regular-144" d="M 1779 -51
+Q 1190 -51 867 214
+Q 544 480 544 966
+L 1120 966
+Q 1120 723 1293 585
+Q 1466 448 1779 448
+L 2061 448
+Q 2381 448 2557 589
+Q 2733 730 2733 986
+Q 2733 1440 2317 1498
+L 1344 1638
+Q 986 1690 787 1936
+Q 589 2182 589 2586
+Q 589 3046 905 3308
+Q 1222 3571 1779 3571
+L 2061 3571
+Q 2573 3571 2896 3318
+Q 3219 3066 3245 2656
+L 2662 2656
+Q 2650 2842 2486 2963
+Q 2323 3085 2061 3085
+L 1779 3085
+Q 1485 3085 1318 2950
+Q 1152 2816 1152 2586
+Q 1152 2214 1491 2163
+L 2400 2035
+Q 3296 1907 3296 986
+Q 3296 493 2973 221
+Q 2650 -51 2061 -51
+L 1779 -51
+z
+" transform="scale(0.015625)"/>
+ <path id="JetBrainsMono-Regular-110" d="M 621 0
+L 621 4672
+L 1197 4672
+L 1197 2067
+L 1869 2067
+L 2854 3520
+L 3514 3520
+L 2381 1843
+L 3578 0
+L 2906 0
+L 1882 1568
+L 1197 1568
+L 1197 0
+L 621 0
+z
+" transform="scale(0.015625)"/>
+ <path id="JetBrainsMono-Regular-169" d="M 1542 0
+L 346 3520
+L 966 3520
+L 1734 1152
+Q 1805 941 1856 745
+Q 1907 550 1933 442
+Q 1965 550 2009 745
+Q 2054 941 2118 1152
+L 2886 3520
+L 3494 3520
+L 2298 0
+L 1542 0
+z
+" transform="scale(0.015625)"/>
+ </defs>
+ <use xlink:href="#JetBrainsMono-Regular-f5"/>
+ <use xlink:href="#JetBrainsMono-Regular-ff" transform="translate(60 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-14c" transform="translate(120 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-fc" transform="translate(180 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-151" transform="translate(240 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-d6" transform="translate(300 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-329" transform="translate(360 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-d7" transform="translate(420 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-122" transform="translate(480 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-11a" transform="translate(540 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-33d" transform="translate(600 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-f5" transform="translate(660 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-140" transform="translate(720 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-bd" transform="translate(780 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-13d" transform="translate(840 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-fc" transform="translate(900 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-ff" transform="translate(960 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-d7" transform="translate(1020 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-113" transform="translate(1080 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-e1" transform="translate(1140 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-357" transform="translate(1200 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-bd" transform="translate(1260 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-ff" transform="translate(1320 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-33d" transform="translate(1380 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-f5" transform="translate(1440 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-140" transform="translate(1500 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-bd" transform="translate(1560 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-13d" transform="translate(1620 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-fc" transform="translate(1680 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-ff" transform="translate(1740 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-d7" transform="translate(1800 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-113" transform="translate(1860 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-e1" transform="translate(1920 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-33d" transform="translate(1980 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-d6" transform="translate(2040 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-113" transform="translate(2100 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-122" transform="translate(2160 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-d6" transform="translate(2220 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-33d" transform="translate(2280 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-11a" transform="translate(2340 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-bd" transform="translate(2400 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-ff" transform="translate(2460 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-11b" transform="translate(2520 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-33d" transform="translate(2580 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-dd" transform="translate(2640 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-122" transform="translate(2700 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-d7" transform="translate(2760 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-144" transform="translate(2820 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-33d" transform="translate(2880 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-d6" transform="translate(2940 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-e1" transform="translate(3000 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-11b" transform="translate(3060 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-d7" transform="translate(3120 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-fc" transform="translate(3180 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-11a" transform="translate(3240 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-bd" transform="translate(3300 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-140" transform="translate(3360 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-110" transform="translate(3420 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-144" transform="translate(3480 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-33d" transform="translate(3540 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-140" transform="translate(3600 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-e1" transform="translate(3660 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-14c" transform="translate(3720 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-140" transform="translate(3780 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-ff" transform="translate(3840 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-e1" transform="translate(3900 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-169" transform="translate(3960 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-bd" transform="translate(4020 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-113" transform="translate(4080 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-329" transform="translate(4140 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-11a" transform="translate(4200 0)"/>
+ <use xlink:href="#JetBrainsMono-Regular-dd" transform="translate(4260 0)"/>
+ </g>
+ </g>
+ <g id="text_14">
+ <!-- Top 1 -->
+ <g style="fill: #0a0b0f" transform="translate(48 206) scale(0.26 -0.26)">
+ <defs>
+ <path id="Inter-SemiBold-19b" d="M 259 3953
+L 259 4656
+L 3966 4656
+L 3966 3953
+L 2531 3953
+L 2531 0
+L 1697 0
+L 1697 3953
+L 259 3953
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-SemiBold-316" d="M 1947 -72
+Q 1438 -72 1063 154
+Q 688 381 483 786
+Q 278 1191 278 1728
+Q 278 2272 483 2680
+Q 688 3088 1063 3313
+Q 1438 3538 1947 3538
+Q 2456 3538 2831 3313
+Q 3206 3088 3412 2680
+Q 3619 2272 3619 1728
+Q 3619 1191 3412 786
+Q 3206 381 2831 154
+Q 2456 -72 1947 -72
+z
+M 1947 588
+Q 2231 588 2418 741
+Q 2606 894 2700 1153
+Q 2794 1413 2794 1731
+Q 2794 2053 2700 2312
+Q 2606 2572 2418 2725
+Q 2231 2878 1947 2878
+Q 1666 2878 1478 2725
+Q 1291 2572 1198 2312
+Q 1106 2053 1106 1731
+Q 1106 1413 1198 1153
+Q 1291 894 1478 741
+Q 1666 588 1947 588
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-SemiBold-34b" d="M 431 -1306
+L 431 3494
+L 1225 3494
+L 1225 2916
+L 1278 2916
+Q 1338 3038 1453 3183
+Q 1569 3328 1769 3433
+Q 1969 3538 2278 3538
+Q 2681 3538 3007 3331
+Q 3334 3125 3526 2723
+Q 3719 2322 3719 1741
+Q 3719 1166 3530 762
+Q 3341 359 3016 148
+Q 2691 -63 2275 -63
+Q 1975 -63 1776 39
+Q 1578 141 1459 284
+Q 1341 428 1278 553
+L 1244 553
+L 1244 -1306
+L 431 -1306
+z
+M 2056 606
+Q 2463 606 2673 929
+Q 2884 1253 2884 1744
+Q 2884 2231 2676 2550
+Q 2469 2869 2056 2869
+Q 1653 2869 1440 2561
+Q 1228 2253 1228 1744
+Q 1228 1234 1443 920
+Q 1659 606 2056 606
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-SemiBold-6f1" transform="scale(0.015625)"/>
+ <path id="Inter-SemiBold-53e" d="M 2241 4656
+L 2241 0
+L 1413 0
+L 1413 3913
+L 1381 3913
+L 294 3131
+L 294 3925
+L 1316 4656
+L 2241 4656
+z
+" transform="scale(0.015625)"/>
+ </defs>
+ <use xlink:href="#Inter-SemiBold-19b"/>
+ <use xlink:href="#Inter-SemiBold-316" transform="translate(58.203125 0)"/>
+ <use xlink:href="#Inter-SemiBold-34b" transform="translate(119.09375 0)"/>
+ <use xlink:href="#Inter-SemiBold-6f1" transform="translate(181.5 0)"/>
+ <use xlink:href="#Inter-SemiBold-53e" transform="translate(206.703125 0)"/>
+ </g>
+ </g>
+ <g id="text_15">
+ <!-- Issues of 100 with a changed file first -->
+ <g style="fill: #5b6474" transform="translate(48 236) scale(0.18 -0.18)">
+ <defs>
+ <path id="Inter-Regular-c5" d="M 1156 4656
+L 1156 0
+L 563 0
+L 563 4656
+L 1156 4656
+z
+" transform="scale(0.015625)"/>
+ </defs>
+ <use xlink:href="#Inter-Regular-c5"/>
+ <use xlink:href="#Inter-Regular-367" transform="translate(26.859375 0)"/>
+ <use xlink:href="#Inter-Regular-367" transform="translate(79.640625 0)"/>
+ <use xlink:href="#Inter-Regular-393" transform="translate(132.421875 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(191.546875 0)"/>
+ <use xlink:href="#Inter-Regular-367" transform="translate(249.84375 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(302.625 0)"/>
+ <use xlink:href="#Inter-Regular-316" transform="translate(330.75 0)"/>
+ <use xlink:href="#Inter-Regular-287" transform="translate(390.71875 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(427.734375 0)"/>
+ <use xlink:href="#Inter-Regular-53e" transform="translate(455.859375 0)"/>
+ <use xlink:href="#Inter-Regular-53d" transform="translate(496.53125 0)"/>
+ <use xlink:href="#Inter-Regular-53d" transform="translate(559.625 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(622.71875 0)"/>
+ <use xlink:href="#Inter-Regular-3d8" transform="translate(650.84375 0)"/>
+ <use xlink:href="#Inter-Regular-2b1" transform="translate(732.6875 0)"/>
+ <use xlink:href="#Inter-Regular-379" transform="translate(756.90625 0)"/>
+ <use xlink:href="#Inter-Regular-29e" transform="translate(789.625 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(848.75 0)"/>
+ <use xlink:href="#Inter-Regular-1fb" transform="translate(876.875 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(933.03125 0)"/>
+ <use xlink:href="#Inter-Regular-24a" transform="translate(961.15625 0)"/>
+ <use xlink:href="#Inter-Regular-29e" transform="translate(1018.28125 0)"/>
+ <use xlink:href="#Inter-Regular-1fb" transform="translate(1077.40625 0)"/>
+ <use xlink:href="#Inter-Regular-305" transform="translate(1133.5625 0)"/>
+ <use xlink:href="#Inter-Regular-292" transform="translate(1192.640625 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(1253.96875 0)"/>
+ <use xlink:href="#Inter-Regular-255" transform="translate(1312.265625 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(1373.5 0)"/>
+ <use xlink:href="#Inter-Regular-287" transform="translate(1401.625 0)"/>
+ <use xlink:href="#Inter-Regular-2b1" transform="translate(1438.640625 0)"/>
+ <use xlink:href="#Inter-Regular-2e0" transform="translate(1462.859375 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(1487.078125 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(1545.375 0)"/>
+ <use xlink:href="#Inter-Regular-287" transform="translate(1573.5 0)"/>
+ <use xlink:href="#Inter-Regular-2b1" transform="translate(1610.515625 0)"/>
+ <use xlink:href="#Inter-Regular-354" transform="translate(1634.734375 0)"/>
+ <use xlink:href="#Inter-Regular-367" transform="translate(1672.375 0)"/>
+ <use xlink:href="#Inter-Regular-379" transform="translate(1725.15625 0)"/>
+ </g>
+ </g>
+ <g id="text_16">
+ <!-- 43 -->
+ <g style="fill: #0a0b0f" transform="translate(72.745937 477.84) scale(0.28 -0.28)">
+ <defs>
+ <path id="Inter-Bold-542" d="M 316 828
+L 316 1581
+L 2263 4656
+L 3459 4656
+L 3459 1597
+L 4041 1597
+L 4041 828
+L 3459 828
+L 3459 0
+L 2544 0
+L 2544 828
+L 316 828
+z
+M 2563 1597
+L 2563 3606
+L 2525 3606
+L 1278 1634
+L 1278 1597
+L 2563 1597
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Bold-541" d="M 2059 -63
+Q 1553 -63 1161 110
+Q 769 284 542 593
+Q 316 903 309 1306
+L 1269 1306
+Q 1281 1044 1506 886
+Q 1731 728 2063 728
+Q 2406 728 2625 904
+Q 2844 1081 2844 1366
+Q 2844 1653 2612 1836
+Q 2381 2019 1975 2019
+L 1544 2019
+L 1544 2728
+L 1975 2728
+Q 2316 2728 2530 2900
+Q 2744 3072 2744 3353
+Q 2744 3622 2558 3789
+Q 2372 3956 2069 3956
+Q 1766 3956 1545 3797
+Q 1325 3638 1319 3366
+L 400 3366
+Q 406 3763 628 4069
+Q 850 4375 1226 4547
+Q 1603 4719 2075 4719
+Q 2553 4719 2912 4544
+Q 3272 4369 3470 4072
+Q 3669 3775 3669 3413
+Q 3669 3019 3426 2758
+Q 3184 2497 2797 2422
+L 2797 2388
+Q 3306 2322 3572 2030
+Q 3838 1738 3838 1303
+Q 3838 906 3609 598
+Q 3381 291 2979 114
+Q 2578 -63 2059 -63
+z
+" transform="scale(0.015625)"/>
+ </defs>
+ <use xlink:href="#Inter-Bold-542"/>
+ <use xlink:href="#Inter-Bold-541" transform="translate(67.625 0)"/>
+ </g>
+ </g>
+ <g id="text_17">
+ <!-- 0.1.3 -->
+ <g style="fill: #2e3440" transform="translate(69.709375 652) scale(0.2 -0.2)">
+ <use xlink:href="#Inter-Medium-53d"/>
+ <use xlink:href="#Inter-Medium-5de" transform="translate(61.859375 0)"/>
+ <use xlink:href="#Inter-Medium-53e" transform="translate(83.40625 0)"/>
+ <use xlink:href="#Inter-Medium-5de" transform="translate(124.90625 0)"/>
+ <use xlink:href="#Inter-Medium-541" transform="translate(152.703125 0)"/>
+ </g>
+ </g>
+ <g id="text_18">
+ <!-- 13 -->
+ <g style="fill: #2e3440" transform="translate(165.04125 571.44) scale(0.24 -0.24)">
+ <defs>
+ <path id="Inter-SemiBold-541" d="M 2034 -63
+Q 1544 -63 1164 104
+Q 784 272 565 572
+Q 347 872 334 1263
+L 1175 1263
+Q 1194 975 1437 806
+Q 1681 638 2034 638
+Q 2409 638 2650 831
+Q 2891 1025 2891 1334
+Q 2891 1653 2642 1854
+Q 2394 2056 1950 2056
+L 1538 2056
+L 1538 2700
+L 1950 2700
+Q 2313 2700 2541 2887
+Q 2769 3075 2769 3381
+Q 2769 3678 2570 3858
+Q 2372 4038 2044 4038
+Q 1722 4038 1483 3869
+Q 1244 3700 1234 3403
+L 431 3403
+Q 438 3791 655 4087
+Q 872 4384 1236 4551
+Q 1600 4719 2050 4719
+Q 2516 4719 2859 4544
+Q 3203 4369 3392 4076
+Q 3581 3784 3581 3431
+Q 3581 3038 3350 2772
+Q 3119 2506 2741 2422
+L 2741 2384
+Q 3228 2316 3489 2022
+Q 3750 1728 3750 1291
+Q 3750 900 3528 594
+Q 3306 288 2918 112
+Q 2531 -63 2034 -63
+z
+" transform="scale(0.015625)"/>
+ </defs>
+ <use xlink:href="#Inter-SemiBold-53e"/>
+ <use xlink:href="#Inter-SemiBold-541" transform="translate(42.28125 0)"/>
+ </g>
+ </g>
+ <g id="text_19">
+ <!-- 0.1.2 -->
+ <g style="fill: #2e3440" transform="translate(156.064063 652) scale(0.2 -0.2)">
+ <use xlink:href="#Inter-Medium-53d"/>
+ <use xlink:href="#Inter-Medium-5de" transform="translate(61.859375 0)"/>
+ <use xlink:href="#Inter-Medium-53e" transform="translate(83.40625 0)"/>
+ <use xlink:href="#Inter-Medium-5de" transform="translate(124.90625 0)"/>
+ <use xlink:href="#Inter-Medium-53f" transform="translate(155.234375 0)"/>
+ </g>
+ </g>
+ <g id="text_20">
+ <!-- 35 -->
+ <g style="fill: #2e3440" transform="translate(249.266875 502.8) scale(0.24 -0.24)">
+ <defs>
+ <path id="Inter-SemiBold-543" d="M 1931 -63
+Q 1475 -63 1117 109
+Q 759 281 550 579
+Q 341 878 328 1263
+L 1141 1263
+Q 1156 975 1384 795
+Q 1613 616 1931 616
+Q 2303 616 2545 866
+Q 2788 1116 2788 1509
+Q 2788 1906 2539 2164
+Q 2291 2422 1906 2422
+Q 1694 2422 1492 2342
+Q 1291 2263 1172 2134
+L 416 2256
+L 659 4656
+L 3353 4656
+L 3353 3956
+L 1350 3956
+L 1219 2719
+L 1244 2719
+Q 1375 2872 1611 2970
+Q 1847 3069 2128 3069
+Q 2550 3069 2883 2870
+Q 3216 2672 3406 2323
+Q 3597 1975 3597 1528
+Q 3597 1066 3384 706
+Q 3172 347 2797 142
+Q 2422 -63 1931 -63
+z
+" transform="scale(0.015625)"/>
+ </defs>
+ <use xlink:href="#Inter-SemiBold-541"/>
+ <use xlink:href="#Inter-SemiBold-543" transform="translate(63.625 0)"/>
+ </g>
+ </g>
+ <g id="text_21">
+ <!-- BM25 -->
+ <g style="fill: #2e3440" transform="translate(236.364062 652) scale(0.2 -0.2)">
+ <use xlink:href="#Inter-Medium-41"/>
+ <use xlink:href="#Inter-Medium-124" transform="translate(65.671875 0)"/>
+ <use xlink:href="#Inter-Medium-53f" transform="translate(156.9375 0)"/>
+ <use xlink:href="#Inter-Medium-543" transform="translate(218.5625 0)"/>
+ </g>
+ </g>
+ <g id="text_22">
+ <!-- 20 -->
+ <g style="fill: #2e3440" transform="translate(335.35625 549.6) scale(0.24 -0.24)">
+ <defs>
+ <path id="Inter-SemiBold-53f" d="M 419 0
+L 419 600
+L 2034 2191
+Q 2375 2538 2553 2784
+Q 2731 3031 2731 3328
+Q 2731 3656 2511 3847
+Q 2291 4038 1959 4038
+Q 1609 4038 1400 3830
+Q 1191 3622 1191 3263
+L 394 3263
+Q 394 3703 595 4031
+Q 797 4359 1153 4539
+Q 1509 4719 1969 4719
+Q 2434 4719 2787 4544
+Q 3141 4369 3337 4064
+Q 3534 3759 3534 3369
+Q 3534 3113 3436 2863
+Q 3338 2613 3088 2303
+Q 2838 1994 2384 1556
+L 1575 731
+L 1575 697
+L 3603 697
+L 3603 0
+L 419 0
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-SemiBold-53d" d="M 2113 -63
+Q 1263 -63 792 564
+Q 322 1191 322 2325
+Q 322 3456 794 4087
+Q 1266 4719 2113 4719
+Q 2956 4719 3428 4087
+Q 3900 3456 3900 2325
+Q 3900 1191 3429 564
+Q 2959 -63 2113 -63
+z
+M 2113 638
+Q 2569 638 2814 1078
+Q 3059 1519 3059 2325
+Q 3059 3134 2814 3578
+Q 2569 4022 2113 4022
+Q 1656 4022 1409 3576
+Q 1163 3131 1163 2325
+Q 1163 1519 1408 1078
+Q 1653 638 2113 638
+z
+" transform="scale(0.015625)"/>
+ </defs>
+ <use xlink:href="#Inter-SemiBold-53f"/>
+ <use xlink:href="#Inter-SemiBold-53d" transform="translate(62.3125 0)"/>
+ </g>
+ </g>
+ <g id="text_23">
+ <!-- grep -->
+ <g style="fill: #2e3440" transform="translate(328.821875 652) scale(0.2 -0.2)">
+ <use xlink:href="#Inter-Medium-292"/>
+ <use xlink:href="#Inter-Medium-354" transform="translate(61.96875 0)"/>
+ <use xlink:href="#Inter-Medium-266" transform="translate(98.734375 0)"/>
+ <use xlink:href="#Inter-Medium-34b" transform="translate(157.46875 0)"/>
+ </g>
+ </g>
+ <g id="text_24">
+ <!-- 0.1.3 vs BM25, McNemar exact: -->
+ <g style="fill: #5b6474" transform="translate(48 696) scale(0.18 -0.18)">
+ <use xlink:href="#Inter-Regular-53d"/>
+ <use xlink:href="#Inter-Regular-5de" transform="translate(60.5625 0)"/>
+ <use xlink:href="#Inter-Regular-53e" transform="translate(80.734375 0)"/>
+ <use xlink:href="#Inter-Regular-5de" transform="translate(121.40625 0)"/>
+ <use xlink:href="#Inter-Regular-541" transform="translate(147.53125 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(209.296875 0)"/>
+ <use xlink:href="#Inter-Regular-3d4" transform="translate(237.421875 0)"/>
+ <use xlink:href="#Inter-Regular-367" transform="translate(293.625 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(346.40625 0)"/>
+ <use xlink:href="#Inter-Regular-41" transform="translate(374.53125 0)"/>
+ <use xlink:href="#Inter-Regular-124" transform="translate(439.96875 0)"/>
+ <use xlink:href="#Inter-Regular-53f" transform="translate(530.296875 0)"/>
+ <use xlink:href="#Inter-Regular-543" transform="translate(591.28125 0)"/>
+ <use xlink:href="#Inter-Regular-5dd" transform="translate(647.921875 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(676.734375 0)"/>
+ <use xlink:href="#Inter-Regular-124" transform="translate(704.859375 0)"/>
+ <use xlink:href="#Inter-Regular-24a" transform="translate(795.1875 0)"/>
+ <use xlink:href="#Inter-Regular-12c" transform="translate(852.3125 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(927.65625 0)"/>
+ <use xlink:href="#Inter-Regular-2fe" transform="translate(985.953125 0)"/>
+ <use xlink:href="#Inter-Regular-1fb" transform="translate(1073.546875 0)"/>
+ <use xlink:href="#Inter-Regular-354" transform="translate(1129.703125 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(1167.34375 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(1195.46875 0)"/>
+ <use xlink:href="#Inter-Regular-3e1" transform="translate(1251.515625 0)"/>
+ <use xlink:href="#Inter-Regular-1fb" transform="translate(1306.109375 0)"/>
+ <use xlink:href="#Inter-Regular-24a" transform="translate(1362.265625 0)"/>
+ <use xlink:href="#Inter-Regular-379" transform="translate(1419.390625 0)"/>
+ <use xlink:href="#Inter-Regular-5e1" transform="translate(1452.109375 0)"/>
+ </g>
+ </g>
+ <g id="text_25">
+ <!-- +8 issues, p = 0.200, not significant -->
+ <g style="fill: #3e4757" transform="translate(59.994531 734) scale(0.18 -0.18)">
+ <defs>
+ <path id="Inter-SemiBold-5ff" d="M 1800 734
+L 1800 1975
+L 584 1975
+L 584 2640
+L 1800 2640
+L 1800 3878
+L 2506 3878
+L 2506 2640
+L 3725 2640
+L 3725 1975
+L 2506 1975
+L 2506 734
+L 1800 734
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-SemiBold-547" d="M 2047 -63
+Q 1541 -63 1152 106
+Q 763 275 542 572
+Q 322 869 322 1247
+Q 322 1538 450 1784
+Q 578 2031 798 2197
+Q 1019 2363 1294 2409
+L 1294 2438
+Q 934 2519 712 2806
+Q 491 3094 491 3472
+Q 491 3831 692 4112
+Q 894 4394 1245 4556
+Q 1597 4719 2047 4719
+Q 2494 4719 2845 4556
+Q 3197 4394 3400 4112
+Q 3603 3831 3603 3472
+Q 3603 3094 3379 2806
+Q 3156 2519 2803 2438
+L 2803 2409
+Q 3072 2363 3292 2197
+Q 3513 2031 3644 1784
+Q 3775 1538 3775 1247
+Q 3775 869 3553 572
+Q 3331 275 2940 106
+Q 2550 -63 2047 -63
+z
+M 2047 581
+Q 2441 581 2677 781
+Q 2913 981 2913 1306
+Q 2913 1641 2666 1856
+Q 2419 2072 2047 2072
+Q 1669 2072 1423 1856
+Q 1178 1641 1178 1306
+Q 1178 981 1414 781
+Q 1650 581 2047 581
+z
+M 2047 2703
+Q 2369 2703 2578 2893
+Q 2788 3084 2788 3391
+Q 2788 3694 2581 3878
+Q 2375 4063 2047 4063
+Q 1716 4063 1511 3878
+Q 1306 3694 1306 3391
+Q 1306 3088 1514 2895
+Q 1722 2703 2047 2703
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-SemiBold-2b1" d="M 431 0
+L 431 3494
+L 1244 3494
+L 1244 0
+L 431 0
+z
+M 838 3988
+Q 644 3988 505 4117
+Q 366 4247 366 4434
+Q 366 4619 505 4748
+Q 644 4878 838 4878
+Q 1035 4878 1174 4748
+Q 1313 4619 1313 4434
+Q 1313 4247 1174 4117
+Q 1035 3988 838 3988
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-SemiBold-367" d="M 1753 -72
+Q 1150 -72 758 186
+Q 366 444 275 919
+L 1034 1063
+Q 1172 550 1769 550
+Q 2069 550 2245 670
+Q 2422 791 2422 969
+Q 2422 1266 1950 1369
+L 1353 1497
+Q 372 1709 372 2475
+Q 372 2800 550 3037
+Q 728 3275 1045 3406
+Q 1363 3538 1781 3538
+Q 2375 3538 2720 3291
+Q 3066 3044 3172 2638
+L 2447 2494
+Q 2384 2675 2228 2803
+Q 2072 2931 1791 2931
+Q 1534 2931 1359 2817
+Q 1184 2703 1184 2525
+Q 1184 2372 1298 2273
+Q 1413 2175 1681 2116
+L 2275 1991
+Q 3253 1781 3253 1047
+Q 3253 716 3062 464
+Q 2872 213 2533 70
+Q 2194 -72 1753 -72
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-SemiBold-393" d="M 1628 -44
+Q 1088 -44 759 300
+Q 431 644 431 1272
+L 431 3494
+L 1244 3494
+L 1244 1397
+Q 1244 1047 1426 847
+Q 1609 647 1928 647
+Q 2253 647 2462 856
+Q 2672 1066 2672 1447
+L 2672 3494
+L 3488 3494
+L 3488 0
+L 2716 0
+L 2709 700
+Q 2397 -44 1628 -44
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-SemiBold-266" d="M 1975 -72
+Q 1447 -72 1067 150
+Q 688 372 483 775
+Q 278 1178 278 1725
+Q 278 2263 479 2670
+Q 681 3078 1051 3308
+Q 1422 3538 1922 3538
+Q 2347 3538 2711 3352
+Q 3075 3166 3297 2777
+Q 3519 2388 3519 1775
+L 3519 1519
+L 1088 1519
+Q 1103 1053 1348 809
+Q 1594 566 1984 566
+Q 2253 566 2445 681
+Q 2638 797 2719 1019
+L 3466 866
+Q 3341 444 2948 186
+Q 2556 -72 1975 -72
+z
+M 1091 2072
+L 2728 2072
+Q 2691 2447 2489 2673
+Q 2288 2900 1925 2900
+Q 1553 2900 1336 2661
+Q 1119 2422 1091 2072
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-SemiBold-5dd" d="M 385 -1197
+L 660 687
+L 1497 687
+L 953 -1197
+L 385 -1197
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-SemiBold-5f0" d="M 647 772
+L 647 1472
+L 3663 1472
+L 3663 772
+L 647 772
+z
+M 647 2225
+L 647 2919
+L 3663 2919
+L 3663 2225
+L 647 2225
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-SemiBold-5de" d="M 1019 -53
+Q 809 -53 664 90
+Q 519 234 519 447
+Q 519 656 664 800
+Q 809 944 1019 944
+Q 1231 944 1376 800
+Q 1522 656 1522 447
+Q 1522 234 1376 90
+Q 1231 -53 1019 -53
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-SemiBold-305" d="M 1244 2047
+L 1244 0
+L 431 0
+L 431 3494
+L 1200 3494
+L 1209 2797
+Q 1522 3538 2291 3538
+Q 2831 3538 3157 3194
+Q 3484 2850 3484 2222
+L 3484 0
+L 2672 0
+L 2672 2097
+Q 2672 2447 2490 2647
+Q 2309 2847 1991 2847
+Q 1666 2847 1455 2637
+Q 1244 2428 1244 2047
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-SemiBold-379" d="M 2047 3494
+L 2047 2856
+L 1372 2856
+L 1372 984
+Q 1372 794 1451 705
+Q 1531 616 1719 616
+Q 1775 616 1865 630
+Q 1956 644 2016 656
+L 2144 28
+Q 2009 -13 1868 -30
+Q 1728 -47 1600 -47
+Q 1097 -47 828 203
+Q 559 453 559 916
+L 559 2856
+L 63 2856
+L 63 3494
+L 559 3494
+L 559 4325
+L 1372 4325
+L 1372 3494
+L 2047 3494
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-SemiBold-292" d="M 1938 -1381
+Q 1306 -1381 925 -1150
+Q 544 -919 413 -572
+L 1100 -325
+Q 1181 -475 1367 -619
+Q 1553 -763 1934 -763
+Q 2313 -763 2541 -586
+Q 2769 -409 2769 -34
+L 2769 625
+L 2700 625
+Q 2638 500 2522 365
+Q 2406 231 2212 142
+Q 2019 53 1716 53
+Q 1316 53 989 242
+Q 663 431 470 809
+Q 278 1188 278 1756
+Q 278 2328 470 2726
+Q 663 3125 991 3331
+Q 1319 3538 1722 3538
+Q 2031 3538 2231 3434
+Q 2431 3331 2550 3186
+Q 2669 3041 2731 2916
+L 2775 2916
+L 2775 3494
+L 3572 3494
+L 3572 -9
+Q 3572 -478 3359 -781
+Q 3147 -1084 2778 -1232
+Q 2409 -1381 1938 -1381
+z
+M 1944 694
+Q 2341 694 2556 978
+Q 2772 1263 2772 1763
+Q 2772 2259 2559 2564
+Q 2347 2869 1944 2869
+Q 1531 2869 1320 2553
+Q 1109 2238 1109 1763
+Q 1109 1278 1321 986
+Q 1534 694 1944 694
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-SemiBold-287" d="M 2269 3494
+L 2269 2856
+L 1513 2856
+L 1513 0
+L 703 0
+L 703 2856
+L 63 2856
+L 63 3494
+L 703 3494
+L 703 3828
+Q 703 4175 850 4408
+Q 997 4641 1242 4758
+Q 1488 4875 1788 4875
+Q 2003 4875 2168 4840
+Q 2334 4806 2413 4778
+L 2247 4147
+Q 2194 4163 2117 4180
+Q 2041 4197 1938 4197
+Q 1709 4197 1611 4084
+Q 1513 3972 1513 3766
+L 1513 3494
+L 2269 3494
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-SemiBold-24a" d="M 1947 -72
+Q 1438 -72 1063 154
+Q 688 381 483 786
+Q 278 1191 278 1728
+Q 278 2272 483 2680
+Q 688 3088 1063 3313
+Q 1438 3538 1947 3538
+Q 2531 3538 2936 3245
+Q 3341 2953 3453 2441
+L 2694 2281
+Q 2628 2553 2437 2715
+Q 2247 2878 1953 2878
+Q 1528 2878 1317 2550
+Q 1106 2222 1106 1731
+Q 1106 1409 1200 1150
+Q 1294 891 1481 739
+Q 1669 588 1953 588
+Q 2253 588 2445 758
+Q 2638 928 2703 1209
+L 3463 1050
+Q 3350 528 2944 228
+Q 2538 -72 1947 -72
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-SemiBold-1fb" d="M 1406 -72
+Q 1075 -72 809 48
+Q 544 169 391 403
+Q 238 638 238 981
+Q 238 1375 430 1592
+Q 622 1809 926 1907
+Q 1231 2006 1569 2041
+Q 2025 2091 2228 2133
+Q 2431 2175 2431 2356
+L 2431 2372
+Q 2431 2628 2275 2770
+Q 2119 2913 1822 2913
+Q 1516 2913 1334 2778
+Q 1153 2644 1091 2472
+L 338 2625
+Q 491 3088 892 3313
+Q 1294 3538 1819 3538
+Q 2066 3538 2317 3480
+Q 2569 3422 2778 3286
+Q 2988 3150 3116 2917
+Q 3244 2684 3244 2334
+L 3244 0
+L 2466 0
+L 2466 481
+L 2434 481
+Q 2319 256 2066 92
+Q 1813 -72 1406 -72
+z
+M 1616 531
+Q 1991 531 2214 747
+Q 2438 963 2438 1253
+L 2438 1666
+Q 2381 1622 2237 1589
+Q 2094 1556 1933 1532
+Q 1772 1509 1666 1494
+Q 1391 1456 1208 1343
+Q 1025 1231 1025 991
+Q 1025 766 1190 648
+Q 1356 531 1616 531
+z
+" transform="scale(0.015625)"/>
+ </defs>
+ <use xlink:href="#Inter-SemiBold-5ff"/>
+ <use xlink:href="#Inter-SemiBold-547" transform="translate(67.28125 0)"/>
+ <use xlink:href="#Inter-SemiBold-6f1" transform="translate(131.296875 0)"/>
+ <use xlink:href="#Inter-SemiBold-2b1" transform="translate(156.5 0)"/>
+ <use xlink:href="#Inter-SemiBold-367" transform="translate(182.671875 0)"/>
+ <use xlink:href="#Inter-SemiBold-367" transform="translate(237.609375 0)"/>
+ <use xlink:href="#Inter-SemiBold-393" transform="translate(292.546875 0)"/>
+ <use xlink:href="#Inter-SemiBold-266" transform="translate(353.78125 0)"/>
+ <use xlink:href="#Inter-SemiBold-367" transform="translate(412.90625 0)"/>
+ <use xlink:href="#Inter-SemiBold-5dd" transform="translate(467.84375 0)"/>
+ <use xlink:href="#Inter-SemiBold-6f1" transform="translate(497.6875 0)"/>
+ <use xlink:href="#Inter-SemiBold-34b" transform="translate(522.890625 0)"/>
+ <use xlink:href="#Inter-SemiBold-6f1" transform="translate(585.296875 0)"/>
+ <use xlink:href="#Inter-SemiBold-5f0" transform="translate(610.5 0)"/>
+ <use xlink:href="#Inter-SemiBold-6f1" transform="translate(677.78125 0)"/>
+ <use xlink:href="#Inter-SemiBold-53d" transform="translate(702.984375 0)"/>
+ <use xlink:href="#Inter-SemiBold-5de" transform="translate(766.171875 0)"/>
+ <use xlink:href="#Inter-SemiBold-53f" transform="translate(798.0625 0)"/>
+ <use xlink:href="#Inter-SemiBold-53d" transform="translate(860.375 0)"/>
+ <use xlink:href="#Inter-SemiBold-53d" transform="translate(926.34375 0)"/>
+ <use xlink:href="#Inter-SemiBold-5dd" transform="translate(989.53125 0)"/>
+ <use xlink:href="#Inter-SemiBold-6f1" transform="translate(1019.375 0)"/>
+ <use xlink:href="#Inter-SemiBold-305" transform="translate(1044.578125 0)"/>
+ <use xlink:href="#Inter-SemiBold-316" transform="translate(1105.765625 0)"/>
+ <use xlink:href="#Inter-SemiBold-379" transform="translate(1166.65625 0)"/>
+ <use xlink:href="#Inter-SemiBold-6f1" transform="translate(1201.953125 0)"/>
+ <use xlink:href="#Inter-SemiBold-367" transform="translate(1227.15625 0)"/>
+ <use xlink:href="#Inter-SemiBold-2b1" transform="translate(1282.09375 0)"/>
+ <use xlink:href="#Inter-SemiBold-292" transform="translate(1308.265625 0)"/>
+ <use xlink:href="#Inter-SemiBold-305" transform="translate(1370.8125 0)"/>
+ <use xlink:href="#Inter-SemiBold-2b1" transform="translate(1432 0)"/>
+ <use xlink:href="#Inter-SemiBold-287" transform="translate(1458.171875 0)"/>
+ <use xlink:href="#Inter-SemiBold-2b1" transform="translate(1497.640625 0)"/>
+ <use xlink:href="#Inter-SemiBold-24a" transform="translate(1523.8125 0)"/>
+ <use xlink:href="#Inter-SemiBold-1fb" transform="translate(1583.046875 0)"/>
+ <use xlink:href="#Inter-SemiBold-305" transform="translate(1640.46875 0)"/>
+ <use xlink:href="#Inter-SemiBold-379" transform="translate(1701.65625 0)"/>
+ </g>
+ </g>
+ <g id="text_26">
+ <!-- Top 5 -->
+ <g style="fill: #0a0b0f" transform="translate(434 206) scale(0.26 -0.26)">
+ <use xlink:href="#Inter-SemiBold-19b"/>
+ <use xlink:href="#Inter-SemiBold-316" transform="translate(58.203125 0)"/>
+ <use xlink:href="#Inter-SemiBold-34b" transform="translate(119.09375 0)"/>
+ <use xlink:href="#Inter-SemiBold-6f1" transform="translate(181.5 0)"/>
+ <use xlink:href="#Inter-SemiBold-543" transform="translate(206.703125 0)"/>
+ </g>
+ </g>
+ <g id="text_27">
+ <!-- Issues of 100 with a changed file in the -->
+ <g style="fill: #5b6474" transform="translate(434 236) scale(0.18 -0.18)">
+ <use xlink:href="#Inter-Regular-c5"/>
+ <use xlink:href="#Inter-Regular-367" transform="translate(26.859375 0)"/>
+ <use xlink:href="#Inter-Regular-367" transform="translate(79.640625 0)"/>
+ <use xlink:href="#Inter-Regular-393" transform="translate(132.421875 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(191.546875 0)"/>
+ <use xlink:href="#Inter-Regular-367" transform="translate(249.84375 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(302.625 0)"/>
+ <use xlink:href="#Inter-Regular-316" transform="translate(330.75 0)"/>
+ <use xlink:href="#Inter-Regular-287" transform="translate(390.71875 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(427.734375 0)"/>
+ <use xlink:href="#Inter-Regular-53e" transform="translate(455.859375 0)"/>
+ <use xlink:href="#Inter-Regular-53d" transform="translate(496.53125 0)"/>
+ <use xlink:href="#Inter-Regular-53d" transform="translate(559.625 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(622.71875 0)"/>
+ <use xlink:href="#Inter-Regular-3d8" transform="translate(650.84375 0)"/>
+ <use xlink:href="#Inter-Regular-2b1" transform="translate(732.6875 0)"/>
+ <use xlink:href="#Inter-Regular-379" transform="translate(756.90625 0)"/>
+ <use xlink:href="#Inter-Regular-29e" transform="translate(789.625 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(848.75 0)"/>
+ <use xlink:href="#Inter-Regular-1fb" transform="translate(876.875 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(933.03125 0)"/>
+ <use xlink:href="#Inter-Regular-24a" transform="translate(961.15625 0)"/>
+ <use xlink:href="#Inter-Regular-29e" transform="translate(1018.28125 0)"/>
+ <use xlink:href="#Inter-Regular-1fb" transform="translate(1077.40625 0)"/>
+ <use xlink:href="#Inter-Regular-305" transform="translate(1133.5625 0)"/>
+ <use xlink:href="#Inter-Regular-292" transform="translate(1192.640625 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(1253.96875 0)"/>
+ <use xlink:href="#Inter-Regular-255" transform="translate(1312.265625 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(1373.5 0)"/>
+ <use xlink:href="#Inter-Regular-287" transform="translate(1401.625 0)"/>
+ <use xlink:href="#Inter-Regular-2b1" transform="translate(1438.640625 0)"/>
+ <use xlink:href="#Inter-Regular-2e0" transform="translate(1462.859375 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(1487.078125 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(1545.375 0)"/>
+ <use xlink:href="#Inter-Regular-2b1" transform="translate(1573.5 0)"/>
+ <use xlink:href="#Inter-Regular-305" transform="translate(1597.71875 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(1656.796875 0)"/>
+ <use xlink:href="#Inter-Regular-379" transform="translate(1684.921875 0)"/>
+ <use xlink:href="#Inter-Regular-29e" transform="translate(1717.640625 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(1776.765625 0)"/>
+ </g>
+ </g>
+ <g id="text_28">
+ <!-- first 5 -->
+ <g style="fill: #5b6474" transform="translate(434 260) scale(0.18 -0.18)">
+ <use xlink:href="#Inter-Regular-287"/>
+ <use xlink:href="#Inter-Regular-2b1" transform="translate(37.015625 0)"/>
+ <use xlink:href="#Inter-Regular-354" transform="translate(61.234375 0)"/>
+ <use xlink:href="#Inter-Regular-367" transform="translate(98.875 0)"/>
+ <use xlink:href="#Inter-Regular-379" transform="translate(151.65625 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(184.375 0)"/>
+ <use xlink:href="#Inter-Regular-543" transform="translate(212.5 0)"/>
+ </g>
+ </g>
+ <g id="text_29">
+ <!-- 75 -->
+ <g style="fill: #0a0b0f" transform="translate(460.535312 378) scale(0.28 -0.28)">
+ <defs>
+ <path id="Inter-Bold-546" d="M 553 0
+L 2491 3838
+L 2491 3869
+L 234 3869
+L 234 4656
+L 3488 4656
+L 3488 3856
+L 1544 0
+L 553 0
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Bold-543" d="M 1963 -63
+Q 1484 -63 1111 114
+Q 738 291 520 600
+Q 303 909 291 1306
+L 1222 1306
+Q 1234 1034 1450 864
+Q 1666 694 1963 694
+Q 2313 694 2538 925
+Q 2763 1156 2763 1525
+Q 2763 1897 2533 2133
+Q 2303 2369 1947 2369
+Q 1738 2369 1545 2284
+Q 1353 2200 1247 2063
+L 391 2213
+L 613 4656
+L 3431 4656
+L 3431 3869
+L 1403 3869
+L 1284 2691
+L 1309 2691
+Q 1434 2859 1679 2968
+Q 1925 3078 2225 3078
+Q 2647 3078 2976 2881
+Q 3306 2684 3497 2339
+Q 3688 1994 3688 1547
+Q 3688 1078 3470 715
+Q 3253 353 2864 145
+Q 2475 -63 1963 -63
+z
+" transform="scale(0.015625)"/>
+ </defs>
+ <use xlink:href="#Inter-Bold-546"/>
+ <use xlink:href="#Inter-Bold-543" transform="translate(57.1875 0)"/>
+ </g>
+ </g>
+ <g id="text_30">
+ <!-- 0.1.3 -->
+ <g style="fill: #2e3440" transform="translate(455.709375 652) scale(0.2 -0.2)">
+ <use xlink:href="#Inter-Medium-53d"/>
+ <use xlink:href="#Inter-Medium-5de" transform="translate(61.859375 0)"/>
+ <use xlink:href="#Inter-Medium-53e" transform="translate(83.40625 0)"/>
+ <use xlink:href="#Inter-Medium-5de" transform="translate(124.90625 0)"/>
+ <use xlink:href="#Inter-Medium-541" transform="translate(152.703125 0)"/>
+ </g>
+ </g>
+ <g id="text_31">
+ <!-- 30 -->
+ <g style="fill: #2e3440" transform="translate(548.19875 518.4) scale(0.24 -0.24)">
+ <use xlink:href="#Inter-SemiBold-541"/>
+ <use xlink:href="#Inter-SemiBold-53d" transform="translate(63.625 0)"/>
+ </g>
+ </g>
+ <g id="text_32">
+ <!-- 0.1.2 -->
+ <g style="fill: #2e3440" transform="translate(542.064062 652) scale(0.2 -0.2)">
+ <use xlink:href="#Inter-Medium-53d"/>
+ <use xlink:href="#Inter-Medium-5de" transform="translate(61.859375 0)"/>
+ <use xlink:href="#Inter-Medium-53e" transform="translate(83.40625 0)"/>
+ <use xlink:href="#Inter-Medium-5de" transform="translate(124.90625 0)"/>
+ <use xlink:href="#Inter-Medium-53f" transform="translate(155.234375 0)"/>
+ </g>
+ </g>
+ <g id="text_33">
+ <!-- 61 -->
+ <g style="fill: #2e3440" transform="translate(637.5 421.68) scale(0.24 -0.24)">
+ <defs>
+ <path id="Inter-SemiBold-545" d="M 2097 -63
+Q 1763 -63 1447 51
+Q 1131 166 876 425
+Q 622 684 472 1118
+Q 322 1553 322 2194
+Q 322 2991 545 3555
+Q 769 4119 1178 4419
+Q 1588 4719 2147 4719
+Q 2581 4719 2918 4547
+Q 3256 4375 3467 4078
+Q 3678 3781 3728 3403
+L 2909 3403
+Q 2844 3669 2647 3833
+Q 2450 3997 2147 3997
+Q 1659 3997 1396 3575
+Q 1134 3153 1134 2413
+L 1169 2413
+Q 1338 2716 1645 2886
+Q 1953 3056 2328 3056
+Q 2738 3056 3064 2861
+Q 3391 2666 3581 2322
+Q 3772 1978 3772 1538
+Q 3772 1078 3562 717
+Q 3353 356 2976 146
+Q 2600 -63 2097 -63
+z
+M 2094 616
+Q 2341 616 2537 736
+Q 2734 856 2848 1061
+Q 2963 1266 2963 1522
+Q 2963 1772 2852 1975
+Q 2741 2178 2545 2297
+Q 2350 2416 2103 2416
+Q 1856 2416 1657 2292
+Q 1459 2169 1343 1964
+Q 1228 1759 1228 1519
+Q 1228 1272 1340 1067
+Q 1453 863 1648 739
+Q 1844 616 2094 616
+z
+" transform="scale(0.015625)"/>
+ </defs>
+ <use xlink:href="#Inter-SemiBold-545"/>
+ <use xlink:href="#Inter-SemiBold-53e" transform="translate(63.96875 0)"/>
+ </g>
+ </g>
+ <g id="text_34">
+ <!-- BM25 -->
+ <g style="fill: #2e3440" transform="translate(622.364063 652) scale(0.2 -0.2)">
+ <use xlink:href="#Inter-Medium-41"/>
+ <use xlink:href="#Inter-Medium-124" transform="translate(65.671875 0)"/>
+ <use xlink:href="#Inter-Medium-53f" transform="translate(156.9375 0)"/>
+ <use xlink:href="#Inter-Medium-543" transform="translate(218.5625 0)"/>
+ </g>
+ </g>
+ <g id="text_35">
+ <!-- 54 -->
+ <g style="fill: #2e3440" transform="translate(721.40875 443.52) scale(0.24 -0.24)">
+ <defs>
+ <path id="Inter-SemiBold-542" d="M 334 866
+L 334 1531
+L 2313 4656
+L 3350 4656
+L 3350 1553
+L 3950 1553
+L 3950 866
+L 3350 866
+L 3350 0
+L 2550 0
+L 2550 866
+L 334 866
+z
+M 2566 1553
+L 2566 3706
+L 2528 3706
+L 1188 1591
+L 1188 1553
+L 2566 1553
+z
+" transform="scale(0.015625)"/>
+ </defs>
+ <use xlink:href="#Inter-SemiBold-543"/>
+ <use xlink:href="#Inter-SemiBold-542" transform="translate(61.234375 0)"/>
+ </g>
+ </g>
+ <g id="text_36">
+ <!-- grep -->
+ <g style="fill: #2e3440" transform="translate(714.821875 652) scale(0.2 -0.2)">
+ <use xlink:href="#Inter-Medium-292"/>
+ <use xlink:href="#Inter-Medium-354" transform="translate(61.96875 0)"/>
+ <use xlink:href="#Inter-Medium-266" transform="translate(98.734375 0)"/>
+ <use xlink:href="#Inter-Medium-34b" transform="translate(157.46875 0)"/>
+ </g>
+ </g>
+ <g id="text_37">
+ <!-- 0.1.3 vs BM25, McNemar exact: -->
+ <g style="fill: #5b6474" transform="translate(434 696) scale(0.18 -0.18)">
+ <use xlink:href="#Inter-Regular-53d"/>
+ <use xlink:href="#Inter-Regular-5de" transform="translate(60.5625 0)"/>
+ <use xlink:href="#Inter-Regular-53e" transform="translate(80.734375 0)"/>
+ <use xlink:href="#Inter-Regular-5de" transform="translate(121.40625 0)"/>
+ <use xlink:href="#Inter-Regular-541" transform="translate(147.53125 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(209.296875 0)"/>
+ <use xlink:href="#Inter-Regular-3d4" transform="translate(237.421875 0)"/>
+ <use xlink:href="#Inter-Regular-367" transform="translate(293.625 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(346.40625 0)"/>
+ <use xlink:href="#Inter-Regular-41" transform="translate(374.53125 0)"/>
+ <use xlink:href="#Inter-Regular-124" transform="translate(439.96875 0)"/>
+ <use xlink:href="#Inter-Regular-53f" transform="translate(530.296875 0)"/>
+ <use xlink:href="#Inter-Regular-543" transform="translate(591.28125 0)"/>
+ <use xlink:href="#Inter-Regular-5dd" transform="translate(647.921875 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(676.734375 0)"/>
+ <use xlink:href="#Inter-Regular-124" transform="translate(704.859375 0)"/>
+ <use xlink:href="#Inter-Regular-24a" transform="translate(795.1875 0)"/>
+ <use xlink:href="#Inter-Regular-12c" transform="translate(852.3125 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(927.65625 0)"/>
+ <use xlink:href="#Inter-Regular-2fe" transform="translate(985.953125 0)"/>
+ <use xlink:href="#Inter-Regular-1fb" transform="translate(1073.546875 0)"/>
+ <use xlink:href="#Inter-Regular-354" transform="translate(1129.703125 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(1167.34375 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(1195.46875 0)"/>
+ <use xlink:href="#Inter-Regular-3e1" transform="translate(1251.515625 0)"/>
+ <use xlink:href="#Inter-Regular-1fb" transform="translate(1306.109375 0)"/>
+ <use xlink:href="#Inter-Regular-24a" transform="translate(1362.265625 0)"/>
+ <use xlink:href="#Inter-Regular-379" transform="translate(1419.390625 0)"/>
+ <use xlink:href="#Inter-Regular-5e1" transform="translate(1452.109375 0)"/>
+ </g>
+ </g>
+ <g id="text_38">
+ <!-- +14 issues, p = 0.013 -->
+ <g style="fill: #ffffff" transform="translate(445.979688 734) scale(0.18 -0.18)">
+ <use xlink:href="#Inter-SemiBold-5ff"/>
+ <use xlink:href="#Inter-SemiBold-53e" transform="translate(67.28125 0)"/>
+ <use xlink:href="#Inter-SemiBold-542" transform="translate(109.5625 0)"/>
+ <use xlink:href="#Inter-SemiBold-6f1" transform="translate(176.171875 0)"/>
+ <use xlink:href="#Inter-SemiBold-2b1" transform="translate(201.375 0)"/>
+ <use xlink:href="#Inter-SemiBold-367" transform="translate(227.546875 0)"/>
+ <use xlink:href="#Inter-SemiBold-367" transform="translate(282.484375 0)"/>
+ <use xlink:href="#Inter-SemiBold-393" transform="translate(337.421875 0)"/>
+ <use xlink:href="#Inter-SemiBold-266" transform="translate(398.65625 0)"/>
+ <use xlink:href="#Inter-SemiBold-367" transform="translate(457.78125 0)"/>
+ <use xlink:href="#Inter-SemiBold-5dd" transform="translate(512.71875 0)"/>
+ <use xlink:href="#Inter-SemiBold-6f1" transform="translate(542.5625 0)"/>
+ <use xlink:href="#Inter-SemiBold-34b" transform="translate(567.765625 0)"/>
+ <use xlink:href="#Inter-SemiBold-6f1" transform="translate(630.171875 0)"/>
+ <use xlink:href="#Inter-SemiBold-5f0" transform="translate(655.375 0)"/>
+ <use xlink:href="#Inter-SemiBold-6f1" transform="translate(722.65625 0)"/>
+ <use xlink:href="#Inter-SemiBold-53d" transform="translate(747.859375 0)"/>
+ <use xlink:href="#Inter-SemiBold-5de" transform="translate(811.046875 0)"/>
+ <use xlink:href="#Inter-SemiBold-53d" transform="translate(840.15625 0)"/>
+ <use xlink:href="#Inter-SemiBold-53e" transform="translate(906.125 0)"/>
+ <use xlink:href="#Inter-SemiBold-541" transform="translate(948.40625 0)"/>
+ </g>
+ </g>
+ <g id="text_39">
+ <!-- Top 10 -->
+ <g style="fill: #0a0b0f" transform="translate(820 206) scale(0.26 -0.26)">
+ <use xlink:href="#Inter-SemiBold-19b"/>
+ <use xlink:href="#Inter-SemiBold-316" transform="translate(58.203125 0)"/>
+ <use xlink:href="#Inter-SemiBold-34b" transform="translate(119.09375 0)"/>
+ <use xlink:href="#Inter-SemiBold-6f1" transform="translate(181.5 0)"/>
+ <use xlink:href="#Inter-SemiBold-53e" transform="translate(206.703125 0)"/>
+ <use xlink:href="#Inter-SemiBold-53d" transform="translate(248.984375 0)"/>
+ </g>
+ </g>
+ <g id="text_40">
+ <!-- Issues of 100 with a changed file in the -->
+ <g style="fill: #5b6474" transform="translate(820 236) scale(0.18 -0.18)">
+ <use xlink:href="#Inter-Regular-c5"/>
+ <use xlink:href="#Inter-Regular-367" transform="translate(26.859375 0)"/>
+ <use xlink:href="#Inter-Regular-367" transform="translate(79.640625 0)"/>
+ <use xlink:href="#Inter-Regular-393" transform="translate(132.421875 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(191.546875 0)"/>
+ <use xlink:href="#Inter-Regular-367" transform="translate(249.84375 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(302.625 0)"/>
+ <use xlink:href="#Inter-Regular-316" transform="translate(330.75 0)"/>
+ <use xlink:href="#Inter-Regular-287" transform="translate(390.71875 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(427.734375 0)"/>
+ <use xlink:href="#Inter-Regular-53e" transform="translate(455.859375 0)"/>
+ <use xlink:href="#Inter-Regular-53d" transform="translate(496.53125 0)"/>
+ <use xlink:href="#Inter-Regular-53d" transform="translate(559.625 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(622.71875 0)"/>
+ <use xlink:href="#Inter-Regular-3d8" transform="translate(650.84375 0)"/>
+ <use xlink:href="#Inter-Regular-2b1" transform="translate(732.6875 0)"/>
+ <use xlink:href="#Inter-Regular-379" transform="translate(756.90625 0)"/>
+ <use xlink:href="#Inter-Regular-29e" transform="translate(789.625 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(848.75 0)"/>
+ <use xlink:href="#Inter-Regular-1fb" transform="translate(876.875 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(933.03125 0)"/>
+ <use xlink:href="#Inter-Regular-24a" transform="translate(961.15625 0)"/>
+ <use xlink:href="#Inter-Regular-29e" transform="translate(1018.28125 0)"/>
+ <use xlink:href="#Inter-Regular-1fb" transform="translate(1077.40625 0)"/>
+ <use xlink:href="#Inter-Regular-305" transform="translate(1133.5625 0)"/>
+ <use xlink:href="#Inter-Regular-292" transform="translate(1192.640625 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(1253.96875 0)"/>
+ <use xlink:href="#Inter-Regular-255" transform="translate(1312.265625 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(1373.5 0)"/>
+ <use xlink:href="#Inter-Regular-287" transform="translate(1401.625 0)"/>
+ <use xlink:href="#Inter-Regular-2b1" transform="translate(1438.640625 0)"/>
+ <use xlink:href="#Inter-Regular-2e0" transform="translate(1462.859375 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(1487.078125 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(1545.375 0)"/>
+ <use xlink:href="#Inter-Regular-2b1" transform="translate(1573.5 0)"/>
+ <use xlink:href="#Inter-Regular-305" transform="translate(1597.71875 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(1656.796875 0)"/>
+ <use xlink:href="#Inter-Regular-379" transform="translate(1684.921875 0)"/>
+ <use xlink:href="#Inter-Regular-29e" transform="translate(1717.640625 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(1776.765625 0)"/>
+ </g>
+ </g>
+ <g id="text_41">
+ <!-- first 10 -->
+ <g style="fill: #5b6474" transform="translate(820 260) scale(0.18 -0.18)">
+ <use xlink:href="#Inter-Regular-287"/>
+ <use xlink:href="#Inter-Regular-2b1" transform="translate(37.015625 0)"/>
+ <use xlink:href="#Inter-Regular-354" transform="translate(61.234375 0)"/>
+ <use xlink:href="#Inter-Regular-367" transform="translate(98.875 0)"/>
+ <use xlink:href="#Inter-Regular-379" transform="translate(151.65625 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(184.375 0)"/>
+ <use xlink:href="#Inter-Regular-53e" transform="translate(212.5 0)"/>
+ <use xlink:href="#Inter-Regular-53d" transform="translate(253.171875 0)"/>
+ </g>
+ </g>
+ <g id="text_42">
+ <!-- 82 -->
+ <g style="fill: #0a0b0f" transform="translate(845.319062 356.16) scale(0.28 -0.28)">
+ <defs>
+ <path id="Inter-Bold-547" d="M 2081 -63
+Q 1559 -63 1156 107
+Q 753 278 523 575
+Q 294 872 294 1250
+Q 294 1541 425 1786
+Q 556 2031 784 2195
+Q 1013 2359 1297 2406
+L 1297 2434
+Q 925 2513 694 2800
+Q 463 3088 463 3469
+Q 463 3828 672 4111
+Q 881 4394 1247 4556
+Q 1613 4719 2081 4719
+Q 2547 4719 2914 4556
+Q 3281 4394 3492 4111
+Q 3703 3828 3703 3469
+Q 3703 3088 3468 2800
+Q 3234 2513 2872 2434
+L 2872 2406
+Q 3150 2359 3376 2195
+Q 3603 2031 3739 1786
+Q 3875 1541 3875 1250
+Q 3875 872 3644 575
+Q 3413 278 3008 107
+Q 2603 -63 2081 -63
+z
+M 2081 644
+Q 2438 644 2658 833
+Q 2878 1022 2878 1325
+Q 2878 1634 2651 1832
+Q 2425 2031 2081 2031
+Q 1734 2031 1509 1832
+Q 1284 1634 1284 1325
+Q 1284 1025 1503 834
+Q 1722 644 2081 644
+z
+M 2081 2731
+Q 2378 2731 2573 2909
+Q 2769 3088 2769 3366
+Q 2769 3644 2576 3817
+Q 2384 3991 2081 3991
+Q 1778 3991 1586 3819
+Q 1394 3647 1394 3366
+Q 1394 3088 1587 2909
+Q 1781 2731 2081 2731
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Bold-53f" d="M 388 0
+L 388 688
+L 2038 2234
+Q 2353 2544 2523 2773
+Q 2694 3003 2694 3284
+Q 2694 3597 2489 3776
+Q 2284 3956 1972 3956
+Q 1647 3956 1451 3762
+Q 1256 3569 1256 3228
+L 344 3228
+Q 344 3681 551 4017
+Q 759 4353 1128 4536
+Q 1497 4719 1978 4719
+Q 2472 4719 2840 4542
+Q 3209 4366 3414 4056
+Q 3619 3747 3619 3344
+Q 3619 3084 3517 2831
+Q 3416 2578 3155 2264
+Q 2894 1950 2416 1513
+L 1713 819
+L 1713 784
+L 3681 784
+L 3681 0
+L 388 0
+z
+" transform="scale(0.015625)"/>
+ </defs>
+ <use xlink:href="#Inter-Bold-547"/>
+ <use xlink:href="#Inter-Bold-53f" transform="translate(65.09375 0)"/>
+ </g>
+ </g>
+ <g id="text_43">
+ <!-- 0.1.3 -->
+ <g style="fill: #2e3440" transform="translate(841.709375 652) scale(0.2 -0.2)">
+ <use xlink:href="#Inter-Medium-53d"/>
+ <use xlink:href="#Inter-Medium-5de" transform="translate(61.859375 0)"/>
+ <use xlink:href="#Inter-Medium-53e" transform="translate(83.40625 0)"/>
+ <use xlink:href="#Inter-Medium-5de" transform="translate(124.90625 0)"/>
+ <use xlink:href="#Inter-Medium-541" transform="translate(152.703125 0)"/>
+ </g>
+ </g>
+ <g id="text_44">
+ <!-- 30 -->
+ <g style="fill: #2e3440" transform="translate(934.19875 518.4) scale(0.24 -0.24)">
+ <use xlink:href="#Inter-SemiBold-541"/>
+ <use xlink:href="#Inter-SemiBold-53d" transform="translate(63.625 0)"/>
+ </g>
+ </g>
+ <g id="text_45">
+ <!-- 0.1.2 -->
+ <g style="fill: #2e3440" transform="translate(928.064062 652) scale(0.2 -0.2)">
+ <use xlink:href="#Inter-Medium-53d"/>
+ <use xlink:href="#Inter-Medium-5de" transform="translate(61.859375 0)"/>
+ <use xlink:href="#Inter-Medium-53e" transform="translate(83.40625 0)"/>
+ <use xlink:href="#Inter-Medium-5de" transform="translate(124.90625 0)"/>
+ <use xlink:href="#Inter-Medium-53f" transform="translate(155.234375 0)"/>
+ </g>
+ </g>
+ <g id="text_46">
+ <!-- 77 -->
+ <g style="fill: #2e3440" transform="translate(1022.185625 371.76) scale(0.24 -0.24)">
+ <defs>
+ <path id="Inter-SemiBold-546" d="M 578 0
+L 2559 3925
+L 2559 3956
+L 259 3956
+L 259 4656
+L 3428 4656
+L 3428 3938
+L 1447 0
+L 578 0
+z
+" transform="scale(0.015625)"/>
+ </defs>
+ <use xlink:href="#Inter-SemiBold-546"/>
+ <use xlink:href="#Inter-SemiBold-546" transform="translate(59.578125 0)"/>
+ </g>
+ </g>
+ <g id="text_47">
+ <!-- BM25 -->
+ <g style="fill: #2e3440" transform="translate(1008.364063 652) scale(0.2 -0.2)">
+ <use xlink:href="#Inter-Medium-41"/>
+ <use xlink:href="#Inter-Medium-124" transform="translate(65.671875 0)"/>
+ <use xlink:href="#Inter-Medium-53f" transform="translate(156.9375 0)"/>
+ <use xlink:href="#Inter-Medium-543" transform="translate(218.5625 0)"/>
+ </g>
+ </g>
+ <g id="text_48">
+ <!-- 71 -->
+ <g style="fill: #2e3440" transform="translate(1110.76125 390.48) scale(0.24 -0.24)">
+ <use xlink:href="#Inter-SemiBold-546"/>
+ <use xlink:href="#Inter-SemiBold-53e" transform="translate(57.625 0)"/>
+ </g>
+ </g>
+ <g id="text_49">
+ <!-- grep -->
+ <g style="fill: #2e3440" transform="translate(1100.821875 652) scale(0.2 -0.2)">
+ <use xlink:href="#Inter-Medium-292"/>
+ <use xlink:href="#Inter-Medium-354" transform="translate(61.96875 0)"/>
+ <use xlink:href="#Inter-Medium-266" transform="translate(98.734375 0)"/>
+ <use xlink:href="#Inter-Medium-34b" transform="translate(157.46875 0)"/>
+ </g>
+ </g>
+ <g id="text_50">
+ <!-- 0.1.3 vs BM25, McNemar exact: -->
+ <g style="fill: #5b6474" transform="translate(820 696) scale(0.18 -0.18)">
+ <use xlink:href="#Inter-Regular-53d"/>
+ <use xlink:href="#Inter-Regular-5de" transform="translate(60.5625 0)"/>
+ <use xlink:href="#Inter-Regular-53e" transform="translate(80.734375 0)"/>
+ <use xlink:href="#Inter-Regular-5de" transform="translate(121.40625 0)"/>
+ <use xlink:href="#Inter-Regular-541" transform="translate(147.53125 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(209.296875 0)"/>
+ <use xlink:href="#Inter-Regular-3d4" transform="translate(237.421875 0)"/>
+ <use xlink:href="#Inter-Regular-367" transform="translate(293.625 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(346.40625 0)"/>
+ <use xlink:href="#Inter-Regular-41" transform="translate(374.53125 0)"/>
+ <use xlink:href="#Inter-Regular-124" transform="translate(439.96875 0)"/>
+ <use xlink:href="#Inter-Regular-53f" transform="translate(530.296875 0)"/>
+ <use xlink:href="#Inter-Regular-543" transform="translate(591.28125 0)"/>
+ <use xlink:href="#Inter-Regular-5dd" transform="translate(647.921875 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(676.734375 0)"/>
+ <use xlink:href="#Inter-Regular-124" transform="translate(704.859375 0)"/>
+ <use xlink:href="#Inter-Regular-24a" transform="translate(795.1875 0)"/>
+ <use xlink:href="#Inter-Regular-12c" transform="translate(852.3125 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(927.65625 0)"/>
+ <use xlink:href="#Inter-Regular-2fe" transform="translate(985.953125 0)"/>
+ <use xlink:href="#Inter-Regular-1fb" transform="translate(1073.546875 0)"/>
+ <use xlink:href="#Inter-Regular-354" transform="translate(1129.703125 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(1167.34375 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(1195.46875 0)"/>
+ <use xlink:href="#Inter-Regular-3e1" transform="translate(1251.515625 0)"/>
+ <use xlink:href="#Inter-Regular-1fb" transform="translate(1306.109375 0)"/>
+ <use xlink:href="#Inter-Regular-24a" transform="translate(1362.265625 0)"/>
+ <use xlink:href="#Inter-Regular-379" transform="translate(1419.390625 0)"/>
+ <use xlink:href="#Inter-Regular-5e1" transform="translate(1452.109375 0)"/>
+ </g>
+ </g>
+ <g id="text_51">
+ <!-- +5 issues, p = 0.383, not significant -->
+ <g style="fill: #3e4757" transform="translate(831.987656 734) scale(0.18 -0.18)">
+ <use xlink:href="#Inter-SemiBold-5ff"/>
+ <use xlink:href="#Inter-SemiBold-543" transform="translate(67.28125 0)"/>
+ <use xlink:href="#Inter-SemiBold-6f1" transform="translate(128.515625 0)"/>
+ <use xlink:href="#Inter-SemiBold-2b1" transform="translate(153.71875 0)"/>
+ <use xlink:href="#Inter-SemiBold-367" transform="translate(179.890625 0)"/>
+ <use xlink:href="#Inter-SemiBold-367" transform="translate(234.828125 0)"/>
+ <use xlink:href="#Inter-SemiBold-393" transform="translate(289.765625 0)"/>
+ <use xlink:href="#Inter-SemiBold-266" transform="translate(351 0)"/>
+ <use xlink:href="#Inter-SemiBold-367" transform="translate(410.125 0)"/>
+ <use xlink:href="#Inter-SemiBold-5dd" transform="translate(465.0625 0)"/>
+ <use xlink:href="#Inter-SemiBold-6f1" transform="translate(494.90625 0)"/>
+ <use xlink:href="#Inter-SemiBold-34b" transform="translate(520.109375 0)"/>
+ <use xlink:href="#Inter-SemiBold-6f1" transform="translate(582.515625 0)"/>
+ <use xlink:href="#Inter-SemiBold-5f0" transform="translate(607.71875 0)"/>
+ <use xlink:href="#Inter-SemiBold-6f1" transform="translate(675 0)"/>
+ <use xlink:href="#Inter-SemiBold-53d" transform="translate(700.203125 0)"/>
+ <use xlink:href="#Inter-SemiBold-5de" transform="translate(763.390625 0)"/>
+ <use xlink:href="#Inter-SemiBold-541" transform="translate(792.84375 0)"/>
+ <use xlink:href="#Inter-SemiBold-547" transform="translate(856.46875 0)"/>
+ <use xlink:href="#Inter-SemiBold-541" transform="translate(920.484375 0)"/>
+ <use xlink:href="#Inter-SemiBold-5dd" transform="translate(981.96875 0)"/>
+ <use xlink:href="#Inter-SemiBold-6f1" transform="translate(1011.8125 0)"/>
+ <use xlink:href="#Inter-SemiBold-305" transform="translate(1037.015625 0)"/>
+ <use xlink:href="#Inter-SemiBold-316" transform="translate(1098.203125 0)"/>
+ <use xlink:href="#Inter-SemiBold-379" transform="translate(1159.09375 0)"/>
+ <use xlink:href="#Inter-SemiBold-6f1" transform="translate(1194.390625 0)"/>
+ <use xlink:href="#Inter-SemiBold-367" transform="translate(1219.59375 0)"/>
+ <use xlink:href="#Inter-SemiBold-2b1" transform="translate(1274.53125 0)"/>
+ <use xlink:href="#Inter-SemiBold-292" transform="translate(1300.703125 0)"/>
+ <use xlink:href="#Inter-SemiBold-305" transform="translate(1363.25 0)"/>
+ <use xlink:href="#Inter-SemiBold-2b1" transform="translate(1424.4375 0)"/>
+ <use xlink:href="#Inter-SemiBold-287" transform="translate(1450.609375 0)"/>
+ <use xlink:href="#Inter-SemiBold-2b1" transform="translate(1490.078125 0)"/>
+ <use xlink:href="#Inter-SemiBold-24a" transform="translate(1516.25 0)"/>
+ <use xlink:href="#Inter-SemiBold-1fb" transform="translate(1575.484375 0)"/>
+ <use xlink:href="#Inter-SemiBold-305" transform="translate(1632.90625 0)"/>
+ <use xlink:href="#Inter-SemiBold-379" transform="translate(1694.09375 0)"/>
+ </g>
+ </g>
+ <g id="text_52">
+ <!-- MRR -->
+ <g style="fill: #0a0b0f" transform="translate(1206 206) scale(0.26 -0.26)">
+ <defs>
+ <path id="Inter-SemiBold-124" d="M 469 0
+L 469 4656
+L 1725 4656
+L 2609 2253
+Q 2656 2116 2717 1895
+Q 2778 1675 2840 1423
+Q 2903 1172 2956 941
+Q 3009 1169 3071 1420
+Q 3134 1672 3195 1892
+Q 3256 2113 3300 2253
+L 4175 4656
+L 5434 4656
+L 5434 0
+L 4603 0
+L 4603 2350
+Q 4603 2525 4608 2783
+Q 4613 3041 4620 3331
+Q 4628 3622 4631 3900
+Q 4553 3600 4465 3303
+Q 4378 3006 4300 2756
+Q 4222 2506 4166 2350
+L 3306 0
+L 2597 0
+L 1725 2350
+Q 1669 2500 1592 2744
+Q 1516 2988 1430 3281
+Q 1344 3575 1256 3875
+Q 1263 3613 1270 3327
+Q 1278 3041 1283 2784
+Q 1288 2528 1288 2350
+L 1288 0
+L 469 0
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-SemiBold-180" d="M 469 0
+L 469 4656
+L 2209 4656
+Q 3013 4656 3431 4243
+Q 3850 3831 3850 3166
+Q 3850 2694 3637 2353
+Q 3425 2013 3013 1850
+L 4022 0
+L 3088 0
+L 2172 1709
+L 1303 1709
+L 1303 0
+L 469 0
+z
+M 1303 2400
+L 2088 2400
+Q 2559 2400 2778 2598
+Q 2997 2797 2997 3166
+Q 2997 3541 2778 3748
+Q 2559 3956 2081 3956
+L 1303 3956
+L 1303 2400
+z
+" transform="scale(0.015625)"/>
+ </defs>
+ <use xlink:href="#Inter-SemiBold-124"/>
+ <use xlink:href="#Inter-SemiBold-180" transform="translate(92.234375 0)"/>
+ <use xlink:href="#Inter-SemiBold-180" transform="translate(157.46875 0)"/>
+ </g>
+ </g>
+ <g id="text_53">
+ <!-- Mean reciprocal rank of the first -->
+ <g style="fill: #5b6474" transform="translate(1206 236) scale(0.18 -0.18)">
+ <use xlink:href="#Inter-Regular-124"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(90.328125 0)"/>
+ <use xlink:href="#Inter-Regular-1fb" transform="translate(149.609375 0)"/>
+ <use xlink:href="#Inter-Regular-305" transform="translate(205.765625 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(264.84375 0)"/>
+ <use xlink:href="#Inter-Regular-354" transform="translate(292.96875 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(328.953125 0)"/>
+ <use xlink:href="#Inter-Regular-24a" transform="translate(387.25 0)"/>
+ <use xlink:href="#Inter-Regular-2b1" transform="translate(444.375 0)"/>
+ <use xlink:href="#Inter-Regular-34b" transform="translate(468.59375 0)"/>
+ <use xlink:href="#Inter-Regular-354" transform="translate(529.828125 0)"/>
+ <use xlink:href="#Inter-Regular-316" transform="translate(565.8125 0)"/>
+ <use xlink:href="#Inter-Regular-24a" transform="translate(625.78125 0)"/>
+ <use xlink:href="#Inter-Regular-1fb" transform="translate(683.890625 0)"/>
+ <use xlink:href="#Inter-Regular-2e0" transform="translate(740.046875 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(764.265625 0)"/>
+ <use xlink:href="#Inter-Regular-354" transform="translate(792.390625 0)"/>
+ <use xlink:href="#Inter-Regular-1fb" transform="translate(830.03125 0)"/>
+ <use xlink:href="#Inter-Regular-305" transform="translate(886.1875 0)"/>
+ <use xlink:href="#Inter-Regular-2d7" transform="translate(945.265625 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(1000.15625 0)"/>
+ <use xlink:href="#Inter-Regular-316" transform="translate(1028.28125 0)"/>
+ <use xlink:href="#Inter-Regular-287" transform="translate(1088.25 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(1125.265625 0)"/>
+ <use xlink:href="#Inter-Regular-379" transform="translate(1153.390625 0)"/>
+ <use xlink:href="#Inter-Regular-29e" transform="translate(1186.109375 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(1245.234375 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(1303.53125 0)"/>
+ <use xlink:href="#Inter-Regular-287" transform="translate(1331.65625 0)"/>
+ <use xlink:href="#Inter-Regular-2b1" transform="translate(1368.671875 0)"/>
+ <use xlink:href="#Inter-Regular-354" transform="translate(1392.890625 0)"/>
+ <use xlink:href="#Inter-Regular-367" transform="translate(1430.53125 0)"/>
+ <use xlink:href="#Inter-Regular-379" transform="translate(1483.3125 0)"/>
+ </g>
+ </g>
+ <g id="text_54">
+ <!-- changed file -->
+ <g style="fill: #5b6474" transform="translate(1206 260) scale(0.18 -0.18)">
+ <use xlink:href="#Inter-Regular-24a"/>
+ <use xlink:href="#Inter-Regular-29e" transform="translate(57.125 0)"/>
+ <use xlink:href="#Inter-Regular-1fb" transform="translate(116.25 0)"/>
+ <use xlink:href="#Inter-Regular-305" transform="translate(172.40625 0)"/>
+ <use xlink:href="#Inter-Regular-292" transform="translate(231.484375 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(292.8125 0)"/>
+ <use xlink:href="#Inter-Regular-255" transform="translate(351.109375 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(412.34375 0)"/>
+ <use xlink:href="#Inter-Regular-287" transform="translate(440.46875 0)"/>
+ <use xlink:href="#Inter-Regular-2b1" transform="translate(477.484375 0)"/>
+ <use xlink:href="#Inter-Regular-2e0" transform="translate(501.703125 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(525.921875 0)"/>
+ </g>
+ </g>
+ <g id="text_55">
+ <!-- 0.562 -->
+ <g style="fill: #0a0b0f" transform="translate(1209.013125 436.7496) scale(0.28 -0.28)">
+ <defs>
+ <path id="Inter-Bold-53d" d="M 2156 -63
+Q 1275 -63 784 565
+Q 294 1194 294 2325
+Q 294 3456 786 4087
+Q 1278 4719 2156 4719
+Q 3038 4719 3530 4086
+Q 4022 3453 4022 2325
+Q 4022 1194 3531 565
+Q 3041 -63 2156 -63
+z
+M 2156 728
+Q 2588 728 2819 1143
+Q 3050 1559 3050 2325
+Q 3050 3094 2819 3512
+Q 2588 3931 2156 3931
+Q 1728 3931 1497 3511
+Q 1266 3091 1266 2325
+Q 1266 1559 1495 1143
+Q 1725 728 2156 728
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Bold-5de" d="M 1069 -59
+Q 841 -59 684 95
+Q 528 250 528 478
+Q 528 706 684 861
+Q 841 1016 1069 1016
+Q 1297 1016 1453 861
+Q 1609 706 1609 478
+Q 1609 250 1453 95
+Q 1297 -59 1069 -59
+z
+" transform="scale(0.015625)"/>
+ <path id="Inter-Bold-545" d="M 2138 -63
+Q 1781 -63 1451 56
+Q 1122 175 861 439
+Q 600 703 447 1140
+Q 294 1578 294 2219
+Q 294 3000 525 3561
+Q 756 4122 1178 4420
+Q 1600 4719 2172 4719
+Q 2631 4719 2984 4541
+Q 3338 4363 3553 4055
+Q 3769 3747 3816 3366
+L 2878 3366
+Q 2819 3613 2633 3755
+Q 2447 3897 2172 3897
+Q 1713 3897 1472 3497
+Q 1231 3097 1231 2409
+L 1263 2409
+Q 1419 2713 1734 2886
+Q 2050 3059 2431 3059
+Q 2841 3059 3166 2865
+Q 3491 2672 3678 2333
+Q 3866 1994 3866 1556
+Q 3866 1084 3647 718
+Q 3428 353 3039 145
+Q 2650 -63 2138 -63
+z
+M 2131 694
+Q 2475 694 2706 934
+Q 2938 1175 2938 1531
+Q 2938 1881 2711 2122
+Q 2484 2363 2138 2363
+Q 1909 2363 1725 2248
+Q 1541 2134 1434 1945
+Q 1328 1756 1328 1528
+Q 1328 1300 1433 1109
+Q 1538 919 1719 806
+Q 1900 694 2131 694
+z
+" transform="scale(0.015625)"/>
+ </defs>
+ <use xlink:href="#Inter-Bold-53d"/>
+ <use xlink:href="#Inter-Bold-5de" transform="translate(64.515625 0)"/>
+ <use xlink:href="#Inter-Bold-543" transform="translate(97.28125 0)"/>
+ <use xlink:href="#Inter-Bold-545" transform="translate(159.484375 0)"/>
+ <use xlink:href="#Inter-Bold-53f" transform="translate(224.421875 0)"/>
+ </g>
+ </g>
+ <g id="text_56">
+ <!-- 0.1.3 -->
+ <g style="fill: #2e3440" transform="translate(1227.709375 652) scale(0.2 -0.2)">
+ <use xlink:href="#Inter-Medium-53d"/>
+ <use xlink:href="#Inter-Medium-5de" transform="translate(61.859375 0)"/>
+ <use xlink:href="#Inter-Medium-53e" transform="translate(83.40625 0)"/>
+ <use xlink:href="#Inter-Medium-5de" transform="translate(124.90625 0)"/>
+ <use xlink:href="#Inter-Medium-541" transform="translate(152.703125 0)"/>
+ </g>
+ </g>
+ <g id="text_57">
+ <!-- 0.191 -->
+ <g style="fill: #2e3440" transform="translate(1307.58375 552.3456) scale(0.24 -0.24)">
+ <defs>
+ <path id="Inter-SemiBold-548" d="M 1953 -66
+Q 1516 -66 1175 106
+Q 834 278 625 578
+Q 416 878 366 1259
+L 1191 1259
+Q 1253 991 1450 823
+Q 1647 656 1953 656
+Q 2438 656 2700 1079
+Q 2963 1503 2963 2247
+L 2931 2247
+Q 2763 1950 2455 1776
+Q 2147 1603 1769 1603
+Q 1359 1603 1032 1798
+Q 706 1994 514 2337
+Q 322 2681 322 3119
+Q 322 3578 533 3943
+Q 744 4309 1123 4518
+Q 1503 4728 2006 4722
+Q 2334 4719 2650 4605
+Q 2966 4491 3219 4231
+Q 3472 3972 3622 3539
+Q 3772 3106 3772 2466
+Q 3772 1666 3548 1100
+Q 3325 534 2917 234
+Q 2509 -66 1953 -66
+z
+M 1991 2244
+Q 2241 2244 2439 2367
+Q 2638 2491 2755 2697
+Q 2872 2903 2872 3147
+Q 2872 3384 2759 3589
+Q 2647 3794 2450 3917
+Q 2253 4041 2003 4041
+Q 1756 4041 1559 3920
+Q 1363 3800 1248 3595
+Q 1134 3391 1134 3138
+Q 1134 2884 1245 2682
+Q 1356 2481 1550 2362
+Q 1744 2244 1991 2244
+z
+" transform="scale(0.015625)"/>
+ </defs>
+ <use xlink:href="#Inter-SemiBold-53d"/>
+ <use xlink:href="#Inter-SemiBold-5de" transform="translate(63.1875 0)"/>
+ <use xlink:href="#Inter-SemiBold-53e" transform="translate(86.1875 0)"/>
+ <use xlink:href="#Inter-SemiBold-548" transform="translate(128.46875 0)"/>
+ <use xlink:href="#Inter-SemiBold-53e" transform="translate(192.4375 0)"/>
+ </g>
+ </g>
+ <g id="text_58">
+ <!-- 0.1.2 -->
+ <g style="fill: #2e3440" transform="translate(1314.064063 652) scale(0.2 -0.2)">
+ <use xlink:href="#Inter-Medium-53d"/>
+ <use xlink:href="#Inter-Medium-5de" transform="translate(61.859375 0)"/>
+ <use xlink:href="#Inter-Medium-53e" transform="translate(83.40625 0)"/>
+ <use xlink:href="#Inter-Medium-5de" transform="translate(124.90625 0)"/>
+ <use xlink:href="#Inter-Medium-53f" transform="translate(155.234375 0)"/>
+ </g>
+ </g>
+ <g id="text_59">
+ <!-- 0.478 -->
+ <g style="fill: #2e3440" transform="translate(1388.42125 462.9888) scale(0.24 -0.24)">
+ <use xlink:href="#Inter-SemiBold-53d"/>
+ <use xlink:href="#Inter-SemiBold-5de" transform="translate(63.1875 0)"/>
+ <use xlink:href="#Inter-SemiBold-542" transform="translate(95.078125 0)"/>
+ <use xlink:href="#Inter-SemiBold-546" transform="translate(161.6875 0)"/>
+ <use xlink:href="#Inter-SemiBold-547" transform="translate(217.890625 0)"/>
+ </g>
+ </g>
+ <g id="text_60">
+ <!-- BM25 -->
+ <g style="fill: #2e3440" transform="translate(1394.364063 652) scale(0.2 -0.2)">
+ <use xlink:href="#Inter-Medium-41"/>
+ <use xlink:href="#Inter-Medium-124" transform="translate(65.671875 0)"/>
+ <use xlink:href="#Inter-Medium-53f" transform="translate(156.9375 0)"/>
+ <use xlink:href="#Inter-Medium-543" transform="translate(218.5625 0)"/>
+ </g>
+ </g>
+ <g id="text_61">
+ <!-- 0.365 -->
+ <g style="fill: #2e3440" transform="translate(1474.97375 498.0264) scale(0.24 -0.24)">
+ <use xlink:href="#Inter-SemiBold-53d"/>
+ <use xlink:href="#Inter-SemiBold-5de" transform="translate(63.1875 0)"/>
+ <use xlink:href="#Inter-SemiBold-541" transform="translate(92.640625 0)"/>
+ <use xlink:href="#Inter-SemiBold-545" transform="translate(156.265625 0)"/>
+ <use xlink:href="#Inter-SemiBold-543" transform="translate(220.234375 0)"/>
+ </g>
+ </g>
+ <g id="text_62">
+ <!-- grep -->
+ <g style="fill: #2e3440" transform="translate(1486.821875 652) scale(0.2 -0.2)">
+ <use xlink:href="#Inter-Medium-292"/>
+ <use xlink:href="#Inter-Medium-354" transform="translate(61.96875 0)"/>
+ <use xlink:href="#Inter-Medium-266" transform="translate(98.734375 0)"/>
+ <use xlink:href="#Inter-Medium-34b" transform="translate(157.46875 0)"/>
+ </g>
+ </g>
+ <g id="text_63">
+ <!-- 1 when it comes first, 0.5 when second, -->
+ <g style="fill: #5b6474" transform="translate(1206 696) scale(0.18 -0.18)">
+ <use xlink:href="#Inter-Regular-53e"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(40.671875 0)"/>
+ <use xlink:href="#Inter-Regular-3d8" transform="translate(68.796875 0)"/>
+ <use xlink:href="#Inter-Regular-29e" transform="translate(150.640625 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(209.765625 0)"/>
+ <use xlink:href="#Inter-Regular-305" transform="translate(268.0625 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(327.140625 0)"/>
+ <use xlink:href="#Inter-Regular-2b1" transform="translate(355.265625 0)"/>
+ <use xlink:href="#Inter-Regular-379" transform="translate(379.484375 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(412.203125 0)"/>
+ <use xlink:href="#Inter-Regular-24a" transform="translate(440.328125 0)"/>
+ <use xlink:href="#Inter-Regular-316" transform="translate(497.453125 0)"/>
+ <use xlink:href="#Inter-Regular-2fe" transform="translate(557.421875 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(645.015625 0)"/>
+ <use xlink:href="#Inter-Regular-367" transform="translate(703.3125 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(756.09375 0)"/>
+ <use xlink:href="#Inter-Regular-287" transform="translate(784.21875 0)"/>
+ <use xlink:href="#Inter-Regular-2b1" transform="translate(821.234375 0)"/>
+ <use xlink:href="#Inter-Regular-354" transform="translate(845.453125 0)"/>
+ <use xlink:href="#Inter-Regular-367" transform="translate(883.09375 0)"/>
+ <use xlink:href="#Inter-Regular-379" transform="translate(935.875 0)"/>
+ <use xlink:href="#Inter-Regular-5dd" transform="translate(968.59375 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(997.40625 0)"/>
+ <use xlink:href="#Inter-Regular-53d" transform="translate(1025.53125 0)"/>
+ <use xlink:href="#Inter-Regular-5de" transform="translate(1086.09375 0)"/>
+ <use xlink:href="#Inter-Regular-543" transform="translate(1113.484375 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(1172.8125 0)"/>
+ <use xlink:href="#Inter-Regular-3d8" transform="translate(1200.9375 0)"/>
+ <use xlink:href="#Inter-Regular-29e" transform="translate(1282.78125 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(1341.90625 0)"/>
+ <use xlink:href="#Inter-Regular-305" transform="translate(1400.203125 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(1459.28125 0)"/>
+ <use xlink:href="#Inter-Regular-367" transform="translate(1487.40625 0)"/>
+ <use xlink:href="#Inter-Regular-266" transform="translate(1540.1875 0)"/>
+ <use xlink:href="#Inter-Regular-24a" transform="translate(1598.484375 0)"/>
+ <use xlink:href="#Inter-Regular-316" transform="translate(1655.609375 0)"/>
+ <use xlink:href="#Inter-Regular-305" transform="translate(1715.578125 0)"/>
+ <use xlink:href="#Inter-Regular-255" transform="translate(1774.65625 0)"/>
+ <use xlink:href="#Inter-Regular-5dd" transform="translate(1835.890625 0)"/>
+ </g>
+ </g>
+ <g id="text_64">
+ <!-- 0 past rank 100. -->
+ <g style="fill: #5b6474" transform="translate(1206 720) scale(0.18 -0.18)">
+ <use xlink:href="#Inter-Regular-53d"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(63.09375 0)"/>
+ <use xlink:href="#Inter-Regular-34b" transform="translate(91.21875 0)"/>
+ <use xlink:href="#Inter-Regular-1fb" transform="translate(153.4375 0)"/>
+ <use xlink:href="#Inter-Regular-367" transform="translate(209.59375 0)"/>
+ <use xlink:href="#Inter-Regular-379" transform="translate(262.375 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(295.09375 0)"/>
+ <use xlink:href="#Inter-Regular-354" transform="translate(323.21875 0)"/>
+ <use xlink:href="#Inter-Regular-1fb" transform="translate(360.859375 0)"/>
+ <use xlink:href="#Inter-Regular-305" transform="translate(417.015625 0)"/>
+ <use xlink:href="#Inter-Regular-2d7" transform="translate(476.09375 0)"/>
+ <use xlink:href="#Inter-Regular-6f1" transform="translate(530.984375 0)"/>
+ <use xlink:href="#Inter-Regular-53e" transform="translate(559.109375 0)"/>
+ <use xlink:href="#Inter-Regular-53d" transform="translate(599.78125 0)"/>
+ <use xlink:href="#Inter-Regular-53d" transform="translate(662.875 0)"/>
+ <use xlink:href="#Inter-Regular-5de" transform="translate(723.4375 0)"/>
+ </g>
+ </g>
+ </g>
+ </g>
+ <defs>
+ <clipPath id="pd3e7befa96">
+ <rect x="0" y="0" width="1600" height="900"/>
+ </clipPath>
+ </defs>
+</svg>
diff --git a/docs/benchmarks.md b/docs/benchmarks.md
index 0aaf274..95173f2 100644
--- a/docs/benchmarks.md
+++ b/docs/benchmarks.md
@@ -13,6 +13,7 @@ endorsement is implied.
| Code-graph engine: speed | Done, on a pre-release build that followed Graphify 0.9.77. The 0.1.0 engine: an exploratory survey, 14 October 2026; its registered quiet-host repeat is pending. Updates after commits: Graphicle 0.1.0 against Graphify 0.9.91, registered before the first update, 15 October 2026. 13 codebases against Graphify 0.9.91: Graphicle's 0.1.1 memory engine (a pre-release build), one session per program, 15 October 2026 | Django (pre-release build): code-only extract 7.5 s against 72.8 s for Graphify 0.9.77. Kubernetes v1.37.1 (the 0.1.0 engine, which follows Graphify 0.9.88; exploratory, one run each on one Linux host, the same 16 CPUs, 8 workers, with four recorded deviations): code-only extract 198.4 s against 1,597.9 s for Graphify 0.9.88, the same graph. [Details](#speed-on-kubernetes). Updates after each of 30 commits on prometheus, tokio and poetry (one Linux node, 4 CPUs per run): 6 to 8 times less time than Graphify 0.9.91, with the same differences from a fresh build in both. [Details](#updates-after-commits). 13 codebases, 3 operations each (Graphicle's 0.1.1 memory engine, a pre-release build, against Graphify 0.9.91; the same machine, 3 CPUs and 8 workers each): 3.0 to 22.7 times less time in all 39 measurements; the graphs differ slightly, with node counts within 4.7% and edge counts within 2.0%. [Details](#speed-on-13-codebases-against-graphify-0991) |
| Code-graph engine: peak memory | A pre-release build with 0.1.1's changes to how the engine holds its data, against Graphify 0.9.91, 15 October 2026; five measurements rechecked on a build of the merged 0.1.1 source | Less peak memory than Graphify 0.9.91 in all 39 measurements (13 repositories; extract, priming update and update with no change), from 0.29 to 0.97 times Graphify's figure; Kubernetes extract 2,091.5 against 2,767 MiB. One Linux node (its 8 H100 GPUs not used), 8 workers; Graphicle's peak RSS against Graphify's peak PSS. [Details](#peak-memory-against-graphify-0991) |
| Coding agents: Claude Code with Graphicle, Graphify or neither | Four task sets, each test registered before any answer was scored; Claude Code with Opus 5.5, and one set repeated with Haiku 5.5 | Graphicle tied plain Claude Code on finding files and facts in every test, and no token saving is claimed against it. Against Graphify 0.9.91, Graphicle found more facts on Graphify's showcase corpus and used fewer tokens in all four task sets (on SWE-bench Verified, a secondary comparison); in two of them, Graphicle's arm included a prototype that does not ship. [Details](#coding-agents-with-graphicle-graphify-or-neither) |
+| Retrieval: finding the files a fix changes | Graphicle 0.1.3 and the 0.1.2 release, offline, 21 October 2026, on 100 SWE-bench Verified issues never used for tuning and 80 issues used for tuning | On the held-out issues, a file the fix changed was among the first 5 files of 0.1.3's context packet for 75, against 61 for BM25 (SWE-bench style; McNemar exact p = 0.013) and 54 for grep on the issue's names; for the first file and the first 10 files the differences from BM25 are not significant. Ranking only: the agent test of 0.1.3 is pending ([retrieval benchmark](benchmarks/retrieval.md)) |
| Agent memory: comparison with seven memory systems | Done, on development sets, with a proxy evaluator | Every system's scores and the 21 registered comparisons are [below](#agent-memory-comparison-with-seven-memory-systems). None of them is a headline claim |
| Agent memory: retrieval defaults | Chosen | Model-free retrieval runs on development data, plus held-out checks; their records are not published yet, so no numbers are given |
@@ -121,13 +122,15 @@ That is the parity claim, with these limits:
- **Known differences.** PDF text comes from `pdf-extract`, not pypdf, so PDF
word counts and text can differ, and command-line progress messages are the
engine's own.
-- **Known difference.** On gohugoio/hugo v0.167.0, the graph after
- `graphicle graph update` differs from Graphify 0.9.88's in one attribute of
- one node: the stored front matter of a Markdown page that closes a YAML list
- at the start of a line. Graphicle's YAML parser rejects that list, so
- Graphicle stores the page's front matter fields as text and loses the list's
- nine entries. Nodes, edges and communities are the same, code-only `extract`
- gives the same graph, and answers are not affected.
+- **Known difference (checked build).** On gohugoio/hugo v0.167.0, the graph
+ after `graphicle graph update` differed from Graphify 0.9.88's in one
+ attribute of one node: the stored front matter of a Markdown page that
+ closes a YAML list at the start of a line. The checked build's YAML parser
+ rejected that list, so it stored the page's front matter fields as text and
+ lost the list's nine entries. Nodes, edges and communities were the same,
+ code-only `extract` gave the same graph, and answers were not affected.
+ From 0.1.3 the parser reads that page's front matter as YAML; the hugo
+ comparison has not been run again since.
- **Names.** Folder, environment-variable, command and installed-file names
are translated by one documented table
(`crates/graphicle-graph/tools/naming.py`), which the checks apply.
diff --git a/docs/benchmarks/retrieval.json b/docs/benchmarks/retrieval.json
new file mode 100644
index 0000000..b17d83b
--- /dev/null
+++ b/docs/benchmarks/retrieval.json
@@ -0,0 +1,1276 @@
+{
+ "about": "Graphicle's offline retrieval benchmark (docs/benchmarks/retrieval.md): for each issue, the rank of the first file its fix changed in each system's list (null: not in the list). retrieval_chart.py draws docs/assets/retrieval-*.svg and .png and prints the page's tables from this file.",
+ "measured": "2026-10-21",
+ "systems": {
+ "graphicle-0.1.3": {
+ "label": "Graphicle 0.1.3",
+ "legend": "Graphicle 0.1.3",
+ "short": "0.1.3"
+ },
+ "graphicle-0.1.2": {
+ "label": "Graphicle 0.1.2",
+ "legend": "Graphicle 0.1.2",
+ "short": "0.1.2"
+ },
+ "bm25": {
+ "label": "BM25, SWE-bench style",
+ "legend": "BM25 (SWE-bench style)",
+ "short": "BM25"
+ },
+ "grep": {
+ "label": "grep for the names in the issue (rg 14.1.1)",
+ "legend": "grep for the issue's names",
+ "short": "grep"
+ },
+ "graphicle-0.1.3-ranked": {
+ "label": "Graphicle 0.1.3, its ranking before the packet",
+ "legend": "",
+ "short": ""
+ },
+ "graphicle-0.1.2-ranked": {
+ "label": "Graphicle 0.1.2, its ranking before the packet",
+ "legend": "",
+ "short": ""
+ }
+ },
+ "compare": [
+ "graphicle-0.1.3",
+ "bm25"
+ ],
+ "sets": {
+ "held-out": {
+ "table_title": "Held-out set: SWE-bench Verified, never used for tuning",
+ "tasks": [
+ {
+ "id": "astropy__astropy-13453",
+ "repo": "astropy/astropy",
+ "language": "Python",
+ "gold_files": 1
+ },
+ {
+ "id": "astropy__astropy-13579",
+ "repo": "astropy/astropy",
+ "language": "Python",
+ "gold_files": 1
+ },
+ {
+ "id": "astropy__astropy-7336",
+ "repo": "astropy/astropy",
+ "language": "Python",
+ "gold_files": 1
+ },
+ {
+ "id": "astropy__astropy-8872",
+ "repo": "astropy/astropy",
+ "language": "Python",
+ "gold_files": 1
+ },
+ {
+ "id": "django__django-10914",
+ "repo": "django/django",
+ "language": "Python",
+ "gold_files": 1
+ },
+ {
+ "id": "django__django-11163",
+ "repo": "django/django",
+ "language": "Python",
+ "gold_files": 1
+ },
+ {
+ "id": "django__django-11239",
+ "repo": "django/django",
+ "language": "Python",
+ "gold_files": 1
+ },
+ {
+ "id": "django__django-11400",
+ "repo": "django/django",
+ "language": "Python",
+ "gold_files": 3
+ },
+ {
+ "id": "django__django-11477",
+ "repo": "django/django",
+ "language": "Python",
+ "gold_files": 1
+ },
+ {
+ "id": "django__django-11790",
+ "repo": "django/django",
+ "language": "Python",
+ "gold_files": 1
+ },
+ {
+ "id": "django__django-12155",
+ "repo": "django/django",
+ "language": "Python",
+ "gold_files": 2
+ },
+ {
+ "id": "django__django-12273",
+ "repo": "django/django",
+ "language": "Python",
+ "gold_files": 1
+ },
+ {
+ "id": "django__django-12406",
+ "repo": "django/django",
+ "language": "Python",
+ "gold_files": 2
+ },
+ {
+ "id": "django__django-12774",
+ "repo": "django/django",
+ "language": "Python",
+ "gold_files": 1
+ },
+ {
+ "id": "django__django-12965",
+ "repo": "django/django",
+ "language": "Python",
+ "gold_files": 1
+ },
+ {
+ "id": "django__django-13158",
+ "repo": "django/django",
+ "language": "Python",
+ "gold_files": 1
+ },
+ {
+ "id": "django__django-13195",
+ "repo": "django/django",
+ "language": "Python",
+ "gold_files": 3
+ },
+ {
+ "id": "django__django-13212",
+ "repo": "django/django",
+ "language": "Python",
+ "gold_files": 2
+ },
+ {
+ "id": "django__django-13315",
+ "repo": "django/django",
+ "language": "Python",
+ "gold_files": 1
+ },
+ {
+ "id": "django__django-13343",
+ "repo": "django/django",
+ "language": "Python",
+ "gold_files": 1
+ },
+ {
+ "id": "django__django-13406",
+ "repo": "django/django",
+ "language": "Python",
+ "gold_files": 1
+ },
+ {
+ "id": "django__django-13410",
+ "repo": "django/django",
+ "language": "Python",
+ "gold_files": 1
+ },
+ {
+ "id": "django__django-13551",
+ "repo": "django/django",
+ "language": "Python",
+ "gold_files": 1
+ },
+ {
+ "id": "django__django-13741",
+ "repo": "django/django",
+ "language": "Python",
+ "gold_files": 1
+ },
+ {
+ "id": "django__django-13810",
+ "repo": "django/django",
+ "language": "Python",
+ "gold_files": 1
+ },
+ {
+ "id": "django__django-13821",
+ "repo": "django/django",
+ "language": "Python",
+ "gold_files": 1
+ },
+ {
+ "id": "django__django-13837",
+ "repo": "django/django",
+ "language": "Python",
+ "gold_files": 1
+ },
+ {
+ "id": "django__django-13933",
+ "repo": "django/django",
+ "language": "Python",
+ "gold_files": 1
+ },
+ {
+ "id": "django__django-13964",
+ "repo": "django/django",
+ "language": "Python",
+ "gold_files": 1
+ },
+ {
+ "id": "django__django-14155",
+ "repo": "django/django",
+ "language": "Python",
+ "gold_files": 1
+ },
+ {
+ "id": "django__django-14349",
+ "repo": "django/django",
+ "language": "Python",
+ "gold_files": 1
+ },
+ {
+ "id": "django__django-14373",
+ "repo": "django/django",
+ "language": "Python",
+ "gold_files": 1
+ },
+ {
+ "id": "django__django-14493",
+ "repo": "django/django",
+ "language": "Python",
+ "gold_files": 1
+ },
+ {
+ "id": "django__django-14580",
+ "repo": "django/django",
+ "language": "Python",
+ "gold_files": 1
+ },
+ {
+ "id": "django__django-14765",
+ "repo": "django/django",
+ "language": "Python",
+ "gold_files": 1
+ },
+ {
+ "id": "django__django-14855",
+ "repo": "django/django",
+ "language": "Python",
+ "gold_files": 1
+ },
+ {
+ "id": "django__django-14999",
+ "repo": "django/django",
+ "language": "Python",
+ "gold_files": 1
+ },
+ {
+ "id": "django__django-15252",
+ "repo": "django/django",
+ "language": "Python",
+ "gold_files": 1
+ },
+ {
+ "id": "django__django-15277",
+ "repo": "django/django",
+ "language": "Python",
+ "gold_files": 1
+ },
+ {
+ "id": "django__django-15382",
+ "repo": "django/django",
+ "language": "Python",
+ "gold_files": 1
+ },
+ {
+ "id": "django__django-15629",
+ "repo": "django/django",
+ "language": "Python",
+ "gold_files": 4
+ },
+ {
+ "id": "django__django-15695",
+ "repo": "django/django",
+ "language": "Python",
+ "gold_files": 1
+ },
+ {
+ "id": "django__django-16082",
+ "repo": "django/django",
+ "language": "Python",
+ "gold_files": 1
+ },
+ {
+ "id": "django__django-16315",
+ "repo": "django/django",
+ "language": "Python",
+ "gold_files": 2
+ },
+ {
+ "id": "django__django-16333",
+ "repo": "django/django",
+ "language": "Python",
+ "gold_files": 1
+ },
+ {
+ "id": "django__django-16485",
+ "repo": "django/django",
+ "language": "Python",
+ "gold_files": 1
+ },
+ {
+ "id": "django__django-16493",
+ "repo": "django/django",
+ "language": "Python",
+ "gold_files": 1
+ },
+ {
+ "id": "django__django-16527",
+ "repo": "django/django",
+ "language": "Python",
+ "gold_files": 1
+ },
+ {
+ "id": "django__django-16819",
+ "repo": "django/django",
+ "language": "Python",
+ "gold_files": 1
+ },
+ {
+ "id": "django__django-9296",
+ "repo": "django/django",
+ "language": "Python",
+ "gold_files": 1
+ },
+ {
+ "id": "matplotlib__matplotlib-20676",
+ "repo": "matplotlib/matplotlib",
+ "language": "Python",
+ "gold_files": 1
+ },
+ {
+ "id": "matplotlib__matplotlib-23412",
+ "repo": "matplotlib/matplotlib",
+ "language": "Python",
+ "gold_files": 1
+ },
+ {
+ "id": "matplotlib__matplotlib-23476",
+ "repo": "matplotlib/matplotlib",
+ "language": "Python",
+ "gold_files": 1
+ },
+ {
+ "id": "matplotlib__matplotlib-24570",
+ "repo": "matplotlib/matplotlib",
+ "language": "Python",
+ "gold_files": 1
+ },
+ {
+ "id": "matplotlib__matplotlib-25287",
+ "repo": "matplotlib/matplotlib",
+ "language": "Python",
+ "gold_files": 1
+ },
+ {
+ "id": "matplotlib__matplotlib-26113",
+ "repo": "matplotlib/matplotlib",
+ "language": "Python",
+ "gold_files": 1
+ },
+ {
+ "id": "matplotlib__matplotlib-26466",
+ "repo": "matplotlib/matplotlib",
+ "language": "Python",
+ "gold_files": 1
+ },
+ {
+ "id": "psf__requests-1142",
+ "repo": "psf/requests",
+ "language": "Python",
+ "gold_files": 1
+ },
+ {
+ "id": "psf__requests-5414",
+ "repo": "psf/requests",
+ "language": "Python",
+ "gold_files": 1
+ },
+ {
+ "id": "pydata__xarray-3095",
+ "repo": "pydata/xarray",
+ "language": "Python",
+ "gold_files": 2
+ },
+ {
+ "id": "pydata__xarray-3677",
+ "repo": "pydata/xarray",
+ "language": "Python",
+ "gold_files": 1
+ },
+ {
+ "id": "pydata__xarray-4356",
+ "repo": "pydata/xarray",
+ "language": "Python",
+ "gold_files": 1
+ },
+ {
+ "id": "pydata__xarray-4695",
+ "repo": "pydata/xarray",
+ "language": "Python",
+ "gold_files": 1
+ },
+ {
+ "id": "pylint-dev__pylint-4661",
+ "repo": "pylint-dev/pylint",
+ "language": "Python",
+ "gold_files": 1
+ },
+ {
+ "id": "pylint-dev__pylint-6528",
+ "repo": "pylint-dev/pylint",
+ "language": "Python",
+ "gold_files": 2
+ },
+ {
+ "id": "pytest-dev__pytest-10051",
+ "repo": "pytest-dev/pytest",
+ "language": "Python",
+ "gold_files": 1
+ },
+ {
+ "id": "pytest-dev__pytest-10081",
+ "repo": "pytest-dev/pytest",
+ "language": "Python",
+ "gold_files": 1
+ },
+ {
+ "id": "pytest-dev__pytest-5809",
+ "repo": "pytest-dev/pytest",
+ "language": "Python",
+ "gold_files": 1
+ },
+ {
+ "id": "pytest-dev__pytest-6202",
+ "repo": "pytest-dev/pytest",
+ "language": "Python",
+ "gold_files": 1
+ },
+ {
+ "id": "scikit-learn__scikit-learn-10297",
+ "repo": "scikit-learn/scikit-learn",
+ "language": "Python",
+ "gold_files": 1
+ },
+ {
+ "id": "scikit-learn__scikit-learn-10908",
+ "repo": "scikit-learn/scikit-learn",
+ "language": "Python",
+ "gold_files": 1
+ },
+ {
+ "id": "scikit-learn__scikit-learn-13124",
+ "repo": "scikit-learn/scikit-learn",
+ "language": "Python",
+ "gold_files": 1
+ },
+ {
+ "id": "scikit-learn__scikit-learn-13328",
+ "repo": "scikit-learn/scikit-learn",
+ "language": "Python",
+ "gold_files": 1
+ },
+ {
+ "id": "scikit-learn__scikit-learn-25747",
+ "repo": "scikit-learn/scikit-learn",
+ "language": "Python",
+ "gold_files": 1
+ },
+ {
+ "id": "scikit-learn__scikit-learn-25931",
+ "repo": "scikit-learn/scikit-learn",
+ "language": "Python",
+ "gold_files": 1
+ },
+ {
+ "id": "scikit-learn__scikit-learn-9288",
+ "repo": "scikit-learn/scikit-learn",
+ "language": "Python",
+ "gold_files": 1
+ },
+ {
+ "id": "sphinx-doc__sphinx-10323",
+ "repo": "sphinx-doc/sphinx",
+ "language": "Python",
+ "gold_files": 1
+ },
+ {
+ "id": "sphinx-doc__sphinx-11445",
+ "repo": "sphinx-doc/sphinx",
+ "language": "Python",
+ "gold_files": 1
+ },
+ {
+ "id": "sphinx-doc__sphinx-11510",
+ "repo": "sphinx-doc/sphinx",
+ "language": "Python",
+ "gold_files": 1
+ },
+ {
+ "id": "sphinx-doc__sphinx-7985",
+ "repo": "sphinx-doc/sphinx",
+ "language": "Python",
+ "gold_files": 1
+ },
+ {
+ "id": "sphinx-doc__sphinx-8459",
+ "repo": "sphinx-doc/sphinx",
+ "language": "Python",
+ "gold_files": 1
+ },
+ {
+ "id": "sphinx-doc__sphinx-8721",
+ "repo": "sphinx-doc/sphinx",
+ "language": "Python",
+ "gold_files": 1
+ },
+ {
+ "id": "sphinx-doc__sphinx-9229",
+ "repo": "sphinx-doc/sphinx",
+ "language": "Python",
+ "gold_files": 1
+ },
+ {
+ "id": "sphinx-doc__sphinx-9281",
+ "repo": "sphinx-doc/sphinx",
+ "language": "Python",
+ "gold_files": 1
+ },
+ {
+ "id": "sphinx-doc__sphinx-9602",
+ "repo": "sphinx-doc/sphinx",
+ "language": "Python",
+ "gold_files": 1
+ },
+ {
+ "id": "sympy__sympy-11618",
+ "repo": "sympy/sympy",
+ "language": "Python",
+ "gold_files": 1
+ },
+ {
+ "id": "sympy__sympy-12096",
+ "repo": "sympy/sympy",
+ "language": "Python",
+ "gold_files": 1
+ },
+ {
+ "id": "sympy__sympy-12419",
+ "repo": "sympy/sympy",
+ "language": "Python",
+ "gold_files": 1
+ },
+ {
+ "id": "sympy__sympy-13091",
+ "repo": "sympy/sympy",
+ "language": "Python",
+ "gold_files": 21
+ },
+ {
+ "id": "sympy__sympy-14248",
+ "repo": "sympy/sympy",
+ "language": "Python",
+ "gold_files": 3
+ },
+ {
+ "id": "sympy__sympy-14976",
+ "repo": "sympy/sympy",
+ "language": "Python",
+ "gold_files": 1
+ },
+ {
+ "id": "sympy__sympy-15875",
+ "repo": "sympy/sympy",
+ "language": "Python",
+ "gold_files": 1
+ },
+ {
+ "id": "sympy__sympy-16450",
+ "repo": "sympy/sympy",
+ "language": "Python",
+ "gold_files": 1
+ },
+ {
+ "id": "sympy__sympy-17630",
+ "repo": "sympy/sympy",
+ "language": "Python",
+ "gold_files": 1
+ },
+ {
+ "id": "sympy__sympy-18211",
+ "repo": "sympy/sympy",
+ "language": "Python",
+ "gold_files": 1
+ },
+ {
+ "id": "sympy__sympy-19637",
+ "repo": "sympy/sympy",
+ "language": "Python",
+ "gold_files": 1
+ },
+ {
+ "id": "sympy__sympy-19783",
+ "repo": "sympy/sympy",
+ "language": "Python",
+ "gold_files": 2
+ },
+ {
+ "id": "sympy__sympy-22080",
+ "repo": "sympy/sympy",
+ "language": "Python",
+ "gold_files": 2
+ },
+ {
+ "id": "sympy__sympy-24213",
+ "repo": "sympy/sympy",
+ "language": "Python",
+ "gold_files": 1
+ },
+ {
+ "id": "sympy__sympy-24562",
+ "repo": "sympy/sympy",
+ "language": "Python",
+ "gold_files": 1
+ }
+ ],
+ "n": 100,
+ "results": {
+ "graphicle-0.1.3": {
+ "hit@1": 43,
+ "hit@5": 75,
+ "hit@10": 82,
+ "mrr": 0.5617
+ },
+ "graphicle-0.1.2": {
+ "hit@1": 13,
+ "hit@5": 30,
+ "hit@10": 30,
+ "mrr": 0.1912
+ },
+ "bm25": {
+ "hit@1": 35,
+ "hit@5": 61,
+ "hit@10": 77,
+ "mrr": 0.4776
+ },
+ "grep": {
+ "hit@1": 20,
+ "hit@5": 54,
+ "hit@10": 71,
+ "mrr": 0.3653
+ },
+ "graphicle-0.1.3-ranked": {
+ "hit@1": 42,
+ "hit@5": 76,
+ "hit@10": 82,
+ "mrr": 0.5639
+ },
+ "graphicle-0.1.2-ranked": {
+ "hit@1": 16,
+ "hit@5": 29,
+ "hit@10": 35,
+ "mrr": 0.2251
+ }
+ },
+ "mcnemar": {
+ "1": {
+ "only_a": 19,
+ "only_b": 11
+ },
+ "5": {
+ "only_a": 21,
+ "only_b": 7
+ },
+ "10": {
+ "only_a": 13,
+ "only_b": 8
+ }
+ }
+ },
+ "dev": {
+ "table_title": "Development set: issues filed in July 2026, used for tuning",
+ "tasks": [
+ {
+ "id": "DynamoRIO__dynamorio-8017",
+ "repo": "DynamoRIO/dynamorio",
+ "language": "C",
+ "gold_files": 3
+ },
+ {
+ "id": "IfcOpenShell__IfcOpenShell-8887",
+ "repo": "IfcOpenShell/IfcOpenShell",
+ "language": "C++",
+ "gold_files": 1
+ },
+ {
+ "id": "JasperFx__marten-5080",
+ "repo": "JasperFx/marten",
+ "language": "C#",
+ "gold_files": 1
+ },
+ {
+ "id": "JasperFx__wolverine-3456",
+ "repo": "JasperFx/wolverine",
+ "language": "C#",
+ "gold_files": 5
+ },
+ {
+ "id": "JasperFx__wolverine-3582",
+ "repo": "JasperFx/wolverine",
+ "language": "C#",
+ "gold_files": 1
+ },
+ {
+ "id": "JasperFx__wolverine-3695",
+ "repo": "JasperFx/wolverine",
+ "language": "C#",
+ "gold_files": 3
+ },
+ {
+ "id": "SubtitleEdit__subtitleedit-12151",
+ "repo": "SubtitleEdit/subtitleedit",
+ "language": "C#",
+ "gold_files": 2
+ },
+ {
+ "id": "SubtitleEdit__subtitleedit-12763",
+ "repo": "SubtitleEdit/subtitleedit",
+ "language": "C#",
+ "gold_files": 1
+ },
+ {
+ "id": "SubtitleEdit__subtitleedit-12895",
+ "repo": "SubtitleEdit/subtitleedit",
+ "language": "C#",
+ "gold_files": 1
+ },
+ {
+ "id": "agentgateway__agentgateway-2452",
+ "repo": "agentgateway/agentgateway",
+ "language": "Rust",
+ "gold_files": 1
+ },
+ {
+ "id": "agentscope-ai__agentscope-java-2189",
+ "repo": "agentscope-ai/agentscope-java",
+ "language": "Java",
+ "gold_files": 2
+ },
+ {
+ "id": "agentscope-ai__agentscope-java-2257",
+ "repo": "agentscope-ai/agentscope-java",
+ "language": "Java",
+ "gold_files": 1
+ },
+ {
+ "id": "agentscope-ai__agentscope-java-2260",
+ "repo": "agentscope-ai/agentscope-java",
+ "language": "Java",
+ "gold_files": 1
+ },
+ {
+ "id": "apache__paimon-8536",
+ "repo": "apache/paimon",
+ "language": "Java",
+ "gold_files": 1
+ },
+ {
+ "id": "apache__paimon-8874",
+ "repo": "apache/paimon",
+ "language": "Java",
+ "gold_files": 1
+ },
+ {
+ "id": "apache__parquet-java-3642",
+ "repo": "apache/parquet-java",
+ "language": "Java",
+ "gold_files": 1
+ },
+ {
+ "id": "apache__parquet-java-3645",
+ "repo": "apache/parquet-java",
+ "language": "Java",
+ "gold_files": 1
+ },
+ {
+ "id": "apache__parquet-java-3669",
+ "repo": "apache/parquet-java",
+ "language": "Java",
+ "gold_files": 1
+ },
+ {
+ "id": "apache__shardingsphere-39104",
+ "repo": "apache/shardingsphere",
+ "language": "Java",
+ "gold_files": 1
+ },
+ {
+ "id": "apache__shardingsphere-39137",
+ "repo": "apache/shardingsphere",
+ "language": "Java",
+ "gold_files": 1
+ },
+ {
+ "id": "apache__shardingsphere-39237",
+ "repo": "apache/shardingsphere",
+ "language": "Java",
+ "gold_files": 1
+ },
+ {
+ "id": "btraceio__btrace-894",
+ "repo": "btraceio/btrace",
+ "language": "Java",
+ "gold_files": 3
+ },
+ {
+ "id": "btraceio__btrace-895",
+ "repo": "btraceio/btrace",
+ "language": "Java",
+ "gold_files": 5
+ },
+ {
+ "id": "btraceio__btrace-910",
+ "repo": "btraceio/btrace",
+ "language": "Java",
+ "gold_files": 4
+ },
+ {
+ "id": "c-ares__c-ares-1190",
+ "repo": "c-ares/c-ares",
+ "language": "C",
+ "gold_files": 4
+ },
+ {
+ "id": "colbymchenry__codegraph-1317",
+ "repo": "colbymchenry/codegraph",
+ "language": "C",
+ "gold_files": 2
+ },
+ {
+ "id": "colbymchenry__codegraph-1318",
+ "repo": "colbymchenry/codegraph",
+ "language": "C",
+ "gold_files": 1
+ },
+ {
+ "id": "colbymchenry__codegraph-1370",
+ "repo": "colbymchenry/codegraph",
+ "language": "C",
+ "gold_files": 1
+ },
+ {
+ "id": "duckdb__ducklake-1339",
+ "repo": "duckdb/ducklake",
+ "language": "C++",
+ "gold_files": 2
+ },
+ {
+ "id": "duckdb__ducklake-1340",
+ "repo": "duckdb/ducklake",
+ "language": "C++",
+ "gold_files": 3
+ },
+ {
+ "id": "elsa-workflows__elsa-core-7898",
+ "repo": "elsa-workflows/elsa-core",
+ "language": "C#",
+ "gold_files": 1
+ },
+ {
+ "id": "floci-io__floci-1837",
+ "repo": "floci-io/floci",
+ "language": "Java",
+ "gold_files": 1
+ },
+ {
+ "id": "floci-io__floci-1870",
+ "repo": "floci-io/floci",
+ "language": "Java",
+ "gold_files": 1
+ },
+ {
+ "id": "floci-io__floci-2015",
+ "repo": "floci-io/floci",
+ "language": "Java",
+ "gold_files": 2
+ },
+ {
+ "id": "fluent__fluent-bit-12029",
+ "repo": "fluent/fluent-bit",
+ "language": "C",
+ "gold_files": 2
+ },
+ {
+ "id": "gitbutlerapp__gitbutler-14920",
+ "repo": "gitbutlerapp/gitbutler",
+ "language": "Rust",
+ "gold_files": 2
+ },
+ {
+ "id": "gleam-lang__gleam-5958",
+ "repo": "gleam-lang/gleam",
+ "language": "Rust",
+ "gold_files": 1
+ },
+ {
+ "id": "gleam-lang__gleam-6021",
+ "repo": "gleam-lang/gleam",
+ "language": "Rust",
+ "gold_files": 3
+ },
+ {
+ "id": "h4ckf0r0day__obscura-412",
+ "repo": "h4ckf0r0day/obscura",
+ "language": "Rust",
+ "gold_files": 1
+ },
+ {
+ "id": "h4ckf0r0day__obscura-421",
+ "repo": "h4ckf0r0day/obscura",
+ "language": "Rust",
+ "gold_files": 1
+ },
+ {
+ "id": "h4ckf0r0day__obscura-440",
+ "repo": "h4ckf0r0day/obscura",
+ "language": "Rust",
+ "gold_files": 1
+ },
+ {
+ "id": "jsonata-js__jsonata-814",
+ "repo": "jsonata-js/jsonata",
+ "language": "JS/TS",
+ "gold_files": 4
+ },
+ {
+ "id": "kvcache-ai__Mooncake-2892",
+ "repo": "kvcache-ai/Mooncake",
+ "language": "C++",
+ "gold_files": 1
+ },
+ {
+ "id": "kvcache-ai__Mooncake-2964",
+ "repo": "kvcache-ai/Mooncake",
+ "language": "C++",
+ "gold_files": 2
+ },
+ {
+ "id": "lakehq__sail-2292",
+ "repo": "lakehq/sail",
+ "language": "Rust",
+ "gold_files": 1
+ },
+ {
+ "id": "lance-format__lance-7618",
+ "repo": "lance-format/lance",
+ "language": "Rust",
+ "gold_files": 1
+ },
+ {
+ "id": "lance-format__lance-8049",
+ "repo": "lance-format/lance",
+ "language": "Rust",
+ "gold_files": 1
+ },
+ {
+ "id": "langchain4j__langchain4j-5755",
+ "repo": "langchain4j/langchain4j",
+ "language": "Java",
+ "gold_files": 1
+ },
+ {
+ "id": "langchain4j__langchain4j-5847",
+ "repo": "langchain4j/langchain4j",
+ "language": "Java",
+ "gold_files": 2
+ },
+ {
+ "id": "langchain4j__langchain4j-5869",
+ "repo": "langchain4j/langchain4j",
+ "language": "Java",
+ "gold_files": 2
+ },
+ {
+ "id": "luau-lang__luau-2506",
+ "repo": "luau-lang/luau",
+ "language": "C++",
+ "gold_files": 1
+ },
+ {
+ "id": "modelcontextprotocol__rust-sdk-1005",
+ "repo": "modelcontextprotocol/rust-sdk",
+ "language": "Rust",
+ "gold_files": 1
+ },
+ {
+ "id": "modelcontextprotocol__rust-sdk-1021",
+ "repo": "modelcontextprotocol/rust-sdk",
+ "language": "Rust",
+ "gold_files": 4
+ },
+ {
+ "id": "modelcontextprotocol__rust-sdk-996",
+ "repo": "modelcontextprotocol/rust-sdk",
+ "language": "Rust",
+ "gold_files": 1
+ },
+ {
+ "id": "nearai__ironclaw-6706",
+ "repo": "nearai/ironclaw",
+ "language": "Rust",
+ "gold_files": 4
+ },
+ {
+ "id": "nearai__ironclaw-6712",
+ "repo": "nearai/ironclaw",
+ "language": "Rust",
+ "gold_files": 2
+ },
+ {
+ "id": "notionnext-org__NotionNext-4290",
+ "repo": "notionnext-org/NotionNext",
+ "language": "JS/TS",
+ "gold_files": 1
+ },
+ {
+ "id": "nunit__nunit-5351",
+ "repo": "nunit/nunit",
+ "language": "C#",
+ "gold_files": 3
+ },
+ {
+ "id": "open-gsd__gsd-core-2079",
+ "repo": "open-gsd/gsd-core",
+ "language": "JS/TS",
+ "gold_files": 1
+ },
+ {
+ "id": "open-gsd__gsd-core-2233",
+ "repo": "open-gsd/gsd-core",
+ "language": "JS/TS",
+ "gold_files": 1
+ },
+ {
+ "id": "open-gsd__gsd-core-2261",
+ "repo": "open-gsd/gsd-core",
+ "language": "JS/TS",
+ "gold_files": 2
+ },
+ {
+ "id": "playcanvas__engine-9000",
+ "repo": "playcanvas/engine",
+ "language": "JS/TS",
+ "gold_files": 1
+ },
+ {
+ "id": "playcanvas__engine-9002",
+ "repo": "playcanvas/engine",
+ "language": "JS/TS",
+ "gold_files": 2
+ },
+ {
+ "id": "playcanvas__engine-9066",
+ "repo": "playcanvas/engine",
+ "language": "JS/TS",
+ "gold_files": 2
+ },
+ {
+ "id": "prefix-dev__pixi-6518",
+ "repo": "prefix-dev/pixi",
+ "language": "Rust",
+ "gold_files": 4
+ },
+ {
+ "id": "prefix-dev__pixi-6529",
+ "repo": "prefix-dev/pixi",
+ "language": "Rust",
+ "gold_files": 4
+ },
+ {
+ "id": "root-project__root-22854",
+ "repo": "root-project/root",
+ "language": "C++",
+ "gold_files": 1
+ },
+ {
+ "id": "root-project__root-22857",
+ "repo": "root-project/root",
+ "language": "C++",
+ "gold_files": 1
+ },
+ {
+ "id": "rust-lang__rust-analyzer-22751",
+ "repo": "rust-lang/rust-analyzer",
+ "language": "Rust",
+ "gold_files": 1
+ },
+ {
+ "id": "rust-lang__rust-analyzer-22804",
+ "repo": "rust-lang/rust-analyzer",
+ "language": "Rust",
+ "gold_files": 1
+ },
+ {
+ "id": "rust-lang__rust-analyzer-22855",
+ "repo": "rust-lang/rust-analyzer",
+ "language": "Rust",
+ "gold_files": 1
+ },
+ {
+ "id": "web-infra-dev__rspack-14794",
+ "repo": "web-infra-dev/rspack",
+ "language": "Rust",
+ "gold_files": 1
+ },
+ {
+ "id": "web-infra-dev__rspack-14803",
+ "repo": "web-infra-dev/rspack",
+ "language": "Rust",
+ "gold_files": 1
+ },
+ {
+ "id": "web-infra-dev__rspack-14882",
+ "repo": "web-infra-dev/rspack",
+ "language": "Rust",
+ "gold_files": 1
+ },
+ {
+ "id": "xroche__httrack-599",
+ "repo": "xroche/httrack",
+ "language": "C",
+ "gold_files": 1
+ },
+ {
+ "id": "xroche__httrack-618",
+ "repo": "xroche/httrack",
+ "language": "C",
+ "gold_files": 1
+ },
+ {
+ "id": "xroche__httrack-811",
+ "repo": "xroche/httrack",
+ "language": "C",
+ "gold_files": 1
+ },
+ {
+ "id": "yvgude__lean-ctx-1179",
+ "repo": "yvgude/lean-ctx",
+ "language": "Rust",
+ "gold_files": 1
+ },
+ {
+ "id": "yvgude__lean-ctx-816",
+ "repo": "yvgude/lean-ctx",
+ "language": "Rust",
+ "gold_files": 4
+ },
+ {
+ "id": "yvgude__lean-ctx-969",
+ "repo": "yvgude/lean-ctx",
+ "language": "Rust",
+ "gold_files": 1
+ }
+ ],
+ "n": 80,
+ "results": {
+ "graphicle-0.1.3": {
+ "hit@1": 38,
+ "hit@5": 63,
+ "hit@10": 69,
+ "mrr": 0.6112
+ },
+ "graphicle-0.1.2": {
+ "hit@1": 12,
+ "hit@5": 27,
+ "hit@10": 27,
+ "mrr": 0.2269
+ },
+ "bm25": {
+ "hit@1": 34,
+ "hit@5": 51,
+ "hit@10": 57,
+ "mrr": 0.5225
+ },
+ "grep": {
+ "hit@1": 30,
+ "hit@5": 51,
+ "hit@10": 59,
+ "mrr": 0.5014
+ },
+ "graphicle-0.1.3-ranked": {
+ "hit@1": 37,
+ "hit@5": 63,
+ "hit@10": 69,
+ "mrr": 0.6024
+ },
+ "graphicle-0.1.2-ranked": {
+ "hit@1": 8,
+ "hit@5": 26,
+ "hit@10": 29,
+ "mrr": 0.2133
+ }
+ },
+ "mcnemar": {
+ "1": {
+ "only_a": 11,
+ "only_b": 7
+ },
+ "5": {
+ "only_a": 16,
+ "only_b": 4
+ },
+ "10": {
+ "only_a": 14,
+ "only_b": 2
+ }
+ }
+ }
+ },
+ "chart": {
+ "set": "held-out",
+ "systems": [
+ "graphicle-0.1.3",
+ "graphicle-0.1.2",
+ "bm25",
+ "grep"
+ ],
+ "tagline": "Offline retrieval benchmark, 21 October 2026",
+ "title": "Finding the files a fix changes: 100 SWE-bench Verified issues, held out from tuning",
+ "subtitle": "For each issue: is a file the fix changed among the first k files? Graphicle: the files its context packet cites, then lists. No model calls. Higher is better.",
+ "panels": {
+ "hit@1": {
+ "title": "Top 1",
+ "sub": "Issues of {n} with a changed file first"
+ },
+ "hit@5": {
+ "title": "Top 5",
+ "sub": "Issues of {n} with a changed file in the first 5"
+ },
+ "hit@10": {
+ "title": "Top 10",
+ "sub": "Issues of {n} with a changed file in the first 10"
+ },
+ "mrr": {
+ "title": "MRR",
+ "sub": "Mean reciprocal rank of the first changed file",
+ "note": "1 when it comes first, 0.5 when second, 0 past rank 100."
+ }
+ },
+ "compare_label": "0.1.3 vs BM25, McNemar exact:",
+ "footer": [
+ "Graphicle 0.1.3 and the 0.1.2 release binary run graphicle context on the issue's prompt, with their defaults. BM25: SWE-bench style, one document per source file. grep: rg 14.1.1 for the identifiers and paths the issue names, files ranked by names matched.",
+ "This measures ranking, not whether a coding agent fixes more issues. The agent test of 0.1.3 is pending."
+ ],
+ "url_label": "Method, task list and limits:",
+ "url": "github.com/graphicle-ai/graphicle/blob/main/docs/benchmarks/retrieval.md"
+ }
+}
diff --git a/docs/benchmarks/retrieval.md b/docs/benchmarks/retrieval.md
new file mode 100644
index 0000000..2383388
--- /dev/null
+++ b/docs/benchmarks/retrieval.md
@@ -0,0 +1,225 @@
+# Retrieval benchmark: finding the files a fix changes
+
+Measured on 21 October 2026, offline: no model is called by any system here.
+
+<p align="center">
+ <picture>
+ <source media="(prefers-color-scheme: dark)" srcset="../assets/retrieval-dark.svg">
+ <img src="../assets/retrieval-light.svg" alt="Finding the files a fix changes: 100 SWE-bench Verified issues, held out from tuning. Top 1: Graphicle 0.1.3 43, Graphicle 0.1.2 13, BM25 (SWE-bench style) 35, grep for the issue's names 20; Top 5: Graphicle 0.1.3 75, Graphicle 0.1.2 30, BM25 (SWE-bench style) 61, grep for the issue's names 54; Top 10: Graphicle 0.1.3 82, Graphicle 0.1.2 30, BM25 (SWE-bench style) 77, grep for the issue's names 71; MRR: Graphicle 0.1.3 0.562, Graphicle 0.1.2 0.191, BM25 (SWE-bench style) 0.478, grep for the issue's names 0.365.">
+ </picture>
+</p>
+
+## What this measures, and what it does not
+
+For each issue, the benchmark asks whether a file that the issue's fix changed
+is among the first k files a system returns (hit@k, for k = 1, 5 and 10), and
+how high the first such file comes (mean reciprocal rank, MRR).
+
+It measures ranking only. It does not measure whether a coding agent finds or
+fixes more issues with Graphicle: that needs an agent test, and the agent test
+of 0.1.3 is pending. Our earlier agent tests, of 0.1.0 and 0.1.1 with
+Claude Code, found Graphicle tied with plain Claude Code on finding the files
+a fix changes
+([agent tests](../benchmarks.md#coding-agents-with-graphicle-graphify-or-neither)).
+The two baselines below are fixed procedures, defined exactly; they are not
+what an agent does when it searches with grep or a search engine.
+
+## Results
+
+### Held-out set: 100 SWE-bench Verified issues, never used for tuning
+
+| System | hit@1 | hit@5 | hit@10 | MRR |
+|---|---|---|---|---|
+| Graphicle 0.1.3 | 43 | 75 | 82 | 0.562 |
+| Graphicle 0.1.2 | 13 | 30 | 30 | 0.191 |
+| BM25, SWE-bench style | 35 | 61 | 77 | 0.478 |
+| grep for the names in the issue (rg 14.1.1) | 20 | 54 | 71 | 0.365 |
+| Graphicle 0.1.3, its ranking before the packet | 42 | 76 | 82 | 0.564 |
+| Graphicle 0.1.2, its ranking before the packet | 16 | 29 | 35 | 0.225 |
+
+McNemar exact test, Graphicle 0.1.3 against BM25, SWE-bench style:
+
+| k | only Graphicle 0.1.3 has a hit | only BM25, SWE-bench style has a hit | p (two-sided) |
+|---|---|---|---|
+| 1 | 19 | 11 | 0.200 |
+| 5 | 21 | 7 | 0.013 |
+| 10 | 13 | 8 | 0.383 |
+
+At the 0.05 level, against BM25: the first file, p = 0.200, not significant; the first 5 files, p = 0.013, significant; the first 10 files, p = 0.383, not significant.
+
+### Development set: 80 issues filed in July 2026, used for tuning
+
+0.1.3's ranking changes were developed and measured on this set, so its
+Graphicle 0.1.3 numbers are optimistic; the held-out set is the fair
+comparison.
+
+| System | hit@1 | hit@5 | hit@10 | MRR |
+|---|---|---|---|---|
+| Graphicle 0.1.3 | 38 | 63 | 69 | 0.611 |
+| Graphicle 0.1.2 | 12 | 27 | 27 | 0.227 |
+| BM25, SWE-bench style | 34 | 51 | 57 | 0.522 |
+| grep for the names in the issue (rg 14.1.1) | 30 | 51 | 59 | 0.501 |
+| Graphicle 0.1.3, its ranking before the packet | 37 | 63 | 69 | 0.602 |
+| Graphicle 0.1.2, its ranking before the packet | 8 | 26 | 29 | 0.213 |
+
+### Prompt formats (development set, used for tuning)
+
+The 78 development issues outside root-project/root, each wrapped four ways,
+and Graphicle 0.1.3's ranking before the packet: the instructions above
+with `<issue>` tags; SWE-agent's `<pr_description>` tags; Agentless's
+`--- BEGIN ISSUE ---` and `--- END ISSUE ---` lines; and a question in plain
+words followed by the error in an `<error>` block.
+
+| Format | hit@1 | hit@5 | hit@10 | MRR |
+|---|---|---|---|---|
+| Instructions with `<issue>` tags | 36 | 61 | 67 | 0.599 |
+| SWE-agent, `<pr_description>` | 35 | 62 | 67 | 0.590 |
+| Agentless, `--- BEGIN ISSUE ---` | 35 | 57 | 67 | 0.586 |
+| A question and an `<error>` block | 34 | 60 | 67 | 0.580 |
+
+## Sets
+
+### Held-out: SWE-bench Verified (100 issues, Python)
+
+The 100 issues of our 15 October agent test, from SWE-bench Verified (`princeton-nlp/SWE-bench_Verified` at revision c104f840), all in Python: django/django 46, sympy/sympy 15, sphinx-doc/sphinx 9, matplotlib/matplotlib 7, scikit-learn/scikit-learn 7, astropy/astropy 4, pydata/xarray 4, pytest-dev/pytest 4, psf/requests 2, pylint-dev/pylint 2.
+
+Never used for tuning: 0.1.3's ranking changes were developed and chosen on the development set. This set's totals were checked for each candidate build, and no per-issue result of it was read before the final build was fixed.
+
+Gold files: 1 gold file for 87 issues; 2 gold files for 8 issues; 3 gold files for 3 issues; 4 gold files for 1 issue; 21 gold files for 1 issue.
+
+<details><summary>The 100 issues, by repository</summary>
+
+- django/django (46): `django__django-10914`, `django__django-11163`, `django__django-11239`, `django__django-11400`, `django__django-11477`, `django__django-11790`, `django__django-12155`, `django__django-12273`, `django__django-12406`, `django__django-12774`, `django__django-12965`, `django__django-13158`, `django__django-13195`, `django__django-13212`, `django__django-13315`, `django__django-13343`, `django__django-13406`, `django__django-13410`, `django__django-13551`, `django__django-13741`, `django__django-13810`, `django__django-13821`, `django__django-13837`, `django__django-13933`, `django__django-13964`, `django__django-14155`, `django__django-14349`, `django__django-14373`, `django__django-14493`, `django__django-14580`, `django__django-14765`, `django__django-14855`, `django__django-14999`, `django__django-15252`, `django__django-15277`, `django__django-15382`, `django__django-15629`, `django__django-15695`, `django__django-16082`, `django__django-16315`, `django__django-16333`, `django__django-16485`, `django__django-16493`, `django__django-16527`, `django__django-16819`, `django__django-9296`
+- sympy/sympy (15): `sympy__sympy-11618`, `sympy__sympy-12096`, `sympy__sympy-12419`, `sympy__sympy-13091`, `sympy__sympy-14248`, `sympy__sympy-14976`, `sympy__sympy-15875`, `sympy__sympy-16450`, `sympy__sympy-17630`, `sympy__sympy-18211`, `sympy__sympy-19637`, `sympy__sympy-19783`, `sympy__sympy-22080`, `sympy__sympy-24213`, `sympy__sympy-24562`
+- sphinx-doc/sphinx (9): `sphinx-doc__sphinx-10323`, `sphinx-doc__sphinx-11445`, `sphinx-doc__sphinx-11510`, `sphinx-doc__sphinx-7985`, `sphinx-doc__sphinx-8459`, `sphinx-doc__sphinx-8721`, `sphinx-doc__sphinx-9229`, `sphinx-doc__sphinx-9281`, `sphinx-doc__sphinx-9602`
+- matplotlib/matplotlib (7): `matplotlib__matplotlib-20676`, `matplotlib__matplotlib-23412`, `matplotlib__matplotlib-23476`, `matplotlib__matplotlib-24570`, `matplotlib__matplotlib-25287`, `matplotlib__matplotlib-26113`, `matplotlib__matplotlib-26466`
+- scikit-learn/scikit-learn (7): `scikit-learn__scikit-learn-10297`, `scikit-learn__scikit-learn-10908`, `scikit-learn__scikit-learn-13124`, `scikit-learn__scikit-learn-13328`, `scikit-learn__scikit-learn-25747`, `scikit-learn__scikit-learn-25931`, `scikit-learn__scikit-learn-9288`
+- astropy/astropy (4): `astropy__astropy-13453`, `astropy__astropy-13579`, `astropy__astropy-7336`, `astropy__astropy-8872`
+- pydata/xarray (4): `pydata__xarray-3095`, `pydata__xarray-3677`, `pydata__xarray-4356`, `pydata__xarray-4695`
+- pytest-dev/pytest (4): `pytest-dev__pytest-10051`, `pytest-dev__pytest-10081`, `pytest-dev__pytest-5809`, `pytest-dev__pytest-6202`
+- psf/requests (2): `psf__requests-1142`, `psf__requests-5414`
+- pylint-dev/pylint (2): `pylint-dev__pylint-4661`, `pylint-dev__pylint-6528`
+
+</details>
+
+### Development: 80 issues filed in July 2026 (Rust, Java, C, C#, C++, JavaScript and TypeScript)
+
+80 issues and fixes filed after the training cutoff of the model in our agent tests (July 2026), on 38 less-starred public repositories created before June 2026, so it is not code that model has never seen. The fixing pull requests were created from 2 to 30 July 2026, from SWE-bench-Live/MultiLang and SWE-bench-Live/Windows. Languages: Rust 26, Java 20, C 9, C# 9, C++ 8, JavaScript or TypeScript 8.
+
+This set was used for tuning: 0.1.3's ranking changes were developed and measured on it.
+
+Gold files: 1 gold file for 50 issues; 2 gold files for 14 issues; 3 gold files for 6 issues; 4 gold files for 8 issues; 5 gold files for 2 issues.
+
+<details><summary>The 80 issues, by language</summary>
+
+- Rust (26): `agentgateway__agentgateway-2452`, `gitbutlerapp__gitbutler-14920`, `gleam-lang__gleam-5958`, `gleam-lang__gleam-6021`, `h4ckf0r0day__obscura-412`, `h4ckf0r0day__obscura-421`, `h4ckf0r0day__obscura-440`, `lakehq__sail-2292`, `lance-format__lance-7618`, `lance-format__lance-8049`, `modelcontextprotocol__rust-sdk-1005`, `modelcontextprotocol__rust-sdk-1021`, `modelcontextprotocol__rust-sdk-996`, `nearai__ironclaw-6706`, `nearai__ironclaw-6712`, `prefix-dev__pixi-6518`, `prefix-dev__pixi-6529`, `rust-lang__rust-analyzer-22751`, `rust-lang__rust-analyzer-22804`, `rust-lang__rust-analyzer-22855`, `web-infra-dev__rspack-14794`, `web-infra-dev__rspack-14803`, `web-infra-dev__rspack-14882`, `yvgude__lean-ctx-1179`, `yvgude__lean-ctx-816`, `yvgude__lean-ctx-969`
+- Java (20): `agentscope-ai__agentscope-java-2189`, `agentscope-ai__agentscope-java-2257`, `agentscope-ai__agentscope-java-2260`, `apache__paimon-8536`, `apache__paimon-8874`, `apache__parquet-java-3642`, `apache__parquet-java-3645`, `apache__parquet-java-3669`, `apache__shardingsphere-39104`, `apache__shardingsphere-39137`, `apache__shardingsphere-39237`, `btraceio__btrace-894`, `btraceio__btrace-895`, `btraceio__btrace-910`, `floci-io__floci-1837`, `floci-io__floci-1870`, `floci-io__floci-2015`, `langchain4j__langchain4j-5755`, `langchain4j__langchain4j-5847`, `langchain4j__langchain4j-5869`
+- C (9): `DynamoRIO__dynamorio-8017`, `c-ares__c-ares-1190`, `colbymchenry__codegraph-1317`, `colbymchenry__codegraph-1318`, `colbymchenry__codegraph-1370`, `fluent__fluent-bit-12029`, `xroche__httrack-599`, `xroche__httrack-618`, `xroche__httrack-811`
+- C# (9): `JasperFx__marten-5080`, `JasperFx__wolverine-3456`, `JasperFx__wolverine-3582`, `JasperFx__wolverine-3695`, `SubtitleEdit__subtitleedit-12151`, `SubtitleEdit__subtitleedit-12763`, `SubtitleEdit__subtitleedit-12895`, `elsa-workflows__elsa-core-7898`, `nunit__nunit-5351`
+- C++ (8): `IfcOpenShell__IfcOpenShell-8887`, `duckdb__ducklake-1339`, `duckdb__ducklake-1340`, `kvcache-ai__Mooncake-2892`, `kvcache-ai__Mooncake-2964`, `luau-lang__luau-2506`, `root-project__root-22854`, `root-project__root-22857`
+- JavaScript or TypeScript (8): `jsonata-js__jsonata-814`, `notionnext-org__NotionNext-4290`, `open-gsd__gsd-core-2079`, `open-gsd__gsd-core-2233`, `open-gsd__gsd-core-2261`, `playcanvas__engine-9000`, `playcanvas__engine-9002`, `playcanvas__engine-9066`
+
+</details>
+
+## Systems
+
+Each issue's repository is checked out at the issue's base commit, and every
+system works on that checkout alone.
+
+- **Graphicle 0.1.3.** A release build of the 0.1.3 source. `graphicle setup`
+ syncs the checkout into a fresh data folder with its defaults. Then `graphicle call context` answers the question
+ with the arguments `graphicle context` uses by default: at most 8,400
+ characters and 3,000 tokens, the identifier route on. The question is the
+ prompt an agent got in our agent tests: the instructions below with the
+ issue between `<issue>` tags. The files counted are those the packet's
+ excerpts cite, in order, then the files the packet lists after them, each
+ file once.
+- **Graphicle 0.1.2.** The release binary (GitHub release v0.1.2, Linux
+ x86-64, checked against its `SHA256SUMS`), the same setup and question, and
+ 0.1.2's `graphicle context` defaults: 3,000 tokens, which 0.1.2 packs into
+ at most 12,000 characters. Its packet lists no files after its excerpts.
+- **Graphicle, its ranking before the packet** (both versions, in the tables
+ only): the fused order of up to 400 passages that the packet is chosen from
+ (`debug_candidates: 400`), each file at its first passage.
+- **BM25, SWE-bench style.** One document per source file (its path and
+ contents); Lucene's BM25 with Pyserini's defaults (k1 0.9, b 0.4); the query
+ is the issue text, as lowercase word tokens without Lucene's English stop
+ words and without stemming. Documents: the files Git tracks that have a code
+ extension (tests included), outside vendored and generated folders; every
+ gold file is a document.
+- **grep for the names in the issue.** The identifiers and paths the issue
+ text names (code spans, `snake_case`, camelCase, calls and qualified names;
+ at most 40), each searched with `rg -F -w --count-matches` (ripgrep 14.1.1)
+ over the same files. Files are ranked by the number of distinct names they
+ match, then by the total number of matches. A named path matches the files
+ it ends with and the files that end with it.
+
+The prompt, with the issue in place of `ISSUE`:
+
+````text
+The current folder is a checkout of a software repository. A user reported the issue below.
+
+<issue>
+ISSUE
+</issue>
+
+Your task is to find where the code must change to resolve this issue. Do not fix it: do not edit, create or delete any file. Investigate the repository as you see fit.
+
+When you are done, end your answer with exactly one JSON code block in this form:
+
+```json
+{"files": [{"path": "path/from/the/repository/root.py", "functions": ["ClassName.method_name", "function_name"]}]}
+```
+
+List at most 5 files, the most likely first. List only files that exist in the repository now and would need to change in a fix; leave out tests and documentation. For each file, list the functions or methods that would change, as ClassName.method_name for methods; use an empty list if you cannot tell.
+````
+
+## Metrics
+
+- **Gold files.** The files the fix modifies or deletes that exist at the base
+ commit and have a code extension, without tests and documentation. Files
+ the fix creates are not gold. A Rust file changed only in its test code is
+ not gold.
+- **hit@k.** The number of issues with a gold file among the first k files.
+- **MRR.** The mean over the issues of 1 / the rank of the first gold file,
+ 0 when it is not in the first 100.
+- **McNemar exact test.** Graphicle 0.1.3 against BM25 at each k, on the same
+ issues: a two-sided binomial test on the issues where exactly one of the two
+ has a hit.
+
+## Limitations
+
+- **Ranking, not agent success.** A file in the first 10 is not a fix, and an
+ agent may find the file another way; the agent test of 0.1.3 is pending.
+- **Prompt formats.** Both sets wrap every issue in the same instructions and
+ `<issue>` tags, and 0.1.3 reads marked content first. The check below
+ re-wraps the development issues in three other formats; the held-out set
+ was not re-wrapped.
+- **Python only, held out.** The held-out issues are all Python, and 46 of
+ them are Django's. The development set covers the other languages, but it
+ was used for tuning.
+- **Gold labels.** Only files the fix changed count. A file an agent could
+ start from that the fix did not change is a miss here.
+- **Different units.** BM25 and grep rank whole files. Graphicle ranks
+ passages and reports files, within a character budget.
+- **Budgets.** Graphicle 0.1.2 ran with its own default budget, 12,000
+ characters against 0.1.3's 8,400, which gives its packet more room.
+- **Long questions.** Graphicle 0.1.2 refuses a question over 16,000 bytes.
+ Two development issues are that long, and they count as misses for it;
+ 0.1.3 shortens such a question instead. No held-out question is that long.
+- **Size.** 100 held-out issues: the McNemar tests above give the chance of
+ differences this large between two equal systems.
+- **One run.** One run per system on one Linux machine; the systems are
+ deterministic for a given checkout and settings.
+
+## Files
+
+- [`retrieval.json`](retrieval.json): every issue of both sets, with its
+ repository, language, gold files and each system's rank of its first gold
+ file, and the chart's texts.
+- [`retrieval_chart.py`](retrieval_chart.py): prints the results tables and
+ McNemar tests on this page from `retrieval.json` (`--tables`) and draws the
+ chart (`docs/assets/retrieval-light` and `-dark`, SVG and PNG). The prompt
+ format table comes from the same harness and is not in the data file.
+- The harness that prepared the issues, ran the systems and computed the
+ baselines is not published.
diff --git a/docs/benchmarks/retrieval_chart.py b/docs/benchmarks/retrieval_chart.py
new file mode 100644
index 0000000..e12293c
--- /dev/null
+++ b/docs/benchmarks/retrieval_chart.py
@@ -0,0 +1,344 @@
+#!/usr/bin/env python3
+"""The retrieval benchmark's chart and tables, from its data file.
+
+ python3 retrieval_chart.py --data docs/benchmarks/retrieval.json --out docs/assets --fonts FONT_DIR
+ python3 retrieval_chart.py --data docs/benchmarks/retrieval.json --tables
+
+The first form writes retrieval-light.svg, retrieval-dark.svg and their PNGs (twice the SVG's size) to
+--out; the second prints the Markdown tables of docs/benchmarks/retrieval.md. The data file holds each
+set's results per system (hit@k: the issues with a file the fix changed among the first k files; MRR: the
+mean of 1/rank of the first such file, 0 past rank 100) and, for the two systems compared, the issues
+where only one of them has a hit at each k; this script computes the McNemar exact test from those (a
+two-sided binomial test on the issues where exactly one system has a hit).
+
+Needs matplotlib 3.11 and the Inter 4.1 and JetBrains Mono 2.304 TTF files in FONT_DIR (rsms/inter and
+JetBrains/JetBrainsMono releases); without them it uses DejaVu Sans and says so. The SVGs carry their
+text as outlines, so they show the same everywhere.
+"""
+import argparse
+import html
+import json
+import math
+import os
+import re
+import sys
+
+KS = (1, 5, 10)
+
+
+# ----------------------------------------------------------------------------- numbers
+def mcnemar_exact(only_a, only_b):
+ """Two-sided exact McNemar p from the discordant counts."""
+ n = only_a + only_b
+ if n == 0:
+ return 1.0
+ tail = sum(math.comb(n, i) for i in range(min(only_a, only_b) + 1)) / 2 ** n
+ return min(1.0, 2 * tail)
+
+
+def p_text(p):
+ return "p < 0.001" if p < 0.001 else f"p = {p:.3f}"
+
+
+def summarise(data, set_key):
+ s = data["sets"][set_key]
+ out = {"n": s["n"], "systems": {k: dict(v) for k, v in s["results"].items()}, "mcnemar": {}}
+ for k, t in s.get("mcnemar", {}).items():
+ out["mcnemar"][int(k)] = {**t, "p": mcnemar_exact(t["only_a"], t["only_b"])}
+ return out
+
+
+def tables(data):
+ lines = []
+ a, b = data["compare"]
+ for set_key, s in data["sets"].items():
+ if "results" not in s:
+ continue
+ m = summarise(data, set_key)
+ lines += [f"{s['table_title']} ({m['n']} issues)", "",
+ "| System | hit@1 | hit@5 | hit@10 | MRR |", "|---|---|---|---|---|"]
+ for key in data["systems"]:
+ if key not in m["systems"]:
+ continue
+ sm = m["systems"][key]
+ name = data["systems"][key]["label"]
+ lines.append(f"| {name} | {sm['hit@1']} | {sm['hit@5']} | {sm['hit@10']} | {sm['mrr']:.3f} |")
+ if m["mcnemar"]:
+ la, lb = data["systems"][a]["label"], data["systems"][b]["label"]
+ lines += ["", f"McNemar exact test, {la} against {lb}:", "",
+ f"| k | only {la} has a hit | only {lb} has a hit | p (two-sided) |",
+ "|---|---|---|---|"]
+ for k in KS:
+ t = m["mcnemar"][k]
+ lines.append(f"| {k} | {t['only_a']} | {t['only_b']} | {t['p']:.3f} |")
+ lines.append("")
+ return "\n".join(lines)
+
+
+def alt_text(data):
+ """The chart's alt texts: (short, long). Short: the title and every value; long: also the panels'
+ descriptions, the McNemar results and the footer."""
+ ch = data["chart"]
+ m = summarise(data, ch["set"])
+ a_key, b_key = data["compare"]
+ short, full = [], []
+ for metric in [f"hit@{k}" for k in KS] + ["mrr"]:
+ panel = ch["panels"][metric]
+ values = []
+ for key in ch["systems"]:
+ v = m["systems"][key][metric]
+ values.append(f"{data['systems'][key]['legend']} {v:.3f}" if metric == "mrr"
+ else f"{data['systems'][key]['legend']} {v}")
+ short.append(f"{panel['title']}: " + ", ".join(values))
+ line = f"{panel['title']} ({panel['sub'].format(n=m['n'])}): " + ", ".join(values)
+ if metric != "mrr":
+ k = int(metric[4:])
+ t = m["mcnemar"][k]
+ diff = m["systems"][a_key][metric] - m["systems"][b_key][metric]
+ line += (f"; {ch['compare_label']} {'+' if diff > 0 else ''}{diff} issues, {p_text(t['p'])}"
+ + ("" if t["p"] < 0.05 else ", not significant"))
+ full.append(line)
+ title = ch["title"] + ". "
+ return (title + "; ".join(short) + ".",
+ title + ch["subtitle"] + " " + ". ".join(full) + ". " + " ".join(ch["footer"]) + " "
+ + ch["url_label"] + " " + ch["url"])
+
+
+# ----------------------------------------------------------------------------- drawing
+THEMES = {
+ "light": {"surface": "#FFFFFF", "ink": "#0A0B0F", "ink2": "#2E3440", "muted": "#5B6474", "hair": "#E3E6EC",
+ "chip_win": "#3F5EFB", "tie_bg": "#EBEEF2", "tie_fg": "#3E4757",
+ "series": ["#3F5EFB", "#A9B7FD", "#8A93A3", "#C3C9D4"]},
+ "dark": {"surface": "#0D1117", "ink": "#F4F6FA", "ink2": "#C9CED8", "muted": "#8A93A6", "hair": "#2A2F3B",
+ "chip_win": "#3F5EFB", "tie_bg": "#262C36", "tie_fg": "#C9CED8",
+ "series": ["#5B7CFF", "#2E3D85", "#6B7385", "#3A3F4B"]},
+}
+FONT_FILES = {"regular": "Inter-Regular.ttf", "medium": "Inter-Medium.ttf", "semibold": "Inter-SemiBold.ttf",
+ "bold": "Inter-Bold.ttf", "display": "InterDisplay-SemiBold.ttf", "mono": "JetBrainsMono-Regular.ttf"}
+FALLBACK = {"regular": "normal", "medium": "medium", "semibold": "semibold", "bold": "bold", "display": "semibold",
+ "mono": "normal"}
+FORBIDDEN = [(re.compile("[—–]"), "dash"), (re.compile(r"/tmp|/Users|/private", re.I), "local path")]
+DPI = 72 # 1 pt = 1 px
+CAP = 0.727 # Inter's cap height, in em
+W, H, M, GAP = 1600, 900, 48, 40
+
+
+def draw(data, theme, fonts_dir, base):
+ import matplotlib
+ matplotlib.use("Agg")
+ matplotlib.rcParams["text.hinting"] = "no_hinting"
+ matplotlib.rcParams["svg.hashsalt"] = "graphicle-retrieval"
+ matplotlib.rcParams["svg.fonttype"] = "path"
+ import matplotlib.pyplot as plt
+ from matplotlib.font_manager import FontProperties
+ from matplotlib.patches import FancyBboxPatch, PathPatch, Rectangle
+ from matplotlib.path import Path
+
+ C = THEMES[theme]
+ ch = data["chart"]
+ m = summarise(data, ch["set"])
+ keys = ch["systems"]
+ colors = dict(zip(keys, C["series"]))
+ missing = [f for f in FONT_FILES.values() if not os.path.exists(os.path.join(fonts_dir or "", f))]
+ cache = {}
+
+ def fp(kind, size):
+ if (kind, size) not in cache:
+ path = os.path.join(fonts_dir or "", FONT_FILES[kind])
+ cache[(kind, size)] = (FontProperties(fname=path, size=size) if os.path.exists(path) else
+ FontProperties(family="DejaVu Sans Mono" if kind == "mono" else "DejaVu Sans",
+ weight=FALLBACK[kind], size=size))
+ return cache[(kind, size)]
+
+ fig = plt.figure(figsize=(W / DPI, H / DPI), dpi=DPI)
+ fig.patch.set_facecolor(C["surface"])
+ ax = fig.add_axes([0, 0, 1, 1])
+ ax.set_xlim(0, W)
+ ax.set_ylim(H, 0)
+ ax.axis("off")
+ rend = fig.canvas.get_renderer()
+ texts = []
+
+ def width(s, kind, size):
+ return rend.get_text_width_height_descent(s, fp(kind, size), ismath=False)[0]
+
+ def text(x, y, s, kind, size, color, ha="left"):
+ texts.append((ax.text(x, y, s, fontproperties=fp(kind, size), color=color, ha=ha, va="baseline", zorder=6), s))
+
+ def box(x, y, w, h, color, r=0, z=1):
+ p = (FancyBboxPatch((x, y), w, h, boxstyle=f"round,pad=0,rounding_size={r}", fc=color, ec="none", zorder=z)
+ if r else Rectangle((x, y), w, h, fc=color, ec="none", zorder=z))
+ ax.add_patch(p)
+
+ def bar(x, y_base, w, h, color, r=4):
+ """A column with a rounded data end and a square baseline end."""
+ r = max(0.0, min(r, w / 2, h))
+ yt = y_base - h
+ verts = [(x, y_base), (x, yt + r), (x, yt), (x + r, yt), (x + w - r, yt), (x + w, yt), (x + w, yt + r),
+ (x + w, y_base), (x, y_base)]
+ codes = [Path.MOVETO, Path.LINETO, Path.CURVE3, Path.CURVE3, Path.LINETO, Path.CURVE3, Path.CURVE3,
+ Path.LINETO, Path.CLOSEPOLY]
+ ax.add_patch(PathPatch(Path(verts, codes), fc=color, ec="none", zorder=3))
+
+ def chip(x, yb, s, win, size=18, h=30, pad=12):
+ bg, fg = (C["chip_win"], "#FFFFFF") if win else (C["tie_bg"], C["tie_fg"])
+ w = width(s, "semibold", size) + 2 * pad
+ top = yb - CAP * size - (h - CAP * size) / 2
+ box(x, top, w, h, bg, r=h / 2, z=4)
+ text(x + w / 2, yb, s, "semibold", size, fg, ha="center")
+ return w
+
+ def wrap(s, kind, size, max_w):
+ lines, cur = [], ""
+ for word in s.split():
+ trial = f"{cur} {word}".strip()
+ if cur and width(trial, kind, size) > max_w:
+ lines.append(cur)
+ cur = word
+ else:
+ cur = trial
+ return lines + ([cur] if cur else [])
+
+ # header: wordmark and tagline, legend on the same line, title and subtitle below
+ yb = 60
+ text(M, yb, "Graphicle", "bold", 28, C["ink"])
+ text(M + width("Graphicle", "bold", 28) + 16, yb, ch["tagline"], "regular", 20, C["muted"])
+ items = [(data["systems"][k]["legend"], colors[k]) for k in keys]
+ widths = [16 + 8 + width(n, "medium", 18) for n, _ in items]
+ x = W - M - (sum(widths) + 28 * (len(items) - 1))
+ for (name, color), w in zip(items, widths):
+ box(x, yb - 14, 16, 16, color, r=4, z=3)
+ text(x + 24, yb, name, "medium", 18, C["ink2"])
+ x += w + 28
+ yb += 52
+ text(M, yb, ch["title"], "display", 34, C["ink"])
+ yb += 34
+ for line in wrap(ch["subtitle"], "regular", 20, W - 2 * M):
+ text(M, yb, line, "regular", 20, C["muted"])
+ yb += 26
+ panels_top = yb + 8
+
+ # footer first, so the panels know where they end
+ flines = []
+ for para in ch["footer"]:
+ flines += wrap(para, "regular", 18, W - 2 * M)
+ url = ch["url"]
+ footer_top = H - 22 - 25 * (len(flines) + 1)
+ y = footer_top
+ for line in flines:
+ text(M, y + 18, line, "regular", 18, C["muted"])
+ y += 25
+ label = ch["url_label"] + " "
+ text(M, y + 18, label, "regular", 18, C["muted"])
+ text(M + width(label, "regular", 18), y + 18, url, "mono", 17, C["muted"])
+ box(M, footer_top - 14, W - 2 * M, 1, C["hair"], z=1)
+ panels_bottom = footer_top - 30
+
+ # four panels: hit@1, hit@5, hit@10 (issues of n) and MRR
+ panels = [{"metric": f"hit@{k}", "k": k, "title": ch["panels"][f"hit@{k}"]["title"],
+ "sub": ch["panels"][f"hit@{k}"]["sub"].format(n=m["n"]), "max": m["n"]} for k in KS]
+ panels.append({"metric": "mrr", "k": None, "title": ch["panels"]["mrr"]["title"], "sub": ch["panels"]["mrr"]["sub"],
+ "max": 1.0})
+ PW = (W - 2 * M - GAP * 3) / 4
+ a_key, b_key = data["compare"]
+ sub_lines = [wrap(p["sub"], "regular", 18, PW) for p in panels]
+ plot_top = panels_top + 30 + 24 * max(len(s) for s in sub_lines) + 54
+ notes_h = 2 * 30 + 24
+ base_y = panels_bottom - notes_h - 40
+ plot_h = base_y - plot_top
+ chip_problems = []
+ for i, p in enumerate(panels):
+ x0 = M + i * (PW + GAP)
+ text(x0, panels_top + 26, p["title"], "semibold", 26, C["ink"])
+ hb = panels_top + 26 + 30
+ for line in sub_lines[i]:
+ text(x0, hb, line, "regular", 18, C["muted"])
+ hb += 24
+ slot = PW / len(keys)
+ bw = min(56, slot * 0.6)
+ for j, key in enumerate(keys):
+ sm = m["systems"][key]
+ v = sm[p["metric"]]
+ cx = x0 + slot * (j + 0.5)
+ h = plot_h * (v / p["max"])
+ bar(cx - bw / 2, base_y, bw, h, colors[key])
+ shown = f"{v:.3f}" if p["metric"] == "mrr" else f"{v}"
+ emph = key == keys[0]
+ text(cx, base_y - h - 12, shown, "bold" if emph else "semibold", 28 if emph else 24,
+ C["ink"] if emph else C["ink2"], ha="center")
+ text(cx, base_y + 28, data["systems"][key]["short"], "medium", 20, C["ink2"], ha="center")
+ box(x0, base_y - 0.75, PW, 1.5, C["hair"], z=3.5)
+ ny = base_y + 28 + 44
+ if p["k"]:
+ t = m["mcnemar"][p["k"]]
+ diff = m["systems"][a_key][p["metric"]] - m["systems"][b_key][p["metric"]]
+ label = ch["compare_label"]
+ text(x0, ny, label, "regular", 18, C["muted"])
+ sign = "+" if diff > 0 else ""
+ s = f"{sign}{diff} issues, {p_text(t['p'])}" + ("" if t["p"] < 0.05 else ", not significant")
+ if chip(x0, ny + 38, s, t["p"] < 0.05) > PW:
+ chip_problems.append(f"chip wider than its panel: {s!r}")
+ else:
+ for line in wrap(ch["panels"]["mrr"]["note"], "regular", 18, PW):
+ text(x0, ny, line, "regular", 18, C["muted"])
+ ny += 24
+
+ # checks: no text outside the canvas, no overlaps, no forbidden strings
+ problems = ([f"fonts missing, DejaVu Sans used: {', '.join(missing)}"] if missing else []) + chip_problems
+ fig.canvas.draw()
+ boxes = []
+ for a, s in texts:
+ bb = a.get_window_extent(renderer=rend)
+ x0, x1, y0, y1 = bb.x0, bb.x1, H - bb.y1, H - bb.y0
+ if x0 < 8 or y0 < 8 or x1 > W - 8 or y1 > H - 8:
+ problems.append(f"outside the canvas: {s!r}")
+ for rx, why in FORBIDDEN:
+ if rx.search(s):
+ problems.append(f"{why}: {s!r}")
+ boxes.append((x0, y0, x1, y1, s))
+ for i in range(len(boxes)):
+ for j in range(i + 1, len(boxes)):
+ a, b = boxes[i], boxes[j]
+ if a[0] < b[2] - 1 and b[0] < a[2] - 1 and a[1] < b[3] - 1 and b[1] < a[3] - 1:
+ problems.append(f"overlap: {a[4]!r} / {b[4]!r}")
+ alt_short, alt_long = alt_text(data)
+ fig.savefig(base + ".png", dpi=DPI * 2, facecolor=C["surface"], metadata={"Title": alt_short, "Description": alt_long})
+ fig.savefig(base + ".svg", dpi=DPI, facecolor=C["surface"], metadata={"Date": None})
+ plt.close(fig)
+ svg = open(base + ".svg", encoding="utf-8").read()
+ svg = re.sub(r'width="[\d.]+pt" height="[\d.]+pt"', f'width="{W}" height="{H}"', svg, count=1)
+ i = svg.find(">", svg.find("<svg")) + 1
+ svg = svg[:i] + "\n <title>" + html.escape(alt_short) + "</title>\n <desc>" + html.escape(alt_long) + "</desc>" + svg[i:]
+ with open(base + ".svg", "w", encoding="utf-8") as f:
+ f.write(svg)
+ return problems, alt_short, alt_long
+
+
+def main():
+ ap = argparse.ArgumentParser(description=__doc__.splitlines()[0])
+ ap.add_argument("--data", required=True)
+ ap.add_argument("--out")
+ ap.add_argument("--fonts")
+ ap.add_argument("--tables", action="store_true")
+ a = ap.parse_args()
+ data = json.load(open(a.data, encoding="utf-8"))
+ if a.tables:
+ print(tables(data))
+ return
+ if not a.out:
+ sys.exit("--out or --tables")
+ os.makedirs(a.out, exist_ok=True)
+ bad = []
+ for theme in ("light", "dark"):
+ base = os.path.join(a.out, f"retrieval-{theme}")
+ problems, alt_short, _ = draw(data, theme, a.fonts, base)
+ bad += [f"{theme}: {p}" for p in problems]
+ print(f"{base}.svg and .png")
+ print("alt:", alt_short)
+ if bad:
+ print("\n".join(bad))
+ sys.exit(1)
+
+
+if __name__ == "__main__":
+ main()
diff --git a/docs/configuration.md b/docs/configuration.md
index c248056..a486afe 100644
--- a/docs/configuration.md
+++ b/docs/configuration.md
@@ -24,11 +24,17 @@ how retrieval ranks and packs evidence.
| `server.json` | While `graphicle serve` (or `open`) runs: its port and a secret, so that `graphicle open` signs in only to this folder's server. It is readable by you only |
| `version.json` | The newest Graphicle version that used the folder |
| `gf-cache/` | Graph caches, which are rebuilt when needed |
+| `backups/` | The backups `graphicle backup` writes when you give it no path; `graphicle offboard` removes a project from them |
`graphicle sync` creates the local workspace the first time it runs, so you do
not need `graphicle init`.
-To back up while the app is running, run `graphicle backup /safe/place/graphicle.sqlite3`.
+To back up while the app is running, run `graphicle backup /safe/place/graphicle.sqlite3`,
+or `graphicle backup` to write it to the data folder's `backups/` folder (a
+backup there goes with the data folder, so keep a copy elsewhere too).
+`graphicle offboard --project PROJECT` removes one project from the store and
+from the backups in `backups/`, with a hash-chained receipt; without
+`--apply PLAN_HASH` it only shows its plan.
`graphicle --data-dir NEW_FOLDER restore /safe/place/graphicle.sqlite3`
restores into a new folder and never overwrites existing data. A backup leaves
out provider secrets and the vault key, so reconnect providers after a restore.
@@ -171,6 +177,189 @@ applied. Over MCP, the essentials set (what setup gives Claude Code) uses
this default; `--tools all`, `graph` and `memory` answer `recall_project` in
0.1.0's order.
+A code question ranks the project's source files first (`code_first`,
+`"auto"` by default). A question is a code question when it names code (a
+backtick span, a `snake_case` or `camelCase` name with two lowercase letters
+before its capital, `Type::member`, `call()` or a code file) or reads like an issue or bug report (a code block, a stack
+trace or error line, or two words such as crash, error, fails, expected or
+regression). Its documentation files (Markdown, reStructuredText, AsciiDoc,
+plain text, `README`, `CHANGELOG`, `LICENSE`, files under `doc/`), test
+files and vendored or generated code (`vendor/`, `third_party/`,
+`node_modules/`, `x.min.js`, `x.pb.go`, lock files) count a quarter of
+their fused score in the ranking, before the excerpts are chosen and the
+budget is spent, and the code-graph arm leaves Markdown nodes out. A test
+file is one under a `test`, `tests`, `testing`, `__tests__`, `spec`,
+`testdata` or `fixtures` folder, a `Foo.Tests` or `FooTests` project, or one
+named like a test in Rust (`tests.rs`, `x_test.rs`), Python (`test_x.py`,
+`x_test.py`, `conftest.py`), Go (`x_test.go`), Java, Kotlin and Scala
+(`FooTest.java`, `FooIT.java`, `TestFoo.java`), C# (`FooTests.cs`),
+JavaScript and TypeScript (`x.test.ts`, `x.spec.js`), C and C++
+(`test_x.c`, `x_test.cc`, `x_unittest.cpp`) or Ruby (`x_spec.rb`). These
+keep the order they had:
+
+- a question about documents, notes or decisions (it names a
+ documentation file or uses words such as documentation, docs, readme,
+ notes or decided) that does not read like a report;
+- test files, when a question that does not read like a report names a
+ test, or the call sets `include_tests: true`;
+- a test or document that defines a code name the question names (one
+ with an underscore or an inner capital, as the identifier arm finds it in
+ the code graph) when no source file defines that name, such as a test
+ helper or a fixture.
+
+`code_first: false` keeps that order for every question, and `true` ranks
+source files first for every question. The packet's `code_first` says what
+applied, why, and how many files of each kind it lowered.
+
+A code question is searched by its content, not its instructions
+(`query_focus`, `"auto"` by default; `true` for every question, `false`
+for none). When it marks its content, the query is the marked text, every
+word kept, followed by the names of code in its prose outside the marks
+(backtick spans, identifiers and file paths, leaving out fenced examples and
+placeholders such as `ClassName.method_name` or `path/to/file.py`). A mark
+is a tag of its own (`<issue>` ... `</issue>`, `<pr_description>` ...),
+opening at the start of a line, with text after it or not, and closing
+anywhere after it (HTML elements such as `<details>` do not count), or a pair
+of delimiter lines (`--- BEGIN ISSUE ---` ... `--- END ISSUE ---`, drawn with
+`-`, `=`, `#`, `*` or `~`). The marks are ignored when the text outside them
+is longer than 2,000 characters and they hold less than 40% of the question.
+A question without marks leaves out the general words of instructions, such
+as find, locate, fix, resolve, change, edit, create, delete, implement,
+list, explain, task, issue, problem, question, file, function, method, class
+and please. Either way web addresses are left out, except a code host's link
+to a file (`https://github.com/o/r/blob/<ref>/src/x.rs#L10`, GitLab's
+`/-/blob/`), which becomes the file's path, and so are commit hashes.
+Identifiers, calls, quoted words and paths always stay. BM25, the code-graph
+arm, the files read past the passage bound, a local reranker and the
+excerpts' focus read the query; the packet's `question` is the question, and
+its `query_focus` says what was marked and left out.
+
+The identifiers and file paths a code question names rank their files
+(`identifier_arm`, `"auto"` by default; `true` for any question, `false`
+for none). Its names are every identifier of three or more characters in
+a code block or span that is not a common English word or keyword, and in
+prose the `snake_case`, `SCREAMING_CASE`, camelCase and PascalCase words
+with a capital inside, calls (`name(`) and qualified names (`a.b`, `a::b`,
+`a->b`, `a#b`), whole and by their parts written as code; its paths are the
+file names and paths with a known extension. Each name is matched as a
+whole word, case-sensitively, in the project's passages, and found at its
+definitions in the code graph (unless `graph_retrieval: false`). A file
+scores, for each of the 40 most specific names it holds,
+`ln(1 + files / files holding the name)`, twice that where it defines the
+name, plus twice the weight of a name only it holds when the question names
+its path. Files come in score order, each with its two best passages, as
+the arm `identifiers` of the fusion (weight 1; `arm_weights` sets another).
+The packet's `identifier_arm` lists the names and paths used and how many
+files ranked. With the identifier route on, a question that asks more than
+where its names are keeps the retrieval as before, and its `route` now
+says `names_fused` when the arm ranked them.
+
+`graphicle context` prints at most 8,400 characters by default, so a prompt
+hook that adds the packet under a header stays below the 10,000 characters
+Claude Code shows in full. `--max-chars` sets another size; with only
+`--max-tokens`, the packet holds 4 characters per token, as before.
+
+After its excerpts, a packet lists the paths of the files that rank next and
+that no excerpt quotes, one per line under "Next ranked files"
+(`more_files`: 0 to 40; left out, 10 for a code question and 0 for any
+other). Their room is kept from the excerpts' share of the budget, at most
+an eighth of it, so the packet still fits `max_chars` and `max_tokens`. The
+packet's `more_files` lists the paths.
+
+`code_first`, `query_focus`, `identifier_arm` (each `"auto"`, `true` or
+`false`) and `more_files` (0 to 40) are also flags of `graphicle context`
+(`--code-first false`, `--query-focus true`, `--identifier-arm auto`,
+`--more-files 0`) and switches of `recall_project` over MCP, beside its
+published arguments; `graphicle mcp --set code_first=false` (or
+`more_files=0`, `query_focus=auto`) fixes one for a server, and every packet
+echoes them in `mechanisms.switches`.
+
+A question over 16,000 bytes is shortened, not refused: to the text it
+marks with its own tags when that fits, else to its beginning, cut at a line
+end, followed by the identifiers and file paths of the text cut (at most
+3,000 bytes of them). The packet's `question_shortened` says so:
+`{"bytes": ..., "tagged_content": ..., "kept_bytes": ..., "names_appended":
+...}`.
+
+`notes_first: true` turns on three changes for a call, which are off by
+default (`graphicle context --notes-first`; over MCP, `recall_project` takes
+it beside its published arguments, and `graphicle mcp --set
+notes_first=true` turns it on for a server):
+
+- A question that names no code (no backtick span, `snake_case` or
+ `camelCase` name, `Type::member`, `call()` or code file) takes the first 50
+ files of the fused ranking, one passage each. Code files keep their
+ places; the notes (Markdown, text, PDF and other documents) among them are
+ ordered again among the notes' places: a note whose name or folder matches
+ the question's words, whose headings match, or that has a newer date (the
+ latest ISO date, up to today, in its path or text) comes before the other
+ notes. A question that names code keeps the code ranking.
+- A packet quotes one window of a file, and one of files with identical
+ bytes; the places freed go to the next files. `include_tests: true`, which
+ `--tools all`, `graph` and `memory` send for `recall_project`, keeps 0.1.0's
+ windows as ranked whatever `notes_first` says, and so does an explicit
+ `origin_quota` (`false`: at most two windows per file).
+- Each excerpt of a project file says when its file last changed, in its
+ citation: `Source [repository_file]: notes/node.md:75 (changed 2026-10-15
+ 05:10 UTC)`. The date is that of the last commit that changed the file
+ when Git tracks it and the working tree has not changed it, otherwise the
+ file's modification time, read in the folder the project was last synced
+ from. A note may follow the citation: `Note: may be stale: <file> (defines
+ <name>) changed <date>`, when the excerpt names code (a document link, as
+ `doc_links` records it, written as code: with `_`, `::`, `.`, `/` or `(`,
+ or a capital inside it) whose file changed after the excerpt's file last
+ did. The date is the file's; the change may not touch the named
+ definition. Excerpts are not compared with one another, and the dates do
+ not change their order. `source_age: true` or `false` turns the dates on
+ or off by themselves; `--tools all`, `graph` and `memory` answer
+ `recall_project` without them.
+
+The packet's `notes_first` says what applied (`off` when the call did not
+turn it on), and `source_age` what was dated and marked; each dated source
+carries `changed`, `changed_at` and `changed_basis` (`git` or `mtime`).
+
+`identifier_route` answers a question that is an identifier, or names
+identifiers and only asks where they are defined or used, from the code
+graph instead of the full retrieval: each name's definitions and the places
+that refer to it, as `path:line` lines within the call's budget, and one
+line with the titles of the reviewed memories linked to those definitions
+(none when the call sets `memory_retrieval: false`). The packet has no
+excerpts: its `evidence` and `sources` are empty. `graphicle context` and,
+over MCP, `recall_project` in the essentials set (what setup gives Claude
+Code) take the route unless told otherwise; the HTTP API, `graphicle call
+context` and the SDKs take it only when a call sets `identifier_route:
+true`, and so do `--tools all`, `graph` and `memory`.
+
+A name is a backtick span that reads as an identifier, a `snake_case` or
+`SCREAMING_CASE` word, a camelCase or PascalCase word with a capital inside
+it (`parseConfig`, `ParseConfig`), a dotted or `::` path (`os.path.join`,
+`Store::open`), or a call `name()`. A name alone takes the route. Other
+words may only ask where the names are or what uses them, and one of them
+must: `where is Store::open defined`, `who calls parse_config()`,
+`references to ParseConfig`, `find the callers of run()`. These keep the
+full retrieval:
+
+- a question in plain words, a single plain word (`parser`) included;
+- a question that asks for more than where a name is or what uses it, such
+ as its content, its members, what it calls or where it is mentioned (`how
+ does parse_config() handle a missing file?`, `what is MAX_NAMES?`, `list
+ the fields of RecallArgs`, `callees of parse_config`), whose excerpts rank
+ the named code already;
+- a call with `needs` or `graph_retrieval: false`, a project without a code
+ graph, and a question none of whose names the code graph defines in the
+ files the call may read (`include`).
+
+`graphicle context --no-identifier-route` keeps the retrieval for one call;
+over MCP, `recall_project` takes `identifier_route` beside its published
+arguments, and `graphicle mcp --set identifier_route=false` (or `true`)
+fixes it for a server. The packet's `route` says which path ran:
+`{"path": "identifier", "names": [...], "not_found": [...]}` with each
+name's definitions and references under `symbols` and the linked memories
+under `linked_memories`, or `{"path": "retrieval", "reason": ...}`, the
+reason being `plain_words`, `asks_more`, `not_in_code_graph`,
+`no_code_graph`, `needs`, `graph_retrieval_off`, `too_many_names`, `off` or,
+for a workspace recall, which keeps the retrieval, `workspace`.
+
Each packet lists the defaults it applied in `retrieval_defaults`. To change an
option for one call, send the request through `graphicle call`. Setting an
option to `false` turns it off:
@@ -199,6 +388,14 @@ Other options include the following:
lists them. `graphicle mcp --set doc_links=true` turns it on for every
`recall_project` call of that server ([MCP](mcp.md)). `doc_links: false`
also keeps documents out of the code-graph part of the ranking.
+- `symbol_links: true` follows the links between reviewed memory and the code
+ symbols it is anchored to, one step: an excerpt of code brings in the
+ current reviewed memories linked to a symbol inside it, and a reviewed
+ memory brings in the current code of the symbols it is linked to. It is off
+ by default: each packet counts the links it did not follow in
+ `symbol_links`. `graphicle mcp --set symbol_links=true` turns it on for
+ every `recall_project` call of that server. `symbol_links: false` reads no
+ such link.
These need a build with the `local-inference` feature:
@@ -317,7 +514,16 @@ document.
most 5,000 manifest entries and 64 MiB of text) is internal and is never a
project limit.
-`graphicle sync` respects `.gitignore` and `.git/info/exclude`. It skips
+`graphicle sync` respects `.gitignore`, `.git/info/exclude` and `.ignore`
+files. The first two cover the files Git does not track: a file Git tracks is
+read even when one of them matches it, since Git versions it with the rest (a
+repository that ignores its build output `app.js` and tracks `src/app.js`),
+and the sync's output counts those files (`tracked_ignored`). A file an
+`.ignore` file leaves out stays out, tracked or not. `graphicle config set
+sync.tracked_ignored false` (`"sync": {"tracked_ignored": false}` in
+`models.json`) leaves tracked files that a pattern matches out too, and the
+environment variable `GRAPHICLE_SYNC_TRACKED_IGNORED` (`0` or `1`) overrides
+the setting. It skips
`.git`, `node_modules`, `target`, build output, `.env` files, keys and
credential files, symbolic links and binary files other than documents. It
reads PDF, DOCX, PPTX, XLSX, ODF and EPUB documents, HTML and UTF-8 text. It
@@ -326,8 +532,10 @@ Code's personal `.claude/settings.local.json`, a `.mcp.json` or
`.vscode/mcp.json` holding only Graphicle's entries, and the Graphicle section
of `AGENTS.md` and `CLAUDE.md`, which reads as blank lines. The output of
`sync` counts what it excluded. To make a project smaller, set up a subfolder
-(`graphicle setup path/to/subfolder`), or leave paths out in `.gitignore` or,
-for your machine only, in `.git/info/exclude`.
+(`graphicle setup path/to/subfolder`), or leave untracked paths out in
+`.gitignore` or, for your machine only, in `.git/info/exclude` (with
+`sync.tracked_ignored` set to `false`, tracked paths too), or any path in an
+`.ignore` file.
The code graph has no such limits.
diff --git a/docs/faq.md b/docs/faq.md
index 082b267..882fe45 100644
--- a/docs/faq.md
+++ b/docs/faq.md
@@ -113,14 +113,29 @@ Only as drafts for a person to review.
- **Work state.** `--work-state` gives the agent its own to-do lists. Recall
never uses them as memory.
+## Can I reuse reviewed memory in another project?
+
+Yes, as drafts that a person reviews there. `graphicle call memory.template`
+exports the current project's reviewed procedures and decisions with only
+their kind, title and body: the project's names, the files, symbols and
+quotes they cite, URLs, e-mail addresses, credentials and the `terms` you
+list become placeholders such as `[quote]`. Other words stay, so read a
+template before you share it. `graphicle call memory.import_pack --project
+OTHER --arguments pack.json`, with `{"memories": [...]}` from a template or
+from `memory.export`, imports the reviewed ones as drafts: symbol links are
+matched to that project's code, and quotes are kept only where its own
+sources hold them
+([details](../crates/graphicle/README.md#memory-anchored-to-code-symbols)).
+
## My repository is large. Will sync handle it?
Yes. `graphicle sync` takes up to 100,000 text files and 1 GiB of text per
project, and you can raise both: set `limits.project_files` and
`limits.project_bytes` in `models.json`, or `GRAPHICLE_MAX_PROJECT_FILES` and
`GRAPHICLE_MAX_PROJECT_BYTES`. A larger folder stops with a message that names
-the count, the limit and the setting. You can also extend `.gitignore` or sync
-a subfolder.
+the count, the limit and the setting. You can also extend `.gitignore` (for
+files Git does not track; `graphicle config set sync.tracked_ignored false`
+applies it to tracked files too) or sync a subfolder.
One large or unusual file never stops a sync. A file over 4 MiB, or with more
than 50,000 calls or 2,000,000 syntax nodes, is analysed as far as the limit
@@ -148,6 +163,17 @@ project.
project and returns a hash-chained receipt. The file holds
`{"expected_snapshot": "…"}`, the `repository.snapshot` that
`graphicle status` prints. Backups you made are separate.
+- `graphicle offboard --project PROJECT` removes one project's data from the
+ data folder, with its graph cache and its copies in the backups in the data
+ folder's `backups/` folder, and returns a hash-chained receipt that lists
+ what it removed. Other projects stay, in those backups too. Without
+ `--apply PLAN_HASH` it only shows the plan. Run `graphicle disconnect` in
+ the project's folders first. Backups written elsewhere and the project's
+ `.graphicle/` folder are outside the data folder: delete them yourself.
+ Memories that `memory.import_pack` copied into other projects belong to
+ those projects and stay. A path it refuses (a link, or a backup with
+ another name) is never changed and may still hold the project, so the
+ offboarding then reports that it is not fully verified.
- The app retires memories and deletes connectors.
- To remove everything, delete the data folder ([install.md](install.md#uninstall)).
diff --git a/docs/install.md b/docs/install.md
index 6bb8f0e..b82490f 100644
--- a/docs/install.md
+++ b/docs/install.md
@@ -16,7 +16,7 @@ step.
```sh
brew install graphicle-ai/tap/graphicle
-graphicle --version # graphicle 0.1.2 (core)
+graphicle --version # graphicle 0.1.3 (core)
```
`brew upgrade graphicle` installs a new release. Afterwards, read
@@ -86,6 +86,10 @@ Notes for the preview:
- For the local server, use `127.0.0.1` rather than `localhost`: the server
listens on `127.0.0.1`, and Windows tries `localhost`'s IPv6 address first,
which adds about two seconds to each request.
+- `graphicle offboard` removes a project from the store and its graph cache
+ but leaves the backups in the data folder's `backups/` folder as they are,
+ and lists them as refused: Windows does not tell Graphicle whether a backup
+ file has another name (a hard link) outside the data folder.
- Not on Windows: `graphicle-graph serve --socket` and
`GRAPHICLE_REBUILD_MEMORY_LIMIT_MB`, which need Unix; OCR of scanned PDFs and
images and the legacy document formats, which use a macOS helper; the
@@ -145,7 +149,7 @@ folder with both programs, `LICENSE`, `NOTICE`, `NOTICE.md`, `README.md`,
| Windows, x86-64 (preview) | `x86_64-pc-windows-msvc`, a `.zip` |
```sh
-version=0.1.2
+version=0.1.3
target=aarch64-apple-darwin
base=https://github.com/graphicle-ai/graphicle/releases/download/v$version
curl -fLO "$base/graphicle-$version-$target.tar.gz"
@@ -239,7 +243,7 @@ in them.
## Check the installation
```sh
-graphicle --version # graphicle 0.1.2 (core)
+graphicle --version # graphicle 0.1.3 (core)
graphicle graph --help # the code-graph engine's commands
graphicle doctor # checks the programs, the data folder and your agents
```
diff --git a/docs/mcp.md b/docs/mcp.md
index ba98517..67759ec 100644
--- a/docs/mcp.md
+++ b/docs/mcp.md
@@ -63,7 +63,8 @@ these options:
the new one. Without it, `connect` stops and leaves the entry alone.
- `--hooks` (claude-code and codex only) adds session capture. After each
answer, a background process stores the session's completed turns as sources
- of the project. At the start of each session, the client receives the titles
+ of the project. At the start of each session, the client receives one line
+ on when to use Graphicle's tools and when grep is enough, then the titles
of your reviewed memories and the latest turns (at most 8,000 characters,
never drafts). The hooks never block the client. Claude Code's hooks go into
`.claude/settings.local.json` in the current folder, and Codex's into
@@ -135,25 +136,38 @@ Any client that starts an MCP server over stdio can use the Graphicle server:
- `--allow-learning` adds the tools that propose memory, and `--work-state`
adds the work-state tools.
- `--tools essentials` serves five tools: `query_graph`, `get_node`,
- `get_neighbors`, `recall_project` and `read_project_source`, with one
- sentence of instructions on when to call them. Their descriptions start
- with what an agent looks for and say how answers cite code (file, lines
- and `stable_id`). `--allow-learning`, `--work-state` and
+ `get_neighbors`, `recall_project` and `read_project_source`, with short
+ instructions on when to call them and when grep is enough. Their
+ descriptions start with what an agent looks for and say how answers cite
+ code (file, lines and `stable_id`). `--allow-learning`, `--work-state` and
`--pull-requests` add `propose_memory`, the work-state tools and the
pull-request tools. This is what setup gives Claude Code, which shows the
agent every tool's name and the instructions in each request.
- `--tools graph` serves every tool that reads the code graph: the graph
tools and resources and the graph-history tools (`graph_episodes`,
- `graph_as_of`, `graph_history_stats`, `graph_link`). `--tools memory`
+ `graph_as_of`, `graph_history_stats`, `graph_link`), and on a workspace
+ connection `workspace_map`. `--tools memory`
serves the other tools. The default, `--tools all`, serves both. Two servers over one store,
one of each, compare the integrated server with separate tools; the memory
server's `recall_project` still reads the code graph unless it also has
`--set graph_retrieval=false`.
- `--set graph_retrieval=false` (or `memory_retrieval=false`, or
- `doc_links=true` or `false`) fixes a switch of `recall_project` for the
- whole session (below); `--set doc_links=true` makes every recall follow
- documents' links to code. Repeat `--set` for several; a switch given twice
- is refused.
+ `doc_links`, `symbol_links`, `cross_repo`, `notes_first` or
+ `identifier_route`, `true` or `false`, or `scope=project` or
+ `scope=workspace`) fixes a switch of
+ `recall_project` for the whole session (below); `--set doc_links=true`
+ makes every recall follow documents' links to code, and
+ `--set symbol_links=true` reviewed memory's links to code symbols. Repeat
+ `--set` for several; a switch given twice, or one the server does not
+ know, is refused. `--set scope=project` serves one project, so it is
+ refused with `--workspace`, and `--set scope=workspace` needs
+ `--workspace`.
+- `--manifest` prints the server's manifest as JSON and exits: the
+ program's version, edition and sha256, the tools and instructions it
+ would serve with their sha256, the switches it fixes and those a call may
+ set, the retrieval defaults, and the versions of the store's schema and
+ of its export and receipt formats. Run it with the same options as the
+ server to record exactly what a run used.
- `--pull-requests` adds the graph's pull-request tools, `list_prs`,
`get_pr_impact` and `triage_prs`. They run the GitHub CLI and `git`,
read-only, in the folder the server starts in, which must be the project's
@@ -175,6 +189,9 @@ folder, as the stdio server does
tools, and `serve --mcp-tools` and `serve --mcp-set` work as `--tools` and
`--set` do. The pull-request tools are not served over HTTP, and a tool's
`repo` names another project by its id or key there, never by a folder.
+The answer to `initialize` carries an `Mcp-Session-Id` header: a client that
+sends it back with its later requests has them counted as one agent session
+in the usage report, and a client that does not is served as before.
### Several projects in one connection
@@ -182,10 +199,13 @@ A workspace can hold several projects, for example a library and the
application that imports it. A connection to one project (`graphicle mcp`, or
`/mcp/WORKSPACE_ID/PROJECT_ID`) keeps recall, source reads and memory on that
project: its `recall_project` and `read_project_source` take no `repo`, and it
-has no `list_projects`. Its graph tools and graph-history tools
-(`query_graph`, `get_node`, `get_neighbors`, `shortest_path`, `graph_as_of`
-and the others) do take `repo`: they read the code graph of another project
-the access key can read, and over stdio `repo` can also name a synced folder.
+has no `list_projects` or `workspace_map`. Its graph tools and graph-history
+tools (`query_graph`, `get_node`, `get_neighbors`, `shortest_path`,
+`graph_as_of` and the others) do take `repo`: they read the code graph of
+another project the access key can read, and over stdio `repo` can also name
+a synced folder. Memory and documents stay on the connection's project there
+too: `get_node` lists the reviewed memories linked to a symbol only for this
+project's own code graph, and only this project's documents that name it.
`graphicle mcp` runs with the key saved in your data folder, normally the
owner's, which can read every project of the store.
@@ -213,6 +233,8 @@ A workspace connection has no project of its own:
- `list_projects` lists the projects your key can read, with their ids, 100
at a time (`offset` and `limit` page through them).
+- `workspace_map` maps those projects ([The workspace
+ map](#the-workspace-map)).
- `recall_project` searches every project you can read (at most 8, in the
order they were created) unless `repo` names one: a project id or key, or
with `graphicle mcp --workspace` a synced folder. A search over several
@@ -256,13 +278,46 @@ into it or out of it is followed, and it is not counted. Projects that
starting with the current folder's project. Answers (`graphicle ask`, the
`basic` and `reflect` jobs) still read one project.
+#### The workspace map
+
+`workspace_map` (the `graph.map` operation over HTTP, the SDK and
+`graphicle call`) shows the projects your key can read, 8 at a time
+(`offset` and `limit`, up to 32, page through them; a page reads its
+projects' documents, as a workspace recall does), in the order they were
+created:
+
+- `projects`: each project's id, name and times; `graph`, the file set its
+ code symbols were built from and whether that is the current one; and
+ `counts`:
+ - `files`, `documents` (connector documents your key can read now),
+ `symbols` (code symbols in its code graph) and `memories` (as
+ `project_memory` lists them);
+ - `links`: `imports_out` and `imports_in` (recorded imports from and into
+ the other projects on the map), `document_mentions` (mentions in its
+ documents linked to code, as the `graph.doc_links` operation counts them)
+ and `memory_symbols` (code symbols its memories are anchored to).
+- `imports`: one entry for each pair of projects where a project on this
+ page imports from another project on the map, with the number of recorded
+ imports and the modules imported (the first 20, and `modules_total`).
+ Paging through the map lists each pair once; `import_edges` counts every
+ import between the projects on the map.
+
+Each project is counted exactly as your key's own reads of that project
+would count it, and a project your key may not read is not on the map: no
+entry, no import into it or out of it, and no count that includes it.
+Projects that `graphicle pr` keeps for pull requests are left out unless
+`include_scratch` is true. A project whose counts cannot be read is listed
+with `status: "error"` and its message. The map is read-only, and the imports
+are the ones `graphicle sync` or `graph_link` last recorded.
+
### Tools
| Tool | What it does |
|---|---|
-| `recall_project` | Finds original source evidence and current reviewed memory for a question, within a token budget |
+| `recall_project` | Finds original source evidence and current reviewed memory for a question, within a token budget; an identifier, or a question that only asks where one is defined or used, gets its definitions and references from the code graph |
| `read_project_source` | Reads a source by ID or path, continuing exactly where an excerpt stopped |
| `list_projects` | Lists the workspace's projects you can read, with the ids `repo` takes (workspace connections only) |
+| `workspace_map` | Maps the projects you can read: their counts of files, documents, code symbols, memories and links, and the imports between them (workspace connections only) |
| `repository_status` | Shows source coverage, revisions and memory state |
| `repository_files` | Lists source paths and IDs |
| `project_memory` | Lists memories and drafts with their review state and freshness |
@@ -271,7 +326,7 @@ starting with the current folder's project. Answers (`graphicle ask`, the
| `prepare_memory_refresh` | Prepares current evidence for updating a memory |
| `workflow_status` | Shows queued jobs and their model usage |
| `graph_episodes`, `graph_as_of`, `graph_history_stats` | Read the project's recorded code-graph history and its storage |
-| `graph_link` | Links imports across the workspace's repositories, then recomputes the links from documents to the code they name |
+| `graph_link` | Links imports across the workspace's repositories, then recomputes the links from documents to the code they name. Only the projects that changed, or that import from a project whose exports changed, are linked again (`relinked`); the others keep their links (`reused`) |
| `prepare_observations` | Prepares source excerpts so the agent's own model can propose facts |
| `session_timeline` | Browses captured Claude Code and Codex turns |
| `query_graph` | Searches the code graph breadth-first or depth-first around a question and returns the relevant nodes and edges |
@@ -282,6 +337,13 @@ starting with the current folder's project. Answers (`graphicle ask`, the
| `graph_stats` | Returns node, edge and community counts and the confidence breakdown |
| `shortest_path` | Finds the shortest path between two nodes |
+The server's instructions say when to call `recall_project` and
+`query_graph` (where or how something works, questions across files or
+history, before changing unfamiliar code) and that grep is enough for an
+exact identifier the agent already knows. The descriptions of
+`recall_project`, `query_graph`, `get_node`, `get_neighbors` and
+`shortest_path` end with when to use each instead of grep.
+
The graph tools answer with the same text as the graph-only server, read on
the project's recorded code graph. They take two more arguments: `repo` reads
another project of the workspace (its id or key, or with `graphicle mcp` a
@@ -295,7 +357,13 @@ range, and, when the file's current bytes are the ones the graph recorded,
its checked `file:` byte range and the file's sha256: the same `stable_id`
and window that `recall_project` cites for that symbol, which
`read_project_source` reads. A node whose file changed since is listed with
-`checked: false`.
+`checked: false`. The node of a `get_node` answer also lists, under
+`linked`, the current reviewed memories anchored to that symbol (`memories`:
+id, kind, title and how the link was made) and the documents you may read
+that name it (`documents`); a stale, draft or retired memory is never listed.
+Its citations block names them too. On a connection to one project, they are
+that project's only ([Several projects in one
+connection](#several-projects-in-one-connection)).
While a newer sync waits for its graph, the graph tools read the previous one
and say so (`episode_lag`); a node the answer reaches only through relations
read from changed files is listed with `relation_checked: false`, because
@@ -365,16 +433,42 @@ the links of the excerpts it returns (the packet's `doc_links`, status
connector documents: an excerpt of a document brings in the definitions it
names, and an excerpt of code brings in the passages that name its
definitions. `false` reads no link and keeps documents and their links to
-code out of the code graph and the property graph. The packet's `mechanisms`
-report all three. On a workspace connection a harness can likewise pass
-`scope`, `project` or `workspace`, to search one project or all of them; a
-project connection takes `project` only.
+code out of the code graph and the property graph. `symbol_links`, also
+unlisted, is about reviewed memory's links to the code symbols it is anchored
+to. Left out, recall counts the links it would follow (the packet's
+`symbol_links`, status `counted`) and follows none. `true` follows them one
+step: an excerpt of code brings in the current reviewed memories linked to a
+symbol inside it (marked `via: link`, with the link under `link`), and a
+reviewed memory brings in the current code of the symbols it is linked to.
+`false` reads no such link. `cross_repo`, also unlisted, is about the step
+of a workspace recall that follows imports between projects: `false` turns
+that step alone off, and `true` turns it on even with
+`graph_retrieval: false`; left out, it follows `graph_retrieval`.
+`notes_first: true`, also unlisted and off by default, orders notes and
+documents first for a question in prose, quotes one window per file and
+dates each excerpt ([Configuration](configuration.md#retrieval)); `--tools
+all`, `graph` and `memory` keep 0.1.0's packet whatever it says.
+`identifier_route`, also unlisted and on in the essentials set, answers an
+identifier, or a question that only asks where named identifiers are
+defined or used, with their definitions and references from the code graph
+as `path:line` lines ([Configuration](configuration.md#retrieval)); `false`
+keeps the full retrieval, and `--tools all`, `graph` and `memory` take the
+route only when a call asks for it. The packet's `route` says which path
+ran. On a
+workspace connection a harness can likewise pass `scope`, `project` or
+`workspace`, to search one project or all of them; a project connection takes
+`project` only. Every packet's `mechanisms` echoes the values in force under
+`switches` (`doc_links` and `symbol_links` read `counted` when left out), and
+a switch that is not `true` or `false`, or a field the tool does not list, is
+refused.
`recall_project`'s switches can also be fixed for a whole server:
-`graphicle mcp --set graph_retrieval=false` (or `memory_retrieval`, or
-`doc_links`; `serve --mcp-set …` over HTTP) applies the value to every call,
-refuses a call that asks for the other value, and reports the fixed switches
-in the packet's `mechanisms` under `server_fixed`. For example,
+`graphicle mcp --set graph_retrieval=false` (or `memory_retrieval`,
+`doc_links`, `symbol_links`, `cross_repo`, `notes_first`,
+`identifier_route` or `scope`;
+`serve --mcp-set …` over HTTP) applies the value to every call, refuses a
+call that asks for the other value, and reports the fixed switches in the
+packet's `mechanisms` under `server_fixed`. For example,
`graphicle mcp --set doc_links=true` follows documents' links to code in
every recall of that server.
diff --git a/docs/quickstart.md b/docs/quickstart.md
index 10fe821..917aa48 100644
--- a/docs/quickstart.md
+++ b/docs/quickstart.md
@@ -85,6 +85,7 @@ undo it.
| `--no-hooks` | Add no Git hooks |
| `--tools all` | Give Claude Code every tool of the server, not five (`essentials`, the default for Claude Code) |
| `--guards` | Add hooks that point Claude Code's searches and source reads to the graph tools (off by default) |
+| `--prompt-context` | Add a hook that gives Claude Code `graphicle context`'s packet before each prompt that is a code question (off by default) |
| `--switch-from-graphify` | Switch from Graphify without asking |
| `--json` | Print the result as JSON, for scripts |
diff --git a/docs/troubleshooting.md b/docs/troubleshooting.md
index d07c795..39ee801 100644
--- a/docs/troubleshooting.md
+++ b/docs/troubleshooting.md
@@ -64,7 +64,9 @@ To fit:
is), or the `GRAPHICLE_MAX_PROJECT_FILES` or `GRAPHICLE_MAX_PROJECT_BYTES`
environment variable. [Limits](configuration.md#limits) lists every limit.
- Or leave out folders you do not need. Add them to `.gitignore`, or to
- `.git/info/exclude` to keep the change to your machine.
+ `.git/info/exclude` to keep the change to your machine. A file Git tracks
+ is read whatever these say, unless `graphicle config set
+ sync.tracked_ignored false`; an `.ignore` file leaves out tracked files too.
- Or set up a part of the repository: `cd services/api && graphicle setup`.
Graphicle already skips `.git`, `node_modules`, `target`, `dist`, `build`,
diff --git a/licenses/graphicle-graph/licenses/THIRD_PARTY_LICENSES.html b/licenses/graphicle-graph/licenses/THIRD_PARTY_LICENSES.html
index 05f50a4..0c95565 100644
--- a/licenses/graphicle-graph/licenses/THIRD_PARTY_LICENSES.html
+++ b/licenses/graphicle-graph/licenses/THIRD_PARTY_LICENSES.html
@@ -11193,7 +11193,7 @@ express Statement of Purpose.
</pre>
<h3 id="CDLA-Permissive-2.0">Community Data License Agreement Permissive 2.0</h3>
<p>Used by:</p>
-<ul><li><a href="https://github.com/rustls/webpki-roots">webpki-roots 1.0.9</a></li>
+<ul><li><a href="https://github.com/rustls/webpki-roots">webpki-roots 1.0.10</a></li>
</ul>
<pre># Community Data License Agreement - Permissive - Version 2.0
@@ -11801,7 +11801,7 @@ THIS SOFTWARE.
</pre>
<h3 id="ISC">ISC License</h3>
<p>Used by:</p>
-<ul><li><a href="https://github.com/rustls/webpki">rustls-webpki 0.103.15</a></li>
+<ul><li><a href="https://github.com/rustls/webpki">rustls-webpki 0.103.16</a></li>
</ul>
<pre>Except as otherwise noted, this project is licensed under the following
(ISC-style) terms:
diff --git a/licenses/graphicle/THIRD_PARTY_LICENSES.html b/licenses/graphicle/THIRD_PARTY_LICENSES.html
index 1cda728..82d0385 100644
--- a/licenses/graphicle/THIRD_PARTY_LICENSES.html
+++ b/licenses/graphicle/THIRD_PARTY_LICENSES.html
@@ -11253,8 +11253,8 @@ express Statement of Purpose.
</pre>
<h3 id="CDLA-Permissive-2.0">Community Data License Agreement Permissive 2.0</h3>
<p>Used by:</p>
-<ul><li><a href="https://github.com/rustls/webpki-roots">webpki-root-certs 1.0.9</a></li>
-<li><a href="https://github.com/rustls/webpki-roots">webpki-roots 1.0.9</a></li>
+<ul><li><a href="https://github.com/rustls/webpki-roots">webpki-root-certs 1.0.10</a></li>
+<li><a href="https://github.com/rustls/webpki-roots">webpki-roots 1.0.10</a></li>
</ul>
<pre># Community Data License Agreement - Permissive - Version 2.0
@@ -11862,7 +11862,7 @@ THIS SOFTWARE.
</pre>
<h3 id="ISC">ISC License</h3>
<p>Used by:</p>
-<ul><li><a href="https://github.com/rustls/webpki">rustls-webpki 0.103.15</a></li>
+<ul><li><a href="https://github.com/rustls/webpki">rustls-webpki 0.103.16</a></li>
</ul>
<pre>Except as otherwise noted, this project is licensed under the following
(ISC-style) terms:
diff --git a/sdk/python/graphicle_sdk/client.py b/sdk/python/graphicle_sdk/client.py
index 2daaf58..a45a007 100644
--- a/sdk/python/graphicle_sdk/client.py
+++ b/sdk/python/graphicle_sdk/client.py
@@ -465,8 +465,13 @@ class Project:
``max_tokens`` is at most 16,000. Options include ``limit`` (excerpts, at most 40),
``max_chars`` (default four characters per token), ``mode``, ``needs``,
``memory_retrieval`` / ``graph_retrieval`` / ``doc_links`` (booleans; ``doc_links=True``
- follows documents' links to the code they name, which are otherwise only counted) and
- the local ONNX profiles ``local_embedding_profile`` / ``local_reranker_profile``.
+ follows documents' links to the code they name, which are otherwise only counted),
+ ``notes_first`` (``True`` orders notes first for a question in prose, quotes one window
+ per file and dates each excerpt; off by default), ``identifier_route`` (``True`` answers a
+ question that is an identifier, or only asks where named identifiers are defined or used,
+ with their definitions and references from the code graph and no excerpts; off by
+ default, and the packet's ``route`` says which path ran) and the local ONNX profiles
+ ``local_embedding_profile`` / ``local_reranker_profile``.
``include`` (1-32 source-id prefixes such as ``connector:<id>:``) and ``metadata`` (1-16
exact values of a document's metadata) limit the search to matching sources before
ranking; the packet's ``filter``
diff --git a/sdk/python/graphicle_sdk/tools.py b/sdk/python/graphicle_sdk/tools.py
index 3c5706e..9adc914 100644
--- a/sdk/python/graphicle_sdk/tools.py
+++ b/sdk/python/graphicle_sdk/tools.py
@@ -26,7 +26,8 @@ read; to keep a model to one project, give it a key whose access to the other pr
revoked (the ``graph.access`` operation). ``Tools(project,
cross_project=True)`` opts in to the workspace: the definitions and calls are then those of the
workspace connection ``/mcp/<workspace>``, where ``list_projects`` lists the projects the key may
-read, ``repo`` selects one (this project by default) and ``recall_project`` searches them all,
+read, ``workspace_map`` maps them, ``repo`` selects one (this project by default) and
+``recall_project`` searches them all,
this project first, unless ``repo`` names one. Opt in only where everything the key can read may
reach the model. No tool can approve memory or run commands. Write tools
(``propose_memory``, ``propose_observations`` ...) are published only while the service runs with MCP
@@ -59,7 +60,7 @@ _FIXED = ("repository_id", "workspace_id")
# What reaches other projects: tools listed only for the workspace, and the tools whose ``repo``
# names another project. Without ``cross_project`` they are left out here even if a service
# publishes them on a project connection.
-_WORKSPACE_TOOLS = ("list_projects",)
+_WORKSPACE_TOOLS = ("list_projects", "workspace_map")
_REPO_TOOLS = ("recall_project", "read_project_source")
# Tools whose MCP reply is the text an agent reads unless the call asks for the whole packet in
# ``structuredContent`` (``structured``, beside the published contract); :meth:`Tools.call`
@@ -116,8 +117,8 @@ class Tools:
def definitions(self, *, refresh: bool = False) -> List[Dict[str, Any]]:
"""The published MCP tool definitions (``name``, ``description``, ``inputSchema``,
``annotations``); read-only tools only unless ``include_write``. Without
- ``cross_project``, nothing that reaches another project: no ``list_projects``, and no
- ``repo`` on ``recall_project`` or ``read_project_source``."""
+ ``cross_project``, nothing that reaches another project: no ``list_projects`` or
+ ``workspace_map``, and no ``repo`` on ``recall_project`` or ``read_project_source``."""
if self._definitions is None or refresh:
listed = self._rpc("tools/list") or {}
definitions = []