Topics — API
The facade of the domain package goga.topics — the work-tracker view of the history tree. Git access lives in the nested leaf cell goga.topics.git, the interactive todo entry in goga.topics.editor, the lifecycle hook checkpoints in goga.topics.hooks; all surface through this facade's routines. Identity, addressing, and statuses come from goga.history (see History — API).
The signatures below are the CODEMANIFEST contract of the cell.
Board
collect_topic_board(year: str | None = None, remote: bool = False,
hosts: tuple[str, ...] | None = None,
topics: tuple[str, ...] | None = None,
base_ref: str | None = None) -> list[BoardRecord]
Collect the cross-branch topic inventory of one year — every own-branched topic with its hosting branches, statuses, todo summaries, and divergence markers. base_ref — the configured base of the exchange (see Configuration) — turns on the topic-scoped divergence marker (base when the own tip equals the base, up-to-date when the topic carries the base, propagated when the base carries the whole topic — the state the clear scope addresses, need-update when the pair diverged); None leaves every marker None. year as four digits (None — the current year); remote=True reads remote-tracking refs instead of local branches; hosts keeps only the records whose branch display name exactly equals one of the given names and topics only the records of the named topics (exact slug match, union across values, composed together; an unknown name or slug yields the empty list, never an error). A topic without its own branch — some ref of the full inventory whose branch part normalizes into the slug — passes no records in any mode: it is history. Records sort by scale order of the first maximal status, then alphabetically by topic.
BoardRecord(topic: str, branch: str, statuses: list[str], current: bool,
remote: bool, todo: str | None = None,
divergence: str | None = None)
One row of the board audit view. topic — the slug; branch — the display name of the hosting branch; statuses — the qualified names of the maximal present statuses in scale order; current — the row hosts the current working branch; remote — the hosting ref is remote-tracking; todo — the todo summary (the first non-empty line of todo.md after # markers are stripped) or None; divergence — the marker against the configured base or None.
aggregate_topic_board(records: list[BoardRecord],
hosts: tuple[str, ...] | None = None,
topics: tuple[str, ...] | None = None) -> list[BoardEntry]
Project the per-host records into the default board — a pure projection with no git access: one entry per topic that still has its own branch (a hosting branch whose branch part normalizes into the slug); a topic carried only by merged hosts produces no entry. Several own branches colliding resolves deterministically — the current-branch record, else a non-remote one, else the display-name alphabet — and the entry carries that record's statuses and todo summary. hosts keeps only the entries whose hosts list contains one of the given names and topics only the entries of the named topics (exact slug match, union across values, composed together; the own-branch gate stands first, so a filter never resurrects a topic without its own branch). Entries sort by scale order of the first maximal status, then alphabetically by topic.
BoardEntry(topic: str, branch: str, hosts: list[str], statuses: list[str],
current: bool, remote: bool, todo: str | None = None,
divergence: str | None = None)
One entry of the default board. branch — the display name of the topic's own branch; hosts — the display names of every branch carrying the topic's history, the own branch included, alphabetical; current — the topic's own branch is the current working branch (a merged host carrying the topic's history never marks the entry); remote — the own branch is a remote-tracking ref; the rest as in BoardRecord.
Switching and ensuring
resolve_switch_candidates(identifier: str, year: str | None = None) -> list[SwitchCandidate]
switch_topic(identifier: str, todo: bool = False, year: str | None = None) -> str
ensure_topic(identifier: str, todo: bool = False, year: str | None = None) -> str
resolve_switch_candidates resolves an identifier through the three tiers — exact branch name, exact topic slug (local before remote), prefix — and returns the candidates. switch_topic brings the repository onto the hosting branch (a ValueError carries ambiguity and clean-failure reasons). ensure_topic is the combined orchestration: it switches onto hosted work and creates fresh work from the current HEAD when nothing hosts the identifier — the routine behind goga pipeline <name> -t. With todo=True the external editor opens the topic's todo.md after the switch. Each returns its single result line.
One resolution candidate — topic is None for a branch hosting no topic.
Creation
create_topic(branch_name: str, base_ref: str, todo: str | None = None,
todo_from_stdin: bool = False, publish: bool = False,
commit_message: str | None = None, year: str | None = None,
switch: bool = False) -> str
Create fresh work — a branch named verbatim at base_ref with the topic of the year. The todo resolves through the acquisition ladder: a non-empty todo value wins and the piped channel stays unread; todo_from_stdin=True declares the piped stdin as the source — read fully once at todo-resolution time, decoded strictly UTF-8, verbatim; undeclared piped content is a clean error, a bare pipe falls through to the editor rung. The default path plants one quarantined commit carrying the topic's todo.md (git plumbing, the working copy untouched) — the todo is required there. switch=True checks the branch out instead (the topic directory lands uncommitted, the todo optional). publish=True builds the same one-commit branch and pushes it to origin without switching; commit_message is the publication-only commit template — {slug} (and, on the exchange operations, {base}) substitute. Returns the result line.
enter_topic_todo(topic: str, year: str | None = None,
branch: str | None = None) -> bool
publish_topic(branch_name: str, todo: str, base_ref: str,
commit_message: str | None = None, year: str | None = None) -> str
enter_topic_todo opens the external editor on the topic's todo.md (True — saved, False — cancelled); branch is the branch fact of the delivered event identity (None leaves the identity without one). publish_topic is the fast creation-and-publication cycle.
The creation, publication, switch, ensure, todo-entry, and deletion routines all deliver the topics lifecycle checkpoints — the saved todo text and the commit message pass through the amendment hooks before they are fixed into the artifacts, and each completed moment emits its notification (see Topics — Hooks).
Publication
publish_existing_topic(identifier: str | None, year: str | None = None) -> str
resolve_publication_outcome(own_tip: str, twin_tip: str | None) -> str
publish_existing_topic delivers an existing topic branch to origin as an operation of its own — creating fresh work is not part of it (that is create_topic/publish_topic). identifier=None addresses the current topic; the operation fetches the branch's own origin twin once (a fetch reporting the branch absent on origin overrides the remote-tracking ref, so a twin deleted on the origin side reads as None — never as present through a stale ref), classifies the pair, and pushes only on pushed — delivery, never history rewriting: no force and no lease under any outcome, no local ref moved. The outcome contract, resolved purely by resolve_publication_outcome: a None twin is pushed (the push creates it), equal tips are up-to-date, a twin strictly ahead of the tip is remote-ahead, a twin strictly behind it is pushed (the plain push fast-forwards the twin), and a diverged pair — neither contains the other — raises click.ClickException naming both tips with the manual-git hint. Every completed publication emits topic_published, the idempotent outcomes included. Returns the single result line naming the outcome kind.
Occupancy oracles
check_branch_occupancy(branch_name: str, slug: str, year: str | None = None) -> str | None
check_slug_occupancy(slug: str, year: str | None = None) -> str | None
Read-only probes: the first returns the conflict reason when the branch name or the topic is already occupied, the second when a branch tree of the inventory hosts the slug's topic directory. None — free.
Deletion
resolve_delete_targets(identifiers: list[str], year: str | None = None) -> list[DeleteTarget]
resolve_clear_targets(base_ref: str, year: str | None = None) -> list[DeleteTarget]
delete_topics(targets: list[DeleteTarget], year: str | None = None) -> str
resolve_delete_targets resolves every identifier first (all-or-nothing; a click.ClickException carries no-match, ambiguity, branchless-topic, several-own-branches, and current-branch reasons). resolve_clear_targets resolves the clear scope of one year against a base ref's tree — every own-branched topic whose topic directory the base carries, alphabetical; branchless topics are out of scope silently, an empty scope yields [], the base is resolved once and only read, and the current branch being a target's own branch is a clean error cancelling the whole call. delete_topics removes each target's own local branch, origin twin, and topic directory; a rejected remote deletion restores the failing target's local branch. DeleteTarget(topic, branch, remote, has_dir) carries the resolved target — has_dir is True exactly when the topic directory exists on disk and no branch surviving the deletion carries the topic (the survivors are the inventory minus the target's own branch and twin).
The exchange
update_topic(identifier: str | None, base_ref: str, strategy: str | None,
commit_message: str | None, publish: bool = False,
year: str | None = None) -> str
resolve_propagation(identifier: str | None, base_ref: str, strategy: str | None,
commit_message: str | None, year: str | None = None) -> PropagationPlan
execute_propagation(plan: PropagationPlan) -> str
update_topic brings a topic up to its base under the configured strategy (merge, rebase, ff-else-merge, ff-else-rebase; None — merge). The current topic updates in place behind a read-only pre-flight; another topic updates checkout-free. Every conflict is detected read-only before any mutation; a reconciliation the base resolution wrote is rolled back whenever the update fails the gauntlet. The already-current state is the idempotent success. publish=True pushes the refreshed branch — a rebase under a lease bound to the pre-rebase own tip. resolve_propagation resolves the delivery read-only (the plan the caller confirms — a declined confirmation performs nothing); execute_propagation performs the confirmed checkout-free delivery — build, plant, and the inherent push, with one retry cycle answering a concurrent remote movement and a uniform rollback on every failure. Both nothing-to-do forms are idempotent successes.
resolve_exchange_base(base_ref: str, own_branch: str, own_tip: str) -> ExchangeBase
resolve_exchange_target(identifier: str | None, year: str | None = None) -> ExchangeTarget
render_commit_template(template: str, slug: str, base: str) -> str
resolve_divergence(own_tip: str, base_ref: str | None) -> str | None
The shared core of the exchange. resolve_exchange_base resolves a base as one logical branch — the git version gate (>= 2.40), the single reported fetch, the projection containment, and the reconciliation merge of a diverged local/origin pair. resolve_exchange_target resolves the addressee — identifier=None addresses the current topic, a branch matched by name or prefix addresses its own topic (the slug its branch name normalizes to, never a topic the branch merely carries), a slug addresses that topic wherever it is hosted. render_commit_template is the single template engine of the domain's authored messages ({slug} and {base}). resolve_divergence is the board's marker oracle. ExchangeBase(name, tip, local_branch, reconciled) and ExchangeTarget(topic, branch, current) are the frozen fact bags; PropagationPlan(target, base_ref, strategy, message, year) is the confirmed plan.
Example
from goga.topics import collect_topic_board, ensure_topic
for record in collect_topic_board("2026"):
print(record.topic, record.branch, record.statuses)
# onto the branch hosting feat-x — or fresh work when nothing hosts it
line = ensure_topic("feat-x")
print(line) # e.g. "Switched to branch feat/x"