@bluenyang/reins 0.1.4-rc.2 → 0.1.5-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,125 @@
1
+ import { readFileSync, readdirSync } from 'node:fs';
2
+ import { join } from 'node:path';
3
+ import { parse } from 'yaml';
4
+ import { splitFrontmatter } from './skills.js';
5
+ const HELD = ['blocked', 'checked', 'advised'];
6
+ const WORDS = {
7
+ en: { blocked: 'blocked', checked: 'checked', advised: 'advised' },
8
+ ko: { blocked: '차단', checked: '검사', advised: '권고' },
9
+ };
10
+ const HEAD = {
11
+ en: {
12
+ main: ['id', 'held', 'by', 'gap'],
13
+ role: ['role', 'blocked', 'checked', 'advised', 'blocked items'],
14
+ budget: 'budget scopes',
15
+ },
16
+ ko: {
17
+ main: ['id', '지킴', '수단', '빈틈'],
18
+ role: ['역할', '차단', '검사', '권고', '차단되는 항목'],
19
+ budget: '예산 범위',
20
+ },
21
+ };
22
+ export function readRules(text) {
23
+ const d = parse(text);
24
+ return d?.rules ?? [];
25
+ }
26
+ /** `must_not` items of every role file in `<harness>/roles`, by role name. */
27
+ export function roleMustNot(harness) {
28
+ const out = new Map();
29
+ const dir = join(harness, 'roles');
30
+ for (const f of readdirSync(dir)
31
+ .filter((x) => x.endsWith('.md'))
32
+ .toSorted()) {
33
+ const m = splitFrontmatter(readFileSync(join(dir, f), 'utf8')).data?.['must_not'];
34
+ out.set(f.replace(/\.md$/, ''), Array.isArray(m) ? m.map(String) : []);
35
+ }
36
+ return out;
37
+ }
38
+ /** Every id the table must cover: policy files, role `must_not` items, budget scopes. */
39
+ export function expectedIds(harness) {
40
+ const y = (f) => parse(readFileSync(join(harness, 'policy', f), 'utf8'));
41
+ const ids = [];
42
+ for (const r of y('common-red-lines.yaml')['rules'] ?? [])
43
+ ids.push(r.id);
44
+ for (const s of y('stops.yaml')['stops'] ?? [])
45
+ ids.push(s.id);
46
+ for (const p of y('transitions.yaml')['points'] ?? [])
47
+ ids.push(p.id);
48
+ for (const [role, items] of roleMustNot(harness))
49
+ items.forEach((_, i) => ids.push(`${role}#${i + 1}`));
50
+ for (const s of y('budget.yaml')['scopes'] ?? [])
51
+ ids.push(`budget:${s.name}`);
52
+ return ids;
53
+ }
54
+ /** The rules of `enforcement.yaml`, each with its `must_not` text where it has one. */
55
+ export function enforcementRows(harness) {
56
+ const mustNot = roleMustNot(harness);
57
+ return readRules(readFileSync(join(harness, 'policy', 'enforcement.yaml'), 'utf8')).map((r) => {
58
+ const m = /^(.+)#(\d+)$/.exec(r.id);
59
+ const text = m ? mustNot.get(m[1] ?? '')?.[Number(m[2]) - 1] : undefined;
60
+ return text === undefined ? r : { ...r, text };
61
+ });
62
+ }
63
+ const esc = (s) => s.replaceAll('|', '\\|');
64
+ const table = (head, rows) => [
65
+ `| ${head.join(' | ')} |`,
66
+ `|${head.map(() => '---').join('|')}|`,
67
+ ...rows.map((r) => `| ${r.map(esc).join(' | ')} |`),
68
+ ];
69
+ const isRole = (id) => id.includes('#');
70
+ const isBudget = (id) => id.startsWith('budget:');
71
+ function mainRows(rows, lang, pick) {
72
+ return table(HEAD[lang].main, rows
73
+ .filter((r) => pick(r.id))
74
+ .map((r) => [
75
+ r.id,
76
+ WORDS[lang][r.held],
77
+ r.by.map((b) => `\`${b}\``).join(', '),
78
+ r.gap ?? '—',
79
+ ]));
80
+ }
81
+ function roleRows(rows, lang) {
82
+ const roles = new Map();
83
+ for (const r of rows.filter((x) => isRole(x.id))) {
84
+ const role = r.id.slice(0, r.id.indexOf('#'));
85
+ roles.set(role, [...(roles.get(role) ?? []), r]);
86
+ }
87
+ const count = (rs, h) => String(rs.filter((r) => r.held === h).length);
88
+ const body = [...roles].map(([role, rs]) => [
89
+ role,
90
+ ...HELD.map((h) => count(rs, h)),
91
+ rs
92
+ .filter((r) => r.held === 'blocked')
93
+ .map((r) => r.text ?? r.id)
94
+ .join('; ') || '—',
95
+ ]);
96
+ const budget = rows.filter((r) => isBudget(r.id));
97
+ body.push([HEAD[lang].budget, ...HELD.map((h) => count(budget, h)), '—']);
98
+ return table(HEAD[lang].role, body);
99
+ }
100
+ /** The Markdown tables between the `enforcement` markers; no trailing newline. */
101
+ export function renderTable(rows, lang, view = 'all') {
102
+ if (view === 'redlines')
103
+ return mainRows(rows, lang, (id) => /^C\d+$/.test(id)).join('\n');
104
+ if (view === 'stops')
105
+ return mainRows(rows, lang, (id) => /^[ABDEFGPT]\d+$/.test(id)).join('\n');
106
+ const main = mainRows(rows, lang, (id) => !isRole(id) && !isBudget(id));
107
+ return [...main, '', ...roleRows(rows, lang)].join('\n');
108
+ }
109
+ const MARK = /(<!-- enforcement:begin(?: (\w+))? -->\n)([\s\S]*?)(\n<!-- enforcement:end -->)/g;
110
+ /** Replaces the content of every `enforcement` marker pair with the rendered table; returns the text and how many pairs it found. */
111
+ export function applyMarkers(text, lang, rows) {
112
+ let pairs = 0;
113
+ const out = text.replace(MARK, (_m, open, view, _body, close) => {
114
+ pairs += 1;
115
+ return `${open}${renderTable(rows, lang, view ?? 'all')}${close}`;
116
+ });
117
+ return { text: out, pairs };
118
+ }
119
+ /** Documents that carry markers, with their language and how many pairs each must hold. */
120
+ export const MARKED_DOCS = [
121
+ { file: 'README.md', lang: 'en', pairs: 1 },
122
+ { file: 'docs/README.ko.md', lang: 'ko', pairs: 1 },
123
+ { file: 'docs/design.md', lang: 'en', pairs: 2 },
124
+ { file: 'docs/design.ko.md', lang: 'ko', pairs: 2 },
125
+ ];
@@ -1,5 +1,5 @@
1
- import { existsSync, mkdirSync, readFileSync, readdirSync, statSync, writeFileSync } from 'node:fs';
2
- import { dirname, join, relative, sep } from 'node:path';
1
+ import { existsSync, mkdirSync, readFileSync, readdirSync, realpathSync, statSync, writeFileSync, } from 'node:fs';
2
+ import path, { dirname, join, relative, sep } from 'node:path';
3
3
  export function apply(root, writes, dryRun) {
4
4
  const out = { created: [], changed: [], unchanged: [], removed: [] };
5
5
  for (const w of writes) {
@@ -22,6 +22,20 @@ export function relPath(from, to) {
22
22
  const rel = relative(from, to);
23
23
  return sep === '/' ? rel : rel.split(sep).join('/');
24
24
  }
25
+ /** Whether `to` is `from` or lies under it; `p` selects the path flavour (tests pass `path.win32`). */
26
+ export function isWithin(from, to, p = path) {
27
+ const rel = p.relative(from, to);
28
+ return rel !== '..' && !rel.startsWith(`..${p.sep}`) && !p.isAbsolute(rel);
29
+ }
30
+ /** The real path with symlinks and Windows 8.3 short names (RUNNER~1) resolved; the input when it does not exist. */
31
+ export function realPath(p) {
32
+ try {
33
+ return realpathSync.native(p);
34
+ }
35
+ catch {
36
+ return p;
37
+ }
38
+ }
25
39
  /** Every file under `dir`, as `/`-separated paths relative to `dir`. */
26
40
  export function listFiles(dir) {
27
41
  const out = [];
@@ -1,6 +1,7 @@
1
1
  import { createHash } from 'node:crypto';
2
2
  import { parse, stringify } from 'yaml';
3
3
  import { workTreeReader } from './reader.js';
4
+ import { vendorOf } from './detect.js';
4
5
  import { splitFrontmatter } from './skills.js';
5
6
  /**
6
7
  * Vendor files generated from `.agents/harness/` (design §6). Round one generates Claude Code only:
@@ -17,6 +18,7 @@ function readRole(text) {
17
18
  may: d['may'] ?? [],
18
19
  mustNot: d['must_not'] ?? [],
19
20
  capabilities: d['capabilities'] ?? {},
21
+ fallback: typeof d['fallback_binding'] === 'string' ? d['fallback_binding'] : undefined,
20
22
  body: body.trim(),
21
23
  };
22
24
  }
@@ -29,7 +31,7 @@ function disallowed(c) {
29
31
  out.push('Bash');
30
32
  return out;
31
33
  }
32
- export function claudeAgent(r, b, version) {
34
+ export function claudeAgent(r, b, version, fallbackFor) {
33
35
  const fm = {
34
36
  name: `reins-${r.role}`,
35
37
  description: `reins ${r.role} role. ${r.summary}`,
@@ -43,6 +45,9 @@ export function claudeAgent(r, b, version) {
43
45
  stringify(fm).trimEnd(),
44
46
  '---',
45
47
  `<!-- generated by reins ${version} from .agents/harness/roles/${r.role}.md and bindings.yaml — do not edit; run \`reins update\` -->`,
48
+ ...(fallbackFor
49
+ ? [`<!-- fallback for ${fallbackFor} — the team binds this role to another vendor -->`]
50
+ : []),
46
51
  '',
47
52
  `You are the **${r.role}** role of the reins harness in this repository. ${r.summary}`,
48
53
  '',
@@ -107,14 +112,28 @@ export function generateVendorFiles(root, rd = workTreeReader(root)) {
107
112
  const b = bindings[r.role];
108
113
  if (!b)
109
114
  continue;
115
+ // Committed team defaults only (never the local file), so no user's override makes drift.
116
+ // A role bound to another vendor still gets a Claude file on its fallback model, else pm's.
117
+ let model = b.model;
118
+ let fallbackFor;
110
119
  if (b.vendor !== 'claude') {
111
- out.skipped.push(`${r.role} → ${b.vendor} ${b.model}`);
112
- continue;
120
+ const pm = bindings['pm'];
121
+ const fb = r.fallback && vendorOf(r.fallback) === 'claude'
122
+ ? r.fallback
123
+ : pm && pm.vendor === 'claude'
124
+ ? pm.model
125
+ : undefined;
126
+ if (!fb) {
127
+ out.skipped.push(`${r.role} → ${b.vendor} ${b.model}`);
128
+ continue;
129
+ }
130
+ model = fb;
131
+ fallbackFor = b.vendor;
113
132
  }
114
133
  out.writes.push({
115
134
  path: `.claude/agents/reins-${r.role}.md`,
116
- content: claudeAgent(r, b, version),
117
- why: `role ${r.role}`,
135
+ content: claudeAgent(r, { vendor: 'claude', model }, version, fallbackFor),
136
+ why: fallbackFor ? `role ${r.role} (fallback for ${fallbackFor})` : `role ${r.role}`,
118
137
  });
119
138
  }
120
139
  // skills: Codex, Gemini and Cursor read .agents/skills/ directly; Claude Code reads a byte-identical copy
@@ -8,7 +8,7 @@ function git(args, cwd) {
8
8
  }
9
9
  export function stagedFiles(cwd) {
10
10
  const out = git(['diff', '--cached', '--name-only', '--diff-filter=ACMR'], cwd);
11
- return out ? out.split('\n') : [];
11
+ return out ? out.split(/\r?\n/) : [];
12
12
  }
13
13
  /** The checked-out branch; on a repository without commits `rev-parse` fails, so ask for the symbolic ref instead. */
14
14
  export function currentBranch(cwd) {
@@ -43,7 +43,7 @@ export function repoRoot(cwd) {
43
43
  export function pushedSubjects(remoteSha, localSha, cwd) {
44
44
  try {
45
45
  const out = git(['log', '--format=%s', `${remoteSha}..${localSha}`], cwd);
46
- return out ? out.split('\n') : [];
46
+ return out ? out.split(/\r?\n/) : [];
47
47
  }
48
48
  catch {
49
49
  return [];
@@ -95,7 +95,7 @@ export function readMetrics(root) {
95
95
  catch {
96
96
  return { records, broken };
97
97
  }
98
- for (const line of text.split('\n')) {
98
+ for (const line of text.split(/\r?\n/)) {
99
99
  if (!line.trim())
100
100
  continue;
101
101
  try {
@@ -122,3 +122,51 @@ export function releaseDraftNotes(drafts) {
122
122
  .map(([k, v]) => `${k}: ${JSON.stringify(v)}`)
123
123
  .join(', ')}}, approval: ${d.approval}}`);
124
124
  }
125
+ /** The checks `release.docs` may name (design §4). */
126
+ export const DOC_CHECKS = ['roadmap-row', 'changelog-section', 'mentions-version'];
127
+ /** Reads `release.docs`; [] when the file, the key or an entry is missing or malformed. */
128
+ export function readReleaseDocs(root) {
129
+ const p = join(root, '.agents/harness/install.yaml');
130
+ if (!existsSync(p))
131
+ return [];
132
+ let doc;
133
+ try {
134
+ doc = parse(readFileSync(p, 'utf8'));
135
+ }
136
+ catch {
137
+ return [];
138
+ }
139
+ const list = doc?.release?.docs;
140
+ if (!Array.isArray(list))
141
+ return [];
142
+ const out = [];
143
+ for (const d of list) {
144
+ const check = d?.['check'];
145
+ if (typeof d?.['file'] === 'string' && DOC_CHECKS.includes(check))
146
+ out.push({ file: d['file'], check: check });
147
+ }
148
+ return out;
149
+ }
150
+ const escapeRe = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, (c) => `\\${c}`);
151
+ /**
152
+ * Whether `text` is up to date for version `v` (pure). `roadmap-row`: a table row whose first
153
+ * cell is `v` and whose state cell is not planned/계획. `changelog-section`: rc `## [Unreleased] — v`
154
+ * or `## [v]`; stable only `## [v]`. `mentions-version`: `v` as a token of its own.
155
+ */
156
+ export function checkDoc(text, check, v, stage) {
157
+ const e = escapeRe(v);
158
+ if (check === 'roadmap-row')
159
+ return text.split(/\r?\n/).some((line) => {
160
+ const cells = line.split('|').map((c) => c.trim());
161
+ return (line.trimStart().startsWith('|') &&
162
+ cells[1] === v &&
163
+ cells[2] !== undefined &&
164
+ cells[2] !== '' &&
165
+ !/^(planned|계획)$/i.test(cells[2]));
166
+ });
167
+ if (check === 'changelog-section')
168
+ return stage === 'stable'
169
+ ? new RegExp(`^## \\[${e}\\]`, 'm').test(text)
170
+ : new RegExp(`^## (\\[Unreleased\\] — ${e}(?![\\w.])|\\[${e}\\])`, 'm').test(text);
171
+ return new RegExp(`(?<![\\w.])${e}(?![\\w]|\\.\\d)`).test(text);
172
+ }
@@ -11,7 +11,7 @@ export function readDismissals(root) {
11
11
  const f = join(root, DISMISSED);
12
12
  if (!existsSync(f))
13
13
  return out;
14
- for (const line of readFileSync(f, 'utf8').split('\n')) {
14
+ for (const line of readFileSync(f, 'utf8').split(/\r?\n/)) {
15
15
  try {
16
16
  const d = JSON.parse(line);
17
17
  if (typeof d.key === 'string' && typeof d.units === 'number')
package/cli/dist/reins.js CHANGED
@@ -160,10 +160,14 @@ configure
160
160
  .description('bind roles to models: --set role=model … or --vendors claude,openai,…; no options asks')
161
161
  .option('--set <pairs...>', 'role=model pairs')
162
162
  .option('--vendors <list>', 'rebuild every role from its defaults for these vendors (comma-separated)')
163
+ .option('--local', 'with --set: write your own override to .loctx/bindings.local.yaml')
164
+ .option('--show', 'print what each role actually runs on')
163
165
  .option('--json')
164
166
  .action(async (o) => {
165
- const asker = !o.set && !o.vendors ? await stdinAsker() : undefined;
167
+ const asker = !o.set && !o.vendors && !o.local && !o.show ? await stdinAsker() : undefined;
166
168
  const r = await configureBindings({
169
+ local: o.local,
170
+ show: o.show,
167
171
  set: o.set,
168
172
  vendors: o.vendors?.split(',').map((s) => s.trim()),
169
173
  asker,
@@ -177,8 +181,13 @@ configure
177
181
  process.stderr.write(`reins configure bindings: ${r.refused}\n`);
178
182
  process.exit(2);
179
183
  }
180
- for (const t of r.table)
181
- process.stdout.write(` ${r.changed.includes(t.role) ? '*' : ' '} ${t.role.padEnd(12)} ${t.vendor.padEnd(7)} ${t.model}\n`);
184
+ if (o.show || o.local) {
185
+ for (const t of r.resolved ?? [])
186
+ process.stdout.write(` ${r.changed.includes(t.role) ? '*' : ' '} ${t.role.padEnd(12)} ${t.vendor.padEnd(7)} ${t.model} (${t.source}: ${t.reason})\n`);
187
+ }
188
+ else
189
+ for (const t of r.table)
190
+ process.stdout.write(` ${r.changed.includes(t.role) ? '*' : ' '} ${t.role.padEnd(12)} ${t.vendor.padEnd(7)} ${t.model}\n`);
182
191
  process.stdout.write(r.changed.length ? `changed: ${r.changed.join(', ')}\n` : 'no change\n');
183
192
  const g = r.generated;
184
193
  if (g) {
@@ -366,6 +375,7 @@ program
366
375
  .option('--stage <stage>', 'T1 ticket-start · T2 pre-commit · T3 verdict · T4 pre-push · T5 rc-close')
367
376
  .option('--ticket <id>', 'ticket-start, verdict: the ticket id')
368
377
  .option('--release <version>', 'rc-close: the version the rc closes')
378
+ .option('--stable', "rc-close: print the stable dispatch lines (the user's instruction only)")
369
379
  .option('--drift')
370
380
  .option('--json')
371
381
  .action(async (o) => {
@@ -381,7 +391,14 @@ program
381
391
  chunks.push(c);
382
392
  pushRefs = Buffer.concat(chunks).toString('utf8').split('\n').filter(Boolean);
383
393
  }
384
- const r = runCheck({ stage, drift: o.drift, pushRefs, ticket: o.ticket, release: o.release });
394
+ const r = runCheck({
395
+ stage,
396
+ drift: o.drift,
397
+ pushRefs,
398
+ ticket: o.ticket,
399
+ release: o.release,
400
+ stable: o.stable,
401
+ });
385
402
  // S-8: the verdict code is set before anything is printed, so a closed pipe cannot change it
386
403
  process.exitCode = EXIT[r.verdict];
387
404
  process.stdout.on('error', (e) => {
@@ -0,0 +1,24 @@
1
+ // Re-renders the enforcement tables between the `enforcement` markers of the README and design editions.
2
+ // Run by `pnpm docs:enforcement`; the test in cli/test/enforcement.test.ts fails when they drift.
3
+ import { readFileSync, writeFileSync } from 'node:fs';
4
+ import { resolve } from 'node:path';
5
+ import { fileURLToPath, pathToFileURL } from 'node:url';
6
+ import { MARKED_DOCS, applyMarkers, enforcementRows } from '../lib/enforcement.js';
7
+ // compiled to cli/dist/scripts/: the repository root is three levels up (or the first argument)
8
+ const root = resolve(process.argv[2] ?? fileURLToPath(new URL('../../../', import.meta.url)));
9
+ export function renderDocs() {
10
+ const rows = enforcementRows(resolve(root, 'harness'));
11
+ for (const d of MARKED_DOCS) {
12
+ const path = resolve(root, d.file);
13
+ const { text, pairs } = applyMarkers(readFileSync(path, 'utf8'), d.lang, rows);
14
+ if (pairs !== d.pairs) {
15
+ console.error(`enforcement: ${d.file} has ${pairs} marker pair(s), expected ${d.pairs}`);
16
+ return 1;
17
+ }
18
+ writeFileSync(path, text);
19
+ }
20
+ console.log('enforcement tables rendered');
21
+ return 0;
22
+ }
23
+ if (import.meta.url === pathToFileURL(process.argv[1] ?? '').href)
24
+ process.exitCode = renderDocs();
@@ -2,7 +2,7 @@
2
2
  // Run by the `version` lifecycle script (npm/pnpm version), after package.json is bumped.
3
3
  import { readFileSync, writeFileSync } from 'node:fs';
4
4
  import { resolve } from 'node:path';
5
- import { pathToFileURL } from 'node:url';
5
+ import { fileURLToPath, pathToFileURL } from 'node:url';
6
6
  /** Replaces only the first `"version": "<x>"` value; every other byte stays. Null when there is no such key. */
7
7
  export function replaceVersion(text, version) {
8
8
  const re = /("version"\s*:\s*")[^"]*(")/;
@@ -11,7 +11,7 @@ export function replaceVersion(text, version) {
11
11
  : null;
12
12
  }
13
13
  // compiled to cli/dist/scripts/: the repository root is three levels up (or the first argument)
14
- const root = pathToFileURL(`${resolve(process.argv[2] ?? new URL('../../../', import.meta.url).pathname)}/`);
14
+ const root = pathToFileURL(`${resolve(process.argv[2] ?? fileURLToPath(new URL('../../../', import.meta.url)))}/`);
15
15
  const read = (p) => readFileSync(new URL(p, root), 'utf8');
16
16
  const write = (p, s) => writeFileSync(new URL(p, root), s);
17
17
  export function sync() {
package/docs/README.ko.md CHANGED
@@ -14,10 +14,13 @@ BlueNyang과 Team Croffle의 저장소 열두 곳이 같은 하네스 계보를
14
14
 
15
15
  ## 상태
16
16
 
17
- 0.1.0이 npm에 있습니다: `npx @bluenyang/reins <command>`. 계획의 1차(round one)로, graph 단계이며
17
+ 0.1.4가 npm에 있습니다: `npx @bluenyang/reins <command>`. 계획의 1차(round one)로, graph 단계이며
18
18
  생성되는 벤더 파일은 Claude Code만 검증했습니다. loop와 harness 단계는 0.2에서 graph로부터 깎아
19
- 냅니다. 알려진 문제는 [CHANGELOG.md](../CHANGELOG.md)에 있고, 그 수정은 0.1.1로 나갑니다. 0.1.2에서는
20
- Claude Code 플러그인을 추가합니다.
19
+ 냅니다. 0.1.3에서 루프를 단계 스킬로 나누고 PR → CI → rc 릴리스 흐름을 넣었고, 0.1.4에서 큰 저장소
20
+ 적용을 준비했습니다(릴리스 설정, 모노레포 게이트, migrate 수정). rc 단계인 0.1.5는 어떤 규칙이 강제되고
21
+ 어떤 규칙이 권고인지 밝히고, 모델 할당을 팀과 사용자 두 층으로 나누며, CI를 Ubuntu·Windows·macOS와
22
+ Node 22·24에서 돌립니다. 버전마다 바뀐 것은
23
+ [CHANGELOG.md](../CHANGELOG.md)에, 다음 계획은 로드맵에 있습니다.
21
24
 
22
25
  reins는 자기 루프로 자기 자신을 개발합니다. intent 001(`reins status`), 002(`reins metrics`),
23
26
  003(위반 시나리오)이 각각 intent → spec → plan → ticket 순서를 거쳤고, T1~T5 검사를 통과했으며 코드
@@ -46,10 +49,11 @@ qa-run, deploy, docs, advisor. 역할 파일마다 해서는 안 되는 일이
46
49
  모델을 정합니다. 설계상 감지되지 않은 벤더에 묶인 역할은 fallback으로, 그것도 없으면 pm의 모델로
47
50
  돌아가므로 열두 역할 모두 Claude만으로 돌 수 있습니다.
48
51
 
49
- **레드라인.** 모든 역할에 적용되고 검증기가 강제하는 규칙이 열 개(C1–C10) 있습니다. 몇 가지를 들면
52
+ **레드라인.** 모든 역할에 적용되는 규칙이 열 개(C1–C10) 있습니다. 몇 가지를 들면
50
53
  이렇습니다. 통과만 시키는 구현 금지(C1), 관리 블록·정책·역할 파일 수정 금지(C2), 자기 권한 파일 수정
51
54
  금지(C3), 시크릿 읽기 금지(C4), 훅 우회 금지(C5), deploy 역할 밖의 push·PR·merge·릴리스 금지(C6).
52
- 전체 목록은 [design.ko.md](design.ko.md) 2절에 있습니다.
55
+ 전체 목록은 [design.ko.md](design.ko.md) 2절에 있습니다. 규칙마다 실제로 어떻게 지켜지는지는 아래
56
+ [강제와 권고](#강제와-권고)에 있습니다. 막는 것, 전이 지점에서 검사하는 것, 역할과 스킬에 적혀만 있는 것이 섞여 있습니다.
53
57
 
54
58
  **검증기.** `reins check`는 전환 지점마다 돌아 판정을 하나 출력합니다. 모델을 호출하지 않습니다.
55
59
  역할이 판단을 인수인계 파일에 쓰면 검증기가 그것을 적용할 뿐입니다.
@@ -78,6 +82,79 @@ qa-run, deploy, docs, advisor. 역할 파일마다 해서는 안 되는 일이
78
82
  | `.claude/` | 합니다 | `.agents/`에서 생성한 파일, 직접 고치지 않습니다 |
79
83
  | `.loctx/` | 안 합니다 (gitignore) | ticket, 보고서, 인수인계 `bus/`, `history/`, 로컬 로드맵 |
80
84
 
85
+ ## 강제와 권고
86
+
87
+ 모든 규칙이 강제되는 것은 아닙니다. 규칙은 세 가지 중 하나로 지켜지고, `harness/policy/enforcement.yaml`이 규칙마다 한 줄로 어느 쪽인지 적습니다.
88
+
89
+ - **차단**(blocked): 스크립트·훅·권한 deny가 실행 전에 막습니다.
90
+ - **검사**(checked): 전이 지점 검사, drift 검사, CI가 사후에 잡습니다.
91
+ - **권고**(advised): 역할이나 스킬 문서에만 적혀 있습니다. 코드로는 잡히지 않습니다.
92
+
93
+ 등급은 실제로 지켜지는 부분 가운데 가장 강한 것으로 매기고, 빈 곳은 `빈틈` 열에 적습니다. 훅은 설치했을 때만 적용되고, deny 규칙과 에이전트 도구 제한은 Claude Code에만 있습니다. 규칙 id는 [design.ko.md](design.ko.md) 2·3절에, 근거는 [violations.ko.md](violations.ko.md)에 있습니다. 권고에 머문 규칙은 [0.2](ROADMAP.ko.md)의 입력입니다. 표의 `빈틈` 열은 영어 원문 그대로입니다.
94
+
95
+ <!-- enforcement:begin -->
96
+ | id | 지킴 | 수단 | 빈틈 |
97
+ |---|---|---|---|
98
+ | C1 | 권고 | `role` | judged by reviewers only; nothing detects a hard-coded pass |
99
+ | C2 | 차단 | `hook:pre-commit`, `check:drift` | only when the hook is installed; the edit itself is not prevented |
100
+ | C3 | 차단 | `hook:pre-commit`, `check:drift` | only when the hook is installed; no deny rule covers .claude/settings.json itself |
101
+ | C4 | 차단 | `deny`, `hook:pre-commit` | Claude Code only; .env.* is a finite list, so names such as .env.custom have no deny rule; the hook sees staged paths, not reads |
102
+ | C5 | 차단 | `deny`, `gate`, `check:verdict` | combined or later-position forms such as git commit -nm are not denied |
103
+ | C6 | 권고 | `role` | pre-push holds pushes to the default branch (A4) and the deny rules stop force and --no-verify pushes; any other push, PR, merge, release or tag is not blocked |
104
+ | C7 | 권고 | `role` | — |
105
+ | C8 | 권고 | `role` | — |
106
+ | C9 | 권고 | `role` | — |
107
+ | C10 | 권고 | `role` | T2 lists it but the pre-commit check does not compare the diff with plan.md |
108
+ | A1 | 차단 | `deny`, `hook:pre-push` | moving a published tag forward to a descendant passes the ancestry test |
109
+ | A2 | 권고 | `role` | — |
110
+ | A3 | 권고 | `role` | — |
111
+ | A4 | 차단 | `hook:pre-push` | only a push to the default branch is held; other ways of leaving the machine are not detected |
112
+ | B1 | 검사 | `check:ticket-start` | — |
113
+ | B2 | 권고 | `role` | — |
114
+ | B3 | 권고 | `role`, `check:ticket-start` | the scope conflict is a role's judgement; ticket-start checks only the approval chain |
115
+ | B4 | 권고 | `role` | — |
116
+ | B5 | 권고 | `role` | — |
117
+ | P1 | 권고 | `role` | — |
118
+ | P2 | 검사 | `check:ticket-start`, `check:rc-close` | only ticket-in-plan; a diff is not compared with plan.md |
119
+ | D1 | 검사 | `check:verdict` | does not tell a ticket before rc.1 from an rc after |
120
+ | D2 | 권고 | `role` | no memory across runs |
121
+ | D3 | 권고 | `role` | no alone-versus-full-run comparison |
122
+ | D4 | 차단 | `gate`, `check:verdict` | an empty gate output is only a WARN |
123
+ | D5 | 검사 | `check:verdict` | — |
124
+ | E1 | 권고 | `role` | nothing reads a budget or a token count |
125
+ | E2 | 권고 | `role` | nothing reads a budget or a token count |
126
+ | E3 | 권고 | `role` | T5 lists it but nothing reads a budget or a token count |
127
+ | F1 | 권고 | `role` | the deny rules stop some attempts in Claude Code, but no stop is recorded |
128
+ | F2 | 차단 | `hook:pre-commit`, `check:drift`, `check:ticket-start`, `check:rc-close` | — |
129
+ | F3 | 권고 | `role` | — |
130
+ | G1 | 권고 | `role` | no signal handler and no resume record on an interrupt |
131
+ | G2 | 권고 | `role` | — |
132
+ | T1 | 검사 | `check:ticket-start` | budget-left is not implemented |
133
+ | T2 | 차단 | `hook:pre-commit` | only when the hook is installed; the P2 and C10 diff checks do not exist |
134
+ | T3 | 검사 | `check:verdict` | — |
135
+ | T4 | 차단 | `hook:pre-push` | implements A1 and the default-branch push (A4); A2, A3, C6 and the loop-step check do not exist |
136
+ | T5 | 검사 | `check:rc-close` | E3 is not implemented |
137
+ | T6 | 권고 | `role` | no code runs on an interrupt or a violation signal |
138
+
139
+ | 역할 | 차단 | 검사 | 권고 | 차단되는 항목 |
140
+ |---|---|---|---|---|
141
+ | advisor | 0 | 0 | 2 | — |
142
+ | code-review | 1 | 0 | 2 | edit code |
143
+ | deploy | 1 | 0 | 2 | force-push, delete or move tags, rewrite main |
144
+ | docs | 0 | 0 | 3 | — |
145
+ | implementer | 0 | 0 | 5 | — |
146
+ | lookup | 3 | 0 | 0 | write any file; produce reports or context files; run gates or tests |
147
+ | planner | 0 | 0 | 3 | — |
148
+ | pl | 0 | 0 | 3 | — |
149
+ | pm | 0 | 1 | 2 | — |
150
+ | qa-design | 0 | 0 | 3 | — |
151
+ | qa-run | 0 | 0 | 2 | — |
152
+ | verify-tool | 0 | 2 | 1 | — |
153
+ | 예산 범위 | 0 | 0 | 6 | — |
154
+ <!-- enforcement:end -->
155
+
156
+ 표는 `pnpm docs:enforcement`로 만들고, 테스트가 YAML과 같은지 확인합니다.
157
+
81
158
  ## 시작하기
82
159
 
83
160
  Claude Code에서는 플러그인을 설치하면 저장소 설정까지 맡길 수 있습니다.
@@ -88,7 +165,7 @@ Claude Code에서는 플러그인을 설치하면 저장소 설정까지 맡길
88
165
  /reins:reins-setup
89
166
  ```
90
167
 
91
- Codex, Antigravity, Cursor나 터미널에서는 CLI를 씁니다. Node 20 이상이 필요합니다. 설치하려는 저장소의 루트에서 실행하며, 저장소에 커밋이 하나 이상 있어야
168
+ Codex, Antigravity, Cursor나 터미널에서는 CLI를 씁니다. Node 22 이상이 필요합니다. 설치하려는 저장소의 루트에서 실행하며, 저장소에 커밋이 하나 이상 있어야
92
169
  합니다(0.1.0의 `check`는 커밋이 없는 저장소에서 실패합니다).
93
170
 
94
171
  ```sh
@@ -0,0 +1,98 @@
1
+ schema: reins/policy/enforcement@1
2
+ # How each rule is held today (design §2·§3). One line per rule; this is a statement of fact, not of intent:
3
+ # `stops.yaml` `detect:` says what the design wants, `held:` says what the code does.
4
+ # held: blocked a script, hook or permission deny stops the action before it happens
5
+ # checked a transition check, the drift check or CI catches it afterwards
6
+ # advised written in a role or skill only; nothing in code catches it
7
+ # The grade is the strongest part that really holds; what is left open goes in `gap:`.
8
+ # by: deny · hook:pre-commit · hook:pre-push · check:<stage> · check:drift · gate · ci · agent-tools · role
9
+ # Keys: C1–C10, A1–G2, T1–T6, `<role>#<n>` (n counts the role's `must_not` items from 1), `budget:<scope>`.
10
+ # The tables in README.md, docs/README.ko.md and docs/design*.md are rendered from this file (`pnpm docs:enforcement`).
11
+ rules:
12
+ # common red lines
13
+ - { id: C1, held: advised, by: [role], gap: "judged by reviewers only; nothing detects a hard-coded pass" }
14
+ - { id: C2, held: blocked, by: [hook:pre-commit, check:drift], gap: "only when the hook is installed; the edit itself is not prevented" }
15
+ - { id: C3, held: blocked, by: [hook:pre-commit, check:drift], gap: "only when the hook is installed; no deny rule covers .claude/settings.json itself" }
16
+ - { id: C4, held: blocked, by: [deny, hook:pre-commit], gap: "Claude Code only; .env.* is a finite list, so names such as .env.custom have no deny rule; the hook sees staged paths, not reads" }
17
+ - { id: C5, held: blocked, by: [deny, gate, check:verdict], gap: "combined or later-position forms such as git commit -nm are not denied" }
18
+ - { id: C6, held: advised, by: [role], gap: "pre-push holds pushes to the default branch (A4) and the deny rules stop force and --no-verify pushes; any other push, PR, merge, release or tag is not blocked" }
19
+ - { id: C7, held: advised, by: [role] }
20
+ - { id: C8, held: advised, by: [role] }
21
+ - { id: C9, held: advised, by: [role] }
22
+ - { id: C10, held: advised, by: [role], gap: "T2 lists it but the pre-commit check does not compare the diff with plan.md" }
23
+ # stop conditions
24
+ - { id: A1, held: blocked, by: [deny, hook:pre-push], gap: "moving a published tag forward to a descendant passes the ancestry test" }
25
+ - { id: A2, held: advised, by: [role] }
26
+ - { id: A3, held: advised, by: [role] }
27
+ - { id: A4, held: blocked, by: [hook:pre-push], gap: "only a push to the default branch is held; other ways of leaving the machine are not detected" }
28
+ - { id: B1, held: checked, by: [check:ticket-start] }
29
+ - { id: B2, held: advised, by: [role] }
30
+ - { id: B3, held: advised, by: [role, check:ticket-start], gap: "the scope conflict is a role's judgement; ticket-start checks only the approval chain" }
31
+ - { id: B4, held: advised, by: [role] }
32
+ - { id: B5, held: advised, by: [role] }
33
+ - { id: P1, held: advised, by: [role] }
34
+ - { id: P2, held: checked, by: [check:ticket-start, check:rc-close], gap: "only ticket-in-plan; a diff is not compared with plan.md" }
35
+ - { id: D1, held: checked, by: [check:verdict], gap: "does not tell a ticket before rc.1 from an rc after" }
36
+ - { id: D2, held: advised, by: [role], gap: "no memory across runs" }
37
+ - { id: D3, held: advised, by: [role], gap: "no alone-versus-full-run comparison" }
38
+ - { id: D4, held: blocked, by: [gate, check:verdict], gap: "an empty gate output is only a WARN" }
39
+ - { id: D5, held: checked, by: [check:verdict] }
40
+ - { id: E1, held: advised, by: [role], gap: "nothing reads a budget or a token count" }
41
+ - { id: E2, held: advised, by: [role], gap: "nothing reads a budget or a token count" }
42
+ - { id: E3, held: advised, by: [role], gap: "T5 lists it but nothing reads a budget or a token count" }
43
+ - { id: F1, held: advised, by: [role], gap: "the deny rules stop some attempts in Claude Code, but no stop is recorded" }
44
+ - { id: F2, held: blocked, by: [hook:pre-commit, check:drift, check:ticket-start, check:rc-close] }
45
+ - { id: F3, held: advised, by: [role] }
46
+ - { id: G1, held: advised, by: [role], gap: "no signal handler and no resume record on an interrupt" }
47
+ - { id: G2, held: advised, by: [role] }
48
+ # transition points
49
+ - { id: T1, held: checked, by: [check:ticket-start], gap: "budget-left is not implemented" }
50
+ - { id: T2, held: blocked, by: [hook:pre-commit], gap: "only when the hook is installed; the P2 and C10 diff checks do not exist" }
51
+ - { id: T3, held: checked, by: [check:verdict] }
52
+ - { id: T4, held: blocked, by: [hook:pre-push], gap: "implements A1 and the default-branch push (A4); A2, A3, C6 and the loop-step check do not exist" }
53
+ - { id: T5, held: checked, by: [check:rc-close], gap: "E3 is not implemented" }
54
+ - { id: T6, held: advised, by: [role], gap: "no code runs on an interrupt or a violation signal" }
55
+ # role must_not items, in file order
56
+ - { id: "advisor#1", held: advised, by: [role] }
57
+ - { id: "advisor#2", held: advised, by: [role] }
58
+ - { id: "code-review#1", held: blocked, by: [agent-tools], gap: "Claude agent files only (disallowedTools); shell stays open, so a shell write is not stopped" }
59
+ - { id: "code-review#2", held: advised, by: [role] }
60
+ - { id: "code-review#3", held: advised, by: [role] }
61
+ - { id: "deploy#1", held: advised, by: [role], gap: "the stable dispatch line is only printed on request, nothing refuses it" }
62
+ - { id: "deploy#2", held: blocked, by: [deny, hook:pre-push], gap: "see A1" }
63
+ - { id: "deploy#3", held: advised, by: [role] }
64
+ - { id: "docs#1", held: advised, by: [role] }
65
+ - { id: "docs#2", held: advised, by: [role] }
66
+ - { id: "docs#3", held: advised, by: [role] }
67
+ - { id: "implementer#1", held: advised, by: [role], gap: "see C10" }
68
+ - { id: "implementer#2", held: advised, by: [role] }
69
+ - { id: "implementer#3", held: advised, by: [role], gap: "see C1" }
70
+ - { id: "implementer#4", held: advised, by: [role], gap: "see C6" }
71
+ - { id: "implementer#5", held: advised, by: [role] }
72
+ - { id: "lookup#1", held: blocked, by: [agent-tools], gap: "Claude agent files only" }
73
+ - { id: "lookup#2", held: blocked, by: [agent-tools], gap: "Claude agent files only" }
74
+ - { id: "lookup#3", held: blocked, by: [agent-tools], gap: "Claude agent files only" }
75
+ - { id: "planner#1", held: advised, by: [role] }
76
+ - { id: "planner#2", held: advised, by: [role], gap: "see C10" }
77
+ - { id: "planner#3", held: advised, by: [role], gap: "ticket-start checks that the spec is accepted, not who accepted it" }
78
+ - { id: "pl#1", held: advised, by: [role], gap: "see C6" }
79
+ - { id: "pl#2", held: advised, by: [role] }
80
+ - { id: "pl#3", held: advised, by: [role] }
81
+ - { id: "pm#1", held: advised, by: [role] }
82
+ - { id: "pm#2", held: checked, by: [check:ticket-start], gap: "needs a user entry in approvals and an Approved-by commit trailer; the trailer text can be written by anyone" }
83
+ - { id: "pm#3", held: advised, by: [role], gap: "see C6" }
84
+ - { id: "qa-design#1", held: advised, by: [role] }
85
+ - { id: "qa-design#2", held: advised, by: [role] }
86
+ - { id: "qa-design#3", held: advised, by: [role] }
87
+ - { id: "qa-run#1", held: advised, by: [role] }
88
+ - { id: "qa-run#2", held: advised, by: [role] }
89
+ - { id: "verify-tool#1", held: advised, by: [role] }
90
+ - { id: "verify-tool#2", held: checked, by: [check:verdict], gap: "evidence is text a role writes; the check reads its command line and exit code" }
91
+ - { id: "verify-tool#3", held: checked, by: [check:verdict], gap: "evidence is text a role writes; the check reads its command line and exit code" }
92
+ # budget scopes (budget.yaml)
93
+ - { id: "budget:project", held: advised, by: [role], gap: "no defaults and no reader" }
94
+ - { id: "budget:version", held: advised, by: [role], gap: "no reader" }
95
+ - { id: "budget:rc", held: advised, by: [role], gap: "no reader" }
96
+ - { id: "budget:ticket", held: advised, by: [role], gap: "no reader" }
97
+ - { id: "budget:session", held: advised, by: [role], gap: "no reader" }
98
+ - { id: "budget:role", held: advised, by: [role], gap: "no reader" }