polydeukes 0.6.1 → 0.7.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.
Files changed (106) hide show
  1. package/README.ko.md +14 -28
  2. package/README.md +14 -28
  3. package/dist/baseline.d.ts +37 -1
  4. package/dist/baseline.js +68 -1
  5. package/dist/bin.d.ts +3 -4
  6. package/dist/bin.js +73 -90
  7. package/dist/covenant/bash-line.d.ts +130 -0
  8. package/dist/covenant/bash-line.js +566 -0
  9. package/dist/covenant/declaration-engine.d.ts +108 -0
  10. package/dist/covenant/declaration-engine.js +415 -0
  11. package/dist/covenant/discipline.d.ts +103 -0
  12. package/dist/covenant/discipline.js +667 -0
  13. package/dist/covenant/dispatch.d.ts +153 -0
  14. package/dist/covenant/dispatch.js +237 -0
  15. package/dist/covenant/extract-steps.d.ts +122 -0
  16. package/dist/covenant/extract-steps.js +0 -0
  17. package/dist/covenant/mention.d.ts +117 -0
  18. package/dist/covenant/mention.js +209 -0
  19. package/dist/covenant/module.d.ts +25 -0
  20. package/dist/covenant/module.js +23 -0
  21. package/dist/covenant/mutation-rules.d.ts +40 -0
  22. package/dist/covenant/mutation-rules.js +146 -0
  23. package/dist/covenant/relations.d.ts +46 -0
  24. package/dist/covenant/relations.js +68 -0
  25. package/dist/covenant/run-covenant.d.ts +95 -0
  26. package/dist/covenant/run-covenant.js +164 -0
  27. package/dist/covenant/self-mod.d.ts +55 -0
  28. package/dist/covenant/self-mod.js +84 -0
  29. package/dist/covenant/shell-evidence.d.ts +38 -0
  30. package/dist/covenant/shell-evidence.js +247 -0
  31. package/dist/covenant/shell-mod.d.ts +84 -0
  32. package/dist/covenant/shell-mod.js +213 -0
  33. package/dist/covenant/supply.d.ts +54 -0
  34. package/dist/covenant/supply.js +50 -0
  35. package/dist/covenant/transcript-mod.d.ts +60 -0
  36. package/dist/covenant/transcript-mod.js +254 -0
  37. package/dist/covenant/ttl-witness.d.ts +47 -0
  38. package/dist/covenant/ttl-witness.js +80 -0
  39. package/dist/covenant-check.d.ts +72 -39
  40. package/dist/covenant-check.js +260 -121
  41. package/dist/diff-ir.d.ts +28 -0
  42. package/dist/diff-ir.js +310 -0
  43. package/dist/docs/README.ko.md +8 -8
  44. package/dist/docs/README.md +8 -8
  45. package/dist/docs/catalog.json +44 -28
  46. package/dist/docs/concepts/judgment.ko.md +2 -2
  47. package/dist/docs/concepts/judgment.md +2 -2
  48. package/dist/docs/how-to/configure-project.ko.md +16 -16
  49. package/dist/docs/how-to/configure-project.md +15 -12
  50. package/dist/docs/how-to/connect-surfaces.ko.md +39 -34
  51. package/dist/docs/how-to/connect-surfaces.md +36 -33
  52. package/dist/docs/how-to/write-disciplines.ko.md +61 -6
  53. package/dist/docs/how-to/write-disciplines.md +62 -6
  54. package/dist/docs/index.json +607 -373
  55. package/dist/docs/reference/cli/covenant-check.ko.md +112 -65
  56. package/dist/docs/reference/cli/covenant-check.md +114 -59
  57. package/dist/docs/reference/cli/docs.ko.md +2 -2
  58. package/dist/docs/reference/cli/docs.md +2 -2
  59. package/dist/docs/reference/cli/explain.ko.md +14 -9
  60. package/dist/docs/reference/cli/explain.md +15 -10
  61. package/dist/docs/reference/cli/init.ko.md +52 -52
  62. package/dist/docs/reference/cli/init.md +43 -55
  63. package/dist/docs/reference/configuration/index.ko.md +171 -66
  64. package/dist/docs/reference/configuration/index.md +178 -71
  65. package/dist/docs/reference/packages/adapter-claude-code.ko.md +38 -11
  66. package/dist/docs/reference/packages/adapter-claude-code.md +38 -14
  67. package/dist/docs/reference/packages/adapter-grok.ko.md +77 -0
  68. package/dist/docs/reference/packages/adapter-grok.md +79 -0
  69. package/dist/docs/reference/packages/core.ko.md +49 -3
  70. package/dist/docs/reference/packages/core.md +54 -5
  71. package/dist/docs/reference/packages/polydeukes.ko.md +138 -77
  72. package/dist/docs/reference/packages/polydeukes.md +146 -81
  73. package/dist/docs/reference/packages/sdk-ts.ko.md +161 -0
  74. package/dist/docs/reference/packages/sdk-ts.md +164 -0
  75. package/dist/docs/troubleshooting.ko.md +17 -15
  76. package/dist/docs/troubleshooting.md +18 -14
  77. package/dist/docs/tutorials/first-judgment.ko.md +2 -2
  78. package/dist/docs/tutorials/first-judgment.md +2 -2
  79. package/dist/explain.d.ts +1 -1
  80. package/dist/explain.js +37 -22
  81. package/dist/load-config.d.ts +1 -1
  82. package/dist/load-config.js +1 -1
  83. package/dist/pre-state-reader.d.ts +1 -1
  84. package/dist/pre-state-reader.js +1 -1
  85. package/dist/scaffold-project.d.ts +2 -2
  86. package/dist/scaffold-project.js +9 -3
  87. package/dist/schema/polydeukes.schema.json +12 -0
  88. package/dist/worktree-reader.d.ts +19 -0
  89. package/dist/worktree-reader.js +30 -0
  90. package/package.json +3 -17
  91. package/dist/claude-code-hook.d.ts +0 -79
  92. package/dist/claude-code-hook.js +0 -372
  93. package/dist/claude-code.d.ts +0 -6
  94. package/dist/claude-code.js +0 -6
  95. package/dist/covenant-module.d.ts +0 -25
  96. package/dist/covenant-module.js +0 -42
  97. package/dist/docs/reference/packages/adapter-git.ko.md +0 -101
  98. package/dist/docs/reference/packages/adapter-git.md +0 -108
  99. package/dist/docs/reference/packages/covenant.ko.md +0 -115
  100. package/dist/docs/reference/packages/covenant.md +0 -123
  101. package/dist/index.d.ts +0 -22
  102. package/dist/index.js +0 -21
  103. package/dist/init-claude-code.d.ts +0 -52
  104. package/dist/init-claude-code.js +0 -586
  105. package/dist/init-grok.d.ts +0 -51
  106. package/dist/init-grok.js +0 -242
