Skip to content

Make setupOpenClawOrchestrator own GitHub mention hooks idempotently #1

@OpenCodeEngineer

Description

@OpenCodeEngineer

Summary

Extend setupOpenClawOrchestrator.ts so reruns always provision and preserve OpenClaw GitHub mention orchestration (@githubap, @ClawEngineer) in an idempotent way.

Required behavior

  • Add dedicated configureGithubMentionHooks(...) setup step after gateway/model config.
  • Ensure config keys are set each run:
    • hooks.enabled=true
    • hooks.token=${OPENCLAW_HOOKS_TOKEN} (generate once if missing and persist in ~/.openclaw/.env)
    • hooks.allowRequestSessionKey=true
    • hooks.allowedSessionKeyPrefixes=["hook:github:"]
    • hooks.transformsDir="~/.openclaw/hooks/transforms"
  • Upsert mapping hooks.mappings["github-mentions"]:
    • action agent, agentId=main
    • transform.module="github-mentions.ts"
    • match for issue_comment, pull_request_review_comment, discussion_comment plus optional pull_request_review submitted body via transform.
  • Materialize transform file ~/.openclaw/hooks/transforms/github-mentions.ts with:
    • mention filter for @githubap and @ClawEngineer (CLI override supported)
    • loop prevention for bot/self authors
    • deterministic session key format: hook:github:<owner>/<repo>:<kind>:<id>
    • structured agent payload message
    • HMAC verification with GITHUB_APP_WEBHOOK_SECRET
  • Print final webhook metadata in JSON output:
    • webhookPath, hooksEnabled, mentionsHandles, transformPath

CLI/options

  • Add repeatable: --github-mention-handle <@handle>
  • Add opt-out: --disable-github-mention-hooks
  • Add explicit rotation flag: --rotate-hooks-token

Idempotency

  • Never rotate existing OPENCLAW_HOOKS_TOKEN unless --rotate-hooks-token is provided.
  • Never rewrite transform when content hash is unchanged.
  • Preserve existing custom mappings; only upsert/remove github-mentions entry.
  • Hard fail if mention hooks are enabled but GITHUB_APP_WEBHOOK_SECRET is missing.

Validation

  • Fresh run creates hooks config + transform + token.
  • Re-run does not duplicate mapping or churn token.
  • Mention payload accepted only with valid signature and matching handle.
  • Non-mention/bot payload ignored.
  • Config smoke verifies hooks settings and mapping target.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions