Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

fix: agent-contract key naming, function and module size budgets

garrytanabfb2cf54e34
diff --git a/docs/guides/retrieval-feedback.md b/docs/guides/retrieval-feedback.md
index 660834c9a6..abc45a7db2 100644
--- a/docs/guides/retrieval-feedback.md
+++ b/docs/guides/retrieval-feedback.md
@@ -84,7 +84,7 @@ gbrain config set feedback.learn false # keep learned weights, stop learning
| `feedback.alpha` | 0.1 | Learning rate; the citation signal uses half. |
| `feedback.max_ratings_per_hour` | 120 | Rating calls per client per hour. |
| `feedback.event_retention_days` | 30 | How long answers stay rateable. |
-| `feedback.hint` | true | Show the one-line rating hint on answers. |
+| `feedback.rating_prompt` | true | Show the one-line `how_to_rate` line on answers. |
## Refusals
diff --git a/docs/protocol/MEMORY_VERBS_v1.md b/docs/protocol/MEMORY_VERBS_v1.md
index a938febd12..e2e902d975 100644
--- a/docs/protocol/MEMORY_VERBS_v1.md
+++ b/docs/protocol/MEMORY_VERBS_v1.md
@@ -380,7 +380,7 @@ budget is distinguishable from malformed model output.
#### Answer feedback fields (additive)
`recall` (when its `query` arm searched pages on the hybrid path) and
-`synthesize` add `answer_id` (`ans_…`) and `feedback: { rateable: true, hint? }`
+`synthesize` add `answer_id` (`ans_…`) and `feedback: { rateable: true, how_to_rate? }`
when the caller may change this brain's shared ranking and retrieval feedback is
on. Callers that cannot rate see no new fields. Pass the id to the `rate_answer`
operation to rate how useful the answer's evidence was; see
diff --git a/scripts/module-size-limits.tsv b/scripts/module-size-limits.tsv
index 0960cfb2d1..d0a8c4bde7 100644
--- a/scripts/module-size-limits.tsv
+++ b/scripts/module-size-limits.tsv
@@ -22,8 +22,8 @@ src/core/migrate.ts 602 ratchet schema-migration runner only; migrations live in
src/core/operations.ts 338 ratchet peel target: containment sprint C4-C7; grown v0.46.26.0 megawave op wiring; +chat-connectors wiring (master merge); +5 v0.47 gmail-loops: loopsOperations spread + OP_AREAS; #5105: receipt operation registry wiring; shared-skills integration on company-ingestion base; +2 security wave: withOutputRedaction applied at op registration; +1 #5616: pageEditOperations import (spread shares the pages line); +1 Foundations 1 F1b: attributionOperations import (spread shares the admin line); +1 agent operator wave A6: ops/notices.ts import (mute_notice); +2 agent operator closeout A1: registerOpRoutes import + call (routing logic in fix-routing.ts); +2 retrieval feedback: feedbackOperations import and spread (ops/feedback.ts)
src/core/pglite-engine.ts 2926 ratchet +5 agent operator gate fixes: repair-failed marker gate before the lock and the marker record after a failed auto-repair (logic in pglite-repair.ts, refusal in pglite-repair-consent.ts); +1 System One v1 evals: search arms clamp to searchLimitCap() (import of search/eval-pool-depth.ts; eval-only --eval-pool-depth, production cap unchanged); refactor wave 1 split target (W1 engine-sql); E1 bootstrap moved to engine-sql/bootstrap.ts; ceiling rationale: docs/architecture/key-files/engines-1.md entry for src/core/pglite-engine.ts; evidence delivery: getChunkWindows delegate + type import (+3; SQL in engine-sql/chunks.ts); #5761: +4 markPagesAttendanceBlocked delegate (SQL in engine-sql/pages.ts); +12 eval wave N1-2/N1-3: mergeOntologyFact same-stint noop check + ontology visibility filter in the grandfathered ontology methods; lowered to 3213 #5824: searchVector SQL moved to search/vector-statement.ts (-166); lowered to 3117 #5889: searchTitles SQL moved to engine-sql/titles.ts (-108); lowered to 2915 F4a: getHealth SQL moved to engine-sql/health.ts (-202); +6 F4b: planner-sensitive reads call beforePlannerRead/plannerRead (logic in planner-stats.ts)
src/core/postgres-engine.ts 2917 ratchet +1 System One v1 evals: search arms clamp to searchLimitCap() (import of search/eval-pool-depth.ts; eval-only --eval-pool-depth, production cap unchanged); refactor wave 1 split target (W1 engine-sql); ceiling rationale: docs/architecture/key-files/engines-2.md entry for src/core/postgres-engine.ts; evidence delivery: getChunkWindows scoped-read delegate + type import (+5; SQL in engine-sql/chunks.ts); #5761: +4 markPagesAttendanceBlocked delegate (SQL in engine-sql/pages.ts); +10 eval wave N1-2/N1-3: mergeOntologyFact same-stint noop check + ontology visibility filter in the grandfathered ontology methods; lowered to 3242 #5824: searchVector SQL moved to search/vector-statement.ts, +explainVectorSearch/runVectorAttempt (-156); +6 #5730: onpoisoned wiring on the instance/module/connection-manager pools + poisonedDiscards in getPoolDiagnostics (counter in pool-gauge.ts); +5 #5801: onCheckout observer seam (fires after reserve resolution / transaction-callback entry; listeners in pool-gauge.ts); lowered to 3119 #5889: searchTitles SQL moved to engine-sql/titles.ts (-133); lowered to 2914 F4a: getHealth SQL moved to engine-sql/health.ts (-216); +2 #5984: transactions track held page guards like PGLite (withHeldPageKeys), so repeated guards in one transaction cost no round trips; +1 #5984: traceSqlOptions import for the env-gated GBRAIN_SQL_TRACE bench hook (src/core/sql-trace.ts); v0.60.48.0 merge: #5984 growth re-summed over v0.60.47.0 (2917 measured)
-src/core/search/hybrid.ts 1584 ratchet +2 System One v1: HybridSearchOpts.decide (search/decide-stage.ts); refactor wave 1 split target (W4 hybrid, cut line); ceiling rationale: docs/architecture/key-files/core-search-1.md entry for src/core/search/hybrid.ts; +10 #5691: per-request embedding_query_prefix read once and threaded to the embeds and cache key
-src/core/types.ts 2134 ratchet +5 System One v1 retrieval lane: SearchResult injection_p/injection_suspected, HybridSearchMeta answerability, egress_denied degraded reason; +4 System One v1: SearchResult rerank_score_kind/decide_evidence, HybridSearchMeta decide/rerank; +3 wave review: PAGE_SORT_SQL.updated_asc source_id + id tiebreakers (total order under federated scopes); +5 #4881: OntologyReadOpts extends PageReadScope doc; +3 #4857: PAGE_SORT_SQL.slug total-order tiebreaker comment; grown v0.46.26.0 megawave: EvidenceOpts, pacing/usage result fields, PageFilters growth (#4352 #4218); wave-k: +9 SalienceOpts/AnomaliesOpts source scope (#3867); +20 2026-09 adversarial batch 2: keyword_relaxed_carried stage + relaxed_dropped meta field docs; +16 2026-09 fix wave: SearchResult.keyword_relaxed field + full fusion-demotion doc; (#3867); +9: #4648 rerank_passthrough degraded stage + empty_result_set/malformed_shape reasons | merged v0.48.1.0 true-up; +master v0.48 merge true-up (reranker succession: no_key preflight, reranker_skipped stage, readiness); corrective release: shared internal PageReadScope and PageReadPolicy; ranker wave v0.48.4.0: HybridSearchMeta relational_rerank_pin / keyword_arm_confidence / metadata_boost_gate + SearchResult.relational_pinned (+48 over master's peel); +12: #4681 Page.updated_at_iso + keyset cursor precision docs; #5105: canonical page state shared module and transaction/snapshot delegates; #5105: public page revision fields; upstream integration: preserve independently reviewed master additions with branch facade extraction; #5252 wave: typed vector pool and readiness metadata; merged company ingestion/schema routing changes; retired provider integration removed; +1 write-path wave: 'created' effective-date source; +3 read-path wave: rerank_failed degraded stage + budget reason (closed vocabularies) and its recall classification note; +8 fw3-search: SearchOpts.source_boosts + keyword_arm_failed/title_arm_failed stages; +2 wave-2 W4: ChunkInput.embedding_input_hash (#5553); fix wave 3 x fix wave 2 (v0.60.5.0) composition: +2 at the merge; evidence delivery: optional SearchResult.delivered (+2; shape in search/evidence-delivery.ts); +2 eval wave N1-3: OntologyReadOpts.visibility (remote world-only ontology reads); +4 #5827: GraphNode.source_id and GraphPath from_source_id/to_source_id; +2 #5824: SearchOpts.vectorLegacyGuard rollback switch; +7 #5154: PageFilters.listColumnsOnly (interface field); +11 Foundations 1 F1b: WriteAttributionView + AttributedPageVersion (get_versions / get_write_attribution read shapes); +1 #5988: SearchResult.stale carries the held-file detail (interface field); +10 retrieval feedback: SearchResult feedback_boost/content_hash/triplet/relational_path_edges stamps and RelationalFanoutRow.path_edges (interface fields)
+src/core/search/hybrid.ts 1586 ratchet +2 System One v1: HybridSearchOpts.decide (search/decide-stage.ts); refactor wave 1 split target (W4 hybrid, cut line); ceiling rationale: docs/architecture/key-files/core-search-1.md entry for src/core/search/hybrid.ts; +10 #5691: per-request embedding_query_prefix read once and threaded to the embeds and cache key; +2 triplet scoring: scoreRelationalArm before the keyword-only and vector-fallback returns (logic in hybrid/arms.ts + search/triplet-score.ts)
+src/core/types.ts 2136 ratchet +5 System One v1 retrieval lane: SearchResult injection_p/injection_suspected, HybridSearchMeta answerability, egress_denied degraded reason; +4 System One v1: SearchResult rerank_score_kind/decide_evidence, HybridSearchMeta decide/rerank; +3 wave review: PAGE_SORT_SQL.updated_asc source_id + id tiebreakers (total order under federated scopes); +5 #4881: OntologyReadOpts extends PageReadScope doc; +3 #4857: PAGE_SORT_SQL.slug total-order tiebreaker comment; grown v0.46.26.0 megawave: EvidenceOpts, pacing/usage result fields, PageFilters growth (#4352 #4218); wave-k: +9 SalienceOpts/AnomaliesOpts source scope (#3867); +20 2026-09 adversarial batch 2: keyword_relaxed_carried stage + relaxed_dropped meta field docs; +16 2026-09 fix wave: SearchResult.keyword_relaxed field + full fusion-demotion doc; (#3867); +9: #4648 rerank_passthrough degraded stage + empty_result_set/malformed_shape reasons | merged v0.48.1.0 true-up; +master v0.48 merge true-up (reranker succession: no_key preflight, reranker_skipped stage, readiness); corrective release: shared internal PageReadScope and PageReadPolicy; ranker wave v0.48.4.0: HybridSearchMeta relational_rerank_pin / keyword_arm_confidence / metadata_boost_gate + SearchResult.relational_pinned (+48 over master's peel); +12: #4681 Page.updated_at_iso + keyset cursor precision docs; #5105: canonical page state shared module and transaction/snapshot delegates; #5105: public page revision fields; upstream integration: preserve independently reviewed master additions with branch facade extraction; #5252 wave: typed vector pool and readiness metadata; merged company ingestion/schema routing changes; retired provider integration removed; +1 write-path wave: 'created' effective-date source; +3 read-path wave: rerank_failed degraded stage + budget reason (closed vocabularies) and its recall classification note; +8 fw3-search: SearchOpts.source_boosts + keyword_arm_failed/title_arm_failed stages; +2 wave-2 W4: ChunkInput.embedding_input_hash (#5553); fix wave 3 x fix wave 2 (v0.60.5.0) composition: +2 at the merge; evidence delivery: optional SearchResult.delivered (+2; shape in search/evidence-delivery.ts); +2 eval wave N1-3: OntologyReadOpts.visibility (remote world-only ontology reads); +4 #5827: GraphNode.source_id and GraphPath from_source_id/to_source_id; +2 #5824: SearchOpts.vectorLegacyGuard rollback switch; +7 #5154: PageFilters.listColumnsOnly (interface field); +11 Foundations 1 F1b: WriteAttributionView + AttributedPageVersion (get_versions / get_write_attribution read shapes); +1 #5988: SearchResult.stale carries the held-file detail (interface field); +10 retrieval feedback: SearchResult feedback_boost/content_hash/triplet/relational_path_edges stamps and RelationalFanoutRow.path_edges (interface fields); +2 RelationalFanoutOpts.wide (interface field)
src/core/minions/queue.ts 2522 ratchet grown #4078 + megawave probe-liveness unlatch (#4310) + master private-queue lifecycle: recovery classifier + monotonic lease; security: durable queued authority and confined filesystem dispatch; master integration: grown #4078 + megawave probe-liveness unlatch (#4310) + master private-queue lifecycle: recovery classifier + monotonic lease; harness support: boundary wiring to shared grants, isolated setup, withdrawal and delegated guards; merged v0.49: durable authority and delegated admission both enforced; typed readiness, configuration-blocked lifecycle and bounded release; +9: prune archives completed dream synthesis keys
src/commands/init.ts 1869 ratchet grown v0.46.x keyless capability notices; grown db-availability loop: initPostgresCore typed-failure extraction + --prefer-postgres ladder hook + pgvector rethrow fix; +1 at megawave/wave-k merge; +master-merge true-up; wave-k: merge; #3753 --force re-init engine-preservation guard; +1 wave-k merge-union brace (--prefer-postgres close); +10 ambient-writeback WP8: runWritebackNudge consent ask in both engine epilogues (logic lives in core/onboard/writeback-nudge.ts); +4: v0.48.2 reranker readiness at init + test seam; +1: v0.48.2 provider normalization; +3: v0.48.2 review fixes; master integration: +2: preserve typed PGLite busy errors in schema-only init; shared-skills integration on company-ingestion base; retired provider integration removed; retain stored-vector identity on re-init; -14: first-run bundle + quickstart registration helpers live in init-first-run.ts (writeback/skills asks folded into the bundle)
src/commands/integrations.ts 1739 ratchet grown v0.46.26.0 megawave (#4039 connector compat) + 1 nosemgrep dataflow annotation (path-traversal audit); wave-k: exported heartbeatPath seam (#3900)
diff --git a/src/core/feedback/record.ts b/src/core/feedback/record.ts
index e94d3c6677..7d73ce55ab 100644
--- a/src/core/feedback/record.ts
+++ b/src/core/feedback/record.ts
@@ -74,7 +74,7 @@ export function canTeachSource(
export interface AnswerFeedbackMeta {
answer_id?: string;
- feedback: { rateable: boolean; reason?: 'not_authorized' | 'disabled' | 'empty'; hint?: string };
+ feedback: { rateable: boolean; reason?: 'not_authorized' | 'disabled' | 'empty'; how_to_rate?: string };
}
type Job =
@@ -205,10 +205,10 @@ export async function recordAnswer(ctx: OperationContext, input: RecordAnswerInp
enqueue(ctx.engine, { kind: 'cited', eventId: id, clientId, alpha: settings.alpha, pages: cited });
}
const meta: AnswerFeedbackMeta = { answer_id: id, feedback: { rateable: true } };
- if (settings.hint) {
+ if (settings.ratingPrompt) {
const n = answersSinceHint.get(clientId) ?? 0;
if (n % HINT_EVERY === 0) {
- meta.feedback.hint = `Rate this answer after you use it: rate_answer { answer_id: "${id}", rating: 1-5 } (or pages: [{ ref, rating }] for single pages). Ratings tune this brain's ranking.`;
+ meta.feedback.how_to_rate = `Rate this answer after you use it: rate_answer { answer_id: "${id}", rating: 1-5 } (or pages: [{ ref, rating }] for single pages). Ratings tune this brain's ranking.`;
}
answersSinceHint.set(clientId, n + 1);
}
@@ -267,3 +267,16 @@ export async function recordThinkAnswer(
pages: evidence.map(e => ({ ...e, cited: citedSlugs.has(e.slug) && sourcesBySlug.get(e.slug) === 1 })),
});
}
+
+/** Record a search-shaped answer (rows as returned) and return its additive meta fields. */
+export async function searchAnswerFeedback(
+ ctx: OperationContext,
+ op: 'query' | 'search' | 'recall',
+ rows: Array<{ slug: string; source_id?: string; content_hash?: string | null; relational_path_edges?: string[] }>,
+): Promise<Record<string, unknown>> {
+ return feedbackMetaFields(await recordAnswer(ctx, {
+ op,
+ pages: rows.map(r => ({ source_id: r.source_id, slug: r.slug, content_hash: r.content_hash })),
+ links: relationalPathLinks(rows),
+ }));
+}
diff --git a/src/core/feedback/settings.ts b/src/core/feedback/settings.ts
index d5ed213160..75e84c3f99 100644
--- a/src/core/feedback/settings.ts
+++ b/src/core/feedback/settings.ts
@@ -17,8 +17,8 @@ export interface FeedbackSettings {
alpha: number;
maxRatingsPerHour: number;
eventRetentionDays: number;
- /** Emit the one-line rating hint on answers. */
- hint: boolean;
+ /** Show the one-line "how to rate" line on answers. */
+ ratingPrompt: boolean;
}
export const FEEDBACK_DEFAULTS: FeedbackSettings = Object.freeze({
@@ -29,7 +29,7 @@ export const FEEDBACK_DEFAULTS: FeedbackSettings = Object.freeze({
alpha: 0.1,
maxRatingsPerHour: 120,
eventRetentionDays: 30,
- hint: true,
+ ratingPrompt: true,
});
export const FEEDBACK_CONFIG_KEYS = [
@@ -40,7 +40,7 @@ export const FEEDBACK_CONFIG_KEYS = [
'feedback.alpha',
'feedback.max_ratings_per_hour',
'feedback.event_retention_days',
- 'feedback.hint',
+ 'feedback.rating_prompt',
] as const;
const CACHE_TTL_MS = 30_000;
@@ -71,7 +71,7 @@ export async function loadFeedbackSettings(engine: BrainEngine): Promise<Feedbac
return null;
}
};
- const [enabled, learn, influence, implicit, alpha, maxRatings, retention, hint] = await Promise.all(
+ const [enabled, learn, influence, implicit, alpha, maxRatings, retention, ratingPrompt] = await Promise.all(
FEEDBACK_CONFIG_KEYS.map(read),
);
const d = FEEDBACK_DEFAULTS;
@@ -83,7 +83,7 @@ export async function loadFeedbackSettings(engine: BrainEngine): Promise<Feedbac
alpha: parseNumber(alpha, d.alpha, 0.001, 1),
maxRatingsPerHour: Math.round(parseNumber(maxRatings, d.maxRatingsPerHour, 1, 100_000)),
eventRetentionDays: Math.round(parseNumber(retention, d.eventRetentionDays, 1, 3650)),
- hint: parseBool(hint, d.hint),
+ ratingPrompt: parseBool(ratingPrompt, d.ratingPrompt),
};
cache = { ts: now, engine, value };
return value;
diff --git a/src/core/ops/facts.ts b/src/core/ops/facts.ts
index 146b96af22..26e4285d53 100644
--- a/src/core/ops/facts.ts
+++ b/src/core/ops/facts.ts
@@ -1,4 +1,4 @@
-import { feedbackMetaFields, recordAnswer, relationalPathLinks } from '../feedback/record.ts';
+import { searchAnswerFeedback } from '../feedback/record.ts';
import { WRITE_REQUEST_PARAM } from '../persistence/params.ts';
import { deliverEvidence, effectivePlan, resolveEvidencePlan, type DeliveryMeta, type EvidencePlan } from '../search/evidence-delivery.ts';
import { randomUUID } from 'node:crypto';
@@ -564,11 +564,7 @@ const recall: Operation = {
...(r.delivered ? { delivered: r.delivered } : {}),
})),
...(searchDegraded ? { search_degraded: searchDegraded } : {}),
- ...(searchDegraded ? {} : feedbackMetaFields(await recordAnswer(ctx, {
- op: 'recall',
- pages: packedResults.map(r => ({ source_id: r.source_id, slug: r.slug, content_hash: r.content_hash })),
- links: relationalPathLinks(packedResults),
- }))),
+ ...(searchDegraded ? {} : await searchAnswerFeedback(ctx, 'recall', packedResults)),
}
: {}),
...(budgetTokens !== null
diff --git a/src/core/ops/search.ts b/src/core/ops/search.ts
index 8b747b605d..07cac55f46 100644
--- a/src/core/ops/search.ts
+++ b/src/core/ops/search.ts
@@ -1,4 +1,4 @@
-import { feedbackMetaFields, recordAnswer, relationalPathLinks } from '../feedback/record.ts';
+import { searchAnswerFeedback } from '../feedback/record.ts';
import { readHolders } from './context.ts';
/**
* Search operation cluster (search + query) — pure move from operations.ts
@@ -455,11 +455,7 @@ async function buildRetrievalResponseMeta(
...(aliases.length ? { other_names: aliases } : {}),
...(heldFiles.length ? { held_files: heldFiles } : {}),
...(hint || readiness.hint ? { hint: [hint, readiness.hint].filter(Boolean).join(' ') } : {}),
- ...(opts.feedbackOp ? feedbackMetaFields(await recordAnswer(ctx, {
- op: opts.feedbackOp,
- pages: (results as SearchResult[]).map(r => ({ source_id: r.source_id, slug: r.slug, content_hash: r.content_hash })),
- links: relationalPathLinks(results as SearchResult[]),
- })) : {}),
+ ...(opts.feedbackOp ? await searchAnswerFeedback(ctx, opts.feedbackOp, results as SearchResult[]) : {}),
};
}
diff --git a/test/feedback-store.test.ts b/test/feedback-store.test.ts
index 08923030b9..263dcb1040 100644
--- a/test/feedback-store.test.ts
+++ b/test/feedback-store.test.ts
@@ -178,7 +178,7 @@ describe('recordAnswer', () => {
});
expect(meta?.feedback.rateable).toBe(true);
expect(meta?.answer_id).toMatch(/^ans_/);
- expect(meta?.feedback.hint).toContain('rate_answer');
+ expect(meta?.feedback.how_to_rate).toContain('rate_answer');
await drainFeedbackQueue(5000);
const weights = await readWeights(engine, 'page', [
{ source_id: 'default', key: 'notes/meeting-example' }, { source_id: 'default', key: 'people/alice-example' },