@@ -2,19 +2,21 @@
2
2
 
3
3
  [English](../how-to/connect-surfaces.md) · **한국어**
4
4
 
5
- > 작업에 맞는 표면을 고릅니다. Claude Code와 Grok는 세션 표면을 배선하고, git은 커밋 표면을 배선합니다.
5
+ > 작업에 맞는 표면을 고릅니다. Claude Code와 Grok는 세션 표면을 배선하고, git은 변경 집합 표면을 배선합니다.
6
6
 
7
7
  두 표면은 같은 설정 어휘를 쓰지만 판정 시점이 다릅니다. AI 파트너가 편집할 때는 세션 표면을,
8
- 변경을 이력으로 기록하기 전에는 커밋 표면을 사용합니다.
8
+ 변경을 이력으로 기록하기 전에는 변경 집합 표면을 사용합니다.
9
9
 
10
10
  <a id="claude-code"></a>
11
11
  ## Claude Code 세션 표면
12
12
 
13
13
  Claude Code에서 AI 파트너와 함께 개발할 때 씁니다.
14
14
 
15
- 1. 패키지를 프로젝트 의존성으로 설치합니다. `pnpm add -D polydeukes`. 일회성 `npx` 실행만으로는
16
- 부족합니다. 두 표면 모두 프로젝트에 설치된 패키지에서 판정기를 불러옵니다.
17
- 2. 프로젝트를 배선합니다. `pnpm exec pdks init claude-code`.
15
+ 1. 패키지를 프로젝트 의존성으로 설치합니다. `pnpm add -D polydeukes
16
+ @polydeukes/adapter-claude-code`. 일회성 `npx` 실행만으로는 부족합니다. 두 표면 모두
17
+ 프로젝트에 설치된 패키지에서 판정기를 불러옵니다.
18
+ 2. 프로젝트 루트에서 배선합니다. `pnpm exec pdks-claude-code init`. 이 실행 파일은 어댑터가
19
+ 제공하며, 먼저 `pdks init`으로 초기 파일을 만든 뒤 Claude Code 등록 산출물을 씁니다.
18
20
  3. 생성된 훅, 병합된 설정, 초기 설정 파일, 문서 안내와 `discipline-draft` 스킬을 확인합니다.
19
21
  4. 훅이 바뀌면 프로젝트를 다시 엽니다. 생성된 훅은 패키지에 판정을 위임하므로 패키지를
20
22
  갱신할 때 훅 파일까지 다시 쓸 필요는 없습니다.
@@ -29,54 +31,55 @@ Claude Code에서 AI 파트너와 함께 개발할 때 씁니다.
29
31
 
30
32
  Grok에서 개발할 때 씁니다.
31
33
 
32
- 1. 패키지를 프로젝트 의존성으로 설치합니다. `pnpm add -D polydeukes`.
33
- 2. 프로젝트를 배선합니다. `pnpm exec pdks init grok`.
34
+ 1. 패키지를 프로젝트 의존성으로 설치합니다. `pnpm add -D polydeukes @polydeukes/adapter-grok`.
35
+ 2. 프로젝트 루트에서 배선합니다. `pnpm exec pdks-grok init`. 어댑터가 이 실행 파일을
36
+ 제공합니다. 먼저 `pdks init`으로 초기 파일을 만든 뒤 Grok 등록 산출물을 씁니다.
34
37
  3. 설치가 끝나면 Hooks 탭을 다시 불러오거나 새 세션을 엽니다.
35
38
 
