agora.observe.formatters
Render domain events as HTML-formatted Matrix messages.
Every formatter is a PURE function domain event -> `` :class:`FormattedMessage`
(a ``content dict ready for matrix_client.send_event(room_id,
"m.room.message", content)). Each produces both a plain body (clients that
don’t render HTML) and an org.matrix.custom.html formatted_body (Element),
escaping every interpolated value. That shared contract is the docstring for the
one-line format_* renderers below; only the ones with a non-obvious contract
(dual input shapes, optional artifact snapshot) carry their own.
Golden-tested: these functions are pure.
Functions
|
|
A compact, collapsed cheat sheet for the observer commands. |
|
|
|
|
|
|
|
|
|
|
Render a review summary. |
|
Render a task-completion card (badge + artifacts + per-postcondition results). |
|
|
|
Render a compact card for a file-write event. |
Classes
What actually exists on disk at review time. |
|
A Matrix message in both plain and HTML form. |
- class agora.observe.formatters.FormattedMessage[source]
Bases:
objectA Matrix message in both plain and HTML form.
msgtypedefaults tom.noticeso clients render these as bot output (dimmed) rather than as a human turn.to_content()produces the exact event content dict.- __init__(body, formatted_body, msgtype='m.notice')
- agora.observe.formatters.format_task_completed(result_content)[source]
Render a task-completion card (badge + artifacts + per-postcondition results). Tolerates both postcondition-result shapes — dicts (MCP path) and
(name, passed, reason)tuples (orchestrator path) — so the same formatter serves both callers; failed predicates show their reason, passed ones don’t.
- class agora.observe.formatters.ArtifactSnapshot[source]
Bases:
objectWhat actually exists on disk at review time.
ReviewCoordinator fills this in so the reviewer sees concrete files + recent commits + any failing gate before the vote, instead of voting on a black box.
- postcondition_failures: list[tuple[str, str, str]]
[(task_id, predicate_name, reason), ...]for every failed postcondition.
- reaction_counts: dict[str, dict[str, int]]
{task_id: {emoji_key: count}}aggregated across all reactions the reviewer left on that task’s cards during the run. Empty dict when no reactions were captured.
- __init__(files, recent_commits, postcondition_failures, reaction_counts=<factory>)
- agora.observe.formatters.format_review_summary(project_name, phase, task_results_summary, artifact=None)[source]
Render a review summary.
Accepts either dicts (MCP path) or
TaskResultdataclass instances (orchestrator path); both carrysuccess/task_idfields.When
artifactis provided, the review summary also shows the file tree, recent commits, and any failed postconditions — so the reviewer votes on concrete state rather than a name alone.
- agora.observe.formatters.format_command_reference()[source]
A compact, collapsed cheat sheet for the observer commands.
Posted once per project at observer attach. Element users can expand the
<details>block to see every verb without typing/agora help.
- agora.observe.formatters.format_write_event(*, task_id, path, operation, size_bytes, hook_summary, preview=None)[source]
Render a compact card for a file-write event.
operationis e.g."write","edit:replace","edit:insert_before","edit:append","fetch:save_as".hook_summaryis a list of(tool_name, success)tuples from the auto-hook chain.previewis an optional short (< ~2 KB) snippet of what was written; it’s rendered in a collapsed<details>block so the room stays legible on scroll but the reviewer can expand and see the actual bytes.