claude-dev-env 8.109.2 → 8.109.4

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 (50) hide show
  1. package/.agents/skills/correction/playbooks/fix.md +1 -1
  2. package/.agents/skills/sync-dev-env/SKILL.md +6 -6
  3. package/.agents/skills/sync-dev-env/scripts/link_plugin_skills.py +66 -15
  4. package/.agents/skills/sync-dev-env/scripts/sync_dev_env_constants/config/constants.py +4 -1
  5. package/.agents/skills/sync-dev-env/scripts/test_link_plugin_skills.py +167 -27
  6. package/AGENTS.md +10 -26
  7. package/bin/install-constants.mjs +6 -5
  8. package/bin/install.agents-home.test.mjs +93 -17
  9. package/bin/install.mjs +90 -46
  10. package/bin/install.prune.test.mjs +44 -7
  11. package/bin/install.test.mjs +12 -5
  12. package/bin/install.transaction.test.mjs +6 -1
  13. package/bin/publish-directory-pointer.mjs +125 -7
  14. package/bin/publish-directory-pointer.test.mjs +160 -0
  15. package/docs/agents-guidance/asks.md +4 -0
  16. package/docs/agents-guidance/banned-word.md +4 -0
  17. package/docs/agents-guidance/core.md +15 -0
  18. package/docs/agents-guidance/evidence.md +4 -0
  19. package/docs/agents-guidance/prose.md +4 -0
  20. package/docs/agents-guidance/tools.md +4 -0
  21. package/docs/rule-guides/asd-ste100-language.md +2 -0
  22. package/docs/rule-guides/cleanup-temp-files.md +1 -1
  23. package/docs/rule-guides/correction-lens.md +4 -0
  24. package/docs/rule-guides/destructive-commands.md +2 -0
  25. package/docs/rule-guides/explore-thoroughly.md +2 -0
  26. package/docs/rule-guides/filesystem-search.md +2 -0
  27. package/docs/rule-guides/no-contrast-framing.md +1 -1
  28. package/docs/rule-guides/proof-before-pull-request.md +2 -0
  29. package/docs/rule-guides/request-scope.md +2 -0
  30. package/docs/rule-guides/research-mode.md +2 -0
  31. package/docs/rule-guides/session-title.md +1 -1
  32. package/docs/rule-guides/shell-invocation.md +2 -0
  33. package/docs/rule-guides/verified-work.md +2 -0
  34. package/docs/rule-guides/verify-before-asking.md +2 -0
  35. package/hooks/context_budget/tests/test_model.py +11 -0
  36. package/hooks/context_budget/tests/test_policy_file.py +10 -1
  37. package/package.json +1 -1
  38. package/rules/correction-lens.md +1 -9
  39. package/rules/index.md +17 -26
  40. package/scripts/account_broker_support.py +10 -1
  41. package/scripts/ci/installer-lifecycle.mjs +11 -6
  42. package/scripts/ci/installer-lifecycle.test.mjs +2 -0
  43. package/scripts/dev_env_scripts_constants/claude_account_constants.py +14 -0
  44. package/scripts/dev_env_scripts_constants/private_term_constants.py +9 -0
  45. package/scripts/dev_env_scripts_constants/test_private_term_constants.py +12 -0
  46. package/scripts/private_term_scan.py +26 -1
  47. package/scripts/test_account_broker_support.py +87 -0
  48. package/scripts/tests/test_private_term_scan.py +106 -0
  49. package/scripts/tests/test_rule_index_shape.py +8 -4
  50. package/scripts/tests/test_verified_work_rule.py +7 -3
@@ -2,15 +2,7 @@
2
2
 
3
3
  **When:** A user corrects you.
4
4
 
5
- Open a control in the guarded repository, in the same run, at the highest capable layer. State the layer, why higher layers fail, and the change opened. Pair layers when both help. Move repeated corrections up a layer. Memory records the decision.
6
-
7
- | Priority | Layer | Control |
8
- |-|-|-|
9
- | 1 | Codebase | Prevent the mistake. |
10
- | 2 | Static analysis | Programmatic check. |
11
- | 3 | Review tooling | Reviewer criterion. |
12
- | 4 | Skill | Agent procedure. |
13
- | 5 | Style guide | Wording rule. |
5
+ Open a control in the guarded repository, in the same run, at the highest capable layer.
14
6
 
15
7
  ## Permanence
16
8
 
package/rules/index.md CHANGED
@@ -1,29 +1,20 @@
1
1
  # Rules
2
- Each line gives a rule in brief. When its trigger matches your task, open the guide and follow it in full.
2
+ Each line names a rule and its trigger. When its trigger matches your task, open the guide and follow it in full.
3
3
 