36
- Grok 프로젝트에는 `.grok/hooks/` 아래에 훅 JSON 파일이 생깁니다. Claude 훅이 이미 있으면
37
- Grok `command`도 파일을 가리킵니다. `.claude/settings.json`도 있다면 같은 `command`를
38
- 등록한 Claude 항목에 맞춰 Grok의 `matcher`를 설정합니다. 값이 모두 같아야 Grok가 중복 등록을
39
- 하나로 처리해 판정기를 두 번 실행하지 않기 때문입니다.
40
- 새 등록의 제한 시간은 60초입니다. Grok 호스트의 기본값은 5초이며, 훅 실행이 시간 초과로
41
- 끝나면 해당 호출을 차단하지 않습니다(fail-open).
39
+ Grok 프로젝트에는 `.grok/hooks/` 아래에 훅 JSON 위임자가 생깁니다. 등록의 제한 시간은
40
+ 60초입니다. Grok 호스트의 기본값은 5초이며, 실행이 시간 초과로 끝나면 해당 호출을
41
+ 차단하지 않습니다(fail-open). 세션 어댑터를 프로젝트에 함께 설치하면 호출마다
42
+ 판정기가 두 번 실행될 있습니다.
42
43
 
43
- Grok는 세션 증인 밸브에 필요한 Claude 형식의 인간 메시지를 공급하지 않습니다. 대화 기록은
44
- Claude JSONL이 아니라 ACP `updates.jsonl`입니다.
45
- 의도한 편집이 차단되면 자신의 터미널에서 수행하세요. 커밋 표면의 증인 프롬프트는 해당
46
- 커밋에만 적용되며, 차단된 Grok 도구 호출을 허용하지는 않습니다.
44
+ Grok는 세션 증인(witness) 밸브에 필요한 Claude 형식의 인간 메시지를 공급하지 않습니다. 대화
45
+ 기록은 Claude JSONL이 아니라 ACP `updates.jsonl`입니다.
46
+ 의도한 편집이 차단되면 자신의 터미널에서 수행하세요. 변경 집합 표면에는 증인 프롬프트가 없으므로
47
+ 차단된 Grok 도구 호출을 커밋 쪽에서 허용할 방법도 없습니다.
47
48
 
48
- <a id="commit-surface"></a>
49
- ## 커밋 표면
49
+ <a id="change-set-surface"></a>
50
+ ## 변경 집합 표면
50
51
 
51
52
  스테이징한 변경을 이력으로 기록하기 전에 Git에서 판정하려면 이 표면을 사용합니다.
52
53
 
53
54
  1. 프로젝트 루트에 `polydeukes.config.yaml`을 만듭니다.
54
55
  2. pre-commit 훅을 추가합니다.
55
- 3. 필요할 때는 `pnpm exec pdks covenant check`를 직접 돌려 같은 판정을 봅니다.
56
+ 3. 필요할 때는 `git diff HEAD | pnpm exec pdks covenant check --diff`를 직접 돌려 같은
57
+ 판정을 봅니다.
56
58
 
57
- lefthook 예시는 다음과 같습니다.
59
+ lefthook 예시는 다음과 같습니다. `git diff`의 플래그는 판정기가 받는 것을 고정합니다. 색 코드
60
+ 없음, 외부 diff 드라이버 없음, textconv 변환 없음, 번역기가 벗기는 `a/`·`b/` 접두입니다. 사용자의
61
+ git 설정이 관측을 바꾸지 못합니다(CLI 레퍼런스 참고).
58
62
 
59
63
  ```yaml
60
64
  pre-commit:
61
65
  commands:
62
66
  covenant:
63
67
  priority: 1
64
- interactive: true
65
- run: ./node_modules/.bin/pdks covenant check
68
+ run: git diff --cached --no-color --no-ext-diff --no-textconv --src-prefix=a/ --dst-prefix=b/ | ./node_modules/.bin/pdks covenant check --diff
66
69
  ```
67
70
 
68
71
  husky 예시는 다음과 같습니다.
69
72
 
70
73
  ```sh
71
74
  # .husky/pre-commit
72
- ./node_modules/.bin/pdks covenant check
75
+ git diff --cached --no-color --no-ext-diff --no-textconv --src-prefix=a/ --dst-prefix=b/ | ./node_modules/.bin/pdks covenant check --diff
73
76
  ```
74
77
 
75
78
  일반 git 훅으로 연결해도 됩니다.
76
79
 
77
80
  ```sh
78
81
  #!/bin/sh
79
- ./node_modules/.bin/pdks covenant check
82
+ git diff --cached --no-color --no-ext-diff --no-textconv --src-prefix=a/ --dst-prefix=b/ | ./node_modules/.bin/pdks covenant check --diff
80
83
  ```
81
84
 
82
85
  일반 훅은 `.git/hooks/pre-commit`으로 저장한 뒤 `chmod +x .git/hooks/pre-commit`으로
@@ -84,12 +87,13 @@ husky 예시는 다음과 같습니다.
84
87
  관리자로 설치하고 YAML을 저장한 뒤 훅 설치 명령을 실행합니다. husky는 git이 찾을 수 있도록
85
88
  husky 설치기로 `.husky/pre-commit`을 저장하세요.
86
89
 
87
- `adapters.git.enforce: advise`이면 위반을 `advised`로 기록하고 stderr에 알린 커밋을
88
- 허용합니다. `block`이면 보호 경로 위반과 `enforce: block`으로 지정한 항목의 위반을
89
- 차단할 있습니다. 일반 항목의 기본값은 여전히 `advise`이며 표면 설정이 이를 승격하지
90
- 않습니다. 증인이 설정돼 있고 터미널에 연결된 경우, 스테이징 검사에서 `/dev/tty` 프롬프트를
91
- 제공합니다. `--worktree`와 `--range`는 프롬프트 없이 보고합니다. 조립 실패는 어느 강제
92
- 수준에서도 종료 코드 2를 반환합니다.
90
+ 판정기는 종료 코드 0 또는 2만 내고 사람에게 묻지 않습니다. 기본값에서는 `protectedPaths`
91
+ 위반을 포함한 표면의 모든 위반이 stderr에 진단 줄을 남기고 행으로 기록되며 종료
92
+ 코드 0입니다. 스테이징된 관문 파일 변경은 이미 세션 표면에서 판정을 받았거나 사람이 직접
93
+ 것이고, 표면에는 사람이 답할 밸브가 없기 때문입니다. `protectedPaths` 위반이나
94
+ `enforce: block` 항목의 위반을 종료 코드 2로 받으려면 명령에 `--enforce block`을 붙입니다.
95
+ 커밋을 멈출지는 훅 배선이 정합니다. 위 예시는 종료 코드를 그대로 따릅니다. 조립 실패는
96
+ 언제나 종료 코드 2입니다.
93
97
 
