diff --git a/agents/conductors/cortex/_cortex.py b/agents/conductors/cortex/_cortex.py index b9b24471..56785d20 100644 --- a/agents/conductors/cortex/_cortex.py +++ b/agents/conductors/cortex/_cortex.py @@ -481,10 +481,9 @@ def run_line(r: dict) -> str: # A project is one disclosure: the closed summary is everything a glance # needs (name, purpose, the recorded run counts, the ledger's newest date); -# opening it shows the current position, the resume chip, the runs as an -# aligned table, and — each collapsed again — the recent history and the -# technical locations. Every field is the parsed ledger's own; nothing is -# read out of a run's prose. +# opening it shows registration and locations, then current position with +# an icon-only resume action, the runs table and collapsed recent history. +# Every field is the parsed ledger's own; nothing is read out of a run's prose. LOG_SHOWN = 5 @@ -511,15 +510,38 @@ def _history_label(d: dict) -> str: return f"Recent log — {shown} of {len(d['log'])} {noun}" +def _registration(d: dict) -> tuple[str, str]: + """Display explicit registration facts without changing the source ledger.""" + now = d["now"] + match = re.match( + r"Registered (\d{4}-\d{2}-\d{2})(?: \(PyAutoCortex#\d+\))?:\s*", now + ) + if match: + try: + _dt.date.fromisoformat(match[1]) + except ValueError: + pass # malformed metadata remains visible as source prose + else: + return match[1], now[match.end():] + opened = [e["date"] for e in d["log"] + if e["kind"] == "note" and e["text"].strip() == "ledger opened"] + return min(opened) if opened else "not recorded", now + + def _card_md(d: dict, row: dict, blob: str) -> list[str]: issue = (f"[{d['issue']}]({d['issue_url']})" if d["issue_url"] else "no issue yet") + registered, now = _registration(d) L = [f'
{_esc(d["key"])} — ' f"{_esc(d['summary'])} · {_esc(_overview_text(d))}", "", - f"{d['status']} · {d['partition']} · {issue}", "", - "**Current position**", "", _md_text(d["now"]) or "_(nothing yet)_", ""] + f"**Registered:** {registered}", "", + f"**Local:** `` {d['local_path']} ``", "", + f"**RAL:** `` {d['ral_root']} ``", "", + "**Current position**", "", _md_text(now) or "_(nothing yet)_", ""] if d["status"] == "active": - L += [_task_row(f"resume {d['key']}", resume_payload(d["key"], row)), ""] + L += [_task_row("", resume_payload(d["key"], row)).replace( + "📋 ", + f'📋'), ""] L += [f"**Runs** ({len(d['runs'])})", ""] if d["runs"]: L += ["| Job | State | Partition | Date | Description |", @@ -538,24 +560,26 @@ def _card_md(d: dict, row: dict, blob: str) -> list[str]: L += ["", f"
{_history_label(d)}", ""] L += [f"- {e['date']} — *{e['kind']}* — {_md_text(e['text'])}" for e in d["log"][:LOG_SHOWN]] or ["- _empty_"] - L += ["", f"[full log]({_ledger_link(d, blob)})", "", "
", "", - "
Locations", "", - f"- Ledger: [{d['rel']}]({_ledger_link(d, blob)})", - f"- Local: `` {d['local_path']} ``", - f"- RAL: `` {d['ral_root']} ``", "", "
", "", "
", ""] + L += ["", f"[full log]({_ledger_link(d, blob)})", "", + f"{d['status']} · {d['partition']} · {issue}", "", + "", "", "", ""] return L -def _full_text_html(text: str, clip: int) -> str: +def _full_text_html(text: str, clip: int, *, clauses: bool = False) -> str: """A description that fits is plain text; a longer one is a disclosure whose summary is the clipped line and whose body is the whole text — keyboard-reachable (`` is focusable) and never truncated away.""" + def display(value: str) -> str: + # Split literal prose separators before escaping; never split entities. + return ";
".join(_esc(part) for part in value.split("; ")) if clauses else _esc(value) + if not _clipped(text, clip): - return _esc(text) + return display(text) short = _clip(text, clip) - return (f'
{_esc(short)}' + return (f'
{display(short)}' f'show less' - f"

{_esc(text)}

") + f"

{display(text)}

") def _runs_table_html(d: dict) -> list[str]: @@ -571,7 +595,7 @@ def _runs_table_html(d: dict) -> list[str]: f'{_esc(r["state"])}' f'{_esc(r["partition"])}' f'{_esc(r["date"])}' - f'{_full_text_html(r["what"], RUN_CLIP)}') + f'{_full_text_html(r["what"], RUN_CLIP, clauses=True)}') H += ["", ""] return H @@ -579,18 +603,26 @@ def _runs_table_html(d: dict) -> list[str]: def _card_html(d: dict, row: dict, blob: str) -> list[str]: issue = (f'{_esc(d["issue"])}' if d["issue_url"] else "no issue yet") + registered, now = _registration(d) H = [f'
', f'

{_esc(d["key"])}

' f'{_esc(d["summary"])}' f'{_esc(_overview_text(d))}
', '
', - f'

{_esc(d["status"])} · {_esc(d["partition"])} · {issue}

', + '
', + f'
Registered:
{_esc(registered)}
', + f'
Local:
{_esc(d["local_path"])}
', + f'
RAL:
{_esc(d["ral_root"])}
', + '
', "

Current position

", - "

" + ("
".join(_esc(x) for x in d["now"].split("\n")) - if d["now"] else '(nothing yet)') - + "

"] + "

" + ("
".join(_esc(x) for x in now.split("\n")) + if now else '(nothing yet)') + + "

"] if d["status"] == "active": - H.append(_html_task(f"resume {_esc(d['key'])}", resume_payload(d["key"], row))) + label = _attr(f"Copy resume prompt for {d['key']}") + H.append(f'') + H.append("
") H.append(f"

Runs ({len(d['runs'])})

") H += _runs_table_html(d) H.append(f'
{_esc(_history_label(d))}') @@ -602,12 +634,8 @@ def _card_html(d: dict, row: dict, blob: str) -> list[str]: else: H.append('

empty

') H += [f'

full log

', - "
", - '
Locations
', - f'
Ledger
{_esc(d["rel"])}
', - f'
Local
{_esc(d["local_path"])}
', - f'
RAL
{_esc(d["ral_root"])}
', - "
", "
", "
"] + f'

{_esc(d["status"])} · {_esc(d["partition"])} · {issue}

', + "", "", ""] return H @@ -708,8 +736,13 @@ def render_dashboard(c: dict) -> str: "details.full>p{margin:.2rem 0 0}" "details.sub{margin:.6rem 0}" "ul.log{margin:.3rem 0;padding-left:1.2rem}" - "dl.where{display:grid;grid-template-columns:max-content minmax(0,1fr);gap:.3rem .8rem;margin:.4rem 0}" + "dl.where{display:grid;grid-template-columns:max-content minmax(0,1fr);gap:.3rem .8rem;margin:1rem 0;color:var(--accent)}" "dl.where dd{margin:0;min-width:0}" + ".position{display:flex;align-items:flex-start;gap:.8rem}" + ".position-text{flex:1;min-width:0}" + ".position-text h4{margin-top:.3rem}" + ".position .resume{flex:none;min-width:44px;min-height:44px;margin-top:.2rem}" + "table.runs td.what{line-height:1.6}" "@media(max-width:34rem){" "table.runs,table.runs tbody{display:block}" "table.runs thead{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0)}" diff --git a/tests/test_cortex_conductor.py b/tests/test_cortex_conductor.py index 92209773..8ffbcec0 100644 --- a/tests/test_cortex_conductor.py +++ b/tests/test_cortex_conductor.py @@ -188,7 +188,8 @@ def test_the_summary_table_has_four_narrow_columns_and_active_rows_only(skeleton def test_one_resume_chip_per_active_project_and_no_other_chips(skeleton): page = _cortex.render_dashboard(_cortex.census(skeleton)) chips = re.findall(r"📋 ([^<]+)", page) - assert chips == ["check in since last time", "resume example", "resume single"] + assert chips == ["check in since last time"] + assert page.count(' str: """One project's disclosure in dashboard.md, opening tag to its close.""" start = page.index(f'
') - # the card's own close is the `
` that ends a blank-line block - # after the Locations fold - loc = page.index("
Locations", start) + loc = page.index("[full log]", start) close = "
\n\n" return page[start:page.index(close, loc) + len(close)] @@ -240,17 +239,17 @@ def test_an_expanded_card_shows_position_runs_table_history_and_locations(skelet assert "| `3002_[0-3]` | running | ral | 2026-09-01 | wave 2, four seeds on the corrected settings |" in card assert ("| `3003` | open | gpu | 2026-09-02 | joint fit on the same four seeds " "chained after 3002 with afterok |") in card - # the order is resume chip → runs → history → locations - assert (card.index("📋 resume example") < card.index("**Runs**") - < card.index("Recent log — 5 of 7 entries") - < card.index("Locations")) + assert (card.index("**Registered:**") < card.index("**Local:**") + < card.index("**RAL:**") < card.index("**Current position**") + < card.index('title="Copy resume prompt for example"') < card.index("**Runs**") + < card.index("Recent log — 5 of 7 entries")) + assert "Locations" not in card last = card.split("Recent log — 5 of 7 entries")[1].split("[full log]")[0] assert len([ln for ln in last.splitlines() if ln.startswith("- ")]) == 5 assert "- 2026-09-01 — *lesson* — the adapt image" in last assert "3001_[0-3] submitted" not in last # the sixth entry - where = card.split("Locations")[1] - assert "- Ledger: [projects/example.md](projects/example.md)" in where - assert "- Local: `` /tmp/example ``" in where and "- RAL: `` /mnt/ral/example ``" in where + assert "[full log](projects/example.md)" in card + assert "**Local:** `` /tmp/example ``" in card and "**RAL:** `` /mnt/ral/example ``" in card single = _md_card(page, "single") assert "no issue yet" in single and "**Runs** (0)\n\n_nothing on the cluster_" in single assert "Recent log — 1 of 1 entry" in single @@ -343,7 +342,7 @@ def test_the_html_twin_wears_the_theme_with_real_copy_buttons(skeleton): nav = re.search(r'