Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 34 additions & 1 deletion agents/conductors/hygiene/_hygiene_condemned.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
the `condemned.md` manifest (the Mind catalog of condemned self-material) and
classifies each entry by its transit clock — **due** (sweep-after date reached,
ready to void) vs **pending** (still in the transit window, recoverable). It
emits a plan; the actual void is delegated to `pyauto-gut void`. Stdlib only —
emits a plan; the actual void is delegated to `pyauto-gut void`. `ref_name`
maps an entry to the Gut ref it archives to; PyAutoGut's board collector and
its void workflow import this module from a checked-out Brain for the same
parse, so the ledger is read one way everywhere. Stdlib only —
the conductor never drags a dependency into the Brain.

Usage:
Expand Down Expand Up @@ -54,6 +57,36 @@ def parse_manifest(text):
return entries


# The archive namespace every Gut ref lives under. `ref_name` reads the
# `archive-ref` field — never the `##` heading, which is a human title and
# differs from the ref name (e.g. heading `pyautohands/pre-2023-history`,
# ref `pyautohands-pre-2023-history`).
ARCHIVE_NS = "refs/heads/archive/condemned/"
_REF_RE = re.compile(re.escape(ARCHIVE_NS) + r"([A-Za-z0-9._*][A-Za-z0-9._/*-]*)")


def ref_name(entry):
"""The Gut ref name `<name>` an entry archives to, or None.

Reads the first `refs/heads/archive/condemned/<name>` in the entry's
`archive-ref` field, tolerating the backticks, `@ <sha>` and
`on <Repo> origin` decorations the ledger actually carries. None means
the entry has no Gut ref at all — `n/a` (a merged branch or a committed
deletion whose bytes live in remote history), a local backup path, or no
field. A batch entry that archived many refs under one prefix returns
the glob as written (e.g. `pyautomind-*`); the caller expands it against
the refs it can see. A trailing `.` or `/` (sentence punctuation) is
stripped.
"""
text = (entry.get("archive-ref") or "").strip()
if not text or text.strip("`").lower().startswith("n/a"):
return None
m = _REF_RE.search(text)
if not m:
return None
return m.group(1).rstrip("./") or None


def _parse_date(s):
try:
return datetime.date.fromisoformat((s or "").strip())
Expand Down
33 changes: 31 additions & 2 deletions board/_theme.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@