94
98
  <a id="witness-and-recovery"></a>
95
99
  ## 증인과 회복
@@ -97,7 +101,8 @@ husky 설치기로 `.husky/pre-commit`을 저장하세요.
97
101
  증인 토큰은 두 표면에서 같은 뜻이지만 전달 방식은 다릅니다.
98
102
 
99
103
  - 세션 표면에서는 대화 메시지 첫 줄에 토큰만 단독으로 넣습니다.
100
- - 커밋 표면에서는 TTY 프롬프트에 전체 토큰을 입력합니다.
104
+ - 변경 집합 표면에는 프롬프트가 없습니다. 판정은 종료 코드로 전달되고, 그것으로 무엇을 할지는
105
+ 훅 배선이 정합니다.
101
106
 
102
107
  밸브는 판정 결과가 차단일 때 확인합니다. 의도한 편집 전에 토큰을 입력해도 되며, 먼저
103
108
  실패하는 요청을 보낼 필요는 없습니다. 정상 판정은 바꾸지 않고, 현재 Grok 대화 기록
@@ -111,5 +116,5 @@ Grok가 훅을 아직 읽지 못했다면 Hooks 탭을 다시 불러오거나
111
116
 
112
117
  - `pdks explain`은 각 표면이 어떤 등록을 조립했는지 보여 줍니다.
113
118
  - `.polydeukes/roi.log`는 표면이 남긴 행을 기록합니다.
114
- - `pdks covenant check --worktree`는 작업 뒤에 쓰기 좋은 즉시 확인 명령입니다.
115
- - `pdks covenant check --range <base>..<head>`는 PR 전에 쓰기 좋은 형태입니다.
119
+ - `git diff HEAD | pdks covenant check --diff`는 작업 뒤에 쓰기 좋은 즉시 확인 명령입니다.
120
+ - `git diff <base>..<head> | pdks covenant check --diff`는 PR 전에 쓰기 좋은 형태입니다.
@@ -3,20 +3,22 @@
3
3
  **English** · [한국어](../how-to/connect-surfaces.ko.md)
4
4
 
5
5
  > Pick the surface that matches the job. Claude Code and Grok wire the session surface; git wires
6
- the commit surface.
6
+ the change-set surface.
7
7
 
8
8
  The two surfaces share the same config vocabulary, but they answer different moments. Use the
9
- session surface when an AI partner is making edits, and use the commit surface when history is about
10
- to be written.
9
+ session surface when an AI partner is making edits, and use the change-set surface when history
10
+ is about to be written.
11
11
 
12
12
  <a id="claude-code"></a>
13
13
  ## Claude Code session surface
14
14
 
15
15
  Use this when the project is developed alongside an AI partner in Claude Code.
16
16
 
17
- 1. Install the package as a project dependency: `pnpm add -D polydeukes`. A one-off `npx` run is
18
- not enough — both surfaces load the judge from the project's own installed package.
19
- 2. Wire the project: `pnpm exec pdks init claude-code`.
17
+ 1. Install both packages as project dependencies: `pnpm add -D polydeukes
18
+ @polydeukes/adapter-claude-code`. A one-off `npx` run is not enough — both surfaces load the
19
+ judge from the project's own installed package.
20
+ 2. Wire the project from its root: `pnpm exec pdks-claude-code init`. The adapter ships this bin;
21
+ it runs `pdks init` for the scaffold, then writes the Claude Code registration artifacts.
20
22
  3. Keep the generated hook file, settings merge, starter config, discovery rule, and
21
23
  discipline-draft skill.
22
24
  4. Reopen the project when the hook changes. The generated hook is a delegator, so upgrading the
@@ -32,54 +34,54 @@ described problem into either a judged entry or a draft entry.
32
34
 
33
35
  Use this when the project is developed in Grok.
34
36
 
35
- 1. Install the package as a project dependency: `pnpm add -D polydeukes`.
36
- 2. Wire the project: `pnpm exec pdks init grok`.
37
+ 1. Install both packages as project dependencies: `pnpm add -D polydeukes @polydeukes/adapter-grok`.
38
+ 2. Wire the project from its root: `pnpm exec pdks-grok init`. The adapter ships this bin; it
39
+ runs `pdks init` for the scaffold, then writes the Grok registration artifacts.
37
40
  3. Reload the Hooks tab or open a new session after the installer finishes.
38
41
 