4
- **Writing**
5
- - **Plain language** ([guide](../docs/rule-guides/asd-ste100-language.md)). Writing chat, narration, or repository prose. Short complete sentences on one topic, active voice, one action per step, each fact said once.
6
- - **No contrast framing** ([guide](../docs/rule-guides/no-contrast-framing.md)). Any sentence a person reads. State the chosen point and leave out the discarded reading.
7
-
8
- **Evidence**
9
- - **Research mode** ([guide](../docs/rule-guides/research-mode.md)). Any claim, recommendation, or advice. Cite a source for each claim, and run the tool that settles a fact before you state it.
10
- - **Verify before asking** ([guide](../docs/rule-guides/verify-before-asking.md)). Before a clarifying question. Look in files, config, environment, and tools first; ask only for a judgment or a preference.
11
- - **Verified work** ([guide](../docs/rule-guides/verified-work.md)). Any task. Research, plan, and build; a fresh `verifier` agent checks each step and reproduces the issue before it confirms the fix. Report only verified results. Ask before new scope.
12
- - **Verify runtime state** ([guide](../docs/rule-guides/verify-runtime-state.md)). Before you say a component works, is healthy, or is not the cause. Get a live signal this session.
13
-
14
- **Before building**
15
- - **Explore thoroughly** ([guide](../docs/rule-guides/explore-thoroughly.md)). Before you log, plan, delegate, or build an ask. Search for existing work and report it in four points with the `search-before-acting` skill.
16
- - **Features start with an eval** ([guide](../docs/rule-guides/features-start-with-an-eval.md)). New feature or behavior change. A reproducible, re-runnable check is still required before any done claim. Red before the fix, the wrong twin fails, and undo fails again.
17
- - **Request scope** ([guide](../docs/rule-guides/request-scope.md)). Asked whether part of a block is still needed, or asked to change one. Propose removing every line a shipped gate already enforces.
18
-
19
- **Shell and files**
20
- - **Shell invocation** ([guide](../docs/rule-guides/shell-invocation.md)). Any Bash command or permission rule. Use `pwsh` on Windows; keep `$(...)`, backticks, and process substitution out of commands.
21
- - **Destructive commands** ([guide](../docs/rule-guides/destructive-commands.md)). Removing files. Keep `rm` literals out of commands, use absolute targets, use `git rm` for tracked files, and copy the guide's no-rm line into subagent prompts.
22
- - **Filesystem search** ([guide](../docs/rule-guides/filesystem-search.md)). Finding files by name, path, size, or date. Scope the search to a project, worktree, or filter, never a root.
23
- - **Clean up temporary files** ([guide](../docs/rule-guides/cleanup-temp-files.md)). Creating scratch files or debug dumps. Track them and remove them when the task ends.
24
-
25
- **Shipping and memory**
4
+ - **Plain language** ([guide](../docs/rule-guides/asd-ste100-language.md)). Writing chat, narration, or repository prose.
5
+ - **No contrast framing** ([guide](../docs/rule-guides/no-contrast-framing.md)). Any sentence a person reads.
6
+ - **Research mode** ([guide](../docs/rule-guides/research-mode.md)). Any claim, recommendation, or advice.
7
+ - **Verify before asking** ([guide](../docs/rule-guides/verify-before-asking.md)). Before a clarifying question.
8
+ - **Verified work** ([guide](../docs/rule-guides/verified-work.md)). Any task.
9
+ - **Verify runtime state** ([guide](../docs/rule-guides/verify-runtime-state.md)). Before you say a component works, is healthy, or is not the cause.
10
+ - **Explore thoroughly** ([guide](../docs/rule-guides/explore-thoroughly.md)). Before you log, plan, delegate, or build an ask.
11
+ - **Features start with an eval** ([guide](../docs/rule-guides/features-start-with-an-eval.md)). New feature or behavior change.
12
+ - **Request scope** ([guide](../docs/rule-guides/request-scope.md)). Asked whether part of a block is still needed, or asked to change one.
13
+ - **Shell invocation** ([guide](../docs/rule-guides/shell-invocation.md)). Any Bash command or permission rule.
14
+ - **Destructive commands** ([guide](../docs/rule-guides/destructive-commands.md)). Removing files.
15
+ - **Filesystem search** ([guide](../docs/rule-guides/filesystem-search.md)). Finding files by name, path, size, or date.
16
+ - **Clean up temporary files** ([guide](../docs/rule-guides/cleanup-temp-files.md)). Creating scratch files or debug dumps.
26
17
  - **Pull request lifecycle**. Before a commit, push, pull request action, or merge. Invoke the `pr-lifecycle` skill; a hook denies those commands until it loads.
27
- - **Proof before a pull request** ([guide](../docs/rule-guides/proof-before-pull-request.md)). Before you open a pull request. Run the change with and without it, and quote both under "Proof in practice".
28
- - **Session title** ([guide](../docs/rule-guides/session-title.md)). The session has a tool whose name ends in `__set_session_title`. Set `<emoji> <name>` when the status changes.
29
- - **Durable facts only** ([guide](../docs/rule-guides/memory-stores-durable-facts.md)). Writing auto-memory or a `MEMORY.md` entry. Keep only a fact that helps a fresh session weeks later.
18
+ - **Proof before a pull request** ([guide](../docs/rule-guides/proof-before-pull-request.md)). Before you open a pull request.
19
+ - **Session title** ([guide](../docs/rule-guides/session-title.md)). The session has a tool whose name ends in `__set_session_title`.
20
+ - **Durable facts only** ([guide](../docs/rule-guides/memory-stores-durable-facts.md)). Writing auto-memory or a `MEMORY.md` entry.
@@ -59,6 +59,7 @@ from dev_env_scripts_constants.account_broker_constants import (
59
59
  utc_time_text,
60
60
  )