`ORGANS` is the palette table, keyed by the same board names as
`config/policy.yaml` `board: boards:` — that mapping is the declared config
surface an adopting fork replaces, so no repo is named here. Five of the six
palettes are sampled from the actual logo files: the mark, the glyph colour
surface an adopting fork replaces, so no repo is named here. Every palette
but the umbrella's is sampled from the actual logo files: the mark, the glyph colour
and the wordmark's own tagline, straight off `logo.png` in each organ's repo.
The
umbrella board has no logo, so its accent and tagline are designed to sit in
Expand Down Expand Up @@ -105,6 +105,17 @@
"ink_light": "#9a5400", "ink_dark": "#ffa733", "glow": "#ff9201",
"hero": ("#372100", "#000000"),
},
# Gut — sampled off PyAutoGut/logo.png: the lime glyph (#8ad414, the
# logo's dominant bright colour) over the dark-olive vignette (#1f3006).
# Lime is far too light to read on white (1.8:1), so the light-scheme ink
# is the same hue taken down to #3f7a00 (5.3:1 on #fff); the dark-scheme
# ink #8fe01a reads at 11.6:1 on #0d1117.
"gut": {
"organ": "Gut",
"tagline": "Delete. Clean. Keep healthy.",
"ink_light": "#3f7a00", "ink_dark": "#8fe01a", "glow": "#8ad414",
"hero": ("#1f3006", "#000000"),
},
# The umbrella is the one board with no logo to sample: the accent and
# the tagline are designed to sit in the family rather than read off a
# file. Replace both from the logo if that repo ever grows one.
Expand Down Expand Up @@ -278,6 +289,24 @@
'<path d="M3.8,26.2 L11.6,26.2 M2.2,30.4 L8.6,30.4 '
'M5.0,34.6 L9.4,34.6"/>'
),
# Gut — a lidded bin with ribs, speed lines entering from the left and
# the void badge (a ringed cross) over its lower-right corner, inside a
# closed ring, as on the logo.
"gut": (
'<circle cx="24" cy="24" r="20.4"/>'
'<path d="M14.6,17.4 L33.0,17.4 L33.0,15.2 Q33.0,14.2 32.0,14.2 '
'L15.6,14.2 Q14.6,14.2 14.6,15.2 Z"/>'
'<path d="M20.6,14.2 L20.6,12.2 Q20.6,11.4 21.4,11.4 L26.2,11.4 '
'Q27.0,11.4 27.0,12.2 L27.0,14.2"/>'
'<path d="M16.2,17.4 L17.8,34.4 Q17.95,35.8 19.3,35.8 L26.0,35.8 '
'M31.4,17.4 L30.8,25.0"/>'
'<path d="M20.6,20.6 L21.2,32.6 M23.8,20.6 L23.8,32.6 '
'M27.0,20.6 L26.7,27.6"/>'
'<path d="M8.4,21.4 L13.4,21.4 M7.4,25.0 L13.8,25.0 '
'M9.2,28.6 L14.2,28.6"/>'
'<circle cx="31.6" cy="32.2" r="5.4"/>'
'<path d="M29.7,30.3 L33.5,34.1 M33.5,30.3 L29.7,34.1"/>'
),
# Umbrella — no logo to sample, so the family language (ring, line-art,
# node dots) applied to the double helix the board already carried.
"organism": (
Expand Down
1 change: 1 addition & 0 deletions config/policy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -171,4 +171,5 @@ board:
memory: PyAutoMemory
heart: PyAutoHeart
hands: PyAutoHands
gut: PyAutoGut
organism: PyAutoScientist
23 changes: 21 additions & 2 deletions tests/test_board_theme.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ def test_board_links_reads_the_declared_family_in_file_order():
# the order `config/policy.yaml` declares — the ruled organ order.
links = _theme.board_links("https://example.invalid")
assert list(links) == ["brain", "mind", "cortex", "memory",
"heart", "hands", "organism"]
"heart", "hands", "gut", "organism"]
assert list(links) == POLICY_BOARDS
assert links["cortex"] == "https://example.invalid/PyAutoCortex/"

Expand All @@ -225,7 +225,8 @@ def test_board_links_renders_the_family_footer_end_to_end():
footer = _theme.boards_footer(
_theme.board_links("https://example.invalid", "heart"), "heart")
order = re.findall(r'data-organ="(\w+)"', footer)
assert order == ["brain", "mind", "cortex", "memory", "hands", "organism"]
assert order == ["brain", "mind", "cortex", "memory", "hands", "gut",
"organism"]


def test_board_links_returns_nothing_when_the_config_is_unreadable():
Expand Down Expand Up @@ -314,3 +315,21 @@ def test_a_bare_list_lines_up_with_the_rest_of_the_page():
# The lists that are layout rather than prose keep their own zero.
assert re.search(r"\.stats\{[^}]*padding:0", css, re.S)
assert re.search(r"\.boards\{[^}]*padding:0", css, re.S)


def test_the_gut_board_is_in_the_family_and_readable():
# PyAutoGut#9: the Gut joined the board family — a palette sampled off its
# logo, a drawn mark, and accents that pass the same contrast bar.
assert "gut" in POLICY_BOARDS
o = _theme.ORGANS["gut"]
assert o["organ"] == "Gut"
assert _contrast(o["ink_light"], "#ffffff") >= 4.5
assert _contrast(o["ink_dark"], "#0d1117") >= 4.5
assert "gut" in _theme.MARKS and "<circle" in _theme.MARKS["gut"]
assert _theme.MARKS["gut"] in _theme.hero("gut", "Dashboard")