39
- A Grok tree gets its own hook JSON under `.grok/hooks/`. When a Claude hook already exists, the Grok
40
- command points at that file so the host does not spawn two judges. If the tree also has
41
- `.claude/settings.json`, the Grok matcher follows the Claude registration that names the same
42
- command, because Grok collapses the two registrations only when command and matcher match.
43
- Generated registrations use a timeout of 60 seconds. The Grok host default is 5 seconds, and a
44
- timed-out hook fails open.
42
+ A Grok tree gets its own hook JSON and delegator under `.grok/hooks/`. Generated registrations
43
+ use a timeout of 60 seconds. The Grok host default is 5 seconds, and a timed-out hook fails
44
+ open. Installing both session adapters in one project can run the judge twice per call.
45
45
 
46
46
  Grok does not supply the Claude-format human message needed by the session witness valve. The
47
47
  session log is ACP `updates.jsonl`, not Claude's JSONL.
48
- For an intentional blocked edit, use your own terminal. A commit-surface prompt witnesses only
49
- that commit; it cannot authorize a blocked Grok tool call.
48
+ For an intentional blocked edit, use your own terminal. The change-set surface has no prompt, so
49
+ there is no way to authorize a blocked Grok tool call from that side either.
50
50
 
51
- <a id="commit-surface"></a>
52
- ## Commit surface
51
+ <a id="change-set-surface"></a>
52
+ ## Change-set surface
53
53
 
54
54
  Use this when you want git to judge staged changes before they become history.
55
55
 
56
56
  1. Create `polydeukes.config.yaml` at the project root.
57
57
  2. Add the pre-commit hook.
58
- 3. Run `pnpm exec pdks covenant check` when you want the same judgment on demand.
58
+ 3. Run `git diff HEAD | pnpm exec pdks covenant check --diff` when you want the same judgment
59
+ on demand.
59
60
 
60
- A minimal lefthook entry looks like this:
61
+ A minimal lefthook entry looks like this. The `git diff` flags pin what the judge receives:
62
+ no color codes, no external diff driver, no textconv rewrite, and the `a/`/`b/` prefixes the
63
+ translator strips — a user's git config cannot change the observation (see the CLI reference).
61
64
 
62
65
  ```yaml
63
66
  pre-commit:
64
67
  commands:
65
68
  covenant:
66
69
  priority: 1
67
- interactive: true
68
- run: ./node_modules/.bin/pdks covenant check
70
+ run: git diff --cached --no-color --no-ext-diff --no-textconv --src-prefix=a/ --dst-prefix=b/ | ./node_modules/.bin/pdks covenant check --diff
69
71
  ```
70
72
 
71
73
  A husky hook looks like this:
72
74
 
73
75
  ```sh
74
76
  # .husky/pre-commit
75
- ./node_modules/.bin/pdks covenant check
77
+ git diff --cached --no-color --no-ext-diff --no-textconv --src-prefix=a/ --dst-prefix=b/ | ./node_modules/.bin/pdks covenant check --diff
76
78
  ```
77
79
 
78
80
  A plain git hook works too:
79
81
 
80
82
  ```sh
81
83
  #!/bin/sh
82
- ./node_modules/.bin/pdks covenant check
84
+ git diff --cached --no-color --no-ext-diff --no-textconv --src-prefix=a/ --dst-prefix=b/ | ./node_modules/.bin/pdks covenant check --diff
83
85
  ```
84
86
 
85
87
  If you use the plain hook, save it as `.git/hooks/pre-commit` and make it executable with
@@ -87,12 +89,12 @@ If you use the plain hook, save it as `.git/hooks/pre-commit` and make it execut
87
89
  For lefthook, install it with your package manager and run its hook installer after saving the YAML.
88
90
  For husky, save `.husky/pre-commit` through husky's own installer so git can find it.
89
91
 
90
- `adapters.git.enforce: advise` records violations as `advised`, writes diagnostics to stderr,
91
- and lets the commit continue. With `block`, protected-path violations and entries explicitly set
92
- to `enforce: block` can stop the commit. An ordinary entry still defaults to `advise`; the surface
93
- does not promote it. When configured and attached to a terminal, the staged path offers a witness
94
- prompt on `/dev/tty`. `--worktree` and `--range` report without prompting. Assembly errors remain
95
- exit 2 at either level.
92
+ The judge emits exit 0 or exit 2 and never prompts. By default every break on this surface a
93
+ `protectedPaths` violation included lands as a row with a diagnostic on stderr and exit 0: a
94
+ staged gate-file change has already passed the session surface or was made by a human, and
95
+ this surface has no valve a human could answer. Add `--enforce block` to the command when you
96
+ want a `protectedPaths` violation or an entry set to `enforce: block` to exit 2. Whether a commit
97
+ stops is your hook wiring: the entries above honour the exit code. Assembly errors always exit 2.
96
98
 
97
99
  <a id="witness-and-recovery"></a>
98
100
  ## Witness and recovery
@@ -100,7 +102,8 @@ exit 2 at either level.
100
102
  The witness token is the same idea on both surfaces, but the delivery is different.
101
103
 
102
104
  - On the session surface, type the token on its own first line in a conversation message.
103
- - On the commit surface, type the full token into the TTY prompt.
105
+ - The change-set surface has no prompt. Its judgment reaches you as an exit code, and your hook
106
+ wiring decides what to do with it.
104
107
 
105
108
  The valve is consulted after the judgment returns a block. You can supply the token before an
106
109
  intentional edit; a previous failed attempt is not required. It does not change a passing verdict
@@ -114,5 +117,5 @@ cannot be loaded, reinstall the package or rebuild the workspace and try again.
114
117
 
115
118
  - `pdks explain` shows which registrations each surface assembled.
116
119
  - `.polydeukes/roi.log` records the rows that the surfaces wrote.
