Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

fix: pre-landing review fixes

garrytan4f4d0cad684a
diff --git a/CHANGELOG.md b/CHANGELOG.md
index d6cb94fd89..f9cea9c6d6 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -14,7 +14,7 @@ identifiers and attribution are available in the pre-removal Git revision
**A page a maintenance job writes from model output keeps its trust tier when the repository is read back (#7905).**
-Patterns, concept and claim-source runs publish their pages as maintenance writes (`submit_job`). The database row was capped at the tier the run declared, at most agent-written, but the file committed to git carried no `trust_tier` marker, and a forged higher marker in the model's text passed through as written. Reading that file back (rebuilding a brain from its repository, or a second brain importing it) rated the page at the source default, operator-curated, so model-written text came back trusted as the owner's own notes. These pages now stamp the same lower-only marker an agent's content write stamps, at the declared tier. A brain with no repository has no file to read back and was not affected. Nothing rewrites pages already stored: a derived page published before this release gets its marker the next time a run republishes it.
+Patterns, concept and claim-source runs publish their pages as maintenance writes (`submit_job`). The database row was capped at the tier the run declared, at most agent-written, but the file committed to git carried no `trust_tier` marker, and a forged higher marker in the model's text passed through as written. Reading that file back (rebuilding a brain from its repository, or a second brain importing it) rated the page at the source default, operator-curated, so model-written text came back trusted as the owner's own notes. These pages now stamp the same lower-only marker an agent's content write stamps, at the declared tier. A page outside the run's output that a patterns run republishes to repair a timeline entry it appended (dropping or normalizing an unverified quote) carries the same declaration, so it gets the marker too, matching the tier the database already gave it. A brain with no repository has no file to read back and was not affected. Nothing rewrites pages already stored: a derived page published before this release gets its marker the next time a run republishes it.
### Itemized changes
diff --git a/test/maintenance-trust-marker-7905.test.ts b/test/maintenance-trust-marker-7905.test.ts
index 7a5a3b4841..272ac317c3 100644
--- a/test/maintenance-trust-marker-7905.test.ts
+++ b/test/maintenance-trust-marker-7905.test.ts
@@ -21,6 +21,7 @@ import { importFromFile } from '../src/core/import-file.ts';
import { parseMarkdown } from '../src/core/markdown.ts';
import { PGLiteEngine } from '../src/core/pglite-engine.ts';
import { maintenancePreflight, publishMaintenancePages } from '../src/core/persistence/prepared-maintenance.ts';
+import { stampPageTrustMarker } from '../src/core/trust/page-write.ts';
import { declareDerivation } from '../src/core/trust/taint.ts';
import type { TrustTier } from '../src/core/trust/tier.ts';
import { managedBrain, settleManagedGitEffects } from './helpers/managed-brain.ts';
@@ -85,3 +86,28 @@ for (const backend of testBackends()) {
}, { databaseUrl }), 120_000);
});
}
+
+// Value: protects=the marker rule's exclusions and lower-only cap on the derivation branch; fails_when=the fence-edit or declaration guard is dropped, or the stored tier no longer caps; why_new=the managed cases above cover declared submit_job pages only; seam=none; no_claim=none beyond protects
+describe('#7905 stampPageTrustMarker: which writes stamp, and at what tier', () => {
+ const derivation = declareDerivation({ tier: 'agent_written', origin: { channel: 'derive:patterns' } }, []);
+ const trust = { tier: 'agent_written' as const, origin: { channel: 'derive:patterns' } };
+ const stamp = (row: Record<string, unknown>, stored: TrustTier | null = null) => {
+ const fm: Record<string, unknown> = {};
+ stampPageTrustMarker(row as never, fm, trust, stored);
+ return fm.trust_tier;
+ };
+
+ test('a declared maintenance page stamps the declared tier', () => {
+ expect(stamp({ operation: 'submit_job', intent: { kind: 'managed_maintenance_page', derivation } })).toBe('agent_written');
+ });
+ test('a maintenance write with no derivation declaration stamps nothing', () => {
+ expect(stamp({ operation: 'submit_job', intent: { kind: 'managed_maintenance_page' } })).toBeUndefined();
+ });
+ test('a fence edit keeps the page tier even when it carries a derivation declaration', () => {
+ expect(stamp({ operation: 'submit_job', intent: { kind: 'managed_facts_entity', derivation } })).toBeUndefined();
+ expect(stamp({ operation: 'takes_add', intent: { derivation } })).toBeUndefined();
+ });
+ test('a declared republication onto a lower stored tier keeps the lower tier', () => {
+ expect(stamp({ operation: 'submit_job', intent: { kind: 'managed_maintenance_page', derivation } }, 'external_untrusted')).toBe('external_untrusted');
+ });
+});