def test_every_theme_entry_but_the_umbrella_is_a_declared_board():
# The reverse of the palette check: a palette for a board nobody declares
# is a footer chip that can never appear.
assert set(_theme.ORGANS) <= set(POLICY_BOARDS) | {"organism"}
97 changes: 97 additions & 0 deletions tests/test_hygiene_condemned.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
"""Tests for `agents/conductors/hygiene/_hygiene_condemned.py` — the one
parser of the Mind's `condemned.md` ledger.

PyAutoGut's board and its void workflow import this module from a checked-out
Brain, so the ledger is read one way everywhere. `ref_name` is the piece they
lean on hardest: a void is keyed by the ref name in `archive-ref`, never by
the `##` heading (the two differ in the real ledger).
"""

import datetime
import sys
from pathlib import Path

BRAIN_HOME = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(BRAIN_HOME / "agents" / "conductors" / "hygiene"))

import _hygiene_condemned as hc # noqa: E402

LEDGER = """\
# Condemned material

## Entry schema

- `type` — `branch` | `stash`

<!--
## example-entry
- type: branch
- archive-ref: refs/heads/archive/condemned/example @ 0de4514
-->

## team/old-spike
- type: branch
- locator: feature/old-spike
- sweep-after: 2026-08-12
- archive-ref: refs/heads/archive/condemned/team-old-spike @ 0de4514

## history/kept
- type: branch
- locator: master
- sweep-after: never — void only on explicit human request
- archive-ref: `refs/heads/archive/condemned/history-kept` on SomeGut origin (55da101c, 442 commits)

## purge/datasets
- type: file
- locator: dataset/old
- sweep-after: 2026-08-29
- archive-ref: n/a — committed deletion; pre-purge SHA `8625a1de`
"""


def test_parse_manifest_skips_prose_sections_and_commented_examples():
entries = hc.parse_manifest(LEDGER)
assert [e["name"] for e in entries] == [
"team/old-spike", "history/kept", "purge/datasets"]


def test_classify_splits_due_pending_and_undated():
entries = hc.parse_manifest(LEDGER)
due, pending, undated = hc.classify(entries, datetime.date(2026, 8, 20))
assert [e["name"] for e in due] == ["team/old-spike"]
assert [e["name"] for e in pending] == ["purge/datasets"]
assert [e["name"] for e in undated] == ["history/kept"]


def test_ref_name_reads_archive_ref_not_the_heading():
entries = {e["name"]: e for e in hc.parse_manifest(LEDGER)}
assert hc.ref_name(entries["team/old-spike"]) == "team-old-spike"
assert hc.ref_name(entries["history/kept"]) == "history-kept"


def test_ref_name_is_none_for_history_only_entries():
for text in ("n/a — committed deletion; pre-purge SHA `8625a1de`",
"`n/a` — committed deletion",
"permanent local mirror backups ~/backups/x.git",
""):
assert hc.ref_name({"archive-ref": text}) is None, text
assert hc.ref_name({}) is None


def test_ref_name_tolerates_the_decorations_the_ledger_carries():
cases = {
"refs/heads/archive/condemned/a-b @ 0de4514": "a-b",
"`refs/heads/archive/condemned/a-b` @ `e6e72cc2`": "a-b",
"refs/heads/archive/condemned/a-b on SomeRepo origin (9dc61c5)": "a-b",
"refs/heads/archive/condemned/team/inference @ c8b6058 (SomeGut)":
"team/inference",
"see refs/heads/archive/condemned/tail-dot.": "tail-dot",
}
for text, want in cases.items():
assert hc.ref_name({"archive-ref": text}) == want, text


def test_ref_name_keeps_a_batch_glob_for_the_caller_to_expand():
entry = {"archive-ref": "37 refs under `refs/heads/archive/condemned/"
"batch-*` on SomeGut origin — all verified"}
assert hc.ref_name(entry) == "batch-*"
Loading