117
- - `pdks covenant check --worktree` is a good on-demand check after a task.
118
- - `pdks covenant check --range <base>..<head>` is the shape to use before a PR.
120
+ - `git diff HEAD | pdks covenant check --diff` is a good on-demand check after a task.
121
+ - `git diff <base>..<head> | pdks covenant check --diff` is the shape to use before a PR.
@@ -50,7 +50,7 @@ disciplines:
50
50
 
51
51
  `flattenKeys`는 번역 값이 아니라 키를 추출합니다. `equal`은 양방향으로 비교하고,
52
52
  `messageBySide`는 어느 파일에 짝이 없는 키가 있는지 알려 줍니다. 기본 강제 수준은
53
- `advise`입니다. 소스 파일 둘 다 존재하고 올바른 JSON이어야 합니다. 커밋 표면은 선택한
53
+ `advise`입니다. 소스 파일 둘 다 존재하고 올바른 JSON이어야 합니다. 변경 집합 표면은 선택한
54
54
  관측 범위에서 파일을 읽고, 세션 편집에서는 바뀌는 파일의 편집 후 내용을 사용합니다.
55
55
 
56
56
  예제 프로젝트 루트에서 키가 같은 파일을 만들고 git 추적 대상으로 등록합니다.
@@ -64,7 +64,7 @@ printf '{"home":"홈"}\n' > locales/ko.json
64
64
  git add locales/en.json locales/ko.json
65
65
  git commit -m 'docs: prepare locale example'
66
66
  printf '{"home":"Home","settings":"Settings"}\n' > locales/en.json
67
- pnpm exec pdks covenant check --worktree
67
+ git diff HEAD | pnpm exec pdks covenant check --diff
68
68
  ```
69
69
 
70
70
  `locale-key-parity`의 `advised` 진단에 영어에만 있는 `settings` 키가 나와야 합니다.
@@ -72,7 +72,7 @@ pnpm exec pdks covenant check --worktree
72
72
 
73
73
  ```sh
74
74
  printf '{"home":"홈","settings":"설정"}\n' > locales/ko.json
75
- pnpm exec pdks covenant check --worktree
75
+ git diff HEAD | pnpm exec pdks covenant check --diff
76
76
  ```
77
77
 
78
78
  이제 키 비교 진단이 없어야 합니다. 번역 값은 서로 다르지만 키는 같습니다.
@@ -82,11 +82,66 @@ pnpm exec pdks covenant check --worktree
82
82
  git restore -- locales/en.json locales/ko.json
83
83
  ```
84
84
 
85
- `--worktree`는 git이 추적하지 않더라도 무시 대상이 아닌 파일을 추가된 파일로 포함합니다.
86
- 이 예제는 수정 사례를 검사하고 쉽게 원상 복구하기 위해 기준 상태를 커밋합니다.
85
+ `git diff HEAD`는 마지막 커밋과의 차이를 냅니다. 아직 git이 추적하지 않는 파일은
86
+ `git add -N`을 거쳐야 diff에 나타납니다. 이 예제는 수정 사례를 검사하고 쉽게 원상 복구하기
87
+ 위해 기준 상태를 커밋합니다.
87
88
  소스 파일이 존재한다는 이유만으로 선언이 실행되지는 않습니다. 관측된 변경 중 하나
88
89
  이상이 해당 선언의 적용 범위와 일치해야 합니다.
89
90
 
