Skip to content

feat(plugins,engine): build lifecycle hooks (on_build_start / on_build_finish) — Issue #11 - #32

Merged
webmaven merged 9 commits into
mainfrom
feature/issue-11-build-lifecycle-hooks
Sep 19, 2026
Merged

webmaven merged 9 commits into
mainfrom
feature/issue-11-build-lifecycle-hooks

Conversation

@webmaven

@webmaven webmaven commented Sep 8, 2026

Copy link
Copy Markdown
Owner

Summary

Implements Issue #11: decouples the engine from concrete plugin imports and adds two new lifecycle hook points that plugins can use to run logic before and after the compilation pipeline.

Changes

golem/plugins/__init__.py

  • GolemBuildAbortError(Exception) — exception plugin authors raise from on_build_start to abort the build
  • BuildResult dataclass — carries compiled_files: list[Path] and output_dir: Path to on_build_finish impls
  • on_build_start(config) hookspec — called before stale detection; supports collect-all-errors abort semantics
  • on_build_finish(config, result: BuildResult) hookspec — called after all documents written to disk
  • __all__ added exposing all public plugin symbols

golem/engine.py

  • Removed hard import of golem.plugins.apidoc.generate_api_docs (engine no longer coupled to any concrete plugin)
  • on_build_start collect-all-errors loop before stale detection: runs ALL implementations, accumulates every GolemBuildAbortError, then raises a single summary error
  • on_build_finish dispatch after disk write with BuildResult
  • Strict mode respected for unexpected plugin exceptions
  • _invoke_build_start_hook scopes inspect.signature narrowly to avoid duplicate hook execution on ValueError/TypeError

golem/plugins/apidoc/__init__.py

  • on_build_start hookimpl restores API doc generation via the lifecycle hook (same logic, now decoupled)

Tests

  • 395 passing, 0 failing
  • New tests cover: collect-all-errors, single abort, on_build_finish payload, apidoc decoupling, no-op when api_packages unset, strict-mode propagation, incremental build result

Closes #11

…on_build_finish hookspecs

Closes part of #11. Adds plugin-facing abort exception and build result
dataclass. Two new hookspecs: on_build_start (collect-all-errors abort
semantics) and on_build_finish (receives BuildResult). Engine callsites
in Task A2.
… apidoc

Closes part of #11.
- Invoke on_build_start before stale detection with collect-all-errors abort pattern
- Invoke on_build_finish with BuildResult(compiled_files, output_dir)
- Remove hardcoded golem.plugins.apidoc import and call from BuildEngine.build_site
- Update lifecycle documentation in engine docstrings
- Add unit tests for collect-all-errors, single abort, finish hook, and apidoc decoupling
- Add __all__ to golem/plugins/__init__.py exposing GolemBuildAbortError and BuildResult
- Update test_plugins_exports to assert GolemBuildAbortError and BuildResult
- Add test_build_engine_strict_mode_raises_when_apidoc_fails
- Add incremental build test checking on_build_finish receives empty compiled_files
…lic APIs

- GolemBuildAbortError: replace RST Example:: with [source,python] fence block
- BuildResult: replace free-text field descriptions with [attributes] labeled list
- apidoc.on_build_start: expand one-liner to full docstring with [parameters] and [raises]
- build_site: add GolemBuildAbortError specifically to [raises] section
@webmaven
webmaven merged commit 89b88c5 into main Sep 19, 2026
1 check passed
@webmaven
webmaven deleted the feature/issue-11-build-lifecycle-hooks branch September 19, 2026 00:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(plugins): introduce build lifecycle hooks (on_build_start, on_build_finish)

1 participant