61
61
  from dev_env_scripts_constants.claude_account_constants import (
62
+ ALL_DEACTIVATED_ACCOUNT_NAMES,
62
63
  CLAUDE_ACCOUNT_ORDER_FILE_NAME,
63
64
  CLAUDE_LAUNCHER_PROGRAM,
64
65
  CREDENTIALS_FILE_NAME,
@@ -133,9 +134,16 @@ def _extra_homes(main_home: Path) -> tuple[Path, ...]:
133
134
  raise BrokerConfigurationError(f"invalid account list {extras_path}: {error}") from error
134
135
 
135
136
 
137
+ def _is_deactivated(account: Account) -> bool:
138
+ all_names = _order_names(account) | {account.home.name.casefold()}
139
+ return not ALL_DEACTIVATED_ACCOUNT_NAMES.isdisjoint(all_names)
140
+
141
+
136
142
  def _append_claude_account(
137
143
  all_accounts: list[Account], all_seen: set[str], account: Account, main_home: Path
138
144
  ) -> None:
145
+ if _is_deactivated(account):
146
+ return
139
147
  key = str(account.home).casefold()
140
148
  if key == str(main_home).casefold():
141
149
  all_accounts[0] = Account(Product.CLAUDE, "main", main_home, True, account.command)
@@ -182,7 +190,8 @@ def load_claude_accounts() -> tuple[Account, ...]:
182
190
 
183
191
  Returns:
184
192
  Main and additional accounts in configured order, each with its place in the account order file
185
- and, for a home under the profiles root, its profile name.
193
+ and, for a home under the profiles root, its profile name. An account named in
194
+ ``ALL_DEACTIVATED_ACCOUNT_NAMES`` is left out.
186
195
 
187
196
  Raises:
188
197
  BrokerConfigurationError: An account list is unreadable.
@@ -79,9 +79,9 @@ function main() {
79
79
  const skillsDirectory = join(claudeHome, 'skills');
80
80
  const agentsHomeSkillsDirectory = join(sandboxHome, '.agents', 'skills');
81
81
  const installedSkills = existsSync(skillsDirectory)
82
- ? readdirSync(skillsDirectory, { withFileTypes: true }).filter((entry) => entry.isDirectory())
82
+ ? readdirSync(skillsDirectory, { withFileTypes: true }).filter((entry) => entry.isSymbolicLink())
83
83
  : [];
84
- record('skills installed', installedSkills.length > 0, `${installedSkills.length} skill dirs`);
84
+ record('skills installed', installedSkills.length > 0, `${installedSkills.length} skill links`);
85
85
  record(
86
86
  'skills live under ~/.agents/skills',
87
87
  existsSync(agentsHomeSkillsDirectory)
@@ -89,8 +89,13 @@ function main() {
89
89
  agentsHomeSkillsDirectory,
90
90
  );
91
91
  record(
92
- '~/.claude/skills is a directory pointer',
93
- existsSync(skillsDirectory) && lstatSync(skillsDirectory).isSymbolicLink(),
92
+ '~/.claude/skills is a folder of skill links',
93
+ existsSync(skillsDirectory)
94
+ && lstatSync(skillsDirectory).isDirectory()
95
+ && installedSkills.length > 0
96
+ && installedSkills.every((entry) => existsSync(join(skillsDirectory, entry.name))
97
+ && existsSync(join(agentsHomeSkillsDirectory, entry.name))
98
+ && realpathSync(join(skillsDirectory, entry.name)) === realpathSync(join(agentsHomeSkillsDirectory, entry.name))),
94
99
  skillsDirectory,
95
100
  );
96
101
  const sampleSkillName = installedSkills.find((entry) => existsSync(join(skillsDirectory, entry.name, 'SKILL.md')))?.name;
@@ -98,14 +103,14 @@ function main() {
98
103
  const lookupSkillPath = join(skillsDirectory, sampleSkillName, 'SKILL.md');
99
104
  const canonicalSkillPath = join(agentsHomeSkillsDirectory, sampleSkillName, 'SKILL.md');
100
105
  record(
101
- 'skill files match through the lookup pointer',
106
+ 'skill files match through the lookup link',
102
107
  existsSync(lookupSkillPath)
103
108
  && existsSync(canonicalSkillPath)
104
109
  && realpathSync(lookupSkillPath) === realpathSync(canonicalSkillPath),
105
110
  sampleSkillName,
106
111
  );
107
112
  } else {
108
- record('skill files match through the lookup pointer', false, 'no skill dirs');
113
+ record('skill files match through the lookup link', false, 'no skill links');
109
114
  }
110
115
 
111
116
  const agentsLookupDirectory = join(claudeHome, 'agents');
@@ -16,6 +16,8 @@ const DRIVER_TIMEOUT_MILLISECONDS = 60_000;
16
16
  });
17
17
  assert.equal(lifecycleProcess.status, 0, `${lifecycleProcess.stdout}\n${lifecycleProcess.stderr}`);
18
18
  assert.match(lifecycleProcess.stdout, /ALL CHECKS PASSED/);
19
+ assert.match(lifecycleProcess.stdout, /\[PASS\] ~\/\.claude\/skills is a folder of skill links/);
20
+ assert.match(lifecycleProcess.stdout, /\[PASS\] skill files match through the lookup link/);
19
21
  assert.match(lifecycleProcess.stdout, /Sandbox removed:/);
20
22
  });
