Repository navigation
feat(analysis-view): share templated positions across manifest tools - #5664
Conversation
Record the outcome, requirements, non-goals, plan and tasks for prefix-variance, an opt-in environment-manifest rule that templates a literal segment with the parameter another tool already uses at that position, so a session's writes to one entity share the read's template. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Add the opt-in prefix-variance template rule. It runs after the other opt-in rules and templates a literal at a position that another tool, of any method or segment count, templates by one of those rules after the same preceding parts, when the literal is one of that parameter's observed values or carries a digit and is spelled like one. The parameter takes the shared parameter's name, tools that now match merge, and a merged position keeps a tool's own rule when one templated it. A write to the one entity a session edited, such as PATCH /api/v1/collections/0RZ576QZQA5KG, becomes patch_collections_by_collection_id on the read's template instead of a literal single-entity tool. Tool naming moves to its own module, and the three comparing passes share the 32-segment split. Manifests that do not list the rule are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Parameters now type their rule as a format rule, a shared opt-in rule or prefix-variance, so nothing reads the union alias. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Record the gates, and the 50 showcase captures with and without the rule: identical output without it, 25 write and 34 read tools templated with it, and the write tools the write-plan branch serves on top. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
[Medium impact] The PR appears safe to merge; no actionable issues remain in the reviewed changes. SummaryAdds opt-in
Diagram%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Grouped request routes] --> B[Existing opt-in rules]
B --> C[Index inferred parameters by preceding route parts]
C --> D{Literal qualifies?}
D -->|Observed value or matching spelling| E[Share parameter name]
D -->|No| F[Keep literal]
E --> G[Merge matching routes]
F --> G
Reviews (5) · Last reviewed commit: "fix(analysis-view): bound the spelling s..." · Reviewed by Greptile |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 930c96d0a1
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
…iers prefix-variance accepted an unobserved literal only when it carried a digit, so a generated identifier that happened to hold none stayed a literal tool: an n8n workflow id such as FkMwxmXNGaGVsXFG, whose reads then never joined the item view. A literal now also qualifies when every value observed at the position has one length of eight or more characters and the literal has that length and uses only their character classes. Across the 50 showcase captures this templates 10 more read tools in Memos and n8n and no words. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 33b0643e8c
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
Five randomly drawn environments rebuilt on VMs with the rule and the write-plan branch: smoke, retrieval and write tasks for two models, and the same calls against the live applications. Record the results, the misses and their causes, and the corpus numbers after the fixed-length clause. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… the literal
A shared position folded every donor's values into the earliest donor's
parameter. With an opaque-token read before sibling-variance reads at
the same position, a PATCH of /api/items/b2 qualified on the sibling's
evidence but became /api/items/{uid} instead of joining the item read's
/api/items/{item_id}. Each position now keeps one donor per naming rule
with its own values, and a literal takes the donor that observed it,
else the earliest one it is spelled like.
Each donor's spelling (length and character classes of its values, and
its fixed-length family) is summarised once per position, so a literal
is checked in time independent of how many values were observed, rather
than copying and rescanning them for every candidate.
A family now forms from one observed value, as the requirement says, so
a digit-free id of the same length shares a position that only one
opaque-token or after-uid-literal tool supplied. The 50 showcase
captures give the same tools as before.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6a8beb589a
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
spellingSummary classified every observed value with three full-size replaceAll copies and a set per distinct character, so a donor holding a multi-megabyte segment cost unaccounted memory and time in finish(). Characters are now classified in one pass, and a value longer than 128 characters takes no part in spelling comparisons: it shares a position only as an exactly observed value. The 50 showcase captures give the same tools. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Summary
A capture session usually edits one scratch entity: it creates it, then updates and deletes it at a fixed path such as
/api/v1/collections/0RZ576QZQA5KG. The environment manifest templates a segment only when sibling routes of the same method and segment count vary there. So those writes stay literal single-entity tools (patch_collections_0rz576qzqa5kg), even though the reads of the same collection were templated as/api/v1/collections/{collection_id}.This PR adds an opt-in template rule,
prefix-variance. It templates such a literal with the parameter another tool already uses at that position, so the write becomespatch_collections_by_collection_idon the read's exact template.Part of #4933. Spec, plan, tasks and verification are in
docs/specs/agent-environments/prefix-variance/.Problem and expected behavior
A literal write tool addresses one entity that may not exist in any later state. Nothing can model its effect. The write-effects gate in #5600 reports these tools as
no-state-target, and they were the largest group it could not serve.With the rule listed in
template_rules:When it applies: a literal at position
pis templated when another tool on the same origin has a parameter atpfrom one of the other opt-in rules, after the same preceding parts. The other tool can have any method and any segment count, so deeper routes such as…/collections/{collection_id}/booksare covered too.Which literals qualify:
Empty literals, stop words and
v1-style versions never qualify, and format-rule positions ({numeric}, …) are never shared.Naming: the parameter takes the shared parameter's name (
collection_id,uid, a pair's_namespaceand_name) and is labelledprefix-variance.Merging: tools whose routes now match merge, and a merged position keeps a tool's own rule when one templated it.
Segment limit: like the sibling rules, it compares routes of at most 32 segments and says so in a limitation.
Change and scope
environmentManifestRules.tsgains the pass. It runs last, so it can share every parameter the other rules produce.prefix-varianceparameter records the rule it shares (sharedRule), which both names it and keys it when routes are compared.environmentManifestNames.ts, so the rules file stays under the length limit;/api/are still excluded asnon-json. That hides 13 write tools in 5 of the showcase captures (Directus, Jellyfin, Keycloak, Miniflux, Shlink). Fixing it changes default output, so it belongs in a separate change.Within the contribution scope: an analysis-view projection change inside an existing boundary; no target execution.
Contract and boundary impact
src/domain/analysisView/), at template-rule application.template_rulesacceptsprefix-variance. The request schema's description names it, which changes the generated tool catalog. Toolparams[].rulecan now beprefix-variance. Requests that don't list it give identical results.basis: "inferred", with its observed values.docs/public/product-catalog.json), package, or installation impact: none beyond the generated MCP catalog.Expected effects (check known effects; use documentation-only on its own).
Unchecked items do not establish absence; leave uncertainties visible.
Evidence and regression coverage
Tests added. Seven cases in
environmentManifestView.test.ts:Corpus evidence (executed over the 50 showcase captures: 45 HAR inspections, 5 browser scenarios):
Unchanged without the rule. Main's build and this branch give byte-identical results without the rule: the manifest with no rules, with the four existing opt-in rules, and the environment-state view. All 150 of 150 hash equal.
Templated with the rule. Added to
after-uid-literal,opaque-tokenandsibling-variance, the rule templates 25 literal write tools and 44 read tools in 10 captures:PATCH,DELETE, archive, and the reads of a workflow whose id holds no digit;mereads.Tools go from 1,591 to 1,578, because Redpanda Console's per-subject reads and the per-memo and per-workflow reads merge.
Left alone, as intended: Espo CRM
layout, Federal Registerfacets, Ghostslug, Shlinkstats, LycheeMetrics::photoand Vault's path names.Combined with feat(environment): apply evidence-gated write effects to the served state #5600 (merged locally with main):
Newly modelled but still unserved, because of what the capture holds:
sharedrelation its create response never returned;tagswhile the update echoes the request's order.End to end on five random environments. Komga, Mealie, n8n, Sentry and Shlink were drawn at random from the ten environments the rule changes, redrawing until one had newly served writes. Each was rebuilt on its own Linux VM from its published scoped HAR with
npm packof #5600 + main + this branch: manifest, bundle, smoke, retrieval tasks forgpt-oss-120bandGLM-5.3-Flash, write tasks graded from the state throughdata/get, and a dry-run dataset. Published results are in brackets.Every smoke task passed. The misses:
id: "sentry"for the/api/0/segment, which the tool schema describes asobserved: 0. Every passing episode, and every GLM episode, passed0.nullorundefinedoptional arguments).qa-03with GLM: the model never called the alert-rules tool.The first n8n run showed that a digit-free workflow id stayed literal: reading that workflow by id failed because the state held only its list fields. The fixed-length clause fixed that, and the rebuilt n8n reads it correctly.
Live comparison, seeded by the same scripts:
Komga 1.29.1: 9 of 12 steps equal. Collection create, update, delete and the reads after them agree apart from the generated id. Two differences remain: the collection list after a create omits the new collection (recorded membership), and a deleted collection's 404 replays the recorded body.
n8n 1.123.85: 3 of 8 steps equal.
These gaps belong to the write and list serving in feat(environment): apply evidence-gated write effects to the served state #5600 and its base, not to this rule.
User-visible output. Komga, with the rule:
{ "name": "patch_collections_by_collection_id", "method": "PATCH", "path_template": "/api/v1/collections/{collection_id}", "api_surface_template": "/api/v1/collections/0RZ576QZQA5KG", "params": [ { "index": 3, "name": "collection_id", "rule": "prefix-variance", "basis": "inferred", "observed_values": ["0RZ576QZQA5KG"] } ], "body_shape": { "type": "object", "properties": { "name": "string", "ordered": "boolean" } }, "statuses": [204], "record_ordinals": [108] }Without the rule the same record is
patch_collections_0rz576qzqa5kgwithparams: [].Remaining proof gaps. The rule is an inference from paths. An app whose identifier-like literal sits beside an opt-in parameter but names a different resource would be templated wrongly. In the 50 captures, every such literal that qualified was the same resource, and every one that didn't qualify was a word.
For evidence-bearing changes:
Validation performed
Run on macOS with Node v22.23.1 at 33b0643 (the rule, the alias removal, and the fixed-length clause); 9a025b3 adds only the verification record.
npm run build:cached,npm run check:fast,npm run format:check,npm run scan:todos,npm run docs:check,npm run verify:test-discovery,npm run mcp-catalog:check: passed.npx knip: passed.npm run jscpd: 3.49% over 3561 files, 3067 clones. Main is 3.49% with 3068.npx vitest run --project domain --project services: 7119 passed, 5 pre-existing skips.npm run test:prepare, thennpm run test:focused --the analysis-view MCP and CLI boundaries, compact input schema, tool schema validity, and environment serve and export boundaries: 7 files, 76 passed.npx vitest run src/domain/analysisView/: 280 passed.jscpd3.49%), and the tools with and withoutprefix-varianceover the 50 captures are unchanged, name for name.jscpd3.49%), and the census over the 50 captures is unchanged.Compatibility, safety, and release
Author readiness
Human owner:
Before merge
type(scope): outcome.🤖 Generated with Claude Code