Skip to content

sno-ai/sno-station-skills / skills/R-recursive-self-improvement/rem-reflect/skill

rem-reflect

Verified

Self Learning from this machine's Claude Code, Codex, Hermes, OpenClaw and Cursor sessions. Decide skill changes and lessons with accept/reject/tbd; recall lessons at session start.

FileKindSize
SKILL.mdskill md14.1 KB
references/labeler.mdmarkdown1.2 KB
references/labeler.schema.jsonconfig1.7 KB
references/local-settings.jsonconfig126 B
references/local-writer.schema.jsonconfig2.3 KB
references/proposal.schema.jsonconfig3.2 KB
references/render.jsonconfig245 B
references/signals.jsonconfig71 B
references/text.jsonconfig4.0 KB
scripts/adopt.test.tsscript13.0 KB
scripts/adopt.tsscript14.3 KB
scripts/agent-sessions.tsscript9.1 KB
scripts/allowance-fallback.test.tsscript16.0 KB
scripts/allowance-request-isolation.test.tsscript7.1 KB
scripts/backend.tsscript9.1 KB
scripts/calls.tsscript8.6 KB
scripts/catalogue-cloud.test.tsscript1.5 KB
scripts/catalogue.tsscript3.2 KB
scripts/chunk.tsscript2.1 KB
scripts/cloud-apply.test.tsscript25.2 KB
scripts/cloud-batch.test.tsscript11.2 KB
scripts/cloud-day.test.tsscript6.8 KB
scripts/cloud-verdict.test.tsscript12.1 KB
scripts/cloud-wait.test.tsscript1.3 KB
scripts/cloud.tsscript24.4 KB
scripts/config.tsscript8.1 KB
scripts/cursor.test.tsscript16.1 KB
scripts/cursor.tsscript6.7 KB
scripts/evidence.tsscript1.5 KB
scripts/first-message.test.tsscript10.3 KB
scripts/harvest.test.tsscript16.5 KB
scripts/harvest.tsscript22.6 KB
scripts/hermes-openclaw.test.tsscript25.6 KB
scripts/identity.test.tsscript3.3 KB
scripts/identity.tsscript3.5 KB
scripts/installed-roots.test.tsscript11.0 KB
scripts/journey-adopt-lesson.test.tsscript4.1 KB
scripts/journey-ops.test.tsscript8.0 KB
scripts/labeler.test.tsscript3.6 KB
scripts/labeler.tsscript9.5 KB
scripts/ledger.tsscript2.1 KB
scripts/lessons.tsscript4.7 KB
scripts/local-filter.test.tsscript3.9 KB
scripts/local-first-output.test.tsscript23.5 KB
scripts/local-settings.tsscript1.4 KB
scripts/local-writer.tsscript12.7 KB
scripts/login-in-place.test.tsscript5.8 KB
scripts/model-json.tsscript4.1 KB
scripts/no-network.test.tsscript5.0 KB
scripts/observe.tsscript1.4 KB
scripts/page-journey.test.tsscript6.7 KB
scripts/pages.test.tsscript4.1 KB
scripts/pages.tsscript4.8 KB
scripts/proposer-loop.test.tsscript1.5 KB
scripts/proposer-validate.test.tsscript9.1 KB
scripts/proposer.tsscript8.7 KB
scripts/recall-hook.test.tsscript20.9 KB
scripts/recall.test.tsscript31.4 KB
scripts/recall.tsscript18.2 KB
scripts/reflect.test.tsscript9.3 KB
scripts/reflect.tsscript14.3 KB
scripts/rem-reflectexecutablescript823 B
scripts/rem-reflect.tsscript17.8 KB
scripts/render-chunk.test.tsscript7.2 KB
scripts/render.tsscript9.7 KB
scripts/report.tsscript8.2 KB
scripts/run-status.test.tsscript19.1 KB
scripts/sampling.test.tsscript2.1 KB
scripts/sampling.tsscript915 B
scripts/selftest-guard.test.tsscript4.2 KB
scripts/selftest/bin/claudeexecutablescript94 B
scripts/selftest/bin/codexexecutablescript93 B
scripts/selftest/bin/shim-core.cjsscript4.6 KB
scripts/selftest/bin/snoexecutablescript5.7 KB
scripts/selftest/fixtures/hermes-session-export.jsonlother1.5 KB
scripts/selftest/fixtures/openclaw-events.jsonlother3.7 KB
scripts/selftest/fixtures/verdict-traces.jsonconfig16.6 KB
scripts/selftest/journey-e2e.shexecutablescript1.4 KB
scripts/selftest/journey.mjsscript9.5 KB
scripts/selftest/observe-journey.mjsscript12.5 KB
scripts/selftest/run-selftest.shexecutablescript7.0 KB
scripts/selftest/spawn-python.mjsexecutablescript765 B
scripts/session.test.tsscript5.2 KB
scripts/session.tsscript251 B
scripts/signal-local.test.tsscript7.0 KB
scripts/skill-impact.test.tsscript6.2 KB
scripts/station-settings.test.tsscript13.6 KB
scripts/store-memory.test.tsscript3.4 KB
scripts/store.tsscript7.7 KB
scripts/test-helpers.tsscript15.3 KB
scripts/text.tsscript760 B
scripts/trigger.test.tsscript3.6 KB
scripts/trigger.tsscript2.5 KB
scripts/verdicts.test.tsscript8.1 KB
scripts/verdicts.tsscript8.0 KB

