governance-core 0.1.0__tar.gz

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 (135) hide show
  1. governance_core-0.1.0/LICENSE +21 -0
  2. governance_core-0.1.0/PKG-INFO +147 -0
  3. governance_core-0.1.0/README.md +122 -0
  4. governance_core-0.1.0/governance_core/__init__.py +6 -0
  5. governance_core-0.1.0/governance_core/agent_rules/shared.allow_commands.txt +34 -0
  6. governance_core-0.1.0/governance_core/agent_rules/shared.deny.txt +2 -0
  7. governance_core-0.1.0/governance_core/agent_rules/shared.deny_commands.txt +51 -0
  8. governance_core-0.1.0/governance_core/agent_rules/shared.deny_commands_regex.txt +61 -0
  9. governance_core-0.1.0/governance_core/agents/README.md +3 -0
  10. governance_core-0.1.0/governance_core/agents/core-auditor.md +90 -0
  11. governance_core-0.1.0/governance_core/agents/design-system-owner.md +109 -0
  12. governance_core-0.1.0/governance_core/clauses/README.md +3 -0
  13. governance_core-0.1.0/governance_core/clauses/art_00_ritual.md +16 -0
  14. governance_core-0.1.0/governance_core/clauses/art_01_project_architecture.md +54 -0
  15. governance_core-0.1.0/governance_core/clauses/art_02_directory_responsibilities.md +41 -0
  16. governance_core-0.1.0/governance_core/clauses/art_02b_core_audit_responsibilities.md +23 -0
  17. governance_core-0.1.0/governance_core/clauses/art_03_contracts.md +40 -0
  18. governance_core-0.1.0/governance_core/clauses/art_04_config_management.md +52 -0
  19. governance_core-0.1.0/governance_core/clauses/art_04b_shared_runtime_state.md +56 -0
  20. governance_core-0.1.0/governance_core/clauses/art_05_cross_agent_collaboration.md +78 -0
  21. governance_core-0.1.0/governance_core/clauses/art_07_code_standards.md +21 -0
  22. governance_core-0.1.0/governance_core/clauses/art_08_test_production_unification.md +34 -0
  23. governance_core-0.1.0/governance_core/clauses/art_09_git_discipline.md +44 -0
  24. governance_core-0.1.0/governance_core/clauses/art_10_artifacts_layout.md +22 -0
  25. governance_core-0.1.0/governance_core/clauses/art_12_scope_enforcement.md +66 -0
  26. governance_core-0.1.0/governance_core/clauses/art_13_constitution_protection.md +36 -0
  27. governance_core-0.1.0/governance_core/clauses/art_14_wrap_up_discipline.md +28 -0
  28. governance_core-0.1.0/governance_core/clauses/art_16_memory_staleness.md +41 -0
  29. governance_core-0.1.0/governance_core/clauses/art_99_appendix_sub_constitution_red_lines.md +35 -0
  30. governance_core-0.1.0/governance_core/cli.py +103 -0
  31. governance_core-0.1.0/governance_core/commands/README.md +3 -0
  32. governance_core-0.1.0/governance_core/commands/audit.md +57 -0
  33. governance_core-0.1.0/governance_core/commands/dashboard.md +76 -0
  34. governance_core-0.1.0/governance_core/commands/extract-skill.md +71 -0
  35. governance_core-0.1.0/governance_core/commands/inventory.md +27 -0
  36. governance_core-0.1.0/governance_core/commands/iterate-constitution.md +173 -0
  37. governance_core-0.1.0/governance_core/commands/learn.md +158 -0
  38. governance_core-0.1.0/governance_core/commands/proposal.md +226 -0
  39. governance_core-0.1.0/governance_core/commands/publish-knowledge.md +180 -0
  40. governance_core-0.1.0/governance_core/commands/sync-infra.md +64 -0
  41. governance_core-0.1.0/governance_core/commands/sync-repos.md +115 -0
  42. governance_core-0.1.0/governance_core/commands/update-skill.md +105 -0
  43. governance_core-0.1.0/governance_core/commands/wrap-up.md +230 -0
  44. governance_core-0.1.0/governance_core/config.py +75 -0
  45. governance_core-0.1.0/governance_core/contracts/README.md +3 -0
  46. governance_core-0.1.0/governance_core/contracts/knowledge_frontmatter_schema.md +300 -0
  47. governance_core-0.1.0/governance_core/contracts/knowledge_index_schema.md +183 -0
  48. governance_core-0.1.0/governance_core/contracts/proposal_frontmatter_schema.md +230 -0
  49. governance_core-0.1.0/governance_core/default_config/config.json.template +23 -0
  50. governance_core-0.1.0/governance_core/hooks/_guard_common.py +100 -0
  51. governance_core-0.1.0/governance_core/hooks/cache-watchdog.py +75 -0
  52. governance_core-0.1.0/governance_core/hooks/command-guard.py +142 -0
  53. governance_core-0.1.0/governance_core/hooks/constitution-reminder.py +31 -0
  54. governance_core-0.1.0/governance_core/hooks/constitutional-review.py +283 -0
  55. governance_core-0.1.0/governance_core/hooks/data-source-guard.py +286 -0
  56. governance_core-0.1.0/governance_core/hooks/direction-guard.py +127 -0
  57. governance_core-0.1.0/governance_core/hooks/edit-write-guard.py +803 -0
  58. governance_core-0.1.0/governance_core/hooks/merge-audit.py +145 -0
  59. governance_core-0.1.0/governance_core/hooks/prompt-context-router.py +173 -0
  60. governance_core-0.1.0/governance_core/hooks/repo-health.py +285 -0
  61. governance_core-0.1.0/governance_core/hooks/scope-guard.py +158 -0
  62. governance_core-0.1.0/governance_core/hooks/session-context.py +544 -0
  63. governance_core-0.1.0/governance_core/hooks/skill-usage-tracker.py +63 -0
  64. governance_core-0.1.0/governance_core/installer.py +290 -0
  65. governance_core-0.1.0/governance_core/knowledge_governance/README.md +3 -0
  66. governance_core-0.1.0/governance_core/knowledge_governance/agent-least-privilege.md +124 -0
  67. governance_core-0.1.0/governance_core/knowledge_governance/artifacts-layout.md +65 -0
  68. governance_core-0.1.0/governance_core/knowledge_governance/constitution-protection-mechanism.md +120 -0
  69. governance_core-0.1.0/governance_core/knowledge_governance/data-analysis-discipline.md +66 -0
  70. governance_core-0.1.0/governance_core/knowledge_governance/design/component-catalog.md +61 -0
  71. governance_core-0.1.0/governance_core/knowledge_governance/design/design-principles.md +55 -0
  72. governance_core-0.1.0/governance_core/knowledge_governance/knowledge-carrier-classes.md +231 -0
  73. governance_core-0.1.0/governance_core/knowledge_governance/knowledge-html-profile.md +344 -0
  74. governance_core-0.1.0/governance_core/knowledge_governance/memory-staleness-policy.md +108 -0
  75. governance_core-0.1.0/governance_core/knowledge_governance/resource-layer-hardening.md +257 -0
  76. governance_core-0.1.0/governance_core/knowledge_governance/scope-enforcement-mechanism.md +148 -0
  77. governance_core-0.1.0/governance_core/knowledge_governance/sub-constitution-red-lines.md +122 -0
  78. governance_core-0.1.0/governance_core/knowledge_governance/test-production-unification.md +83 -0
  79. governance_core-0.1.0/governance_core/knowledge_governance/testing-pyramid.md +76 -0
  80. governance_core-0.1.0/governance_core/skills/README.md +3 -0
  81. governance_core-0.1.0/governance_core/skills/_template.md +63 -0
  82. governance_core-0.1.0/governance_core/skills/constitution-iteration-decision-tree.md +107 -0
  83. governance_core-0.1.0/governance_core/skills/contract-driven-validator.md +143 -0
  84. governance_core-0.1.0/governance_core/skills/cross-clone-base-promotion.md +139 -0
  85. governance_core-0.1.0/governance_core/skills/external-design-reverse-feed.md +133 -0
  86. governance_core-0.1.0/governance_core/skills/lesson-classification.md +91 -0
  87. governance_core-0.1.0/governance_core/skills/memory-staleness-policy.md +36 -0
  88. governance_core-0.1.0/governance_core/skills/proposal-vs-plan-mode-vs-commit.md +80 -0
  89. governance_core-0.1.0/governance_core/skills/session-start-git-hygiene.md +71 -0
  90. governance_core-0.1.0/governance_core/skills/settings-json-merge-semantics.md +43 -0
  91. governance_core-0.1.0/governance_core/skills/shared-code-per-agent-state.md +69 -0
  92. governance_core-0.1.0/governance_core/skills/skill-injection-tiers.md +124 -0
  93. governance_core-0.1.0/governance_core/skills/skill-router-registration.md +137 -0
  94. governance_core-0.1.0/governance_core/skills/slash-command-hot-reload.md +71 -0
  95. governance_core-0.1.0/governance_core/skills/transcript-meta-injection-encoding.md +75 -0
  96. governance_core-0.1.0/governance_core/skills/vendor-browser-runtime.md +83 -0
  97. governance_core-0.1.0/governance_core/tools/audit_harness_expiry.py +201 -0
  98. governance_core-0.1.0/governance_core/tools/audit_hooks.py +398 -0
  99. governance_core-0.1.0/governance_core/tools/audit_html_profile.py +308 -0
  100. governance_core-0.1.0/governance_core/tools/audit_knowledge.py +708 -0
  101. governance_core-0.1.0/governance_core/tools/audit_proposals.py +565 -0
  102. governance_core-0.1.0/governance_core/tools/audit_sub_constitutions.py +263 -0
  103. governance_core-0.1.0/governance_core/tools/backfill_proposal_status.py +256 -0
  104. governance_core-0.1.0/governance_core/tools/build_autogen_blocks.py +405 -0
  105. governance_core-0.1.0/governance_core/tools/build_knowledge_dashboard.py +3108 -0
  106. governance_core-0.1.0/governance_core/tools/build_skill_index.py +218 -0
  107. governance_core-0.1.0/governance_core/tools/check_agent_roles.py +162 -0
  108. governance_core-0.1.0/governance_core/tools/check_constitution_change.py +208 -0
  109. governance_core-0.1.0/governance_core/tools/check_scope.py +201 -0
  110. governance_core-0.1.0/governance_core/tools/derive_session_boundary.py +203 -0
  111. governance_core-0.1.0/governance_core/tools/diff_classify.py +277 -0
  112. governance_core-0.1.0/governance_core/tools/infer_carrier_class.py +283 -0
  113. governance_core-0.1.0/governance_core/tools/inventory.py +385 -0
  114. governance_core-0.1.0/governance_core/tools/migrate_knowledge_frontmatter.py +328 -0
  115. governance_core-0.1.0/governance_core/tools/migrate_proposals_to_shared_state.py +278 -0
  116. governance_core-0.1.0/governance_core/tools/proposal-classify-reminder.py +84 -0
  117. governance_core-0.1.0/governance_core/tools/proposal_lib.py +905 -0
  118. governance_core-0.1.0/governance_core/tools/regen_constitution.py +187 -0
  119. governance_core-0.1.0/governance_core/tools/rotate_state.py +249 -0
  120. governance_core-0.1.0/governance_core/tools/session-boundary-guard.py +476 -0
  121. governance_core-0.1.0/governance_core/tools/skill_catalog.py +164 -0
  122. governance_core-0.1.0/governance_core/tools/sync_infra.py +980 -0
  123. governance_core-0.1.0/governance_core/tools/test_command_guard.py +131 -0
  124. governance_core-0.1.0/governance_core/tools/test_derive_session_boundary.py +208 -0
  125. governance_core-0.1.0/governance_core/tools/test_edit_write_destructive_scan.py +193 -0
  126. governance_core-0.1.0/governance_core/tools/test_repo_health_alarm.py +127 -0
  127. governance_core-0.1.0/governance_core/tools/test_session_boundary_guard.py +324 -0
  128. governance_core-0.1.0/governance_core.egg-info/PKG-INFO +147 -0
  129. governance_core-0.1.0/governance_core.egg-info/SOURCES.txt +133 -0
  130. governance_core-0.1.0/governance_core.egg-info/dependency_links.txt +1 -0
  131. governance_core-0.1.0/governance_core.egg-info/entry_points.txt +2 -0
  132. governance_core-0.1.0/governance_core.egg-info/requires.txt +9 -0
  133. governance_core-0.1.0/governance_core.egg-info/top_level.txt +1 -0
  134. governance_core-0.1.0/pyproject.toml +61 -0
  135. governance_core-0.1.0/setup.cfg +4 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 napheir
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,147 @@
1
+ Metadata-Version: 2.4
2
+ Name: governance-core
3
+ Version: 0.1.0
4
+ Summary: Reusable multi-agent governance infrastructure (hooks + proposal + wrap-up + constitution iteration) extracted from agent-core (P-0059).
5
+ Author: agent-core core agent
6
+ License: MIT
7
+ Keywords: claude-code,multi-agent,governance,proposal,hooks
8
+ Classifier: Development Status :: 3 - Alpha
9
+ Classifier: Intended Audience :: Developers
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Programming Language :: Python :: 3.11
12
+ Classifier: Programming Language :: Python :: 3.12
13
+ Requires-Python: >=3.11
14
+ Description-Content-Type: text/markdown
15
+ License-File: LICENSE
16
+ Requires-Dist: filelock>=3.12
17
+ Requires-Dist: python-frontmatter>=1.0
18
+ Requires-Dist: PyYAML>=6.0
19
+ Provides-Extra: dev
20
+ Requires-Dist: pytest>=7.0; extra == "dev"
21
+ Requires-Dist: pytest-cov>=4.0; extra == "dev"
22
+ Requires-Dist: black>=23.0; extra == "dev"
23
+ Requires-Dist: ruff>=0.1.0; extra == "dev"
24
+ Dynamic: license-file
25
+
26
+ # governance-core
27
+
28
+ [![PyPI](https://img.shields.io/badge/PyPI-0.1.0a0-blue)](https://pypi.org/project/governance-core/)
29
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
30
+
31
+ **Reusable multi-agent governance infrastructure for Claude Code projects.**
32
+
33
+ Drop-in package providing a complete governance layer (constitution clauses,
34
+ safety hooks, proposal workflow, wrap-up discipline, cross-clone sync) so
35
+ you can focus on your project's business logic instead of re-inventing
36
+ multi-agent coordination from scratch.
37
+
38
+ ## What you get
39
+
40
+ Install this package + run `governance-core install` in a new project, and
41
+ your project immediately has:
42
+
43
+ - **5 safety hooks** (PreToolUse + PostToolUse): scope-guard, edit-write-guard,
44
+ session-boundary-guard, command-guard, sensitive-data-guard — all configurable
45
+ via `.governance/config.json`
46
+ - **Proposal workflow** (`/proposal` skill): classify gate, draft / submit /
47
+ approve / complete / archive state machine with audit trail
48
+ - **Wrap-up discipline** (`/wrap-up` skill): STATE.md + git + knowledge
49
+ publishing + skill learning in one command
50
+ - **Constitution iteration** (`/iterate-constitution` skill): structured
51
+ constitutional change workflow with red-line audit
52
+ - **Cross-clone coordination** (`/sync-infra`, `/sync-repos`): physical-files
53
+ sync + cross-repo git operations
54
+ - **17 constitution clauses** (`art_00`..`art_16` + appendix) covering ritual,
55
+ config management, contracts, scope governance, test/prod unification,
56
+ git discipline, artifacts, constitutional protection, wrap-up discipline,
57
+ memory staleness, etc.
58
+
59
+ ## Quick start
60
+
61
+ This package is one half of a 2-piece distribution. The other half is
62
+ [multi-agent-template](https://github.com/napheir/multi-agent-template) — a
63
+ cookiecutter template + bootstrap CLI that generates a new project skeleton.
64
+
65
+ Typical workflow:
66
+
67
+ ```bash
68
+ # One-time setup (per machine)
69
+ pip install cookiecutter
70
+ pip install governance-core
71
+ pip install multi-agent-bootstrap
72
+
73
+ # Per-project: one-line bootstrap
74
+ multi-agent-bootstrap new my-project \
75
+ --agents core,data \
76
+ --ritual-phrase "Acknowledged"
77
+
78
+ # Verify
79
+ cd ~/workshop-claude/my-project
80
+ governance-core doctor --project-root .
81
+ ```
82
+
83
+ See [docs/architecture.md](docs/architecture.md) for the full picture
84
+ (generic vs business boundary, config injection mechanism, upgrade flow,
85
+ cross-clone coordination).
86
+
87
+ ## Standalone CLI usage
88
+
89
+ You can also install governance-core directly into an existing multi-agent
90
+ project (without cookiecutter):
91
+
92
+ ```bash
93
+ cd /path/to/your/project
94
+ pip install governance-core
95
+
96
+ # Write .governance/config.json with your project config
97
+ mkdir -p .governance
98
+ cat > .governance/config.json <<EOF
99
+ {
100
+ "project_name": "my-project",
101
+ "ritual_phrase": "OK",
102
+ "core_agent_name": "core",
103
+ "agents": [
104
+ {"name": "core", "branch": "master", "clone_dir": "agent-core"}
105
+ ]
106
+ }
107
+ EOF
108
+
109
+ # Render clauses + install hooks/skills
110
+ governance-core install --project-root .
111
+
112
+ # Validate
113
+ governance-core doctor --project-root .
114
+ ```
115
+
116
+ Subsequent updates: `git pull` this repo, `pip install -e . --upgrade`,
117
+ then `governance-core upgrade --project-root /path/to/your/project` (this
118
+ preserves your `.governance/config.json` but refreshes clauses/hooks/skills).
119
+
120
+ ## Example content disclaimer
121
+
122
+ Some clauses and knowledge docs in this package contain examples drawn from
123
+ the **upstream project** where governance-core was first developed (domain
124
+ terminology, pipeline names, broker/API references, agent name conventions).
125
+ These are **explanatory examples**, not requirements. Your project's
126
+ `.governance/config.json` supplies its own agent names, ritual phrase, and
127
+ clause keywords; the package's logic is project-agnostic.
128
+
129
+ A v1.0 release will template-ize all example tables; v0.1.0 ships with
130
+ disclaimers attached to mixed clauses and methodology docs.
131
+
132
+ ## Project status
133
+
134
+ **v0.1.0-alpha** (2026-05):
135
+ - API may break between minor versions (0.1.x)
136
+ - Stable from 1.0.0 onwards
137
+ - Bug reports + PRs welcome
138
+
139
+ ## License
140
+
141
+ MIT — see [LICENSE](LICENSE).
142
+
143
+ ## Related
144
+
145
+ - [multi-agent-template](https://github.com/napheir/multi-agent-template) —
146
+ companion cookiecutter template + bootstrap CLI
147
+ - Trade Agent (the project where this package was first developed) — private
@@ -0,0 +1,122 @@
1
+ # governance-core
2
+
3
+ [![PyPI](https://img.shields.io/badge/PyPI-0.1.0a0-blue)](https://pypi.org/project/governance-core/)
4
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
5
+
6
+ **Reusable multi-agent governance infrastructure for Claude Code projects.**
7
+
8
+ Drop-in package providing a complete governance layer (constitution clauses,
9
+ safety hooks, proposal workflow, wrap-up discipline, cross-clone sync) so
10
+ you can focus on your project's business logic instead of re-inventing
11
+ multi-agent coordination from scratch.
12
+
13
+ ## What you get
14
+
15
+ Install this package + run `governance-core install` in a new project, and
16
+ your project immediately has:
17
+
18
+ - **5 safety hooks** (PreToolUse + PostToolUse): scope-guard, edit-write-guard,
19
+ session-boundary-guard, command-guard, sensitive-data-guard — all configurable
20
+ via `.governance/config.json`
21
+ - **Proposal workflow** (`/proposal` skill): classify gate, draft / submit /
22
+ approve / complete / archive state machine with audit trail
23
+ - **Wrap-up discipline** (`/wrap-up` skill): STATE.md + git + knowledge
24
+ publishing + skill learning in one command
25
+ - **Constitution iteration** (`/iterate-constitution` skill): structured
26
+ constitutional change workflow with red-line audit
27
+ - **Cross-clone coordination** (`/sync-infra`, `/sync-repos`): physical-files
28
+ sync + cross-repo git operations
29
+ - **17 constitution clauses** (`art_00`..`art_16` + appendix) covering ritual,
30
+ config management, contracts, scope governance, test/prod unification,
31
+ git discipline, artifacts, constitutional protection, wrap-up discipline,
32
+ memory staleness, etc.
33
+
34
+ ## Quick start
35
+
36
+ This package is one half of a 2-piece distribution. The other half is
37
+ [multi-agent-template](https://github.com/napheir/multi-agent-template) — a
38
+ cookiecutter template + bootstrap CLI that generates a new project skeleton.
39
+
40
+ Typical workflow:
41
+
42
+ ```bash
43
+ # One-time setup (per machine)
44
+ pip install cookiecutter
45
+ pip install governance-core
46
+ pip install multi-agent-bootstrap
47
+
48
+ # Per-project: one-line bootstrap
49
+ multi-agent-bootstrap new my-project \
50
+ --agents core,data \
51
+ --ritual-phrase "Acknowledged"
52
+
53
+ # Verify
54
+ cd ~/workshop-claude/my-project
55
+ governance-core doctor --project-root .
56
+ ```
57
+
58
+ See [docs/architecture.md](docs/architecture.md) for the full picture
59
+ (generic vs business boundary, config injection mechanism, upgrade flow,
60
+ cross-clone coordination).
61
+
62
+ ## Standalone CLI usage
63
+
64
+ You can also install governance-core directly into an existing multi-agent
65
+ project (without cookiecutter):
66
+
67
+ ```bash
68
+ cd /path/to/your/project
69
+ pip install governance-core
70
+
71
+ # Write .governance/config.json with your project config
72
+ mkdir -p .governance
73
+ cat > .governance/config.json <<EOF
74
+ {
75
+ "project_name": "my-project",
76
+ "ritual_phrase": "OK",
77
+ "core_agent_name": "core",
78
+ "agents": [
79
+ {"name": "core", "branch": "master", "clone_dir": "agent-core"}
80
+ ]
81
+ }
82
+ EOF
83
+
84
+ # Render clauses + install hooks/skills
85
+ governance-core install --project-root .
86
+
87
+ # Validate
88
+ governance-core doctor --project-root .
89
+ ```
90
+
91
+ Subsequent updates: `git pull` this repo, `pip install -e . --upgrade`,
92
+ then `governance-core upgrade --project-root /path/to/your/project` (this
93
+ preserves your `.governance/config.json` but refreshes clauses/hooks/skills).
94
+
95
+ ## Example content disclaimer
96
+
97
+ Some clauses and knowledge docs in this package contain examples drawn from
98
+ the **upstream project** where governance-core was first developed (domain
99
+ terminology, pipeline names, broker/API references, agent name conventions).
100
+ These are **explanatory examples**, not requirements. Your project's
101
+ `.governance/config.json` supplies its own agent names, ritual phrase, and
102
+ clause keywords; the package's logic is project-agnostic.
103
+
104
+ A v1.0 release will template-ize all example tables; v0.1.0 ships with
105
+ disclaimers attached to mixed clauses and methodology docs.
106
+
107
+ ## Project status
108
+
109
+ **v0.1.0-alpha** (2026-05):
110
+ - API may break between minor versions (0.1.x)
111
+ - Stable from 1.0.0 onwards
112
+ - Bug reports + PRs welcome
113
+
114
+ ## License
115
+
116
+ MIT — see [LICENSE](LICENSE).
117
+
118
+ ## Related
119
+
120
+ - [multi-agent-template](https://github.com/napheir/multi-agent-template) —
121
+ companion cookiecutter template + bootstrap CLI
122
+ - Trade Agent (the project where this package was first developed) — private
@@ -0,0 +1,6 @@
1
+ """governance-core — reusable multi-agent governance infrastructure.
2
+
3
+ P-0059 Phase 1 skeleton. Generic resources to be migrated in Phase 1.2-1.4.
4
+ """
5
+
6
+ __version__ = "0.1.0"
@@ -0,0 +1,34 @@
1
+ # Read-only Git (no extra confirmation needed)
2
+ prefix:git status
3
+ prefix:git diff
4
+ prefix:git log
5
+ prefix:git branch -l
6
+ prefix:git branch --list
7
+ prefix:git branch -r
8
+ prefix:git branch -a
9
+ prefix:git show
10
+
11
+ # Testing and validation
12
+ prefix:python -m pytest
13
+ prefix:python tools/check_scope.py
14
+ prefix:python tools/post_turn_verify.py
15
+
16
+ # Port check (network precheck commands)
17
+ prefix:python -c "import socket
18
+
19
+ # Safe rm into well-known temp / cache locations
20
+ # (these bypass shared.deny_commands_regex.txt wide rm pattern; see
21
+ # proposals/harden_destructive_command_guard.md sec.2.2b)
22
+ prefix:rm /tmp/
23
+ prefix:rm -f /tmp/
24
+ prefix:rm -rf /tmp/
25
+ prefix:rm -f ~/.claude/cache/
26
+ prefix:rm -rf ~/.claude/cache/
27
+ prefix:rm -f *.tmp
28
+ prefix:rm -f *.log
29
+ prefix:rm -rf __pycache__/
30
+ prefix:rm -rf .pytest_cache/
31
+
32
+ # Windows del equivalents
33
+ prefix:del /q *.tmp
34
+ prefix:del /q *.log
@@ -0,0 +1,2 @@
1
+ common/
2
+ .baseline_commit
@@ -0,0 +1,51 @@
1
+ # Dangerous Git operations
2
+ git push --force
3
+ git push -f
4
+ git reset --hard
5
+ git clean -fd
6
+
7
+ # Git remote-branch destruction (delete remote branches)
8
+ git push origin :
9
+ git push origin --delete
10
+ git push --delete
11
+
12
+ # Git history rewrite
13
+ git filter-branch
14
+ git reflog expire
15
+ git update-ref -d
16
+
17
+ # Dangerous file operations
18
+ rm -rf /
19
+ rm -rf ~
20
+ rm -rf .
21
+
22
+ # .git dir attacks (literal; path variants in shared.deny_commands_regex.txt)
23
+ rm -rf .git
24
+
25
+ # Find-delete pattern
26
+ find . -delete
27
+
28
+ # Windows shell raw destructive forms
29
+ del /F /S /Q
30
+ del /S /Q
31
+ del /Q /F
32
+ del /Q /S
33
+ Remove-Item -Recurse -Force
34
+ Remove-Item -Force -Recurse
35
+
36
+ # Database destructive operations (uppercase)
37
+ DROP TABLE
38
+ DROP DATABASE
39
+ TRUNCATE
40
+
41
+ # Database destructive operations (common-case variants;
42
+ # regex layer also has case-insensitive coverage in deny_commands_regex.txt)
43
+ drop table
44
+ Drop Table
45
+ drop database
46
+ Drop Database
47
+ truncate table
48
+ Truncate Table
49
+
50
+ # External broker trade-unlock commands (only the trade-role agent may unlock, globally denied here)
51
+ unlock_trade
@@ -0,0 +1,61 @@
1
+ # Regex deny patterns for command-guard.py Layer 1.5.
2
+ #
3
+ # Format: one Python regex per line. Blank lines and lines starting with # ignored.
4
+ # Patterns are applied via re.search() so they match anywhere in the command.
5
+ # Commands matching shared.allow_commands.txt prefix list (Layer 0.5) bypass
6
+ # this layer entirely — that is the wide-rm + prefix-whitelist tradeoff
7
+ # discussed in proposals/harden_destructive_command_guard.md sec.2.2 / sec.8 Q1.
8
+ #
9
+ # Bad regex in this file = fail-closed (block all commands, surface error).
10
+
11
+ # rm -rf with any path argument that is not whitelisted
12
+ # (catches absolute Windows paths, $HOME, ../, ./*, etc.)
13
+ ^\s*rm\s+(-[rRfF]+\s+)+[^|;&]*[\w./~$]
14
+ ^\s*sudo\s+rm\s+-
15
+
16
+ # Force push variants (force-with-lease included; --force=anything)
17
+ \bgit\s+push\b.*--force(-with-lease)?\b
18
+ \bgit\s+push\b.*\s-f\b
19
+ \bgit\s+push\b.*\s:\S+
20
+ \bgit\s+push\b.*--delete\b
21
+
22
+ # Branch / tag / remote destruction
23
+ \bgit\s+branch\s+-D\b
24
+ \bgit\s+tag\s+-d\b
25
+ \bgit\s+remote\s+(rm|remove)\b
26
+
27
+ # History rewriting that may not match exact literal forms
28
+ \bgit\s+gc\b.*--prune=now
29
+ \bgit\s+update-ref\s+-d\b
30
+
31
+ # Case-insensitive SQL destruction (covers lowercase + title-case)
32
+ (?i)\b(drop|truncate)\s+(table|database|schema)\b
33
+ (?i)\bdelete\s+from\s+\w+\s*(;|--|$)
34
+
35
+ # SQL TRUNCATE without explicit "table" keyword (some dialects accept
36
+ # TRUNCATE <name>;). Distinguishes from unix `truncate -s SIZE FILE`
37
+ # by requiring no `-` arg (unix truncate needs -s flag).
38
+ (?i)\btruncate\s+\w+\s*(;|$)
39
+
40
+ # find . -delete in any path-arg permutation (catches -type f -delete etc.)
41
+ \bfind\b.*\s-delete\b
42
+
43
+ # PowerShell Remove-Item with -Force or -Recurse, any order/casing.
44
+ # Covers both PS5.1 (powershell.exe) and PS7 (pwsh) since the cmdlet name
45
+ # is identical.
46
+ (?i)\bRemove-Item\b.*(-Recurse|-Force)
47
+ (?i)\bRemove-Item\b.*-r\w*\s.*-f\w*
48
+
49
+ # Windows del with destructive flag combinations
50
+ (?i)\bdel\b.*(/s|/q|/f).*(/s|/q|/f)
51
+
52
+ # Redirect-truncate of sensitive files (.env, .git/, *.db, *.sqlite, config/)
53
+ ^\s*(:|cat\s+/dev/null|true|echo\s*)\s*>\s*\S+
54
+ ^\s*>\s*\S*(\.env|\.git/|\.db|\.sqlite|config/)
55
+
56
+ # rm targeting .git directory anywhere (path-variant of literal above)
57
+ \brm\s+(-[rRfF]+\s+)*\S*\.git(/|\b)
58
+
59
+ # Disk-level destruction (defense in depth, low likelihood)
60
+ \bdd\s+if=.*of=/dev/
61
+ \bmkfs\.\w+\b
@@ -0,0 +1,3 @@
1
+ # governance_core/agents
2
+
3
+ Generic agent role definitions — migrated in Phase 1.3.
@@ -0,0 +1,90 @@
1
+ ---
2
+ name: core-auditor
3
+ description: 项目治理、测试体系、安全审计
4
+ theme: universal
5
+ owner: core
6
+ tools:
7
+ - Read
8
+ - Write
9
+ - Bash
10
+ - Grep
11
+ ---
12
+
13
+ # Core Auditor
14
+
15
+ 你是项目治理与质量保证专家,负责跨 agent 审计和测试体系维护。
16
+
17
+ ## 核心职责
18
+ 1. Scope 合规审计 — 运行 `tools/check_scope.py` 验证 agent 遵守 scope 规则
19
+ 2. 契约演进审计 — 审查 `contracts/` 变更的向后兼容性和 SemVer 遵守
20
+ 3. 配置安全审计 — 检查 `config/` 中的敏感信息泄漏和硬编码违规
21
+ 4. P0-P4 测试体系 — 维护五层测试金字塔(契约/集成/版本化/E2E/每日回归)
22
+ 5. Git 纪律审计 — 验证 Conventional Commits、分支策略、.gitignore
23
+
24
+ ## 工作范围
25
+ - 可修改: `tests/`, `tools/`, `contracts/`, `agent_rules/`, `config/`, `audit/`, `common/`, `skills/`, `agents/`, `.claude/`
26
+ - 可读取: 所有仓库(core 拥有治理权限)
27
+
28
+ ## 当前分支
29
+ master
30
+
31
+ ## 关键工具
32
+ - `python tools/check_scope.py --agent <name>` — scope 验证
33
+ - `python tools/audit_sub_constitutions.py` — 子宪法审计
34
+ - `python tools/run_daily_regression.py` — P4 每日回归测试
35
+ - `pytest tests/` — P0-P3 测试
36
+
37
+ ## 审计输出
38
+ - 审计报告: `audit/`
39
+ - 测试报告: `artifacts/daily_tests/`
40
+ - 测试手册: `tests/daily/MANUAL.md`
41
+
42
+ ## 阶段总结 — Notion 操作手册(Core 专属)
43
+
44
+ 宪法第十四条要求通过 `/wrap-up` skill 完成阶段总结。Core 在 skill 第 3 步(Notion 更新)
45
+ 需按以下操作细节执行。子宪法扩展点(宪法 14.x 末行授权)。
46
+
47
+ ### 负责页面
48
+
49
+ | 手册 | Notion Page ID | 说明 |
50
+ |------|---------------|------|
51
+ | 测试操作手册 | `32852783-35f3-8151-95e6-c07e3622d850` | 质量保证测试体系(P0-P4)、测试用例、Baseline 管理、报告阅读 |
52
+
53
+ (其他 agent 的手册由各自 agent 维护,不属于 core 更新职责。)
54
+
55
+ ### 触发条件(满足任一即需更新)
56
+
57
+ 1. 增加或修改测试用例(tests/ 目录下新增 `test_*.py` 或修改现有测试)
58
+ 2. 更新 Baseline metrics(重新捕获 baseline.json)
59
+ 3. 修改测试架构(P0-P4 层级变更、新增 stage)
60
+ 4. 更新测试手册文档(`tests/daily/MANUAL.md`)
61
+
62
+ ### 更新内容
63
+
64
+ - **核心使用方法**:pytest 命令、门禁脚本、baseline 捕获命令
65
+ - **测试范围**:各 stage 测试数量(S3/S5/S6/S9/Pipeline/Infrastructure)
66
+ - **Baseline Metrics**:当前 baseline 值和容忍度范围
67
+ - **最后更新时间**:当前日期
68
+
69
+ ### 更新流程
70
+
71
+ 1. Core agent 在完成测试相关变更后,**自动**调用 Notion MCP 工具
72
+ 2. 使用 `mcp__notion__API-patch-block-children` 更新页面内容
73
+ 3. 更新失败时,在 STATE.md 中记录原因,**不得跳过**
74
+ 4. 更新成功后,在 skill 输出的 checklist 中标记 `[x] Notion 已更新`
75
+
76
+ ### 跳过判定
77
+
78
+ 本阶段不满足上述任一触发条件时(如纯治理改动、scope 调整、基础设施建设),
79
+ 在 skill checklist 标记 `Notion 跳过(原因: <具体触发条件不满足>)`。
80
+
81
+ ### 禁止行为
82
+
83
+ - 提示用户手动更新 Notion
84
+ - 跳过 Notion 更新而继续下一任务
85
+ - 仅更新 MANUAL.md 而不同步到 Notion
86
+
87
+ ### 内容规范
88
+
89
+ 仅记录面向用户的**操作入口**:命令用法、参数说明、典型示例。
90
+ 不记录内部实现细节。
@@ -0,0 +1,109 @@
1
+ ---
2
+ name: design-system-owner
3
+ description: Dashboard Design System visual consistency and component library management (shared role)
4
+ theme: universal
5
+ owner: core
6
+ tools:
7
+ - Read
8
+ - Write
9
+ - Bash
10
+ - Grep
11
+ - mcp__pencil__get_editor_state
12
+ - mcp__pencil__open_document
13
+ - mcp__pencil__get_guidelines
14
+ - mcp__pencil__get_style_guide_tags
15
+ - mcp__pencil__get_style_guide
16
+ - mcp__pencil__get_variables
17
+ - mcp__pencil__set_variables
18
+ - mcp__pencil__find_empty_space_on_canvas
19
+ - mcp__pencil__batch_get
20
+ - mcp__pencil__batch_design
21
+ - mcp__pencil__get_screenshot
22
+ - mcp__pencil__snapshot_layout
23
+ - mcp__pencil__search_all_unique_properties
24
+ - mcp__pencil__replace_all_matching_properties
25
+ ---
26
+
27
+ # Design System Owner
28
+
29
+ You are the Dashboard Design System Owner, responsible for visual consistency, component library management, and Pencil design prototypes.
30
+
31
+ This is a **shared role** synced from agent-core to all agent clones.
32
+ Primary executor: data agent. Design principles apply to all agents doing UI work.
33
+
34
+ ## Core Responsibilities
35
+
36
+ 1. **Pencil Design Prototypes**: Use Pencil MCP tools to create and iterate page-level designs
37
+ 2. **Design Token Management**: Color, typography, spacing, shape token definition and maintenance
38
+ 3. **Component Library Management**: UI primitives and business component creation, review, evolution
39
+ 4. **Design Reference Maintenance**: `/design` page as the single visual reference for the Design System
40
+ 5. **Design Review**: Ensure new/modified components comply with Design System standards
41
+
42
+ ---
43
+
44
+ ## Core Principle: Design Reference is the Single Source of Truth
45
+
46
+ **Design Reference (.pen design files) is the authoritative source for all visual implementations.**
47
+
48
+ - Frontend code (TSX, theme.ts) is merely one implementation of the Design Reference
49
+ - **Never** skip Design Reference and reverse-engineer specs from frontend code or screenshots
50
+ - **Never** start coding when Design Reference has specification gaps
51
+
52
+ ---
53
+
54
+ ## Design Flow (Design-then-Code)
55
+
56
+ ```
57
+ [User requirement]
58
+ -> Describe new feature/page/improvement
59
+ [Design Agent -> Pencil prototype] <- Create complete Design Reference in .pen file
60
+ -> User reviews in Pencil
61
+ [Confirm design] <- get_screenshot validation, no spec gaps
62
+ ->
63
+ [Data Agent -> React implementation] <- Code strictly based on Design Reference
64
+ ->
65
+ [npm run build + compare against Design Reference]
66
+ ```
67
+
68
+ ---
69
+
70
+ ## HK Color Convention (Mandatory)
71
+
72
+ - **Red = Up/Profit**: `#e53935` (consistent with mainland China/Japan/Korea, opposite to US)
73
+ - **Green = Down/Loss**: `#43A047`
74
+ - CALL options = red family, PUT options = green family
75
+
76
+ ---
77
+
78
+ ## Design Tokens
79
+
80
+ | Code Token | Pencil Variable | Description |
81
+ |-----------|-----------------|-------------|
82
+ | CSS `--background` | `$--background` | Page background |
83
+ | CSS `--card` | `$--card` | Card background |
84
+ | CSS `--foreground` | `$--foreground` | Primary text |
85
+ | CSS `--muted-foreground` | `$--muted-foreground` | Secondary text |
86
+ | CSS `--border` | `$--border` | Border color |
87
+ | CSS `--primary` | `$--primary` | Primary accent |
88
+
89
+ ---
90
+
91
+ ## Key References
92
+
93
+ - Design principles: `knowledge/design/design-principles.md`
94
+ - Component catalog: `knowledge/design/component-catalog.md`
95
+ - Design files: `analysis/dashboard/design/dashboard.pen` (data branch)
96
+ - Component reference: `research/references/claude-code-source/src/components/design-system/` (research branch)
97
+ - Design showcase: `analysis/dashboard/frontend/src/app/design/page.tsx` (data branch)
98
+
99
+ ---
100
+
101
+ ## Tech Stack
102
+
103
+ | Layer | Technology | Location |
104
+ |-------|-----------|----------|
105
+ | Design Tool | Pencil (MCP) | `.pen` files |
106
+ | Framework | Next.js (App Router) | `analysis/dashboard/frontend/` |
107
+ | UI | shadcn/ui + Radix UI | `components/ui/` |
108
+ | Charts | Recharts | All data visualization |
109
+ | Types | TypeScript (strict) | Zero TS errors as compliance gate |
@@ -0,0 +1,3 @@
1
+ # governance_core/clauses
2
+
3
+ Generic constitution clauses (art_*.md) — migrated in Phase 1.3.
@@ -0,0 +1,16 @@
1
+ ---
2
+ clause_id: art_00_ritual
3
+ clause_class: constitution-clause
4
+ extracted_from: agent-core CLAUDE.md (9f31024b)
5
+ source_constitution: constitution/total.md
6
+ generic_status: generic
7
+ phase_2_action: ready-to-use
8
+ ---
9
+
10
+ ## 第零条:仪式
11
+
12
+
13
+ 执行任何任务时,第一句话必须是 **"如君所愿"**。
14
+ 这是确认 Agent 已读取本宪法的信号。
15
+
16
+ ---