@theronap/agnoclast-mcp 0.9.209 โ 0.9.210
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/identifier_routes.mjs +81 -0
- package/lib/server.mjs +15 -15
- package/package.json +1 -1
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
// WHERE AN IDENTIFIER ROUTES, AND WHAT A FILING SESSION MAY CLAIM โ pure renderers (ADR-0075, 2026-10-05).
|
|
2
|
+
//
|
|
3
|
+
// ๐ด THE LINE THIS REPLACES TOLD A SESSION SOMETHING FALSE. `read_page "file:โฆ"` printed "Home: X" for
|
|
4
|
+
// the page whose BODY carried the [[stamp]], and for an unclaimed identifier said "author its page and
|
|
5
|
+
// stamp [[id]] on it (that page becomes the home)". Since ADR-0026 a body stamp routes nothing โ the
|
|
6
|
+
// router reads page_routing_identifiers only โ so following that advice produced a page the router never
|
|
7
|
+
// sends anything to, and the session was told it worked. That is the 2026-10-04 V4 email-surface
|
|
8
|
+
// incident. The server now answers `homes` from CLAIMS and moves stamp pages to `mentionedOn`; this
|
|
9
|
+
// prints the two apart and gives `set_routing_identifier` as the fix.
|
|
10
|
+
//
|
|
11
|
+
// Pure so CI can execute what each state prints.
|
|
12
|
+
|
|
13
|
+
const q = (s) => `"${s}"`
|
|
14
|
+
const pageLabel = (h) => `${q(h.title)} (${h.kind}, ${h.tier})`
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* The read_page identifier view, as lines. Handles the pre-ADR-0075 server too (no `mentionedOn`):
|
|
18
|
+
* there `homes` are stamp pages, so they are printed as mentions, never as where anything routes.
|
|
19
|
+
*/
|
|
20
|
+
export function renderIdentifierResolution(out, { expand = false } = {}) {
|
|
21
|
+
const id = out.identifier
|
|
22
|
+
const lines = [`# ${id} (identifier โ a join key, not a page)`]
|
|
23
|
+
const claimAware = Array.isArray(out.mentionedOn)
|
|
24
|
+
const homes = claimAware ? (out.homes ?? []) : []
|
|
25
|
+
const mentions = claimAware ? out.mentionedOn : (out.homes ?? [])
|
|
26
|
+
const catchAll = claimAware ? (out.catchAll ?? []) : []
|
|
27
|
+
const hidden = claimAware ? Number(out.hiddenClaims ?? 0) : 0
|
|
28
|
+
|
|
29
|
+
if (!claimAware) {
|
|
30
|
+
lines.push('This server cannot say where it ROUTES (it predates ADR-0075); the pages below only mention it, and a mention routes nothing. `my_routing_claims` lists the claims that do.')
|
|
31
|
+
} else if (homes.length === 1 && out.status !== 'duplicate') {
|
|
32
|
+
const h = homes[0]
|
|
33
|
+
const how = h.via === id ? 'claims it' : `claims the folder \`${h.via}\` above it`
|
|
34
|
+
lines.push(`Routes to: ${pageLabel(h)} โ it ${how}. \`read_page ${q(h.title)}\` for the page.`)
|
|
35
|
+
} else if (homes.length >= 1) {
|
|
36
|
+
lines.push(out.status === 'duplicate'
|
|
37
|
+
? `โ More than one page claims this at the same depth โ a record carrying it is filed under all of them (and STAGES if they sit in different brains). Settle which one it belongs to:`
|
|
38
|
+
: `Routes to ${homes.length} pages, deepest claim first โ a record carrying it is filed under each:`)
|
|
39
|
+
for (const h of homes) lines.push(` - ${pageLabel(h)} via \`${h.via}\`${h.brain ? ` ยท ${h.brain}` : ''}`)
|
|
40
|
+
}
|
|
41
|
+
if (hidden > 0) {
|
|
42
|
+
lines.push(`${hidden} claim${hidden === 1 ? '' : 's'} on page${hidden === 1 ? '' : 's'} you cannot open โ ${hidden === 1 ? 'it routes' : 'they route'} all the same.`)
|
|
43
|
+
}
|
|
44
|
+
if (claimAware && homes.length === 0 && hidden === 0) {
|
|
45
|
+
const fallback = catchAll.length
|
|
46
|
+
? ` Records carrying it are filed only under the repo catch-all: ${catchAll.map((h) => q(h.title)).join(', ')} (via \`${catchAll[0].via}\`).`
|
|
47
|
+
: ''
|
|
48
|
+
lines.push(
|
|
49
|
+
`No page claims this, so it routes nowhere on its own.${fallback} If a page is ABOUT it, claim it there: ` +
|
|
50
|
+
`\`set_routing_identifier\` with identifier ${q(id)}${id.startsWith('file:') && !id.endsWith('/') ? ' (or the deepest folder above it, with its trailing slash)' : ''}. ` +
|
|
51
|
+
'A [[stamp]] in a page body does NOT make that page its home.',
|
|
52
|
+
)
|
|
53
|
+
} else if (catchAll.length) {
|
|
54
|
+
lines.push(`Also filed under the repo catch-all: ${catchAll.map((h) => q(h.title)).join(', ')} (via \`${catchAll[0].via}\`).`)
|
|
55
|
+
}
|
|
56
|
+
if (mentions.length) {
|
|
57
|
+
lines.push(`Mentioned on (does not route): ${mentions.map((h) => q(h.title)).join(', ')}`)
|
|
58
|
+
}
|
|
59
|
+
const ev = out.events ?? { visibleCount: 0, recent: [] }
|
|
60
|
+
lines.push(`ยท ${ev.visibleCount} tagged timeline event${ev.visibleCount === 1 ? '' : 's'} visible to you${ev.recent?.length ? ':' : expand ? '.' : ' โ pass expand: true to list recent ones.'}`)
|
|
61
|
+
for (const e of ev.recent ?? []) lines.push(` - ${String(e.occurredAt).slice(0, 10)} ยท ${e.source} ยท ${e.summary}`)
|
|
62
|
+
return lines
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/** intake_materialize: the folder-claim offers, as lines. [] when the server sent none (or is older). */
|
|
66
|
+
export function renderFolderClaimOffers(offers) {
|
|
67
|
+
if (!Array.isArray(offers) || offers.length === 0) return []
|
|
68
|
+
const lines = ['Folder claim offered (nothing was claimed โ decide, do not just accept):']
|
|
69
|
+
for (const o of offers) if (o && typeof o.offer === 'string') lines.push(` - ${o.offer}`)
|
|
70
|
+
return lines.length > 1 ? lines : []
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** author / edit_page: [[file:โฆ]] stamps the write left that route nothing to this page, as lines. */
|
|
74
|
+
export function renderUnroutedPathStamps(body) {
|
|
75
|
+
const stamps = Array.isArray(body?.unroutedPathStamps) ? body.unroutedPathStamps : []
|
|
76
|
+
if (!stamps.length) return []
|
|
77
|
+
const lines = [`โ ${stamps.length} [[file:โฆ]] stamp${stamps.length === 1 ? '' : 's'} on this page route${stamps.length === 1 ? 's' : ''} nothing here: ${stamps.map((s) => `\`${s.identifier}\``).join(', ')}.`]
|
|
78
|
+
if (typeof body.unroutedPathStampsNote === 'string') lines.push(body.unroutedPathStampsNote)
|
|
79
|
+
for (const s of stamps) if (typeof s.fix === 'string') lines.push(` - ${s.fix}`)
|
|
80
|
+
return lines
|
|
81
|
+
}
|
package/lib/server.mjs
CHANGED
|
@@ -9,6 +9,7 @@ import { seatChargeRefusal, seatChargeQuestion } from './seat_charge.mjs'
|
|
|
9
9
|
import { fetchCortex, classify, resolveBase, resolveEnvToken, setSessionKey, setClientVersion, runWithTool, heartbeatPolicy } from './diagnose.mjs'
|
|
10
10
|
import { REPORT_KINDS, REPORT_ISSUE_DESCRIPTION, fileIssue } from './report_issue.mjs'
|
|
11
11
|
import { folderClaimLine } from './folder_claims.mjs'
|
|
12
|
+
import { renderFolderClaimOffers, renderIdentifierResolution, renderUnroutedPathStamps } from './identifier_routes.mjs'
|
|
12
13
|
import { resolveSessionKey, resolveLogSessionId } from './session_key.mjs'
|
|
13
14
|
import { runSendImessage } from './imessage_send.mjs'
|
|
14
15
|
import { formatGrepHits } from './grep_cli.mjs'
|
|
@@ -1343,6 +1344,9 @@ function renderNudge(payload) {
|
|
|
1343
1344
|
// null/undefined no container was ever requested (say nothing)
|
|
1344
1345
|
// containerSkipped is the only one that needs a warning: it means a container WAS asked for and
|
|
1345
1346
|
// did not happen, which is exactly the silence this whole path exists to remove.
|
|
1347
|
+
// ADR-0075 โ the deepest unclaimed folder this unit sits in, offered for the feature page it was
|
|
1348
|
+
// filed onto. Never claimed by the server; the session decides.
|
|
1349
|
+
lines.push(...renderFolderClaimOffers(body?.folderClaimOffers))
|
|
1346
1350
|
if (body?.containerSkipped) {
|
|
1347
1351
|
lines.push(`โ CONTAINER NOT APPLIED โ ${body.containerSkipped}. The record exists but is not inside the event you named; place it with contain_record or leave it out.`)
|
|
1348
1352
|
} else if (body?.contained === true) {
|
|
@@ -1874,7 +1878,7 @@ function renderNudge(payload) {
|
|
|
1874
1878
|
description:
|
|
1875
1879
|
'READ the full authored wiki page for one node (project/person/org/you) by its canonical name โ every section you can see. This is how you READ a node; `grep` only LOCATES pages (snippets + their [[links]]), it does not read them. Navigate like a researcher: read the page you need, then FOLLOW its inline [[links]] by calling read_page on each linked name โ keep following while the linked pages stay relevant, stop when they do not. You decide how deep to go. Returns only what you are permitted to see.',
|
|
1876
1880
|
inputSchema: {
|
|
1877
|
-
name: z.string().describe('the canonical node name exactly as written (e.g. "Agnoclast", "Ben", or a [[link]] target) โ identifier links ([[repo:owner/name]]) resolve to
|
|
1881
|
+
name: z.string().describe('the canonical node name exactly as written (e.g. "Agnoclast", "Ben", or a [[link]] target) โ identifier links ([[repo:owner/name]], [[file:owner/name:path]]) resolve to the page(s) that CLAIM them โ where the router actually files records โ plus the pages that merely mention them, and a visible-event count'),
|
|
1878
1882
|
kind: z.enum(['project', 'person', 'org', 'user']).optional().describe('node kind โ a PREFERENCE, not a filter. The lookup matches every kind by title and only prefers this one when several share a name, so omitting it never hides a person/org/user page. Pass it to disambiguate a name that exists as more than one kind.'),
|
|
1879
1883
|
expand: z.boolean().optional().describe('identifier names only: also list recent visible timeline events for this identifier (default: home + count)'),
|
|
1880
1884
|
history: z.boolean().optional().describe('node names only: return the node\'s TIMELINE (events joined via its [[repo:โฆ]] stamps, reverse-chron, viewer-visible) instead of the page body. The page is the present; this is the history.'),
|
|
@@ -1962,18 +1966,8 @@ function renderNudge(payload) {
|
|
|
1962
1966
|
const r = await fetchCortex(`${BASE}/api/identifier/resolve?${qs}`, { headers: { Authorization: `Bearer ${TOKEN}` } })
|
|
1963
1967
|
if (r.ok) {
|
|
1964
1968
|
const out = await r.json()
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
lines.push(`No authored home carries this stamp yet โ data but no home. If you know what this identifies, author its page and stamp [[${out.identifier}]] on it (that page becomes the home).`)
|
|
1968
|
-
} else if (out.status === 'healthy') {
|
|
1969
|
-
const h = out.homes[0]
|
|
1970
|
-
lines.push(`Home: "${h.title}" (${h.kind}, ${h.tier}) โ \`read_page "${h.title}"\` for the full page.`)
|
|
1971
|
-
} else {
|
|
1972
|
-
lines.push(`โ ${out.homes.length} pages carry this stamp โ possible duplicate homes, consider reconciling:`)
|
|
1973
|
-
for (const h of out.homes) lines.push(` - "${h.title}" (${h.kind}, ${h.tier})`)
|
|
1974
|
-
}
|
|
1975
|
-
lines.push(`ยท ${out.events.visibleCount} tagged timeline event${out.events.visibleCount === 1 ? '' : 's'} visible to you${out.events.recent.length ? ':' : expand ? '.' : ' โ pass expand: true to list recent ones.'}`)
|
|
1976
|
-
for (const e of out.events.recent) lines.push(` - ${String(e.occurredAt).slice(0, 10)} ยท ${e.source} ยท ${e.summary}`)
|
|
1969
|
+
// ADR-0075: `homes` are CLAIMS (where the router files it); stamp pages are `mentionedOn`.
|
|
1970
|
+
const lines = renderIdentifierResolution(out, { expand })
|
|
1977
1971
|
// KWA-28 โ an identifier node is VIRTUAL: derived per read, zero stored rows, so there is no
|
|
1978
1972
|
// as_of to fetch. The item says exactly what to do in that case: "where the object is derived
|
|
1979
1973
|
// per-read, stamp the read itself." Note this as-of means something DIFFERENT from every
|
|
@@ -3988,7 +3982,10 @@ function renderNudge(payload) {
|
|
|
3988
3982
|
const undatedNote = out?.undated === true
|
|
3989
3983
|
? `\nโ This section now carries no explicit calendar date. A reader can see WHEN the text was written but not when the claim was TRUE. If it asserts a status, add the date inline โ you still hold the context. The edit already landed; this is advisory.`
|
|
3990
3984
|
: ''
|
|
3991
|
-
|
|
3985
|
+
// ADR-0075 โ a [[file:โฆ]] stamp this edit wrote that routes nothing here, with the claim that would.
|
|
3986
|
+
const unroutedLines = renderUnroutedPathStamps(out)
|
|
3987
|
+
const unrouted = unroutedLines.length ? `\n${unroutedLines.join('\n')}` : ''
|
|
3988
|
+
return { content: [{ type: 'text', text: `Edited "${name}" (${out.brain} ยท ${out.tier} tier) ยง ${out.heading}. Only that passage changed; every other section is byte-identical. New version: ${out.version}${red}${undatedNote}${unrouted}` }] }
|
|
3992
3989
|
},
|
|
3993
3990
|
)
|
|
3994
3991
|
|
|
@@ -6067,8 +6064,11 @@ function renderNudge(payload) {
|
|
|
6067
6064
|
` can read the page. Re-send with identity_claim_ack: true only if the subject is publishing` +
|
|
6068
6065
|
` their own contact detail; otherwise use a confidential section or set_routing_identifier.`
|
|
6069
6066
|
: ''
|
|
6067
|
+
// ADR-0075 โ [[file:โฆ]] stamps that route nothing here, each with the claim that would. Advisory.
|
|
6068
|
+
const unroutedLines = renderUnroutedPathStamps(out)
|
|
6069
|
+
const unrouted = unroutedLines.length ? `\n${unroutedLines.join('\n')}` : ''
|
|
6070
6070
|
const verb = out?.created ? 'Created + authored' : 'Authored'
|
|
6071
|
-
const note = out?.built ? `${verb} "${name}" (${out.built} tier${out.built === 1 ? '' : 's'}). Links: ${blue} resolved, ${retired} retired, ${red} red.${corrections}${retiredList}${redList}${stamps}${undated}${identityRefused}`
|
|
6071
|
+
const note = out?.built ? `${verb} "${name}" (${out.built} tier${out.built === 1 ? '' : 's'}). Links: ${blue} resolved, ${retired} retired, ${red} red.${corrections}${retiredList}${redList}${stamps}${undated}${identityRefused}${unrouted}`
|
|
6072
6072
|
: `No change to "${name}"${out?.skipped?.length ? ` (${out.skipped.join(', ')})` : ''}.${corrections}`
|
|
6073
6073
|
return { content: [{ type: 'text', text: note }] }
|
|
6074
6074
|
},
|
package/package.json
CHANGED