Skip to content

docs(hooks): clarify setup and execution contracts - #130734

Merged
steipete merged 1 commit into
mainfrom
steipete/hooks-documentation-improvements-afbcb7
Aug 27, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/hooks-documentation-improvements-afbcb7

Conversation

@steipete

Copy link
Copy Markdown
Contributor
Additional instructions

Keep Allow edits from maintainers enabled so maintainers can update the branch when needed.

What Problem This Solves

Operators and plugin authors could follow the hooks docs and still end up with a handler that never runs, a reply that never reaches chat, or an HTTP success mistaken for completed work. The pages mixed internal HOOK.md events, typed api.on(...) hooks, and HTTP ingress; several activation, payload, timeout, and delivery claims had drifted from their implementations.

This is a maintainer-requested, source-audited documentation overhaul. No runtime behavior is changed.

Why This Change Was Made

Make each hook system understandable from its own setup and execution contract. The internal guide now provides a complete enable/restart/trigger/verify/disable flow and a working custom hook. The typed plugin reference includes a complete local-plugin example, all 42 hook names, permission gates, execution kinds, and actual merge/error/timeout semantics. The HTTP guide keeps the common workflow while the configuration reference owns exhaustive routing, mapping, replay, and fan-out contracts.

The audit covered hook discovery/loading, registries/runners, event producers, CLI/config owners, bundled handlers, HTTP dispatch and downstream admission/delivery, Gmail/IMAP, and TaskFlow webhook routes. Runtime-specific statements were checked against their adapters and relevant upstream contracts. Related pages and packaged hook documentation were aligned rather than retaining conflicting copies.

User Impact

  • Clear choice between internal event scripts, typed plugin hooks, and HTTP webhooks.
  • Explicit distinction between discovery/eligibility, configuration, imported registration, and a handler actually running; local/remote and agent/global scope are documented.
  • Accurate reply delivery, synchronous persistence hooks, permissions, timeout behavior, and runtime support boundaries.
  • HTTP admission is distinguished from execution completion and channel delivery; examples explain logs, retries, session keys, and safe email readers.
  • Removes unsafe force-kill guidance and incorrect workspace.dir setup advice, corrects BOOT.md workspace deduplication, and consolidates the bundled catalog.
  • Repairs ten pre-existing broken anchor links found by the full docs audit using stable target anchors and the current agents.entries reference.

Public guides: Internal hooks, Plugin hooks, Webhooks, and Hooks configuration.

Evidence

  • Scope: 18 Markdown files. Production code: +0/-0. Test code: +0/-0. Bundled HOOK.md runtime frontmatter is byte-for-byte unchanged.
  • Fresh independent Codex autoreview at the default P0 blocking threshold: no findings. The implementation and caller audit described above supplies the broader source-contract evidence.
  • node scripts/run-vitest.mjs src/hooks/configured.test.ts src/hooks/internal-hooks.test.ts src/hooks/loader.test.ts src/hooks/policy.test.ts src/hooks/hooks-status.test.ts src/hooks/workspace.test.ts — 6 files, 64 tests passed across 2 shards.
  • Executed the verbatim custom HOOK.md and JavaScript example through real source discovery/loading in isolated temporary state: enable, new/reset replies, unrelated-event non-outcome, and disable passed.
  • Executed the verbatim plugin package, manifest, and TypeScript example through the real plugin loader and hook runner: expected reply, ordinary-message pass-through, user/cron trigger filtering, and conversation-access gating passed.
  • Targeted node_modules/.bin/oxfmt --check --threads=1 and git diff --check — passed.
  • pnpm docs:list — passed.
  • pnpm docs:check-mdx — 791 files passed.
  • pnpm docs:check-links — 6,745 internal links checked, zero broken.
  • pnpm docs:check-config-examples — 1,208 examples validated.
  • pnpm docs:check-i18n-glossary — passed.
  • pnpm docs:check-links:anchors — passed after repairing the existing anchor failures.

No live Gateway, mail account, model provider, or chat channel was used for the example probes. These are source-loader/contract checks, not a claim of live end-to-end email or channel proof. English source docs only; localization remains downstream.

Runtime follow-ups found during the audit remain separate: linked hook-pack root discovery, repeated foreground Gmail watcher exits, and correlated webhook delivery-failure visibility. This PR documents the current limitations instead of quietly changing their behavior.

AI-assisted documentation and source audit.

@clawsweeper

clawsweeper Bot commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime plugin: imap size: M maintainer Maintainer-authored PR labels Aug 27, 2026
@steipete
steipete marked this pull request as ready for review August 27, 2026 05:47
@clawsweeper clawsweeper Bot added merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 27, 2026
@clawsweeper