21
23
 
@@ -9,6 +9,7 @@ main account so its owner never runs out.
9
9
  from __future__ import annotations
10
10
 
11
11
  from dataclasses import dataclass
12
+ from pathlib import PureWindowsPath
12
13
 
13
14
  from dev_env_scripts_constants.shared_tree_constants import CLAUDE_CONFIG_DIR_ENV_VAR
14
15
 
@@ -77,6 +78,19 @@ CLAUDE_LAUNCHER_PROGRAM: LauncherProgram = LauncherProgram(
77
78
  )
78
79
  """Launcher that runs Claude with ``CLAUDE_CONFIG_DIR`` set to the profile home."""
79
80
 
81
+ ALL_DEACTIVATED_PROFILE_NAMES: tuple[str, ...] = ("org-mel",)
82
+ """Lowercase profile names of deactivated Claude accounts the broker never picks."""
83
+
84
+ ALL_DEACTIVATED_ACCOUNT_NAMES: frozenset[str] = frozenset(
85
+ each_name.casefold()
86
+ for each_profile_name in ALL_DEACTIVATED_PROFILE_NAMES
87
+ for each_name in (
88
+ each_profile_name,
89
+ PureWindowsPath(CLAUDE_LAUNCHER_PROGRAM.file_name_template.format(profile_name=each_profile_name)).stem,
90
+ )
91
+ )
92
+ """Every name a deactivated account answers to: its profile name and its launcher name."""
93
+
80
94
  LAUNCHER_REPLACED_SUFFIX: str = ".replaced-"
81
95
  """Suffix, before the run time, of an older launcher the sync moved aside."""
82
96
 
@@ -11,6 +11,11 @@ case::
11
11
  A scan hashes every window of the normalized text whose length matches an
12
12
  entry, so any case, spacing, or punctuation of a name matches. To add a name,
13
13
  append the digest of its normalized form and its length.
