Hooks — The registration contract
How a goga_tool_* package subscribes its hooks to domain actions — the tool-author side of the platform.
A tool may expose a register_hooks(hooks) callable in its facade package — the registration of domain hooks. goga calls it when a command first reaches a hook checkpoint of the run, or when you inspect the registry with goga hooks; commands that use no hooks never call it. Registration is never cached — package edits apply from the next run, without reinstall.
# inside the goga_tool_<tool> package
def register_hooks(hooks):
hooks.subscribe("statuses", "register_statuses", "published", register_published)
def register_published(context):
context.register("published", "mkdocs/published.md", after="planned")
hooks.subscribe(domain, action, name, hook) registers one hook:
domain+action— the action address: the semantic owner domain and the action name within it. The declared addresses:"statuses"/"register_statuses"— the topic-status action (see History — Hooks)"onboarding"/"declare_session","onboarding"/"amend_config"— the onboarding-session actions a tool is invited into viagoga init -t <tool>(see Init — Hooks)- the nine
"topics"addresses —amend_creation,amend_todo_entry,topic_created,topic_published,topic_switched,topic_todo_entered,topic_deleted,topic_updated,topic_propagated, all soft — the topic-lifecycle checkpoints: two amendments before the content is fixed and seven notifications after their moments (see Topics — Hooks) - the eighteen
"pipeline"addresses —amend_workflow(hard),run_created,run_completed, and the fifteen soft bridged mid-run events (the thirteen stage transitions plusrun_resumed/run_interrupted) — the pipeline checkpoints: the workflow amendment before compilation in both the run and the card form, the two notifications around a run's launch, and the live run-interior events delivered over afm's lifecycle hooks (see Pipelines — Hooks) - the five
"build"addresses —validate_build(hard, with verdict collection),build_started,pass_started,pass_completed,build_completed(soft) — the build checkpoints: the validation gate over the resolved run facts before the first pass and the four run notifications (see Build — Hooks) "config"/"amend_config"(hard) — the config amendment: the read-and-amend view over the authored project configuration at the load moment (see Configuration — Hooks)"schema"/"amend_cell"(hard) — the cell amendment: the read-and-contribute view over the authored facts of one cell at the generation moment of the project map;"schema"/"validate_schema"(hard, with verdict collection) — the schema validation gate: the observe-and-veto pass over the final assembled tree after the tools overlay and before serialization (see Schema — Hooks)"contract"/"amend_contract"(hard) — the contract amendment: the read-and-contribute view over the comparison facts of one cell at the comparison moment (see Contract — Hooks)- the two
"codegraph"addresses —amend_nodeandvalidate_graph, both hard — the codegraph checkpoints: the node amendment over the code-derived facts of one node and the observe-and-veto validation gate over the final assembled tree, firing wherever the codegraph routine runs (inside every drift run's producer calls too) (see Codegraph — Hooks) - the four
"drift"addresses —run_started,run_completed(soft),amend_report,amend_entry(hard) — the drift checkpoints: the two run moments plus the whole-list report amendment and the per-entry facts amendment (see Drift — Hooks) - the four
"usages"addresses —sync_started,sync_completed,status_started,status_completed, all soft — the usages run-level moments: the started and completed notifications around each of the two usages operations (see Usages — Hooks) name— the hook name, unique per tool per address; registrations appear in thegoga hookstree under their tool line.hook— the callable executed when the action fires.
The tool identity is assigned by goga from the package name — a package never names itself, and identical hook names of different tools never collide. Enumeration is deterministic: packages in alphabetical order of top-level module name, subscriptions delivered in enumeration order.
The hook signature
A hook receives values only for the parameters it declares by the fixed offered names — context and self:
context— the delivered object of the action. Read attributes and call methods freely; attribute assignment is blocked. What the object carries is fixed by the owner domain's contract — forregister_statusesit is the status registration surface (register(name, filepath, before=..., after=...), names stored qualified<tool>.<name>; see History — Hooks for the scale rules). For the onboarding actions it is the declaration or contribution surface described in Init — Hooks.self— the isolated context of your tool. One instance links all its hook invocations of a run; freely mutable by your tool, invisible to the domains.
The declaration order does not matter; names you did not declare receive nothing.
Error classes and diagnostics
Each action in the catalog fixes how a failing hook is treated. The topic-status, the onboarding, the topics, the two pipeline notification, the four build notification, the two drift run-moment, and the four usages notification actions are soft: a failing hook is skipped with a stderr warning naming the tool, the action, and the reason, and the command continues. A hard action stops the command:
pipeline/amend_workflow— stops at the first failing hook with a clean error (see Pipelines — Hooks)build/validate_build— lets every subscribed tool's hooks run to completion and merges their vetoes into one error that stops the build before any pass (see Build — Hooks)config/amend_config— stops at the first failing tool — a crashed hook or a structurally malformed contribution, the tool's whole contribution discarded — with a clean error naming the tool and the action (see Configuration — Hooks)schema/amend_cell— stops at the first failing tool the same way, its clean error naming the tool, the action, and the failing cell pathschema/validate_schema— runs like the build gate: every subscribed tool's hooks run to completion and their vetoes merge into one error that stopsgoga schemabefore any output (see Schema — Hooks)contract/amend_contract— stops at the first failing tool the same way, its clean error naming the hook, the tool, the action, and the failing cell path — plus the offending type name for a contribution addressed to a type the cell does not declare (see Contract — Hooks)codegraph/amend_node— stops at the first failing tool the same way, its clean error naming the tool, the action, and the failing node cell pathcodegraph/validate_graph— runs like the build gate: every subscribed tool's hooks run to completion and their vetoes merge into one error that stops the run before any output (see Codegraph — Hooks)- the two drift amendments — stop
goga driftat the first failing tool the same way — a crashed hook, a malformed adjustment outside the closed kind/cell/types shape, or a structurally malformed contribution — with a clean error naming the hook or tool, the action, the entry subject where one exists, and the reason (see Drift — Hooks)
The class is chosen by the owner domain when it declares the action.
At registration: a wrong address, an empty name, or a repeated name on the same address is refused with a stderr warning naming the tool, the action, and the reason — the registration is skipped, the rest apply. A crashing callback is a warning; the registrations made before the crash survive. A broken package import is the only fatal case: a clean error naming the package.
Migration note. The old
register_topic_statuses(statuses)callback is gone. After a goga update, a package still carrying it loses its statuses without any diagnostic — they silently disappear from the scale. Moving toregister_hooksis the package author's responsibility. Qualified names of packages with underscores in their name change too: the qualifier is the canonical hyphen identity, sogoga_tool_hello_worldnow registershello-world.publishedwhere it used to registerhello_world.published— existinggoga history status -s <tool>.<name>filters must use the hyphen form.