91
+ <a id="which-list"></a>
92
+ ## 어느 목록에 적는가
93
+
94
+ 규율 목록은 셋이고, 항목이 어느 목록에 속하는지는 소스 축이 정합니다. 기전이 정하지도 않고
95
+ 관계가 정하지도 않습니다. 같은 `companion` 기전이라도 `file` 소스 위에 서면 `disciplines`에
96
+ 있고 `changes` 위에 서면 `changeSetDisciplines`에 있습니다. 선언의 소스를 읽으면 목록이
97
+ 따라 나옵니다.
98
+
99
+ | 선언이 읽는 것 | 목록 | 예 |
100
+ |---|---|---|
101
+ | 변경된 파일과 `file` 소스만 | `disciplines` | 파일 형상 유형들. 신규분 한정, 비가역 표식, 자기사면 금지, 통제 어휘, 이름 규약, `file` 소스 위의 동반 의무, 지문 동기, 순서 불변 |
102
+ | 대화 기록(transcript) | `sessionDisciplines` | 이력 4종. 선행 요구, 단계 순서, 턴 근접, 사전 언명 |
103
+ | 주체(actor) | `sessionDisciplines` | 생산자 전속, 주체 한정 |
104
+ | 명령줄 | `sessionDisciplines` | 명령줄 금지 |
105
+ | 스폰 기록 통로(`sidecar`) | `sessionDisciplines` | `{ sidecar: true }`를 묶는 모든 선언 |
106
+ | `changes` | `changeSetDisciplines` | 변경 집합 위의 짝 맞춤. 함께 움직여야 하는 경로 둘 사이의 `implies` |
107
+
108
+ 항목은 그 소스가 가리키는 목록에 적습니다. 자리를 잘못 잡은 항목은 로드 시점 오류이고,
109
+ 메시지가 항목과 그 항목이 읽는 통로와 가야 할 목록을 함께 대므로, 본문을 그대로 옮기면
110
+ 됩니다. 규칙 자체와 오류 모양은
111
+ [설정 참조](../reference/configuration/index.ko.md#placement-rule)에 있습니다.
112
+
113
+ 표면이 공급해야 할 것을 본체가 읽지 않아도 실제로는 표면에 묶이는 항목이 있습니다. 대화
114
+ 기록을 읽는 밸브(`witness`)가 달린 항목은 밸브 자신의 `extract`가 대화 기록을 묶으므로 세션
115
+ 항목이 됩니다.
116
+
117
+ <a id="posture"></a>
118
+ ## 무인 실시간 표면의 기본 자세
119
+
120
+ 무인 실시간 표면은 터미널 앞에 사람이 없는 어댑터 훅이나 SDK 호출자입니다. 사람이 지켜보는
121
+ 자리에는 적용되지 않는 규칙 둘이 이곳에 적용됩니다.
122
+
123
+ **루프가 회차 안에서 스스로 고치지 못하는 항목을 `enforce: block`으로 올립니다.** 기준은
124
+ "되돌릴 수 없는가"가 아닙니다. 실시간 차단의 비용은 초 단위입니다. 모델이 stderr의 사유를
125
+ 읽고 다시 시도하므로 위반이 그 회차 안에서 고쳐집니다. `advise`로 두면 같은 위반이 뒤의
126
+ 검사, 곧 테스트 실행이나 CI나 리뷰어에게까지 가서 회차 하나를 쓰며 최대 45분이 듭니다.
127
+ "무인이니 전부 차단"이라는 뜻은 아닙니다. 차단은 회피를 낳고 회피는 텔레메트리 행을 남기지
128
+ 않으므로, 루프가 손댈 수 없는 항목은 위반이라도 기록되는 `advise`에 두는 편이 낫습니다. 이
129
+ 기준은 설정 저자의 것입니다.
130
+
131
+ **밸브가 없으므로 사유가 값으로 돌아옵니다.** 실시간 무인 표면에는 증인 밸브가 없습니다.
132
+ TTY도 사람의 턴도 없고, SDK는 증인 인자를 받지 않으며 세션을 지어내지도 않습니다. 그 자리를
133
+ 대신하는 것이 사유를 데이터로 돌려주는 일입니다. `checkCovenant`는
134
+ `{ verdict: 'blocked', reason }`을 돌려주며 `reason`은 판정기 자신의 stderr이고,
135
+ `{ verdict: 'upheld', advisories }`는 종료 코드 0인 실행의 권고 줄을 싣습니다. 소비자는 그
136
+ 텍스트를 사람이 나중에 읽는 자리, 곧 이슈나 로그에 적고 멈춥니다. 권고 텍스트를 모델에게
137
+ 보일지도 소비자가 정합니다. 무인 루프에는 stderr 한 줄을 읽을 사람이 없으므로, 호출자가
138
+ 전달해야 권고가 소비됩니다. 판정 결과의 모양은
139
+ [`@polydeukes/sdk-ts` 참조](../reference/packages/sdk-ts.ko.md)에 있습니다.
140
+
141
+ SDK 자신의 기본값은 실행 전체에 대한 `enforce: 'block'`이며, 이것은 표면의 강제 수준이지
142
+ 항목의 것이 아닙니다. 보호 경로와 `enforce: block` 항목이 호출을 멈추고, 나머지 위반은
143
+ `advised`로 기록됩니다. 두 어댑터도 같은 방식으로 판정기를 스폰합니다.
144
+
90
145
  <a id="when-to-draft"></a>
91
146
  ## 선언 대신 초안으로 남길 때
92
147
 
@@ -110,7 +165,7 @@ disciplines:
110
165
  ## 한 번은 실제로 판정해 보기
111
166
 
112
167
  설정을 저장한 뒤에는 필요한 증거를 공급할 수 있는 판정 경로로 위반과 정상 사례를 모두
113
- 검사합니다. `pdks covenant check --worktree`는 현재 작업 트리의 변경을 판정하고,
168
+ 검사합니다. `git diff HEAD | pdks covenant check --diff`는 현재 작업 트리의 변경을 판정하고,
114
169
  `pdks explain`은 선언과 초안의 등록 상태를 보여 줍니다. 위 번역 예제처럼 한쪽 파일만
115
170
  바꾼 경우와 양쪽 키를 맞춘 경우를 비교하세요.
116
171
 
@@ -50,7 +50,7 @@ disciplines:
50
50
 
51
51
  `flattenKeys` extracts keys, not translation values. `equal` compares both directions and
52
52
  `messageBySide` reports which file has an unmatched key. The default enforcement is `advise`.
53
- Both source files must exist and contain valid JSON. The commit surface reads them from the
53
+ Both source files must exist and contain valid JSON. The change-set surface reads them from the
54
54
  chosen observation; a session edit uses that edit's proposed new contents for the file it changes.
55
55
 
56
56
  From the example project's root, prepare matching tracked files. The commit below requires your
@@ -63,7 +63,7 @@ printf '{"home":"홈"}\n' > locales/ko.json
63
63
  git add locales/en.json locales/ko.json
64
64
  git commit -m 'docs: prepare locale example'
65
65
  printf '{"home":"Home","settings":"Settings"}\n' > locales/en.json
66
- pnpm exec pdks covenant check --worktree
66
+ git diff HEAD | pnpm exec pdks covenant check --diff
67
67
  ```
68
68
 
69
69
  Expect an `advised` diagnostic for `locale-key-parity` naming `settings` as present only in English.
@@ -71,7 +71,7 @@ The command still exits 0. Fix the mismatch and run the same observation again:
71
71
 
72
72
  ```sh
73
73
  printf '{"home":"홈","settings":"설정"}\n' > locales/ko.json
74
- pnpm exec pdks covenant check --worktree
74
+ git diff HEAD | pnpm exec pdks covenant check --diff
75
75
  ```
76
76
 
77
77
  The parity diagnostic should disappear. The values differ intentionally; the keys now match.
@@ -81,10 +81,66 @@ Restore the two example files to their committed baseline when finished:
81
81
  git restore -- locales/en.json locales/ko.json
82
82
  ```
83
83
 
84
- `--worktree` also includes untracked, non-ignored files as additions. This example commits a
85
- baseline to exercise modifications and make cleanup predictable. A declaration does not run
84
+ `git diff HEAD` reports changes against the last commit, so an untracked file needs `git add -N`
85
+ before it appears in the diff. This example commits a baseline to exercise modifications and make
86
+ cleanup predictable. A declaration does not run
86
87
  merely because its source exists: at least one observed change must match its scope.
87
88
 
89
+ <a id="which-list"></a>
90
+ ## Which list does it go in
91
+
92
+ There are three discipline lists, and the source axis decides which one an entry belongs to.
93
+ The mechanism does not decide it and the relation does not decide it: the same `companion`
94
+ mechanism sits in `disciplines` when it stands over `file` sources, and in
95
+ `changeSetDisciplines` when it stands over `changes`. Read the declaration's sources and the
96
+ list follows.
97
+
98
+ | The declaration reads | List | Examples |
99
+ |---|---|---|
100
+ | the changed file and `file` sources only | `disciplines` | the file-shaped types — added-only, one-way markers, self-absolution bans, controlled vocabulary, naming, companion over a `file` source, fingerprint sync, monotonic order |
101
+ | the transcript | `sessionDisciplines` | the four history types — precedent, phase order, turn locality, stated ground |
102
+ | the actor | `sessionDisciplines` | producer-owned, actor scope |
103
+ | the command line | `sessionDisciplines` | forbidden command |
104
+ | the spawn-record channel (`sidecar`) | `sessionDisciplines` | any declaration binding `{ sidecar: true }` |
105
+ | `changes` | `changeSetDisciplines` | pairing over a change set — `implies` between two paths that must move together |
106
+
107
+ Write the entry in the list its sources point at. A misplaced entry is a load-time error that
108
+ names the entry, the channels it reads, and the list it belongs in, so the fix is to move the
109
+ body unchanged. The rule itself and the error shapes are in [the configuration
110
+ reference](../reference/configuration/index.md#placement-rule).
111
+
112
+ An entry can also read nothing a surface has to supply and still be surface-bound in practice:
113
+ a valve (`witness`) that reads the transcript makes its entry a session entry, because the
114
+ valve's own `extract` binds the transcript.
115
+
116
+ <a id="posture"></a>
117
+ ## Posture on an unattended real-time surface
118
+
119
+ An unattended real-time surface is an adapter hook or an SDK caller with no human at the
120
+ terminal. Two rules apply there that do not apply where a person is watching.
121
+
122
+ **Promote an entry to `enforce: block` when the loop cannot fix it inside the turn.** The
123
+ criterion is not "is this irreversible". A real-time block costs seconds: the model reads the
124
+ reason on stderr and retries, so the violation is corrected within the turn. Left at `advise`,
125
+ the same violation travels to a later check — a test run, CI, a reviewer — and costs a whole
126
+ turn, up to 45 minutes. This is not "block everything because nobody is watching": blocking
127
+ produces avoidance, and avoidance leaves no telemetry row, so an entry the loop cannot act on
128
+ belongs at `advise` where its break is at least recorded. The criterion is the config author's.
129
+
130
+ **The reason comes back as a value, because there is no valve.** A real-time unattended
131
+ surface has no witness valve: there is no TTY and no human turn, and the SDK takes no witness
132
+ argument and invents no session. What stands in its place is the reason travelling as data.
133
+ `checkCovenant` returns `{ verdict: 'blocked', reason }` where `reason` is the judge's own
134
+ stderr, and `{ verdict: 'upheld', advisories }` carries the advisory lines of an exit-0 run.
135
+ The consumer writes that text where a person reads it later — an issue, a log — and stops.
136
+ Whether the model sees the advisory text is the consumer's decision too: an unattended loop has
137
+ no reader for a stderr line, so advise is only consumed if the caller passes it on. The
138
+ [`@polydeukes/sdk-ts` reference](../reference/packages/sdk-ts.md) has the verdict shapes.
139
+
140
+ The SDK's own default is `enforce: 'block'` for the run, which is the surface's level, not an
141
+ entry's: protected paths and `enforce: block` entries stop the call, and every other break is
142
+ recorded as `advised`. Both adapters spawn the judge the same way.
143
+
88
144
  <a id="when-to-draft"></a>
89
145
  ## When to draft instead of declaring
90
146
 
@@ -109,7 +165,7 @@ verdict or telemetry. It is still part of the config, so the file remains loadab
109
165
 
110
166
  After you save the config, run the judgment path that can actually see it.
111
167
 
112
- - `pdks covenant check --worktree` shows the same entry against the current tree.
168
+ - `git diff HEAD | pdks covenant check --diff` shows the same entry against the current tree.
113
169
  - `pdks explain` shows the registration and whether it is a declare or a draft.
114
170
  - A one-sided edit to `locales/en.json` or `locales/ko.json` is a good smoke test for the pairing
115
171
  example.