14
+
15
+ A commit identity may also accept one whole address. Each entry of
16
+ ``ALL_COMMIT_IDENTITY_ACCEPTED_ADDRESS_DIGESTS`` is the SHA-256 digest of the
17
+ address in lower case, without its angle brackets and with its punctuation
18
+ kept, so only that address passes.
14
19
  """
15
20
 
16
21
  from __future__ import annotations
@@ -50,6 +55,10 @@ ALL_PRIVATE_TERM_DIGESTS: frozenset[PrivateTermDigest] = frozenset(
50
55
  ALL_COMMIT_IDENTITY_ACCEPTED_DIGESTS: frozenset[PrivateTermDigest] = frozenset(
51
56
  {OWNER_HANDLE_DIGEST}
52
57
  )
58
+ ALL_COMMIT_IDENTITY_ACCEPTED_ADDRESS_DIGESTS: frozenset[str] = frozenset(
59
+ {"4c43a26ae39d54a1cfd322e702a7beadb8b8db9ce1fa7b8b02b2bb467fe334a6"}
60
+ )
61
+ ANGLE_BRACKET_ADDRESS_PATTERN = r"<([^<>]*)>"
53
62
  PRIVATE_TERM_TEXT_ENCODING = "utf-8"
54
63
  PRIVATE_TERM_FINDING_CODE = "private-term"
55
64
  PRIVATE_TERM_MESSAGE_TEMPLATE = (
@@ -5,6 +5,8 @@ from __future__ import annotations
5
5
  import re
6
6
 
7
7
  from dev_env_scripts_constants.private_term_constants import (
8
+ ALL_COMMIT_IDENTITY_ACCEPTED_ADDRESS_DIGESTS,
9
+ ALL_COMMIT_IDENTITY_ACCEPTED_DIGESTS,
8
10
  ALL_EVENT_TEXT_FIELDS,
9
11
  ALL_PRIVATE_TERM_DIGESTS,
10
12
  )
@@ -19,6 +21,16 @@ def test_should_ship_only_digests_of_named_lengths() -> None:
19
21
  assert each_digest.length > 0
20
22
 
21
23
 
24
+ def test_should_keep_every_identity_accepted_digest_among_the_private_terms() -> None:
25
+ assert ALL_COMMIT_IDENTITY_ACCEPTED_DIGESTS <= ALL_PRIVATE_TERM_DIGESTS
26
+
27
+
28
+ def test_should_ship_accepted_identity_addresses_as_sha256_hex_digests() -> None:
29
+ assert ALL_COMMIT_IDENTITY_ACCEPTED_ADDRESS_DIGESTS
30
+ for each_digest in ALL_COMMIT_IDENTITY_ACCEPTED_ADDRESS_DIGESTS:
31
+ assert _SHA256_HEX_PATTERN.fullmatch(each_digest)
32
+
33
+
22
34
  def test_should_read_every_text_a_pull_request_issue_comment_review_or_release_carries() -> None:
23
35
  assert {each_object for each_object, _field, _label in ALL_EVENT_TEXT_FIELDS} == {
24
36
  "pull_request",
@@ -11,6 +11,7 @@ line number, never the name itself, so the public log stays clean::
11
11
  from __future__ import annotations
12
12
 
13
13
  import argparse
14
+ import hashlib
14
15
  import json
15
16
  import re
16
17
  import subprocess
@@ -19,9 +20,11 @@ from collections.abc import Sequence
19
20
  from pathlib import Path
20
21
 
21
22
  from dev_env_scripts_constants.private_term_constants import (
23
+ ALL_COMMIT_IDENTITY_ACCEPTED_ADDRESS_DIGESTS,
22
24
  ALL_COMMIT_IDENTITY_ACCEPTED_DIGESTS,
23
25
  ALL_EVENT_TEXT_FIELDS,
24
26
  ALL_PRIVATE_TERM_DIGESTS,
27
+ ANGLE_BRACKET_ADDRESS_PATTERN,
25
28
  COMMIT_FIELD_SEPARATOR,
26
29
  COMMIT_FIELD_SPLIT_LIMIT,
27
30
  COMMIT_IDENTITY_PART,
@@ -79,6 +82,25 @@ def scan_event(event_path: Path) -> list[str]:
79
82
  return all_findings
80
83
 
81
84
 
85
+ def _mask_accepted_address(address_match: re.Match[str]) -> str:
86
+ address = address_match.group(1)
87
+ if address.isascii():
88
+ address_digest = hashlib.sha256(
89
+ address.lower().encode(PRIVATE_TERM_TEXT_ENCODING)
90
+ ).hexdigest()
91
+ if address_digest in ALL_COMMIT_IDENTITY_ACCEPTED_ADDRESS_DIGESTS:
92
+ return MASKED_ADDRESS
93
+ return address_match.group(0)
94
+
95
+
96
+ def _identity_text_to_scan(identity: str) -> str:
97
+ return re.sub(
98
+ ANGLE_BRACKET_ADDRESS_PATTERN,
99
+ _mask_accepted_address,
100
+ re.sub(GITHUB_NOREPLY_ADDRESS_PATTERN, MASKED_ADDRESS, identity, flags=re.IGNORECASE),
101
+ )
102
+
103
+
82
104
  def _commit_findings(record: str) -> list[str]:
83
105
  full_sha, identity, message = record.split(
84
106
  COMMIT_FIELD_SEPARATOR, COMMIT_FIELD_SPLIT_LIMIT
@@ -87,7 +109,7 @@ def _commit_findings(record: str) -> list[str]:
87
109
  return [
88
110
  *_findings_for(
89
111
  COMMIT_LABEL_TEMPLATE.format(short_sha=short_sha, part=COMMIT_IDENTITY_PART),
90
- re.sub(GITHUB_NOREPLY_ADDRESS_PATTERN, MASKED_ADDRESS, identity, flags=re.IGNORECASE),
112
+ _identity_text_to_scan(identity),
91
113
  ALL_PRIVATE_TERM_DIGESTS - ALL_COMMIT_IDENTITY_ACCEPTED_DIGESTS,
92
114
  ),
93
115
  *_findings_for(
@@ -109,6 +131,9 @@ def scan_commits(repository_root: Path, commit_range: str) -> list[str]:
109
131
  One finding per commit identity or message line that names a private
110
132
  organization. An identity address ending in users.noreply.github.com
111
133
  is left out of the scan, since GitHub builds it from the account handle.
134
+ An identity address whose lower-case spelling matches an accepted
135
+ address digest is left out the same way, so the shared agent account
136
+ passes while another address at the same organization still fails.
112
137
  The owner's own handle passes in an identity and still fails in a
113
138
  message.
114
139
  """
@@ -130,6 +130,93 @@ def test_should_assign_claude_priorities_from_the_order_file(
130
130
  }
131
131
 
132
132
 
133
+ def test_should_leave_a_deactivated_account_out_of_the_claude_roster(
134
+ monkeypatch: pytest.MonkeyPatch, tmp_path: Path
135
+ ) -> None:
136
+ main_home = _claude_home_with_extras(monkeypatch, tmp_path, ["org-mel", "ev"])
137
+ (main_home / "claude-account-order.json").write_text(
138
+ json.dumps(["ev", "claude-org-mel"]), encoding="utf-8"
139
+ )
140
+
141
+ accounts = support.load_claude_accounts()
142
+
143
+ assert [each_account.name for each_account in accounts] == ["main", "ev"]
144
+
145
+
146
+ def test_should_leave_a_deactivated_chain_account_out_of_the_claude_roster(
147
+ monkeypatch: pytest.MonkeyPatch, tmp_path: Path
148
+ ) -> None:
149
+ main_home = _claude_home_with_extras(monkeypatch, tmp_path, ["ev"])
150
+ (main_home / "claude-chain.json").write_text(
151
+ json.dumps(
152
+ {
153
+ "chain": [
154
+ {"command": "C:\\bin\\claude-ORG-MEL.cmd", "credentials_path": str(tmp_path / "dead" / ".credentials.json")},
155
+ {"command": "C:\\bin\\other.cmd", "credentials_path": str(tmp_path / "other" / ".credentials.json")},
156
+ ]
157
+ }
158
+ ),
159
+ encoding="utf-8",
160
+ )
161
+
162
+ accounts = support.load_claude_accounts()
163
+
164
+ assert [each_account.name for each_account in accounts] == ["main", "C:\\bin\\other.cmd", "ev"]
165
+
166
+
167
+ def test_should_keep_the_account_that_only_shares_a_prefix_with_a_deactivated_one(
168
+ monkeypatch: pytest.MonkeyPatch, tmp_path: Path
169
+ ) -> None:
170
+ _claude_home_with_extras(monkeypatch, tmp_path, ["mel", "org-mel-two"])
171
+
172
+ accounts = support.load_claude_accounts()
173
+
174
+ assert [each_account.name for each_account in accounts] == ["main", "mel", "org-mel-two"]
175
+
176
+
177
+ def test_should_leave_out_a_chain_account_whose_credentials_sit_in_a_deactivated_home(
178
+ monkeypatch: pytest.MonkeyPatch, tmp_path: Path
179
+ ) -> None:
180
+ main_home = _claude_home_with_extras(monkeypatch, tmp_path, ["ev"])
181
+ (main_home / "claude-chain.json").write_text(
182
+ json.dumps({"chain": [{"command": "C:\\bin\\work.cmd", "credentials_path": str(tmp_path / "org-mel" / ".credentials.json")}]}),
183
+ encoding="utf-8",
184
+ )
185
+
186
+ accounts = support.load_claude_accounts()
187
+
188
+ assert [each_account.name for each_account in accounts] == ["main", "ev"]
189
+
190
+
191
+ def test_should_keep_a_live_extra_account_when_a_deactivated_chain_entry_points_at_its_home(
192
+ monkeypatch: pytest.MonkeyPatch, tmp_path: Path
193
+ ) -> None:
194
+ main_home = _claude_home_with_extras(monkeypatch, tmp_path, ["ev"])
195
+ (main_home / "claude-chain.json").write_text(
196
+ json.dumps({"chain": [{"command": "claude-org-mel.cmd", "credentials_path": str(tmp_path / "profiles" / "ev" / ".credentials.json")}]}),
197
+ encoding="utf-8",
198
+ )
199
+
200
+ accounts = support.load_claude_accounts()
201
+
202
+ assert [each_account.name for each_account in accounts] == ["main", "ev"]
203
+
204
+
205
+ def test_should_keep_the_main_command_when_a_deactivated_chain_entry_names_the_main_home(
206
+ monkeypatch: pytest.MonkeyPatch, tmp_path: Path
207
+ ) -> None:
208
+ main_home = _claude_home_with_extras(monkeypatch, tmp_path, ["ev"])
209
+ (main_home / "claude-chain.json").write_text(json.dumps({"chain": [{"command": "claude-org-mel.cmd"}]}), encoding="utf-8")
210
+
211
+ accounts = support.load_claude_accounts()
212
+
213
+ assert [(each_account.name, each_account.command) for each_account in accounts] == [("main", "claude"), ("ev", "ev")]
214
+
215
+
216
+ def test_should_name_each_deactivated_account_by_its_profile_and_launcher() -> None:
217
+ assert support.ALL_DEACTIVATED_ACCOUNT_NAMES == {"org-mel", "claude-org-mel"}
218
+
219
+
133
220
  def test_should_read_an_order_file_saved_with_a_byte_order_mark(
134
221
  monkeypatch: pytest.MonkeyPatch, tmp_path: Path
135
222
  ) -> None:
@@ -23,6 +23,11 @@ _FIXTURE_OWNER_HANDLE = "patowner"
23
23
  _CLEAN_IDENTITY = ("Claude", "noreply@example.com")
24
24
  _OWNER_HANDLE = "ohcEnoJ"[::-1]
25
25
  _OWNER_IDENTITY = (_OWNER_HANDLE, f"24366590+{_OWNER_HANDLE}@users.noreply.github.com")
26
+ _FIXTURE_BOT_IDENTITY = ("Pat Bot", "kbot@acmewidget.example.com")
27
+ _KELVIN_SIGN = "\N{KELVIN SIGN}"
28
+ _FIXTURE_BOT_ADDRESS_DIGEST = hashlib.sha256(
29
+ _FIXTURE_BOT_IDENTITY[1].encode("utf-8")
30
+ ).hexdigest()
26
31
 
27
32
 
28
33
  def _fixture_digest(term: str) -> PrivateTermDigest:
@@ -43,6 +48,11 @@ def private_fixture_terms(monkeypatch: pytest.MonkeyPatch) -> None:
43
48
  "ALL_COMMIT_IDENTITY_ACCEPTED_DIGESTS",
44
49
  frozenset({_fixture_digest(_FIXTURE_OWNER_HANDLE)}),
45
50
  )
51
+ monkeypatch.setattr(
52
+ private_term_scan,
53
+ "ALL_COMMIT_IDENTITY_ACCEPTED_ADDRESS_DIGESTS",
54
+ frozenset({_FIXTURE_BOT_ADDRESS_DIGEST}),
55
+ )
46
56
 
47
57
 
48
58
  @pytest.fixture
@@ -57,6 +67,11 @@ def shipped_private_terms(monkeypatch: pytest.MonkeyPatch) -> None:
57
67
  "ALL_COMMIT_IDENTITY_ACCEPTED_DIGESTS",
58
68
  private_term_constants.ALL_COMMIT_IDENTITY_ACCEPTED_DIGESTS,
59
69
  )
70
+ monkeypatch.setattr(
71
+ private_term_scan,
72
+ "ALL_COMMIT_IDENTITY_ACCEPTED_ADDRESS_DIGESTS",
73
+ private_term_constants.ALL_COMMIT_IDENTITY_ACCEPTED_ADDRESS_DIGESTS,
74
+ )
60
75
 
61
76
 
62
77
  def _write_event(tmp_path: Path, event: dict[str, object]) -> Path:
@@ -220,6 +235,97 @@ def test_should_accept_the_owner_handle_as_a_commit_identity(tmp_path: Path) ->
220
235
  assert private_term_scan.scan_commits(repository_root, f"{base}..{head}") == []
221
236
 
222
237
 
238
+ def test_should_accept_an_accepted_address_in_a_commit_identity(tmp_path: Path) -> None:
239
+ repository_root, base, head = _repository_with_commits(
240
+ tmp_path, [("feat: clean change", *_FIXTURE_BOT_IDENTITY)]
241
+ )
242
+ assert private_term_scan.scan_commits(repository_root, f"{base}..{head}") == []
243
+
244
+
245
+ def test_should_accept_an_accepted_address_in_any_letter_case(tmp_path: Path) -> None:
246
+ repository_root, base, head = _repository_with_commits(
247
+ tmp_path, [("feat: clean change", "Pat Bot", "KBot@AcmeWidget.Example.com")]
248
+ )
249
+ assert private_term_scan.scan_commits(repository_root, f"{base}..{head}") == []
250
+
251
+
252
+ def test_should_flag_an_address_that_only_folds_to_an_accepted_address(
253
+ tmp_path: Path,
254
+ ) -> None:
255
+ repository_root, base, head = _repository_with_commits(
256
+ tmp_path, [("feat: clean change", "Pat Bot", f"{_KELVIN_SIGN}bot@acmewidget.example.com")]
257
+ )
258
+ all_findings = private_term_scan.scan_commits(repository_root, f"{base}..{head}")
259
+ assert len(all_findings) == 1
260
+ assert " identity:" in all_findings[0]
261
+
262
+
263
+ def test_should_flag_a_committer_address_beside_an_accepted_author_address(
264
+ tmp_path: Path,
265
+ ) -> None:
266
+ repository_root, base, _head = _repository_with_commits(tmp_path, [])
267
+ _git(
268
+ repository_root,
269
+ "commit",
270
+ "-q",
271
+ "--allow-empty",
272
+ "--author",
273
+ f"{_FIXTURE_BOT_IDENTITY[0]} <{_FIXTURE_BOT_IDENTITY[1]}>",
274
+ "-m",
275
+ "feat: clean change",
276
+ name="Pat Contractor",
277
+ email="pat@acmewidget.example.com",
278
+ )
279
+ head = _git(repository_root, "rev-parse", "HEAD", name="x", email="x@example.com")
280
+ all_findings = private_term_scan.scan_commits(repository_root, f"{base}..{head}")
281
+ assert len(all_findings) == 1
282
+ assert " identity:" in all_findings[0]
283
+
284
+
285
+ def test_should_flag_an_address_that_differs_from_an_accepted_address_only_by_punctuation(
286
+ tmp_path: Path,
287
+ ) -> None:
288
+ repository_root, base, head = _repository_with_commits(
289
+ tmp_path, [("feat: clean change", "Pat Bot", "kbot@acmewidget-example.com")]
290
+ )
291
+ all_findings = private_term_scan.scan_commits(repository_root, f"{base}..{head}")
292
+ assert len(all_findings) == 1
293
+ assert " identity:" in all_findings[0]
294
+
295
+
296
+ def test_should_flag_another_address_at_the_organization_of_an_accepted_address(
297
+ tmp_path: Path,
298
+ ) -> None:
299
+ repository_root, base, head = _repository_with_commits(
300
+ tmp_path, [("feat: clean change", "Pat Contractor", "pat@acmewidget.example.com")]
301
+ )
302
+ all_findings = private_term_scan.scan_commits(repository_root, f"{base}..{head}")
303
+ assert len(all_findings) == 1
304
+ assert " identity:" in all_findings[0]
305
+
306
+
307
+ def test_should_flag_a_private_name_in_the_author_name_beside_an_accepted_address(
308
+ tmp_path: Path,
309
+ ) -> None:
310
+ repository_root, base, head = _repository_with_commits(
311
+ tmp_path, [("feat: clean change", "Acme Widgets Bot", _FIXTURE_BOT_IDENTITY[1])]
312
+ )
313
+ all_findings = private_term_scan.scan_commits(repository_root, f"{base}..{head}")
314
+ assert len(all_findings) == 1
315
+ assert " identity:" in all_findings[0]
316
+
317
+
318
+ def test_should_flag_a_private_name_in_the_message_of_an_accepted_address_commit(
319
+ tmp_path: Path,
320
+ ) -> None:
321
+ repository_root, base, head = _repository_with_commits(
322
+ tmp_path, [("docs: note\n\nWritten for Acme Widgets.", *_FIXTURE_BOT_IDENTITY)]
323
+ )
324
+ all_findings = private_term_scan.scan_commits(repository_root, f"{base}..{head}")
325
+ assert len(all_findings) == 1
326
+ assert " message: Line 3 " in all_findings[0]
327
+
328
+
223
329
  @pytest.mark.usefixtures("shipped_private_terms")
