Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
QM: argument_without_attestation names what is missing (detail missing=...); v2 contract says a long memory_recall query is ranked on its first 2,000 chars, never refused (GST-1304)
garrytanec87d6c3268a
diff --git a/docs/contracts/qm-memory-provider/v2.json b/docs/contracts/qm-memory-provider/v2.jsonindex 0f1db89202..01cac68e8e 100644--- a/docs/contracts/qm-memory-provider/v2.json+++ b/docs/contracts/qm-memory-provider/v2.json@@ -148,7 +148,7 @@"query_chars_ranked": 2000,"own_recent_window_hours": 24},- "arguments_checked": "query and max_chars are checked before any read, also for an unlinked person (invalid_params)",+ "arguments_checked": "query and max_chars are checked before any read, also for an unlinked person (invalid_params); a longer query is ranked on its first 2000 characters and never refused (recall's question is refused over 2000: invalid_params reason question_too_long)","content": {"line": "- <fact> (<YYYY-MM-DD>; <kind>)","never": [@@ -314,7 +314,7 @@{"reason": "argument_without_attestation","fixed_by": "calling_harness",- "fix": "Remove acting_user, or send the x-qm-actor header from a credential holding the attest right; a credential bound to no member never sends acting_user alone."+ "fix": "Remove acting_user, or send the x-qm-actor header from a credential holding the attest right; a credential bound to no member never sends acting_user alone. detail missing=<attest_right|x-qm-actor, comma-separated> names what this call lacked."},{"reason": "invalid_actor_id",diff --git a/docs/guides/qm.md b/docs/guides/qm.mdindex cb859d3647..3d55be2e11 100644--- a/docs/guides/qm.md+++ b/docs/guides/qm.md@@ -30,8 +30,8 @@ a repo exists, saved facts go through the same git-first writer door as `remembefirst, then the facts they may read ranked by `query`. Never page bodies. The textholds as many whole lines as fit, with no marker line (every line is one fact;`structuredContent.truncated` says some were left out), and never exceeds `max_chars`- (a whole number of UTF-16 code units, 200-12000, default 6000). `query` is ranked- on its first 2,000 characters. `recall`'s `question` is capped at 2,000: a longer one is+ (a whole number of UTF-16 code units, 200-12000, default 6000). A longer `query` is+ ranked on its first 2,000 characters, never refused. `recall`'s `question` is capped at 2,000: a longer one isrefused `invalid_params` with reason `question_too_long` and detail`max_chars=2000 received_chars=<n>`, nothing is read, so trim it before calling. Each fact isone line: line breaks and control characters in it become spaces. Ranking isdiff --git a/docs/guides/write-refusals.md b/docs/guides/write-refusals.mdindex d9ada0c3b7..3d6a430058 100644--- a/docs/guides/write-refusals.md+++ b/docs/guides/write-refusals.md@@ -1006,7 +1006,7 @@ Links and the right live in the database, so they are the same on a repo-less br| Code | What happened | What to do ||---|---|---|-| <a id="actor_not_attested"></a>`actor_not_attested` | The call named a person in a way gbrain does not honour. `reason` says which: `no_attest_right` (the credential holds no attest right, or the token of an attest client was issued before the upgrade or by another grant: the message then says to take a new client-credentials token), `op_not_attested` (the operation is not in the credential's attested operations, or is not attestable yet: `list_write_conflicts`, `capture`, `extract_facts` and `takes_add|update|resolve|supersede`; also when a queued write or agent job tool call runs after its operation was removed from the list), `argument_mismatch` (the `acting_user` argument differs from the header, or, with no header on a credential bound to a member, names anyone but that member; its own member id or a canonical id linked to it is dropped and the call runs exactly as the credential), `argument_without_attestation` (`acting_user` came without an attested header from a credential bound to no member, over stdio, or beside an `on_behalf_of` audience), `invalid_actor_id` (the header or argument is not 1-256 visible ASCII characters), `actor_required` (`memory_write` named no attested person) or `audience_not_supported` (the request carries `x-qm-audience`, QM's channel audience, which is refused on every call until wave 2). Nothing was read or written. | `no_attest_right` and `op_not_attested` are the brain operator's call: `fix` carries `gbrain auth rescope --client <id> --attest-actor qm [--attest-ops <list>]`. The other five are fixed in the calling harness: send the canonical id unchanged in the header from the attest credential, the same value or nothing in `acting_user` (on a member-bound credential with no header: its own member id, a canonical id linked to it, or nothing), and no `x-qm-audience`. |+| <a id="actor_not_attested"></a>`actor_not_attested` | The call named a person in a way gbrain does not honour. `reason` says which: `no_attest_right` (the credential holds no attest right, or the token of an attest client was issued before the upgrade or by another grant: the message then says to take a new client-credentials token), `op_not_attested` (the operation is not in the credential's attested operations, or is not attestable yet: `list_write_conflicts`, `capture`, `extract_facts` and `takes_add|update|resolve|supersede`; also when a queued write or agent job tool call runs after its operation was removed from the list), `argument_mismatch` (the `acting_user` argument differs from the header, or, with no header on a credential bound to a member, names anyone but that member; its own member id or a canonical id linked to it is dropped and the call runs exactly as the credential), `argument_without_attestation` (`acting_user` came without an attested header from a credential bound to no member, over stdio, or beside an `on_behalf_of` audience; `detail` is `missing=x-qm-actor`, `missing=attest_right` or both, naming what the call lacked), `invalid_actor_id` (the header or argument is not 1-256 visible ASCII characters), `actor_required` (`memory_write` named no attested person) or `audience_not_supported` (the request carries `x-qm-audience`, QM's channel audience, which is refused on every call until wave 2). Nothing was read or written. | `no_attest_right` and `op_not_attested` are the brain operator's call: `fix` carries `gbrain auth rescope --client <id> --attest-actor qm [--attest-ops <list>]`. The other five are fixed in the calling harness: send the canonical id unchanged in the header from the attest credential, the same value or nothing in `acting_user` (on a member-bound credential with no header: its own member id, a canonical id linked to it, or nothing), and no `x-qm-audience`. || <a id="source_not_attested"></a>`permission_denied` reason `source_not_attested` / `scope_page_not_shared`, `invalid_params` reason `source_is_member_source` | A scope `memory_write` (`source_id`, contract v2) named a source that is not in the credential's `--attest-sources` or not a marked scope source (also when a queued write publishes after the source was dropped), or its own write source; or the scope's `memory/scope` page names readers, is private or sits under a folder rule. Nothing was written. | The operator lists the source with `gbrain auth rescope --client <id> --attest-sources <list>`, or removes `readable_by` / `visibility: private` / the folder rule from `memory/scope`. For the person's own page, leave `source_id` out. See [shared scopes](qm.md#shared-scopes-projects-channels-teams). || <a id="actor_unlinked"></a>`actor_unlinked` | The id is not linked to an enabled member: never linked, unlinked, or the member is disabled or removed. Ids compare exactly, with no case folding. Nothing was read or written. A queued write or agent job made for the person is refused the same way when its link is gone or now names another member. `memory_recall` answers it as an empty success instead (`structuredContent: {facts: [], truncated: false, code: "actor_unlinked"}`), so a person not yet linked reads nothing. | The brain operator links it: `gbrain access member link <member> --qm <id>` (or `gbrain access member enable <member>`). |diff --git a/scripts/build-qm-memory-contract.ts b/scripts/build-qm-memory-contract.tsindex 0713deff1b..9c8f07563a 100644--- a/scripts/build-qm-memory-contract.ts+++ b/scripts/build-qm-memory-contract.ts@@ -58,7 +58,7 @@ const ERROR_NOTES: Partial<Record<typeof ERROR_CODES[number], string>> = {/** v2 changes to v1's fix rows (GST-900: a member-bound credential may name its own member). */const V2_REASON_FIXES: Partial<typeof ACTOR_REASON_FIXES> = {argument_mismatch: { fixed_by: 'calling_harness', fix: 'Send acting_user equal to the x-qm-actor header (with no header, on a credential bound to a member: that member id or a canonical id linked to it), or omit it.' },- argument_without_attestation: { fixed_by: 'calling_harness', fix: 'Remove acting_user, or send the x-qm-actor header from a credential holding the attest right; a credential bound to no member never sends acting_user alone.' },+ argument_without_attestation: { fixed_by: 'calling_harness', fix: 'Remove acting_user, or send the x-qm-actor header from a credential holding the attest right; a credential bound to no member never sends acting_user alone. detail missing=<attest_right|x-qm-actor, comma-separated> names what this call lacked.' },};function toolEntry(name: string, version: QmContractVersion) {@@ -95,7 +95,9 @@ export function buildQmMemoryContract(version: QmContractVersion): Record<stringtools: [...QM_MEMORY_OPS].sort().map(name => toolEntry(name, version)),memory_recall: {limits: { max_chars: { ...MEMORY_RECALL_MAX_CHARS, whole_number: true, unit: 'UTF-16 code units (JavaScript string length)' }, query_chars_ranked: MEMORY_RECALL_QUERY_CHARS, own_recent_window_hours: OWN_RECENT_WINDOW_HOURS },- arguments_checked: 'query and max_chars are checked before any read, also for an unlinked person (invalid_params)',+ arguments_checked: v2+ ? `query and max_chars are checked before any read, also for an unlinked person (invalid_params); a longer query is ranked on its first ${MEMORY_RECALL_QUERY_CHARS} characters and never refused (recall's question is refused over ${QUESTION_MAX_CHARS}: invalid_params reason question_too_long)`+ : 'query and max_chars are checked before any read, also for an unlinked person (invalid_params)',content: { line: '- <fact> (<YYYY-MM-DD>; <kind>)', never: ['page bodies', 'fence markers', 'heading markers', 'line breaks or control characters inside a fact'], bounded_by: 'max_chars: as many whole lines as fit; facts left out set structuredContent.truncated, with no marker line, because every line is one fact' },order: ['own facts from the last ' + OWN_RECENT_WINDOW_HOURS + ' hours, newest first', 'facts the person may read, ranked by query'],ranking: 'keyword-only unless an embedding provider is configured (no embedding call on a keyless brain)',diff --git a/src/core/access/actor.ts b/src/core/access/actor.tsindex c8f7083958..39e7ac0948 100644--- a/src/core/access/actor.ts+++ b/src/core/access/actor.ts@@ -101,7 +101,7 @@ function credentialArgv(caller: ActorCaller): string[] {const transportOf = (transport?: string) => ({ remote: true, transport: transport === 'stdio' ? 'stdio' as const : 'http' as const });/** actor_not_attested with its reason, remedy and (where the operator can fix it) the rescope command. */-export function actorNotAttested(reason: ActorReason, caller: ActorCaller, ctx: { op: string; transport?: string; right?: AttestRight | null; reissue?: boolean; memberBound?: boolean }): OperationError {+export function actorNotAttested(reason: ActorReason, caller: ActorCaller, ctx: { op: string; transport?: string; right?: AttestRight | null; reissue?: boolean; memberBound?: boolean; missing?: Array<'attest_right' | 'x-qm-actor'> }): OperationError {const docs = ERROR_CATALOGUE.actor_not_attested.docs;const rescope = (extra: string[]) => ['gbrain', 'auth', 'rescope', ...credentialArgv(caller), ...extra];const hostOnly = (message: string, argv: string[], why: string, suggestion: string) =>@@ -131,9 +131,12 @@ export function actorNotAttested(reason: ActorReason, caller: ActorCaller, ctx:}return opError('actor_not_attested', `The ${ACTOR_ARGUMENT} argument names someone other than the ${ACTOR_HEADER} header, so nothing was read or written.`,`The header decides whom the call serves; send ${ACTOR_ARGUMENT} equal to it, or leave it out. Text in a conversation never chooses whose notes are read.`, { reason, docs });- case 'argument_without_attestation':- return opError('actor_not_attested', `The ${ACTOR_ARGUMENT} argument is accepted only on an attested call, so nothing was read or written.`,- `Remove ${ACTOR_ARGUMENT} from the arguments. A trusted system names the person in the ${ACTOR_HEADER} header from a credential holding the attest right (gbrain auth rescope ... --attest-actor qm on the brain host).`, { reason, docs });+ case 'argument_without_attestation': {+ const missing = ctx.missing ?? ['attest_right', ACTOR_HEADER];+ const lacks = missing.map(m => (m === 'attest_right' ? 'the attest right on this credential' : `the ${ACTOR_HEADER} header`)).join(' and ');+ return opError('actor_not_attested', `The ${ACTOR_ARGUMENT} argument is accepted only on an attested call, and this call lacks ${lacks}, so nothing was read or written.`,+ `Remove ${ACTOR_ARGUMENT} from the arguments. A trusted system names the person in the ${ACTOR_HEADER} header from a credential holding the attest right (gbrain auth rescope ... --attest-actor qm on the brain host).`, { reason, docs, detail: `missing=${missing.join(',')}` });+ }case 'actor_required':return opError('actor_not_attested', `${ctx.op} writes only as an attested person, and this call names none (no ${ACTOR_HEADER} header on a credential holding the attest right), so nothing was written.`,`Send ${ACTOR_HEADER} with the person's canonical id from a credential the brain operator granted the attest right (${rescope(['--attest-actor', 'qm']).join(' ')}). To save a fact as yourself, call remember.`, { reason, docs });@@ -254,7 +257,7 @@ export async function resolveAttestedActor(engine: Pick<BrainEngine, 'executeRawif (!right || right.system !== 'qm') {const principal = input.auth?.principal;const reissue = !hasArgument && !right && principal?.kind === 'oauth_client' && !!await attestRightOf(engine, { principal });- throw actorNotAttested(hasArgument ? 'argument_without_attestation' : 'no_attest_right', caller, { ...ctx, reissue });+ throw actorNotAttested(hasArgument ? 'argument_without_attestation' : 'no_attest_right', caller, { ...ctx, reissue, missing: ['attest_right'] });}if (!right.ops.includes(input.op) || !attestableOp(input.op, input.opShape)) throw actorNotAttested('op_not_attested', caller, { ...ctx, right });if (hasArgument && argument !== header) throw actorNotAttested('argument_mismatch', caller, ctx);@@ -274,7 +277,10 @@ async function ownMemberArgument(engine: Pick<BrainEngine, 'executeRaw'>, input:argument: string, caller: ActorCaller, ctx: { op: string; transport?: string }): Promise<{ params: Record<string, unknown> }> {const own = input.transport === 'stdio' || input.audienceAsserted || !input.auth ? null: (await memberIdentityFor(engine, input.auth)).find(p => p.startsWith('member:'))?.slice('member:'.length) ?? null;- if (!own) throw actorNotAttested('argument_without_attestation', caller, ctx);+ if (!own) {+ const right = input.transport === 'stdio' ? null : await attestRightOf(engine, caller);+ throw actorNotAttested('argument_without_attestation', caller, { ...ctx, missing: right?.system === 'qm' ? [ACTOR_HEADER] : ['attest_right', ACTOR_HEADER] });+ }if (argument !== own && (await linkedMember(engine, 'qm', argument))?.member !== own) throw actorNotAttested('argument_mismatch', caller, { ...ctx, memberBound: true });const { [ACTOR_ARGUMENT]: _stripped, ...params } = input.params ?? {};return { params };diff --git a/src/core/behavior-change-notice.ts b/src/core/behavior-change-notice.tsindex 41a904873b..efaacb3ea1 100644--- a/src/core/behavior-change-notice.ts+++ b/src/core/behavior-change-notice.ts@@ -1415,7 +1415,7 @@ export const BEHAVIOR_CHANGES: ReadonlyArray<{ since: string; text: ChangeText;{ since: 'TBD', id: 'memory_recall_scope_read_gst1094', text: '`memory_recall` now takes `source_id` and `source_ids`. A call that names sources reads as their audience, never as the attested person: no own recent facts first and no fact from any member page; a page restricted to named readers stays hidden and `visibility: private` is never relaxed. A source outside the credential\'s read grant is refused (`permission_denied`) and `__all__` is refused (`invalid_params`). Without sources, `memory_recall` is unchanged. The contract is `docs/contracts/qm-memory-provider/v2.json`; `v1.json` is unchanged.' },{ since: 'TBD', id: 'member_bound_acting_user_gst900', text: 'A credential bound to a member may now send `acting_user` with no `x-qm-actor` header: its own member id, or a canonical id linked to that member, is dropped and the call runs exactly as the credential; any other value is refused (`actor_not_attested` reason `argument_mismatch`). A credential bound to no member is still refused (`argument_without_attestation`).' },{ since: 'TBD', id: 'qm_scope_writes_gst1113', text: '`memory_write` now takes `source_id`: a credential that lists the source in `gbrain auth rescope --attest-sources` saves the facts on that scope source\'s `memory/scope` page (`visibility: world`, attested to the person); any other source is refused (`permission_denied` reason `source_not_attested`, or `invalid_params` reason `source_is_member_source` for its own write source). Listing a source marks it a QM scope source for good: it is never federated (`sources federate` refuses, `sources restore` leaves it unfederated) and no other grant, token or registration may read it. Remote writes to `memory/scope` other than a scope `memory_write` are refused, and `memory_recall` without sources never reads a scope source.' },- { since: 'TBD', id: 'recall_question_terms_gst1304', text: '`recall` with a `question` over 12 content words (a provider\'s instruction preamble ahead of the turn) is now searched on its last 24 content words and scored on the 12 of those the fewest candidate facts hold, instead of on its first 12, so a keyword-only brain no longer returns no facts because the preamble filled the 12. Shorter questions rank as before. A response whose candidates all fell under the admission floor carries `facts_below_floor: <n>`, and a question over 2,000 characters is refused with reason `question_too_long` and detail `max_chars=2000 received_chars=<n>`.' },+ { since: 'TBD', id: 'recall_question_terms_gst1304', text: '`recall` with a `question` over 12 content words (a provider\'s instruction preamble ahead of the turn) is now searched on its last 24 content words and scored on the 12 of those the fewest candidate facts hold, instead of on its first 12, so a keyword-only brain no longer returns no facts because the preamble filled the 12. Shorter questions rank as before. A response whose candidates all fell under the admission floor carries `facts_below_floor: <n>`, and a question over 2,000 characters is refused with reason `question_too_long` and detail `max_chars=2000 received_chars=<n>`. `actor_not_attested` reason `argument_without_attestation` now names what the call lacked, in its message and in detail `missing=attest_right`, `missing=x-qm-actor` or both; QM tools also carry `detail` in `structuredContent.error`.' },{ since: 'TBD', id: 'recall_max_chars_harn15', text: '`recall` now takes `max_chars` (a whole number from 200 to 12000, as `memory_recall`): it keeps the whole facts, then results, whose text fits, adds no marker and returns `truncated`; without it `recall` is unchanged.' },{ since: 'TBD', id: 'unknown_param_meta_only_harn15', text: 'A read that ignores a parameter the tool does not declare (`mcp.strict_params` `warn`, the default) no longer adds a `[gbrain notice unknown_param kind=info]` text block to the result: the warning is only in `_meta.warnings` (`{code: \'unknown_param\', param, suggestion?}`), so a harness that stores tool output in its turns never stores it. Writes still refuse unknown parameters, and `reject` mode is unchanged.' },];diff --git a/src/core/ops/qm-memory.ts b/src/core/ops/qm-memory.tsindex c08a2bb48a..6384cb090e 100644--- a/src/core/ops/qm-memory.ts+++ b/src/core/ops/qm-memory.ts@@ -320,7 +320,7 @@ const memory_write: Operation = {/*** A successful memory_recall or memory_write result as QM reads it: the model's text alone in `content` (notices stay* in `_meta.gbrain_notices`, so memory_recall's text stays within max_chars) and the result in `structuredContent`.- * A refusal keeps its JSON text block and gains `structuredContent.error` (code, message, reason, fix), as the actor+ * A refusal keeps its JSON text block and gains `structuredContent.error` (code, message, reason, detail, fix), as the actor* refusals carry it, so QM classifies every error from structuredContent. Dry runs and every other tool pass through.*/export function qmMemoryToolResult<T extends { content: Array<{ type: 'text'; text: string }>; isError?: boolean; structuredContent?: Record<string, unknown> }>(name: string, out: T): T {@@ -330,7 +330,7 @@ export function qmMemoryToolResult<T extends { content: Array<{ type: 'text'; teif (out.isError) {if (out.structuredContent || !result || typeof result !== 'object') return out;const env = result as Record<string, unknown>;- return { ...out, structuredContent: { error: { code: env.code, message: env.message, ...(env.reason ? { reason: env.reason } : {}), ...(env.write_error ? { write_error: env.write_error } : {}), ...(env.fix ? { fix: env.fix } : {}) } } };+ return { ...out, structuredContent: { error: { code: env.code, message: env.message, ...(env.reason ? { reason: env.reason } : {}), ...(env.detail ? { detail: env.detail } : {}), ...(env.write_error ? { write_error: env.write_error } : {}), ...(env.fix ? { fix: env.fix } : {}) } } };}if (!result || typeof result !== 'object' || 'dry_run' in result) return out;const { text, ...structured } = result as Record<string, unknown>;diff --git a/src/mcp/dispatch.ts b/src/mcp/dispatch.tsindex 1c9727cc2e..539caa3c5a 100644--- a/src/mcp/dispatch.ts+++ b/src/mcp/dispatch.ts@@ -974,11 +974,11 @@ function actorRefusal(e: OperationError, opts: DispatchOpts, op: string, header:return withStructuredError(errorResult(e, opts, { op }));}-/** An error result with its JSON envelope's code, message, reason and fix also in `structuredContent.error`, which QM reads. */+/** An error result with its JSON envelope's code, message, reason, detail and fix also in `structuredContent.error`, which QM reads. */function withStructuredError(out: ToolResult): ToolResult {try {const env = JSON.parse(out.content[0]!.text) as Record<string, unknown>;- out.structuredContent = { error: { code: env.code, message: env.message, ...(env.reason ? { reason: env.reason } : {}), ...(env.fix ? { fix: env.fix } : {}) } };+ out.structuredContent = { error: { code: env.code, message: env.message, ...(env.reason ? { reason: env.reason } : {}), ...(env.detail ? { detail: env.detail } : {}), ...(env.fix ? { fix: env.fix } : {}) } };} catch { /* the text block still carries the code */ }return out;}diff --git a/test/qm-memory-contract.test.ts b/test/qm-memory-contract.test.tsindex ea95e2d9fb..cd4e8c9164 100644--- a/test/qm-memory-contract.test.ts+++ b/test/qm-memory-contract.test.ts@@ -106,4 +106,12 @@ describe('QM memory-provider contract v2 (GST-1094 scope read, GST-900)', () =>expect(scopeWrite.saved_as).toMatchObject({ page: 'memory/scope', visibility: 'world' });expect(scopeWrite.rule).toContain('attest_sources');});++ test('it says what an over-long query, an over-long recall question and an unattested acting_user get (GST-1304)', () => {+ expect(fixture.memory_recall.arguments_checked).toContain('a longer query is ranked on its first 2000 characters and never refused');+ const notes = Object.fromEntries(fixture.errors.codes.map((c: { code: string; note?: string }) => [c.code, c.note]));+ expect(notes.invalid_params).toContain('question_too_long');+ const reasons = fixture.errors.codes.find((c: { code: string }) => c.code === 'actor_not_attested').reasons;+ expect(reasons.find((r: { reason: string }) => r.reason === 'argument_without_attestation').fix).toContain('detail missing=');+ });});diff --git a/test/qm-memory-tools.test.ts b/test/qm-memory-tools.test.tsindex 0aff9c570e..b81979318e 100644--- a/test/qm-memory-tools.test.ts+++ b/test/qm-memory-tools.test.ts@@ -715,6 +715,33 @@ for (const kind of testBackends()) {expect((hidden.structuredContent as { error: { code: string } }).error.code).toBe('unknown_tool');}, 60_000);+ test('acting_user without attestation names what is missing in detail: the header, the attest right, or both (GST-1304)', async () => {+ const cases: Array<[Who, string]> = [+ [{ token: 'qm' }, 'missing=x-qm-actor'],+ [{ token: 'plain' }, 'missing=attest_right,x-qm-actor'],+ [{ token: 'plain', actor: ALICE_ID }, 'missing=attest_right'],+ ];+ for (const [as, detail] of cases) {+ const out = await call(as, 'memory_recall', { query: 'harbor ledger', acting_user: ALICE_ID });+ expect(out.json).toMatchObject({ code: 'actor_not_attested', reason: 'argument_without_attestation', detail });+ expect(out.structured?.error).toMatchObject({ code: 'actor_not_attested', reason: 'argument_without_attestation', detail });+ }+ const qmOnly = await call({ token: 'qm' }, 'memory_recall', { query: 'harbor ledger', acting_user: ALICE_ID });+ expect(qmOnly.json.message).toContain('x-qm-actor');+ expect(qmOnly.json.message).not.toContain('attest right');+ }, 60_000);++ test('a memory_recall query over query_chars_ranked is ranked on its first 2,000 characters, never refused (v1 contract; GST-1304)', async () => {+ expect((await write(alice, [{ fact: 'Alice audits the harbor ledger canarylongquery', provenance: 'x' }])).structured!.status).toBe('committed');+ const head = 'harbor ledger budget canarylongquery ';+ const out = await recall(alice, head + 'filler words that pad the question '.repeat(80));+ expect(out.isError).toBe(false);+ expect(out.json.code).toBeUndefined();+ expect(out.text).toContain('canarylongquery');+ const tailOnly = await recall(alice, 'filler words that pad the question '.repeat(60) + ' harbor ledger budget');+ expect(tailOnly.isError).toBe(false);+ }, 60_000);+test('a keyless brain ranks by keyword and makes no embedding call', async () => {let embedCalls = 0;try {