src/core/ is Headcrab's pure functional core. It decides whether a session is in scope, renders the stable reminder block, transforms eligible spawn-task params, and builds/verifies the task sandwich that preserves the original task.
- Deterministic scope parsing and scoped-parent/worker classification.
- Stable reminder rendering with no runtime side effects.
sessions_spawntask transformation logic that preserves non-task params.- Task sandwich construction, delimiter collision avoidance, and duplicate-wrapper detection.
- Small pure helpers that can be tested without OpenClaw running.
- OpenClaw hook registration or plugin entrypoint code.
api.logger, telemetry, metrics, tracing, or logging config.- File system writes, persistence, network calls, background jobs, or schedulers.
- Test-only fixtures or synthetic healthcheck reporting.
- User/session-specific identifiers outside values passed into pure functions.
../constants.jsfor canonical text and delimiter constants.- Node standard library utilities when they support deterministic local behavior, such as hashing/signing delimiter tokens.
- Other modules inside
src/core/when dependency direction remains simple and acyclic.
- OpenClaw SDK/runtime APIs.
src/delegate-mode-plugin.js,src/openclaw-hook-adapter.js,src/healthcheck.js,index.js,test/, orscripts/.- Logger instances or code that emits runtime observability.
- Packages that move data outside the process.
- Keep new policy decisions here only when they are pure and independent from hook shape.
- If a feature needs runtime context, translate that context in
OpenClawHookAdapterand pass only the minimum plain data into core. - If task wrapping evolves, preserve the invariant that the original task remains byte-for-byte between validated delimiters.
- If duplicate detection changes, keep it resilient against accidental delimiter collisions and partial/malformed wrappers.