224
330
  def test_should_flag_the_owner_handle_in_a_commit_message(tmp_path: Path) -> None:
225
331
  repository_root, base, head = _repository_with_commits(
@@ -33,9 +33,10 @@ INDEX_SKILL_POINTER_PATTERN = re.compile(r"the `[a-z-]+` skill")
33
33
 
34
34
  INDEX_FILE_NAME = "index.md"
35
35
  INDEX_PATH = RULES_DIRECTORY / INDEX_FILE_NAME
36
- MAXIMUM_ENTRY_BYTES = 1_500
37
- MAXIMUM_INDEX_BYTES = 4_000
38
- MAXIMUM_ALWAYS_ON_BYTES = 6_000
36
+ SHARED_TRUNK_PATH = PACKAGE_ROOT / "AGENTS.md"
37
+ MAXIMUM_ENTRY_BYTES = 1_400
38
+ MAXIMUM_INDEX_BYTES = 2_300
39
+ MAXIMUM_ALWAYS_ON_BYTES = 5_400
39
40
  CODEX_VERBATIM_ENTRY_NAMES = frozenset({"question-presentation.md"})
40
41
  INDEX_SHAPE_EXEMPT_ENTRY_NAMES = CODEX_VERBATIM_ENTRY_NAMES
41
42
  CODEX_MATERIALIZED_GUIDE_NAMES = frozenset(
@@ -258,7 +259,10 @@ def test_each_guide_has_exactly_one_owner() -> None:
258
259
 
259
260
 
260
261
  def test_always_loaded_entries_stay_inside_the_total_byte_budget() -> None:
261
- always_on_bytes = len(INDEX_PATH.read_bytes()) + sum(
262
+ trunk_and_index_bytes = len(SHARED_TRUNK_PATH.read_bytes()) + len(
263
+ INDEX_PATH.read_bytes()
264
+ )
265
+ always_on_bytes = trunk_and_index_bytes + sum(
262
266
  len(each_path.read_bytes())
263
267
  for each_path in _entry_paths()
264
268
  if _loads_in_every_session(_entry_text(each_path))
@@ -1,4 +1,4 @@
1
- """The always-loaded rules index carries the verified-work flow, and its guide spells out every step."""
1
+ """The always-loaded rules index points at the verified-work guide, and the guide carries the flow and spells out every step."""
2
2
 
3
3
  from pathlib import Path
4
4
 
@@ -10,8 +10,12 @@ GUIDE_PATH = PACKAGE_ROOT / "docs" / "rule-guides" / "verified-work.md"
10
10
  def test_the_index_points_every_session_at_the_verified_work_guide() -> None:
11
11
  index_text = INDEX_PATH.read_text(encoding="utf-8")
12
12
  assert "- **Verified work** ([guide](../docs/rule-guides/verified-work.md))." in index_text
13
- assert "reproduces the issue before it confirms the fix" in index_text
14
- assert "Ask before new scope." in index_text
13
+
14
+
15
+ def test_the_guide_opens_with_the_flow_in_brief() -> None:
16
+ guide_text = GUIDE_PATH.read_text(encoding="utf-8")
17
+ assert "reproduces the issue before it confirms the fix" in guide_text
18
+ assert "Ask before new scope." in guide_text
15
19
 
16
20
 
17
21
  def test_the_guide_runs_six_steps_in_order() -> None: