Skip to content

feature/hook discoverability 2603#228

Merged
emesal merged 2 commits into
devfrom
feature/hook-discoverability-2603
Mar 15, 2026
Merged

feature/hook discoverability 2603#228
emesal merged 2 commits into
devfrom
feature/hook-discoverability-2603

Conversation

@emesal
Copy link
Copy Markdown
Owner

@emesal emesal commented Mar 15, 2026

  • feat: add (harness docs) module with hooks-docs for hook discoverability
  • fix: valid JSON in generated hooks.md + category validation test

emesal added 2 commits March 15, 2026 15:17
Adds HOOK_METADATA as the single source of truth for all hook contracts,
replacing the hand-authored docs/hooks.md hook reference. From it we derive:

- hooks-docs: a scheme alist injected into every tein context, discoverable
  via (import (harness docs)) then (describe hooks-docs) or
  (module-doc hooks-docs 'pre_message) for a specific hook's payload/return contract
- docs/hooks.md hook reference section: regenerated via `just generate-docs`
  (cargo test -p chibi-core --test generate_docs)

HARNESS_PREAMBLE converts from &str to LazyLock<String> to splice the
generated hooks-docs alist at startup. EVAL_PRELUDE imports (harness docs)
so both hooks-docs and harness-tools-docs are pre-available in all contexts.

Tests: completeness (every HookPoint variant has a HOOK_METADATA entry),
scheme alist evaluation, (harness docs) module availability in both tiers,
and markdown freshness (fails if docs/hooks.md is stale).
- json_block() now places commas after values (before // comments) so
  generated JSON blocks are syntactically valid once comments stripped;
  previously commas were appended after the comment text
- replace split_once description-first-word heuristic for string examples
  with "..." placeholder (consistent with return fields, avoids corpus
  strings like "file_head," leaking into example values)
- add test_hook_metadata_categories_valid: asserts every HOOK_METADATA
  entry's category appears in generate_hooks_markdown's category_order,
  preventing silent category drop on typo/new category
- add explanatory comment to HARNESS_DOCS_MODULE explaining the
  intentional top-level binding re-export pattern (no local definitions)
- regenerate docs/hooks.md from fixed generator
@emesal emesal merged commit 2a5513e into dev Mar 15, 2026
6 of 8 checks passed
@emesal emesal deleted the feature/hook-discoverability-2603 branch March 15, 2026 15:46
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.

1 participant