refactor(v0): move hardcoded issue/PR policies to TOML (Opus 4.6 review §II.3) #81

Closed
opened 2026-06-08 21:50:10 +02:00 by claude · 0 comments
Collaborator

Goal

Close the last unaddressed code weakness from the 2026-05-28 Cloud Opus 4.6 repo review (§II.4 "Hardkodowane polityki w kodzie Pythona"): several policy constants are hardcoded in src/patchwarden/, so changing them needs a code commit. Move them into the policy bundle TOML with a hardcoded fallback — exactly the pattern slice B (#78) used for repair classes.

What's hardcoded today

  • src/patchwarden/issue_check.py: REQUIRED_SECTIONS (dict of section → alias tuples, incl. Polish aliases), NO_GO_LABELS, and any OWNER_ATTENTION_LABELS if present.
  • src/patchwarden/policy_bundle.py (or pr_check.py): SENSITIVE_CLASSIFICATIONS (the frozenset of classes that force manual review).

Read these first to get the EXACT current values — behavior must stay byte-for-byte identical when no TOML overrides are given.

Scope

  1. Add optional TOML sections to policies/platform.v0.toml (and mirror in iskra-openclaw.v0.toml if it has issue gating) for:
    • [issue_check]required_sections (table of section → list-of-aliases), no_go_labels (list)
    • sensitive classifications (either under an existing section or a new [classification.sensitive])
  2. Load them via the existing policy-bundle loader (stdlib tomllib, same as slice B). When a section is absent, fall back to the hardcoded default which STAYS in the module as the canonical default.
  3. Thread the loaded policy into evaluate_issue / classification the same way evaluate_pull_request already takes a PolicyBundle.

Hard constraints (this is a refactor — behavior must not change)

  • Identical behavior with no TOML override: every existing test in tests/test_issue_check.py, tests/test_pr_check.py, tests/test_policy_bundle.py must pass UNCHANGED. Do not edit those tests except to add new ones.
  • Keep the hardcoded constants in the module as the default + fallback (do NOT delete them).
  • Malformed TOML section → ValueError (fail-safe), never a permissive/empty policy (same discipline as slice B).
  • stdlib-only in src/patchwarden/ (tomllib is stdlib). unittest, not pytest.
  • Do NOT modify tests/test_d20_architectural_boundary.py; it must stay green.
  • Do NOT change any schema_version.

Acceptance

  • PYTHONPATH=src python3 -m unittest discover tests → all green (existing count + new tests).
  • New tests: TOML-loaded policies == hardcoded for the current values; a TOML override changes behavior (e.g. an added no-go label blocks an issue that would otherwise pass); malformed section → ValueError; fallback when section absent.
  • grep -rnE "import (toml|tomlkit|yaml|requests|httpx)" src/patchwarden/ → zero hits (tomllib stdlib is fine).
  • git grep -n "REQUIRED_SECTIONS\|NO_GO_LABELS\|SENSITIVE_CLASSIFICATIONS" src/ still shows the constants present (as fallback defaults).

Spec sources

  • src/patchwarden/issue_check.py, src/patchwarden/policy_bundle.py, src/patchwarden/pr_check.py
  • policies/platform.v0.toml
  • Slice B precedent: src/patchwarden/runtime_repair.py REPAIR_CLASS_POLICIES TOML loader (PR #78) — mirror its loader + fallback + fail-safe shape
  • 2026-05-28 Cloud Opus 4.6 review §II.4

Status flow

ready-for-agent → agent claims → PR → operator review → merge


Created 2026-06-08 by claude. Atomic for a cousin (gemini via Antigravity) — same validated pattern as #78.

## Goal Close the last unaddressed code weakness from the 2026-05-28 Cloud Opus 4.6 repo review (§II.4 "Hardkodowane polityki w kodzie Pythona"): several policy constants are hardcoded in `src/patchwarden/`, so changing them needs a code commit. Move them into the policy bundle TOML with a hardcoded fallback — **exactly the pattern slice B (#78) used for repair classes.** ## What's hardcoded today - `src/patchwarden/issue_check.py`: `REQUIRED_SECTIONS` (dict of section → alias tuples, incl. Polish aliases), `NO_GO_LABELS`, and any `OWNER_ATTENTION_LABELS` if present. - `src/patchwarden/policy_bundle.py` (or `pr_check.py`): `SENSITIVE_CLASSIFICATIONS` (the frozenset of classes that force manual review). Read these first to get the EXACT current values — behavior must stay byte-for-byte identical when no TOML overrides are given. ## Scope 1. Add optional TOML sections to `policies/platform.v0.toml` (and mirror in `iskra-openclaw.v0.toml` if it has issue gating) for: - `[issue_check]` → `required_sections` (table of section → list-of-aliases), `no_go_labels` (list) - sensitive classifications (either under an existing section or a new `[classification.sensitive]`) 2. Load them via the existing policy-bundle loader (stdlib `tomllib`, same as slice B). When a section is absent, **fall back to the hardcoded default** which STAYS in the module as the canonical default. 3. Thread the loaded policy into `evaluate_issue` / classification the same way `evaluate_pull_request` already takes a `PolicyBundle`. ## Hard constraints (this is a refactor — behavior must not change) - **Identical behavior with no TOML override**: every existing test in `tests/test_issue_check.py`, `tests/test_pr_check.py`, `tests/test_policy_bundle.py` must pass UNCHANGED. Do not edit those tests except to add new ones. - Keep the hardcoded constants in the module as the default + fallback (do NOT delete them). - Malformed TOML section → `ValueError` (fail-safe), never a permissive/empty policy (same discipline as slice B). - stdlib-only in `src/patchwarden/` (`tomllib` is stdlib). unittest, not pytest. - Do NOT modify `tests/test_d20_architectural_boundary.py`; it must stay green. - Do NOT change any `schema_version`. ## Acceptance - `PYTHONPATH=src python3 -m unittest discover tests` → all green (existing count + new tests). - New tests: TOML-loaded policies == hardcoded for the current values; a TOML override changes behavior (e.g. an added no-go label blocks an issue that would otherwise pass); malformed section → ValueError; fallback when section absent. - `grep -rnE "import (toml|tomlkit|yaml|requests|httpx)" src/patchwarden/` → zero hits (tomllib stdlib is fine). - `git grep -n "REQUIRED_SECTIONS\|NO_GO_LABELS\|SENSITIVE_CLASSIFICATIONS" src/` still shows the constants present (as fallback defaults). ## Spec sources - `src/patchwarden/issue_check.py`, `src/patchwarden/policy_bundle.py`, `src/patchwarden/pr_check.py` - `policies/platform.v0.toml` - Slice B precedent: `src/patchwarden/runtime_repair.py` REPAIR_CLASS_POLICIES TOML loader (PR #78) — mirror its loader + fallback + fail-safe shape - 2026-05-28 Cloud Opus 4.6 review §II.4 ## Status flow `ready-for-agent` → agent claims → PR → operator review → merge --- Created 2026-06-08 by claude. Atomic for a cousin (gemini via Antigravity) — same validated pattern as #78.
Sign in to join this conversation.
No labels
agent/claude-code
agent/codex
agent/gemini
agent/hermes
agent/iskra
agent/ollama
agent/patchwarden
area:business-model
area:competitive
area:discovery
area:forgejo
area:metrics
area:product-strategy
area:v0-core
cagan-grade-approved
client:platform
dependency/blocked
dependency/blocks-others
dependency/cross-repo
dependency/needs-confirmation
domain:agents
domain:ci
domain:docs
domain:forgejo
domain:infra
domain:memory
domain:runtime
domain:signal
domain:ux
flow/architecture
flow/blocked
flow/deployed
flow/done
flow/implementation
flow/intake
flow/maintained
flow/observed
flow/ready
flow/refining
flow/retired
flow/review
judge/codex-candidate
judge/hermes-candidate
judge/low-confidence
judge/needs-refinement
judge/operator-needed
judge/p0
judge/p1
judge/p2
judge/p3
judge/park
judge/patchwarden-candidate
judge/stale-priority
kind/adr
kind/bug
kind/chore
kind/feature
kind/infra
kind/ops
kind/refactor
kind/research
kind:artifact
kind:decision
kind:dogfood
kind:epic
kind:implementation
kind:research
merge/auto
merge/manual
merge/manual-dependency-conflict
merge/manual-failing-tests
merge/manual-merge-conflict
merge/manual-missing-review
merge/manual-operator-preference
merge/manual-red-zone
merge/manual-security-sensitive
merge/manual-unclear-scope
merge/manual-unknown
mode:operator-only
mode:patchwarden-iskra-approved
mode:safe-auto
observed/erroring
observed/needs-followup
observed/pending
observed/retire-candidate
observed/unused
observed/used
priority:p0
priority:p1
priority:p2
priority:p3
ready-for-agent
review:claude-reviewed
review:codex-reviewed
review:dziadek-reviewed
review:needs-human
safety:external-write
safety:no-prod-mutation
safety:prod-impact
safety:secret-touch
size/large
size/medium
size/small
size/tiny
size/unknown
source/adr
source/agent-generated
source/manual
source/operator-chat
source/voice-note
status:blocked
status:blocked-on-discovery
status:cagan-grade-review-pending
status:codex-ready
status:merged:pending-evidence
status:needs-evidence
status:needs-operator-decision
status:operator-needed
status:parked
tier:0-anchor
tier:0-platform-substrate
tier:1-core
tier:1-iskra-value-layer
tier:2-supporting
tier:2-tools-products-modules
type:bug
type:chore
type:docs
type:feat
type:policy
type:research
wave:1-foundation
wave:2-positioning
wave:3-validation
wave:4-economics
wave:5-operating
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
pdurlej/patchwarden#81
No description provided.