scripts/cloud-verdict.test.ts

View on GitHub
import { test } from 'node:test';
import assert from 'node:assert/strict';
import { execFileSync } from 'node:child_process';
import { chmodSync, existsSync, readFileSync, writeFileSync } from 'node:fs';
import { join } from 'node:path';
import { run } from './rem-reflect.ts';
import { appendLedger, readLedger } from './ledger.ts';
import { flushCloudVerdicts } from './cloud.ts';
import { commitStore, readState, writeState } from './store.ts';
import { fixtureConfig, makeStore, tmp, writeStationSettings, FixtureBackend } from './test-helpers.ts';

test('ordinary reject stays successful when upload is rejected, and a same-day retry sends its linked verdict', () => {
  const config = fixtureConfig();
  const store = makeStore(config);
  const id = '20260921-0100/codex';
  appendLedger(store, { type: 'proposal', proposal_id: id, run_id: '20260921-0100', half: 'codex',
    kind: 'patch', target: '/installed/target', region: 'body', purpose: { summary: 'a change', page_ids: ['page'] },
    verdict: 'pending', judgment_id: 'j-original' });
  const bin = tmp('sno-verdict');
  const capture = join(bin, 'verdict.json');
  const sno = join(bin, 'sno');
  writeFileSync(sno, [
    '#!/usr/bin/env node',
    "const fs = require('node:fs');",
    "const args = process.argv.slice(2);",
    "if (args.join(' ') === 'station consent --json') { console.log(JSON.stringify({ consent: process.env.REM_TEST_CONSENT })); process.exit(0); }",
    "if (args[0] !== 'rem' || args[1] !== 'verdict') { console.error('unexpected network verb'); process.exit(2); }",
    "if (process.env.REM_TEST_CONSENT !== 'full') { console.error('upload rejected: consent ' + process.env.REM_TEST_CONSENT); process.exit(1); }",
    "const ledger = fs.readFileSync(process.env.REM_TEST_LEDGER, 'utf8');",
    "if (!ledger.includes('\\\"verdict\\\":\\\"Rejected\\\"')) { console.error('local decision did not happen first'); process.exit(2); }",
    "if (process.env.REM_TEST_FAIL === '1') { console.error('temporary cloud outage'); process.exit(1); }",
    "fs.writeFileSync(process.env.REM_REQUEST_CAPTURE, JSON.stringify(args));",
    "console.log(JSON.stringify({schema_version:1,judgment_id:args[2],verdict:args[3],acknowledged:true}));",
  ].join('\n') + '\n');
  chmodSync(sno, 0o755);
  const env = { ...process.env, PATH: `${bin}:${process.env.PATH ?? ''}`, REM_REFLECT_STORE: store,
    REM_TEST_LEDGER: join(store, 'ledger', 'skill-impact.jsonl'), REM_REQUEST_CAPTURE: capture };
  const entry = join(import.meta.dirname, 'rem-reflect.ts');

  const off = execFileSync(process.execPath, ['--experimental-strip-types', entry, 'reject', id],
    { env: { ...env, REM_TEST_CONSENT: 'off' }, encoding: 'utf8' });
  assert.match(off, /Rejected/);
  assert.match(off, /cloud verdict j-original send failed: .*upload rejected: consent off/);
  assert.equal(existsSync(capture), false);
  assert.ok(readLedger(store).some(row => row.type === 'verdict' && row.proposal_id === id && row.verdict === 'Rejected'));
  assert.ok(readLedger(store).some(row => row.type === 'cloud-verdict' && row.judgment_id === 'j-original' && row.status === 'pending'));

  const state = readState(store);
  state.last_terminal = { id: '20260921-0000', date: '2026-09-21', status: 'success' };
  writeState(store, state);
  commitStore(store, 'already completed today');
  const failed = execFileSync(process.execPath, ['--experimental-strip-types', entry, 'run', '--now', '2026-09-21T01:00:00Z'],
    { env: { ...env, REM_TEST_CONSENT: 'full', REM_TEST_FAIL: '1' }, encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'] });
  assert.match(failed, /already succeeded/);
  assert.match(failed, /cloud verdict j-original send failed: .*temporary cloud outage/);
  assert.equal(readState(store).last_terminal?.status, 'success');
  assert.match(readFileSync(join(store, 'run.log'), 'utf8'), /cloud verdict j-original send failed/);
  assert.equal(existsSync(capture), false);
  assert.ok(readLedger(store).some(row => row.type === 'cloud-verdict' && row.judgment_id === 'j-original' && row.status === 'pending'));
  const full = execFileSync(process.execPath, ['--experimental-strip-types', entry, 'run', '--now', '2026-09-21T01:00:00Z'],
    { env: { ...env, REM_TEST_CONSENT: 'full' }, encoding: 'utf8' });
  assert.match(full, /already succeeded/);
  assert.deepEqual(JSON.parse(readFileSync(capture, 'utf8')), ['rem', 'verdict', 'j-original', 'reject']);
  assert.ok(readLedger(store).some(row => row.type === 'cloud-verdict' && row.judgment_id === 'j-original' && row.status === 'acked'));
});

test('a promoted verdict keeps --all-projects through retry and records only an acknowledgment that echoes general', t => {
  const bin = tmp('promoted-verdict');
  const capture = join(bin, 'args.json');
  const sno = join(bin, 'sno');
  writeFileSync(sno, [
    '#!/usr/bin/env node',
    "const fs = require('node:fs');",
    "const args = process.argv.slice(2);",
    "if (args.join(' ') === 'station consent --json') { console.log(JSON.stringify({ consent: 'full' })); process.exit(0); }",
    "fs.writeFileSync(process.env.REM_REQUEST_CAPTURE, JSON.stringify(args));",
    "const answer = {schema_version:1,judgment_id:args[2],verdict:args[3],acknowledged:true};",
    "if (process.env.REM_ECHO_PROMOTION === '1') answer.applies_to = 'general';",
    "console.log(JSON.stringify(answer));",
  ].join('\n') + '\n');
  chmodSync(sno, 0o755);
  const prior = { PATH: process.env.PATH, REM_REQUEST_CAPTURE: process.env.REM_REQUEST_CAPTURE,
    REM_ECHO_PROMOTION: process.env.REM_ECHO_PROMOTION };
  process.env.PATH = `${bin}:${prior.PATH ?? ''}`;
  process.env.REM_REQUEST_CAPTURE = capture;
  t.after(() => {
    for (const [key, value] of Object.entries(prior)) {
      if (value === undefined) delete process.env[key]; else process.env[key] = value;
    }
  });

  const store = makeStore(fixtureConfig());
  appendLedger(store, { type: 'cloud-verdict', judgment_id: 'j-promoted', item_id: 'L-promoted', verdict: 'accept',
    status: 'pending', applies_to: 'general', at: '2026-09-23' });
  delete process.env.REM_ECHO_PROMOTION;
  const failed = flushCloudVerdicts(store);
  assert.equal(failed.sent, 0);
  assert.equal(failed.pending, 1);
  assert.match(failed.errors.join('\n'), /cloud verdict j-promoted send failed: .*mismatched acknowledgment/);
  assert.equal(readLedger(store).filter(row => row.judgment_id === 'j-promoted').at(-1)?.status, 'pending');

  process.env.REM_ECHO_PROMOTION = '1';
  assert.deepEqual(flushCloudVerdicts(store), { sent: 1, pending: 0, errors: [] });
  assert.deepEqual(JSON.parse(readFileSync(capture, 'utf8')), ['rem', 'verdict', 'j-promoted', 'accept', '--all-projects']);
  const acked = readLedger(store).filter(row => row.judgment_id === 'j-promoted').at(-1);
  assert.equal(acked?.status, 'acked');
  assert.equal(acked?.applies_to, 'general');
});


test('queued accept, reject and tbd verdicts send in both sharing modes, and local-first sends nothing', t => {
  const bin = tmp('mode-verdicts');
  const capture = join(bin, 'sent.jsonl');
  writeFileSync(join(bin, 'sno'), `#!/usr/bin/env node
const fs = require('node:fs');
const args = process.argv.slice(2);
if (args[0] !== 'rem' || args[1] !== 'verdict') process.exit(2);
fs.appendFileSync(process.env.REM_REQUEST_CAPTURE, JSON.stringify(args) + '\\n');
console.log(JSON.stringify({schema_version:1,judgment_id:args[2],verdict:args[3],acknowledged:true}));
`, { mode: 0o755 });
  const before = { PATH: process.env.PATH, SNO_PROFILE_DIR: process.env.SNO_PROFILE_DIR, REM_REQUEST_CAPTURE: process.env.REM_REQUEST_CAPTURE };
  Object.assign(process.env, { PATH: `${bin}:${process.env.PATH ?? ''}`, REM_REQUEST_CAPTURE: capture });
  t.after(() => { for (const [key, value] of Object.entries(before)) { if (value === undefined) delete process.env[key]; else process.env[key] = value; } });
  for (const mode of ['local-first', 'agent-native', 'rem-enhanced']) {
    process.env.SNO_PROFILE_DIR = writeStationSettings(mode);
    const store = makeStore(fixtureConfig());
    for (const verdict of ['accept', 'reject', 'tbd']) appendLedger(store, {
      type: 'cloud-verdict', judgment_id: `j-${mode}-${verdict}`, item_id: `L-${verdict}`, verdict, status: 'pending',
    });
    const result = flushCloudVerdicts(store);
    assert.deepEqual(result, { sent: mode === 'local-first' ? 0 : 3, pending: mode === 'local-first' ? 3 : 0, errors: [] });
    if (mode === 'local-first') assert.equal(existsSync(capture), false);
  }
  const commands = readFileSync(capture, 'utf8').trim().split('\n').map(line => JSON.parse(line));
  assert.deepEqual(commands, ['agent-native', 'rem-enhanced'].flatMap(mode => ['accept', 'reject', 'tbd']
    .map(verdict => ['rem', 'verdict', `j-${mode}-${verdict}`, verdict])));
});


test('a native run stores history links without cloud judgments and its later local verdict uploads', t => {
  const config = fixtureConfig();
  const store = makeStore(config);
  const id = '20260920-0100/codex';
  appendLedger(store, { type: 'proposal', proposal_id: id, run_id: '20260920-0100', half: 'codex',
    kind: 'patch', target: '/installed/target', region: 'body', purpose: { summary: 'a local change', page_ids: ['local-page'] },
    verdict: 'pending' });
  const bin = tmp('native-linked-verdict');
  const capture = join(bin, 'verdict.json');
  const request = join(bin, 'request.json');
  writeFileSync(join(bin, 'sno'), `#!/usr/bin/env node
const fs = require('node:fs');
const args = process.argv.slice(2);
if (args.join(' ') === 'rem judge --json') {
  const batch = JSON.parse(fs.readFileSync(0, 'utf8'));
  fs.writeFileSync(process.env.REM_NATIVE_REQUEST, JSON.stringify(batch));
  console.log(JSON.stringify({schema_version:1,run_id:batch.run_id,history_acknowledged:true,
    history_links:[{kind:'proposal',local_id:${JSON.stringify(id)},judgment_id:'j-native-local'}],
    halves:[{harness:'codex',pages:[],lessons:[],proposals:[{judgment_id:'j-new-cloud',proposal:{kind:'no_action',purpose:{summary:'Cloud judgment excluded from the local report',page_ids:[]}}}],read_judgments:[],log_entry:'Cloud judgment excluded from the local report'}]}));
  process.exit(0);
}
if (args[0] !== 'rem' || args[1] !== 'verdict') process.exit(2);
fs.writeFileSync(process.env.REM_REQUEST_CAPTURE, JSON.stringify(args));
console.log(JSON.stringify({schema_version:1,judgment_id:args[2],verdict:args[3],acknowledged:true}));
`, { mode: 0o755 });
  const before = { PATH: process.env.PATH, SNO_PROFILE_DIR: process.env.SNO_PROFILE_DIR,
    REM_REQUEST_CAPTURE: process.env.REM_REQUEST_CAPTURE, REM_NATIVE_REQUEST: process.env.REM_NATIVE_REQUEST };
  Object.assign(process.env, { PATH: `${bin}:${process.env.PATH ?? ''}`, SNO_PROFILE_DIR: writeStationSettings('agent-native'),
    REM_REQUEST_CAPTURE: capture, REM_NATIVE_REQUEST: request });
  t.after(() => { for (const [key, value] of Object.entries(before)) { if (value === undefined) delete process.env[key]; else process.env[key] = value; } });
  const result = run(store, new Date('2026-09-21T00:00:00Z'), 'u', new FixtureBackend());
  assert.equal(result.code, 0, result.lines.join('\n'));
  const batch = JSON.parse(readFileSync(request, 'utf8'));
  assert.equal(batch.history.proposals[0].proposal_id, id, 'the service received the local item it associates');
  assert.ok(readLedger(store).some(row => row.type === 'cloud-link' && row.local_id === id && row.judgment_id === 'j-native-local'));
  assert.equal(readLedger(store).filter(row => row.type === 'proposal').length, 1, 'cloud proposals are not applied');
  const report = readFileSync(join(store, 'staging', '20260921-0000', 'REPORT.md'), 'utf8');
  assert.doesNotMatch(report, /Cloud judgment excluded|j-native-local|j-new-cloud/);
  const entry = join(import.meta.dirname, 'rem-reflect.ts');
  const verdict = execFileSync(process.execPath, ['--experimental-strip-types', entry, 'reject', id],
    { env: { ...process.env, REM_REFLECT_STORE: store }, encoding: 'utf8' });
  assert.match(verdict, /Rejected/);
  assert.deepEqual(JSON.parse(readFileSync(capture, 'utf8')), ['rem', 'verdict', 'j-native-local', 'reject']);
  assert.ok(readLedger(store).some(row => row.type === 'cloud-verdict' && row.judgment_id === 'j-native-local' && row.status === 'acked'));
  assert.equal(readFileSync(join(store, 'staging', '20260921-0000', 'REPORT.md'), 'utf8'), report, 'verdict delivery leaves the run report unchanged');
});
reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis.Stars: 472kUpdated Claude CodeCodexVerifiedInstall
diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness.Stars: 322kUpdated Claude CodeCodexVerifiedInstall
dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependenciesStars: 322kUpdated Claude CodeCodexVerifiedInstall
executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is availableStars: 322kUpdated Claude CodeCodexVerifiedInstall