Skip to content

Commit c62c402

Browse files
massu2002claude
andauthored
監査から旧い言葉の表を外し、雛形の手順を新しい言葉にする (#36)
Custom Properties を標準の言葉へ寄せ終えた(2026-09-30 に人が適用し、 定義と値を API で照合、監査の所見 0 件)。寄せる途中だけ旧い言葉を通す ための LEGACY を外した。旧い言葉は「標準に無い値」(Warning)になる。 定義からも外したので入れられないが、選択肢を戻されたときに気づける。 owner_team に Team の名前を使わない決定は、表を外すと確かめられなく なる。API で取った Team 一覧と比べ、Team の名前が入っていれば知らせる ようにした。Team が増えても表を直さなくてよい。 顧客案件の雛形の手順 3 が旧い言葉(repo_type=customer、 lifecycle=development)のままだったので、8 Property の値にした。稼働前と 稼働後で production_impact と governance_profile が変わることも書いた。 実測: テスト 35 件 OK。判定を壊す 14 通りすべてで落ちた。実 Organization への読み取り実行で所見 0 件のまま。 Closes #35 Co-authored-by: Claude Opus 5.5 <[email protected]>
1 parent 4f6e04c commit c62c402

3 files changed

Lines changed: 64 additions & 97 deletions

File tree

‎scripts/ci/org_audit.py‎

Lines changed: 16 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,10 @@
5454
#: data_classification `public` を足す。 Public な Repository を表す値が
5555
#: 標準に無かった
5656
#: `owner_team` は標準でも選択肢を閉じていない(「...」)ので、 値の種類は
57-
#: 見ない(None)。
57+
#: 見ない(None)。 ただし Team の名前は使わない(担当は機能の言葉で表す。
58+
#: Team は権限の単位)。
59+
#: lifecycle に development / production は無い。 開発中か稼働中かは
60+
#: production_impact が持つ(2026-09-30 に寄せた)。
5861
STANDARD = {
5962
"domain": ("visual-inspection", "robotics", "platform", "research",
6063
"internal", "other"),
@@ -73,17 +76,6 @@
7376
#: 定義が取れなくても Repository ごとに確かめる Property(前から必須)。
7477
ALWAYS_REQUIRED = ("repo_type", "lifecycle")
7578

76-
#: 標準へ寄せる前の言葉 → 寄せた先。 **移行を確かめたら消す。**
77-
#: 寄せる途中も、 組の判定(strict など)は寄せた先の意味で行う。
78-
#: None は寄せ先を Repository ごとに決めるもの(機械では決まらない)。
79-
#: lifecycle の development / production の区別は production_impact が持つ。
80-
LEGACY = {
81-
"repo_type": {"core": "product-core", "customer": "customer-project",
82-
"docs": "documentation", "org-config": "platform"},
83-
"lifecycle": {"development": "active", "production": "active"},
84-
"owner_team": {"developers": None, "maintainers": None},
85-
}
86-
8779
#: 版を持つ Property。 **値を入れない。** Core の版の正本は customer
8880
#: Repository の versions.yaml(commit SHA)。 Property にも書くと正本が
8981
#: 2 つになり、 片方だけ更新されて食い違う。
@@ -266,32 +258,25 @@ def _expected_properties(org: dict) -> tuple:
266258
return tuple(k for k in STANDARD if k in defined or k in ALWAYS_REQUIRED)
267259

268260

269-
def _new_word(key: str, value):
270-
"""旧い言葉なら寄せた先(決まらなければ None)、 それ以外はそのまま。"""
271-
return LEGACY.get(key, {}).get(value, value)
272-
273-
274-
def _check_properties(name: str, info: dict, expected: tuple, add) -> dict:
275-
"""値を 1 つずつ確かめ、 標準の言葉に寄せた値を返す(組の判定に使う)。"""
261+
def _check_properties(name: str, info: dict, expected: tuple, teams: set,
262+
add) -> dict:
263+
"""値を 1 つずつ確かめ、 正しい値だけを返す(組の判定に使う)。"""
276264
p = info["properties"]
277265
now = {}
278266
for key in expected:
279267
v = p.get(key)
280268
if not v:
281269
add(WARNING, "missing_property", name, f"{key} が未設定")
282270
continue
283-
if v in LEGACY.get(key, {}):
284-
to = LEGACY[key][v]
285-
add(INFO, "legacy_value", name,
286-
f"{key}={v} は標準の言葉へ寄せる途中"
287-
+ (f"(→ {to})" if to else "(寄せ先は Repository ごとに決める)"))
288-
if to:
289-
now[key] = to
290-
continue
291271
allowed = STANDARD[key]
292272
if allowed is not None and v not in allowed:
293273
add(WARNING, "unknown_value", name, f"{key}={v} は標準に無い値")
294274
continue
275+
if key == "owner_team" and v in teams:
276+
add(WARNING, "team_as_owner", name,
277+
f"owner_team={v} は Team の名前"
278+
"(担当は機能の言葉で表す。 Team は権限の単位)")
279+
continue
295280
now[key] = v
296281
for key in VERSION_PROPERTIES:
297282
if p.get(key):
@@ -302,7 +287,7 @@ def _check_properties(name: str, info: dict, expected: tuple, add) -> dict:
302287

303288

304289
def _check_combinations(name: str, info: dict, now: dict, add) -> None:
305-
"""値どうしの組。 **寄せた先の意味で**判定する。"""
290+
"""値どうしの組。 標準に無い値は使わない(先に所見にしている)。"""
306291
rt, gp = now.get("repo_type"), now.get("governance_profile")
307292
if rt == "unclassified":
308293
add(WARNING, "unclassified_repo", name,
@@ -335,12 +320,12 @@ def add(sev, code, repo, msg):
335320
"repo": repo, "message": msg})
336321

337322
expected = _expected_properties(org)
323+
teams = set(org.get("teams") or {})
338324
for name, info in repos.items():
339325
if info["archived"]:
340326
# 棚卸し対象外。 ただし lifecycle が archived でなければ、
341327
# 一覧では稼働中に見えるので知らせる
342-
lc = _new_word("lifecycle", info["properties"].get("lifecycle"))
343-
if lc != "archived":
328+
if info["properties"].get("lifecycle") != "archived":
344329
add(WARNING, "archive_drift", name,
345330
"GitHub では archived だが lifecycle が archived でない")
346331
continue
@@ -350,7 +335,7 @@ def add(sev, code, repo, msg):
350335
add(CRITICAL if f == "CLAUDE.md" else WARNING,
351336
"missing_required_file", name, f"{f} が無い")
352337
# --- Custom Properties ---
353-
now = _check_properties(name, info, expected, add)
338+
now = _check_properties(name, info, expected, teams, add)
354339
_check_combinations(name, info, now, add)
355340
# --- 保護 ---
356341
for cap in info["plan_limited"]:

‎scripts/ci/test_org_audit.py‎

Lines changed: 37 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -212,20 +212,20 @@ def test_an_archived_repo_still_marked_active_is_found(self) -> None:
212212
"""**一覧では稼働中に見える。**
213213
214214
この判定は前からあったが、 archived を先に飛ばしていたので
215-
一度も動いていなかった。 旧い言葉(production)でも見つけること。
215+
一度も動いていなかった。
216216
"""
217-
for lc in ("active", "production"):
217+
for lc in ("active", "maintenance"):
218218
with self.subTest(lifecycle=lc):
219219
findings, _ = A.classify(_org(), {"r": _repo(
220220
archived=True, properties=_props(lifecycle=lc))}, {})
221221
self.assertEqual(_codes(findings), ["archive_drift"])
222222

223223

224224
class ItSpeaksTheStandardVocabularyTest(unittest.TestCase):
225-
"""**Custom Properties を標準(§6)の言葉へ寄せる。**
225+
"""**Custom Properties は標準(§6)の言葉で書く。**
226226
227-
寄せる途中は旧い言葉も通す(所見は INFO)。 寄せたかどうかは、
228-
この監査の所見が 0 件になることで確かめる。
227+
2026-09-30 に寄せ終えた。 決めた値の表で所見 0 件になること、
228+
旧い言葉がもう通らないことを確かめる。
229229
"""
230230

231231
#: 決めた Target(as_is_inventory.md §9.1)。 名前は伏せている
@@ -247,14 +247,11 @@ class ItSpeaksTheStandardVocabularyTest(unittest.TestCase):
247247
"standard", "internal", "none"),
248248
}
249249

250-
#: 寄せる前の実測値(2026-09-30)。 名前は伏せている。
251-
BEFORE = {
252-
"core-a": (True, "core", "development", "developers"),
253-
"core-b": (True, "core", "development", "developers"),
254-
"customer-a": (True, "customer", "production", "developers"),
255-
"customer-b": (True, "customer", "production", "developers"),
256-
"platform": (False, "org-config", "production", "maintainers"),
257-
"docs": (True, "docs", "production", "maintainers"),
250+
#: 寄せる前に使っていた言葉(2026-09-30 まで)。
251+
OLD_WORDS = {
252+
"repo_type": ("core", "customer", "docs", "org-config",
253+
"template", "workflow"),
254+
"lifecycle": ("development", "production"),
258255
}
259256

260257
def test_all_eight_properties_of_the_standard_are_audited(self) -> None:
@@ -278,51 +275,34 @@ def test_the_decided_target_has_no_findings(self) -> None:
278275
findings, _ = A.classify(_org(), repos, {})
279276
self.assertEqual(findings, [])
280277

281-
def test_the_values_before_the_change_are_only_on_the_way(self) -> None:
282-
"""**寄せる前の実測値で、 余計な所見を出さないこと。**
278+
def test_the_old_words_are_no_longer_accepted(self) -> None:
279+
"""**寄せ終えたので、 旧い言葉は「標準に無い値」になる。**
283280
284-
出るのは「寄せる途中」(INFO)と「定義が無い」の 2 種類だけ。
285-
旧い言葉を誤りとして数えると、 適用前から直すものが埋もれる。
281+
定義からも外したので入れられないはずだが、 選択肢を戻されたときに
282+
気づけるようにする。
286283
"""
287-
repos = {}
288-
for name, (private, rt, lc, ot) in self.BEFORE.items():
289-
repos[name] = _repo(private=private, properties={
290-
"repo_type": rt, "lifecycle": lc, "owner_team": ot,
291-
"core_version": None})
292-
org = _org(properties=_schema(
293-
["repo_type", "lifecycle", "owner_team", "core_version"]))
294-
findings, _ = A.classify(org, repos, {})
295-
legacy = [f for f in findings if f["code"] == "legacy_value"]
296-
undefined = [f for f in findings
297-
if f["code"] == "missing_property_definition"]
298-
self.assertEqual(len(legacy), 18, "6 件 × 3 Property")
299-
self.assertTrue(all(f["severity"] == A.INFO for f in legacy))
300-
self.assertEqual(sorted(f["message"].split()[2] for f in undefined),
301-
["criticality", "data_classification", "domain",
302-
"governance_profile", "production_impact"])
303-
self.assertEqual(len(findings), 18 + 5, _codes(findings))
304-
305-
def test_a_legacy_value_names_where_it_goes(self) -> None:
306-
findings, _ = A.classify(_org(), {"r": _repo(
307-
properties=_props(repo_type="core"))}, {})
308-
self.assertEqual(_codes(findings), ["legacy_value"])
309-
self.assertIn("product-core", findings[0]["message"])
310-
311-
def test_a_legacy_value_is_judged_by_its_new_meaning(self) -> None:
312-
"""**寄せる途中も組の判定を止めない。** core は product-core として
313-
strict を求める。"""
314-
findings, _ = A.classify(_org(), {"r": _repo(properties=_props(
315-
repo_type="core", governance_profile="standard",
316-
production_impact="indirect"))}, {})
317-
self.assertEqual(_codes(findings), ["legacy_value", "profile_mismatch"])
318-
319-
def test_a_team_name_as_owner_has_no_automatic_mapping(self) -> None:
320-
"""developers / maintainers は Team の名前。 機能の言葉へは
321-
Repository ごとに寄せる(機械では決まらない)。"""
322-
findings, _ = A.classify(_org(), {"r": _repo(
323-
properties=_props(owner_team="developers"))}, {})
324-
self.assertEqual(_codes(findings), ["legacy_value"])
325-
self.assertIn("Repository ごと", findings[0]["message"])
284+
for key, words in self.OLD_WORDS.items():
285+
for w in words:
286+
with self.subTest(key=key, value=w):
287+
findings, _ = A.classify(_org(), {"r": _repo(
288+
properties=_props(**{key: w}))}, {})
289+
self.assertEqual(_codes(findings), ["unknown_value"])
290+
self.assertEqual(findings[0]["severity"], A.WARNING)
291+
292+
def test_a_team_name_as_owner_is_found(self) -> None:
293+
"""**担当は機能の言葉で表す。** Team は権限の単位(D12)。
294+
295+
Team の一覧は API から取るので、 Team が増えても表を直さなくてよい。
296+
"""
297+
org = _org(teams={"developers": [], "maintainers": []})
298+
for team in ("developers", "maintainers"):
299+
with self.subTest(owner_team=team):
300+
findings, _ = A.classify(org, {"r": _repo(
301+
properties=_props(owner_team=team))}, {})
302+
self.assertEqual(_codes(findings), ["team_as_owner"])
303+
findings, _ = A.classify(org, {"r": _repo(
304+
properties=_props(owner_team="platform"))}, {})
305+
self.assertEqual(findings, [], "機能の言葉まで Team 名と誤認しています")
326306

327307
def test_owner_team_is_an_open_vocabulary(self) -> None:
328308
"""標準も owner_team の選択肢を閉じていない(「...」)。"""
@@ -333,20 +313,12 @@ def test_owner_team_is_an_open_vocabulary(self) -> None:
333313
self.assertEqual(findings, [])
334314

335315
def test_a_value_outside_the_standard_is_found(self) -> None:
336-
"""いまの定義にある `template` は標準に無い(使用 0 件)。"""
316+
"""標準に無い値(定義から外した `template` など)を見つける。"""
337317
findings, _ = A.classify(_org(), {"r": _repo(
338318
properties=_props(repo_type="template"))}, {})
339319
self.assertEqual(_codes(findings), ["unknown_value"])
340320
self.assertEqual(findings[0]["severity"], A.WARNING)
341321

342-
def test_every_legacy_word_goes_to_a_standard_word(self) -> None:
343-
for key, table in A.LEGACY.items():
344-
for old, new in table.items():
345-
with self.subTest(key=key, old=old):
346-
self.assertNotIn(old, A.STANDARD[key] or ())
347-
if new is not None:
348-
self.assertIn(new, A.STANDARD[key])
349-
350322
def test_a_missing_value_is_found(self) -> None:
351323
findings, _ = A.classify(_org(), {"r": _repo(
352324
properties=_props(governance_profile=None))}, {})

‎templates/customer-project/README.md‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,17 @@ PDM Core + Image-Acquisition-PDM Core + この Repository = 顧客検査シス
5656
-C <作業ディレクトリ> '*/templates/customer-project'
5757
```
5858

59-
3. Custom Properties を設定する(`repo_type=customer`、`lifecycle=development`、`owner_team`)
59+
3. Custom Properties を 8 つすべて設定する(Organization の管理者が行う)
60+
61+
| Property | 値 |
62+
|---|---|
63+
| `repo_type` / `lifecycle` / `owner_team` | `customer-project` / `active` / `delivery` |
64+
| `domain` / `criticality` | 案件に合わせる(検査なら `visual-inspection` / `high`) |
65+
| `data_classification` | `customer-confidential` |
66+
| `production_impact` / `governance_profile` | 稼働前は `none` / `standard`。現場で稼働したら `direct` / `strict` |
67+
68+
設定後に `MirumeAI/.github` の `scripts/ci/org_audit.py`(読み取りだけ)を実行し、所見に出ないことを確かめる。
69+
値の意味は `MirumeAI/development-docs` の `00_management/repository_management.md`
6070
4. Team の権限を確認する(`developers=write` / `maintainers=admin`)
6171
5. `versions.yaml` の commit SHA を埋める
6272
6. `CLAUDE.md` を置く(正本は `MirumeAI/development-docs`)

0 commit comments

Comments
 (0)