SLOPSHOPPER

nixie-policy

SDK contract probe: a policy mod that guards tool calls

guardcommand
A shopper browsing a rack in a slop shop
Preview · a replayed session in a sandbox
claude · ~/work/app · nixie-policy
› fix the failing auth test and add an audit log call ⏺ Read(src/auth.ts) ⎿ Read 6 lines ⏺ Update(src/auth.ts) ⎿ Added 2 lines, removed 1 line ⏺ Bash(bun test) ⎿ 3 pass, 1 fail ● Done. refresh now rejects expired claims and logs an audit event. ✻ Worked for 42s · done 4:20 PM › /nixie-alive ⎿ nixie-policy: nixie-policy alive ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── › ? for shortcuts
README

<h1>nixie</h1>

A personal assistant platform that its owner runs and controls: every rule readable and editable, every decision recorded, and personal data kept on the owner's own hosts.

<a href="./docs/README.md">Documentation</a> • <a href="./docs/README.md#decisions">Decisions</a> • <a href="./AGENTS.md">Agent Guidelines</a>

Status

nixie is in Phase 2, Research, and has no product code. The work runs in 4 phases: brainstorm, research, design, and decide. Decisions are recorded as research settles each question.

Checks

bun install
bun run check        # every check CI runs

Layout

  • docs/ holds the overview, the principles, the scope, the decision records, and the designs for what is not built yet. Start with the overview.
  • research/ holds the spikes: throwaway experiments that answer research questions.
Source 1 files
hooks/register.js 54 lines
1export function register(on) {
2  on('session.start', handleSessionStart);
3  on('command.run', { command: 'nixie-alive' }, handleAliveCommand);
4  on('tool.call', handleToolCall);
5  on('tool.check', handleToolCheck);
6}
7
8// Each marker in a Bash command picks one policy outcome, so one prompt exercises all of them.
9// /nixie-alive answers only while the module is loaded, so a host can probe for it.
10async function handleSessionStart($, event, next) {
11  await $.command.register({
12    description: 'Report that the nixie policy mod is loaded',
13    immediate: true,
14    name: 'nixie-alive',
15  });
16  return next(event);
17}
18
19function handleAliveCommand() {
20  return { text: 'nixie-policy alive' };
21}
22
23function handleToolCall($, event, next) {
24  if (event.tool !== 'Bash') {
25    return next(event);
26  }
27  return checkBash($, event, next);
28}
29
30function checkBash($, event, next) {
31  if (event.command.includes('MARK_DENY')) {
32    return { deny: 'nixie-policy denied this command.' };
33  }
34  if (event.command.includes('MARK_REWRITE')) {
35    return next({ ...event, command: 'echo rewritten-by-nixie' });
36  }
37  if (event.command.includes('MARK_ANSWER_TEXT')) {
38    return { result: 'answered-by-nixie as text' };
39  }
40  if (event.command.includes('MARK_ANSWER')) {
41    // The result takes the tool's own output shape, here Bash's.
42    return { result: { interrupted: false, stderr: '', stdout: 'answered-by-nixie' } };
43  }
44  return next(event);
45}
46
47async function handleToolCheck($, event, next) {
48  const decided = await next(event);
49  if (event.tool === 'Bash' && event.input.command.includes('MARK_CHECK')) {
50    return { decision: 'deny', reason: 'nixie-policy tool.check denied this command.' };
51  }
52  return decided;
53}
54