clawsweeper Bot commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Codex review: found issues before merge. Reviewed August 27, 2026, 1:54 AM ET / 05:54 UTC.

ClawSweeper review

What this changes

The PR reorganizes documentation for internal hooks, typed plugin hooks, and HTTP webhook ingress, and updates related CLI, configuration, bundled-hook, and Codex reference pages.

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

Keep this protected maintainer PR open: its hook documentation work is useful, but it regresses current Codex runtime documentation from the managed 0.150.1 release to 0.149.1.

Priority: P2
Reviewed head: b6412d780c2633638fb34f71100a522ae00834d9

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The documentation audit is substantial, but a concrete current-main runtime-documentation regression blocks a higher rating.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored documentation-only change has no changed runtime behavior requiring contributor real-behavior proof.
Patch quality 🦐 gold shrimp (3/6) 1 actionable review finding remain.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored documentation-only change has no changed runtime behavior requiring contributor real-behavior proof.
Evidence reviewed 6 items Current managed runtime contract: Current main pins the bundled Codex dependency to 0.150.1.
Current runtime owner: The Codex bridge exports 0.150.1 as its managed app-server version, with 0.149.0 only as the external-binary compatibility floor.
Introduced documentation regression: The PR changes the documented managed binary from 0.150.1 to 0.149.1 and replaces the current 0.150.1 picker table with an older one.
Findings 1 actionable finding [P2] Restore the current managed Codex version references
Security None None.

How this fits together

OpenClaw’s Gateway supports internal event scripts, plugin lifecycle hooks, and inbound HTTP hooks. These docs tell operators which surface to use and how the selected surface reaches a Gateway action or agent run.

flowchart LR
  A[Operator or plugin author] --> B[Hooks documentation]
  B --> C[Internal event scripts]
  B --> D[Plugin lifecycle hooks]
  B --> E[HTTP hook ingress]
  C --> F[Gateway event handling]
  D --> F
  E --> F
  F --> G[Agent run or recorded outcome]
Loading

Before merge

  • Restore the current managed Codex version references (P2) - This reverts current main’s 0.150.1 managed-runtime update to 0.149.1 and replaces its corresponding picker table. The package pin and runtime owner both declare 0.150.1, so retain the hook rewrite but reapply this reference content from current main.
  • Resolve merge risk (P1) - Merging would publish stale 0.149.1 managed-runtime and model-catalog guidance despite current main shipping and declaring 0.150.1.
  • Resolve merge risk (P1) - Independent documentation-command reruns are unavailable in this read-only environment; rerun the relevant documentation checks after correcting the stale Codex references.

Findings

  • [P2] Restore the current managed Codex version references — docs/plugins/codex-harness-reference.md:174-175
Agent review details

Security

None.

PR surface

Docs +951. Total +951 across 18 files.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 0 0 0 0
Docs 18 1939 988 +951
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 18 1939 988 +951

Review metrics

Metric Value Why it matters
Managed runtime documentation 0.150.1 → 0.149.1 across 4 Codex guides plus one picker table The branch reverses current managed-runtime documentation, which can mislead operators during setup and upgrade.

Stored data model

Persistent data-model change detected: serialized state: src/hooks/bundled/session-memory/HOOK.md, vector/embedding metadata: src/hooks/bundled/README.md. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Restore current Codex runtime references (recommended)
    Keep the hooks changes while restoring the 0.150.1 version and current model-list documentation from main before merging.
  2. Pause the mixed documentation update
    Pause this PR if the broad rewrite cannot be refreshed without retaining stale Codex reference material.
Copy recommended automerge instruction
@clawsweeper automerge

Special instructions:
Restore the current 0.150.1 managed Codex references and model-list content while preserving the hook documentation changes.

Technical review

Best possible solution:

Retain the hook documentation overhaul, but restore the current 0.150.1 Codex version and picker information from main before merge.

Do we have a high-confidence way to reproduce the issue?

Yes—source reproducible: current main’s package and runtime version owner declare 0.150.1, while this branch documents 0.149.1.

Is this the best way to solve the issue?

No—the hooks documentation direction is sound, but retaining the current 0.150.1 Codex references is necessary for an accurate, maintainable update.

Full review comments:

  • [P2] Restore the current managed Codex version references — docs/plugins/codex-harness-reference.md:174-175
    This reverts current main’s 0.150.1 managed-runtime update to 0.149.1 and replaces its corresponding picker table. The package pin and runtime owner both declare 0.150.1, so retain the hook rewrite but reapply this reference content from current main.
    Confidence: 0.99

Overall correctness: patch is incorrect
Overall confidence: 0.98

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 42ce03e72e34.

Labels

Label changes:

  • add P2: The PR introduces a concrete documentation mismatch with the current managed Codex runtime contract.
  • add merge-risk: 🚨 other: Merging would replace current runtime and model-catalog guidance with stale values not represented by the compatibility-specific labels.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool and patch quality is 🦐 gold shrimp.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: This maintainer-authored documentation-only change has no changed runtime behavior requiring contributor real-behavior proof.

Label justifications:

  • P2: The PR introduces a concrete documentation mismatch with the current managed Codex runtime contract.
  • merge-risk: 🚨 other: Merging would replace current runtime and model-catalog guidance with stale values not represented by the compatibility-specific labels.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: This maintainer-authored documentation-only change has no changed runtime behavior requiring contributor real-behavior proof.

Evidence

What I checked:

Likely related people:

  • steipete: Recent history includes the prior hooks documentation and configuration work that this PR rewrites. (role: recent hooks and documentation contributor; confidence: high; commits: 30e7ecb45435, 4c3bf144665e; files: docs/automation/hooks.md, docs/plugins/hooks.md, src/hooks/bundled/README.md)
  • Vincent Koc: Authored the current-main commit that set the managed Codex version to 0.150.1. (role: managed Codex runtime update author; confidence: high; commits: c45cc17e0505; files: extensions/codex/package.json, extensions/codex/src/app-server/version.ts, docs/plugins/codex-harness-reference.md)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Restore the current 0.150.1 Codex references and picker table, then rerun the affected documentation checks.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@steipete

Copy link
Copy Markdown
Contributor Author

ClawSweeper finding and rank-up resolution

The reported Codex version downgrade is not part of this PR. It comes from comparing an older branch tip directly with newer main, rather than reviewing the merge-base-to-head patch. No Codex runtime version or picker-table restoration is needed.

I fetched GitHub's actual merge ref and verified:

The merge-base-to-head diff is empty for all four cited Codex guides (codex-computer-use, codex-harness-reference, codex-harness, and codex-native-plugins), extensions/codex/package.json, and extensions/codex/src/app-server/version.ts. Each of those six files has an identical Git blob in the test merge and its main parent. The newer main-owned update from c45cc17e05055e9485b37ff7e2377b962465abeb is therefore preserved, not reverted.

Disposition: reject the downgrade finding and its derived merge-risk claim. Skip the rank-up move to restore those files because the merge already retains them. There is no source correction requiring another commit or a rebase solely for main drift.

The stored-data warning is also not a schema or migration change: only Markdown prose changed, and both edited bundled HOOK.md frontmatter blocks are byte-for-byte unchanged. Production code and test code deltas are both zero.

The read-only review environment's inability to rerun docs commands is disclosed, not evidence of a failing check. The PR body records the completed local docs/source-loader checks and 64 passing focused tests; exact-head CI run 33043650526 is successful. Native review artifacts have also validated with no accepted actionable findings. No live mail/channel proof is claimed for this docs-only change.

@steipete

Copy link
Copy Markdown
Contributor Author

Land-ready for reviewed head b6412d780c2633638fb34f71100a522ae00834d9. Exact-head CI run 33043650526 completed successfully, including check-docs and the required openclaw/ci-gate.

Scope remains 18 Markdown files; production +0/-0, tests +0/-0, and bundled HOOK.md runtime frontmatter unchanged. Source inspection confirms the documented setup, permission, timeout, reply and HTTP admission/completion boundaries. Both verbatim examples passed through the real source loaders in isolated state, including trigger filtering and permission gating. Independent Codex autoreview found no findings; native review artifacts validated with no accepted actionable findings.

Completed local proof commands (full results are in the PR body):

git diff --check e2e030e2b0ae59580422ef8f20bdccc149862536 b6412d780c2633638fb34f71100a522ae00834d9
node scripts/run-vitest.mjs src/hooks/configured.test.ts src/hooks/internal-hooks.test.ts src/hooks/loader.test.ts src/hooks/policy.test.ts src/hooks/hooks-status.test.ts src/hooks/workspace.test.ts
pnpm docs:list
pnpm docs:check-mdx
pnpm docs:check-links
pnpm docs:check-config-examples
pnpm docs:check-i18n-glossary
pnpm docs:check-links:anchors

The focused suite passed 64 tests in six files. The ClawSweeper finding and rank-up resolution is independently confirmed by the actual merge-result blobs; no restoration or rebase is needed. No live Gateway, provider, email or channel execution is claimed. Proceeding through native prepare/merge with the approved head unchanged.

@steipete
steipete merged commit 7eebd6d into main Aug 27, 2026
133 checks passed
@steipete
steipete deleted the steipete/hooks-documentation-improvements-afbcb7 branch August 27, 2026 06:12
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation gateway Gateway runtime maintainer Maintainer-authored PR merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. P2 Normal backlog priority with limited blast radius. plugin: imap rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: M status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant