Skip to content

ContextReduction hook is a permanent no-op: install.sh never installs the rtk binary it depends on #1480

Description

@nbost130

Summary

hooks/ContextReduction.hook.sh is installed and registered as a PreToolUse:Bash hook, and the docs describe it as delivering 60-90% token reduction. But install.sh never installs the rtk binary it depends on, and the hook's dependency guard exits 0 silently when it is missing.

The result: on any machine without rtk already on PATH, the hook is a permanent no-op, and nothing anywhere reports that. Meanwhile LIFEOS/DOCUMENTATION/Tools/Tools.md and hooks/README.md both state the feature is active. I discovered this only because I misattributed an unrelated bug to a context-reduction layer that turned out never to have run.

Three related defects, in severity order.


1. install.sh ships a hook whose binary dependency it never installs

rg -c 'rtk' install.shzero matches.

The hook's guard:

# Guards: skip silently if dependencies missing
if ! command -v rtk &>/dev/null || ! command -v jq &>/dev/null; then
  exit 0
fi

exit 0 on every Bash call, forever, with no signal. Silent-fail-by-design is what let this sit undetected.

The docs already know the install command — LIFEOS/DOCUMENTATION/Tools/Tools.md documents it as:

curl -fsSL https://raw.githubusercontent.com/rtk-ai/rtk/refs/heads/master/install.sh | sh

It just never runs anywhere in the installer.

Suggested fix (either is fine, the second is cheaper):

  • Install rtk as a step in install.sh; or
  • Have the hook fail loud once rather than exit 0 forever — e.g. emit a one-time warning to stderr, or have the installer print a post-install notice that context reduction is inactive until rtk is present.

Silent is the part that hurts. A dead hook you know about is fine.

2. ContextReduction.test.ts is documented but does not exist

hooks/README.md cites a regression gate:

Regression gate: cd hooks && bun test ContextReduction.test.ts (30 probes — read-path identity + kept-class structure).

That file is not in hooks/, and not in the install payload. bun test reports no matches.

This matters more than a typical missing test, because the invariant it claims to guard is the one in the hook header:

only rewrite when the rtk subcommand is a transparent passthrough to the SAME binary AND parse failure falls back to identical semantics. NEVER rewrite read-path commands whose stdout the model reasons over as evidence — search (rg/grep), file reads (cat/head), listings (ls/tree/find), diffs, HTTP (curl/wget), queries (psql/aws). rtk's parse-fail "runs raw" under a DIFFERENT binary there (rg→BSD grep → silent wrong-empty).

So the gate protecting against silent evidence corruption is documented, referenced by name, and has never run. Either ship the test or drop the claim from the README.

3. Nothing warns users away from rtk init -g

Once rtk is installed, both rtk verify and rtk gain print:

[warn] No hook installed — run `rtk init -g` for automatic token savings

This nag is misleading in a LifeOS install. ContextReduction.hook.sh is the hook; rtk simply doesn't recognize one it didn't write. Following the advice installs rtk's own stock global hook, which carries none of the read-path restraint quoted above, and would reintroduce exactly the rg→BSD-grep silent-corruption class the LifeOS hook header was written to prevent.

A one-line note in Tools.md under the RTK section, and/or in the hook header, would close it.


Reproduction

On a clean machine (macOS, no prior rtk):

command -v rtk                  # => absent
# ...run the LifeOS installer...
command -v rtk                  # => still absent

The hook is registered in settings.json under PreToolUse / matcher Bash, and no-ops on every invocation.

After installing rtk manually (v0.43.0), the hook works exactly as designed:

git status   ->  rtk git status      # status-path: rewritten
rg foo src/  ->  (no rewrite)        # read-path: correctly left alone
rtk verify   ->  154/154 tests passed
rtk gain     ->  93.0% saved

So the hook logic is sound. Only the install path and the docs are wrong.

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