Skip to content

Hooks

The extension platform connecting goga domains and tool packages.

The hooks domain is the mechanism behind every domain extension: a domain declares an action at a checkpoint of its run; an installed goga_tool_* package subscribes a hook to that action; when a command first reaches the checkpoint, goga enumerates the tool packages, calls each register_hooks callback, and delivers the action's context to the subscribed hooks. Which tasks it solves:

  • Domains expose extension points without knowing their consumers — a domain declares an action address and the error class; the platform owns the enumeration, registration, and delivery.
  • Tool packages extend domains with no goga code changes — a package registers its hooks at run time; registration is never cached, so package edits apply from the next run without reinstall.
  • Inspection — goga hooks assembles the registry once and prints it as a tree: tool, domain, action — the fact of registration, including every refused registration with its reason.

The declared actions today:

Domain Address Error class Purpose
History statuses/register_statuses soft The status-scale registration.
Init onboarding/declare_session, onboarding/amend_config soft The two onboarding actions — a tool reaches them via goga init -t <tool>.
Topics topics/amend_creation, topics/amend_todo_entry soft Two amendments before the content is fixed.
Topics topics/topic_created, topics/topic_published, topics/topic_switched, topics/topic_todo_entered, topics/topic_deleted, topics/topic_updated, topics/topic_propagated soft Seven notifications after their moments.
Pipelines pipeline/amend_workflow hard The workflow amendment delivered before compilation in both the run and the card form.
Pipelines pipeline/run_created, pipeline/run_completed soft The two notifications around a run's launch.
Pipelines the fifteen bridged mid-run events soft The thirteen stage transitions plus run_resumed / run_interrupted, delivered live while the run executes over afm's lifecycle hooks.
Build build/validate_build hard The validation gate with verdict collection over the resolved run facts, delivered before the first pass.
Build build/build_started, build/pass_started, build/pass_completed, build/build_completed soft The four run notifications carrying the run's facts.
Configuration config/amend_config hard The read-and-amend view over the authored project configuration, delivered at the load moment of every host-side config-consuming command.
Schema schema/amend_cell hard The read-and-contribute view over the authored facts of one cell, delivered at the generation moment of the project map.
Schema schema/validate_schema hard The observe-and-veto pass with verdict collection over the final assembled tree, delivered after the tools overlay and before serialization.
Contract contract/amend_contract hard The read-and-contribute view over the comparison facts of one cell, delivered at the comparison moment of the run.
Usages usages/sync_started, usages/sync_completed, usages/status_started, usages/status_completed soft The started and completed notifications around each of the two usages operations.
Codegraph codegraph/amend_node, codegraph/validate_graph hard The node amendment over the code-derived facts of one node and the validation gate with verdict collection over the final assembled tree — firing wherever the codegraph routine runs, including inside every drift run's producer calls.
Drift drift/run_started, drift/run_completed soft The run moments around every drift comparison — completion fires on every terminal state, crashes included.
Drift drift/amend_report, drift/amend_entry hard The whole-list report adjustment and the per-entry facts amendment.

The authoring side — how a tool package writes its register_hooks callback — is the registration contract. Four feature domains expose no hook actions today — Connect, Install (a post-install lifecycle callback instead), Lint, and Upgrade.

Model

  • Action — an address domain / name plus an error class (soft: a failing hook is skipped with a warning; hard: the command stops at the first failure). The owner domain chooses the class when it declares the action.
  • Registry — one per run, assembled lazily on first use at a checkpoint: packages in alphabetical order of top-level module name, subscriptions delivered in enumeration order. Commands that use no hooks never build the registry.
  • Tool identity — assigned by goga from the package name (the goga_tool_ prefix dropped, underscores as hyphens); a package never names itself, and identical hook names of different tools never collide.
  • Delivery — a hook receives values only for the parameters it declares by the fixed offered names (context, self); the context is read-only (attribute assignment blocked), self is the tool's isolated per-run state.

In this directory

  • CLI — the goga hooks command reference
  • Configuration — the domain reads no configuration section
  • Hooks — the registration contract for tool-package authors
  • API — the goga.hooks package facade