Skill Tracer
Skills › Compound Engineering › ce-ideate › web-research-cache.md

web-research-cache.md

56 lines · skills/ce-ideate/references/web-research-cache.md at 3449230

Open on GitHub

Most marks come from matching words in the file, so treat them as pointers.

1# Web Research Cache
2
3Read this when checking the cache before dispatching `web-researcher`, or when appending fresh research to the cache after dispatch. The behavior here is conditional — most invocations either hit the cache or write to it once and move on.
4

Web Research Cache

Read this when checking the cache before dispatching web-researcher, or when appending fresh research to the cache after dispatch. The behavior here is conditional — most invocations either hit the cache or write to it once and move on.

Raw lines 1 to 4
Starts an agent dispatching :3
Starts an agent dispatch :3
5## Cache file shape
6
7```json
8[
9 {
10 "key": {
11 "mode": "repo|elsewhere-software|elsewhere-non-software",
12 "focus_hint_normalized": "<lowercase, whitespace-collapsed focus hint or empty string>",
13 "topic_surface_hash": "<short hash of the user-supplied topic surface>"
14 },
15 "result": "<web-researcher output as plain text>",
16 "ts": "<iso8601>"
17 }
19```
21Files live under `<scratch-dir>/web-research-cache.json`, where `<scratch-dir>` is `<scratch-root>/ce-ideate/<run-id>`, resolved once in `references/grounding.md` Phase 1.

Cache file shape

[
  {
    "key": {
      "mode": "repo|elsewhere-software|elsewhere-non-software",
      "focus_hint_normalized": "<lowercase, whitespace-collapsed focus hint or empty string>",
      "topic_surface_hash": "<short hash of the user-supplied topic surface>"
    },
    "result": "<web-researcher output as plain text>",
    "ts": "<iso8601>"
  }
]

Files live under <scratch-dir>/web-research-cache.json, where <scratch-dir> is <scratch-root>/ce-ideate/<run-id>, resolved once in references/grounding.md Phase 1.

Raw lines 5 to 22
23## Reuse check
25Before dispatching `web-researcher`, resolve the scratch root (the parent of `<scratch-dir>`) in bash and list sibling run-id directories — refinement loops within a session may legitimately reuse another run's cache by topic, not run-id:
27```bash
28SCRATCH_DIR="<absolute scratch-dir resolved in Phase 1>"
29SCRATCH_ROOT="$(dirname "$SCRATCH_DIR")"
30find "$SCRATCH_ROOT" -maxdepth 2 -name 'web-research-cache.json' -type f 2>/dev/null
31```
33`find` exits 0 with empty output when no cache files exist, so the first-run case does not abort the reuse-check step.
35Read each matching file. If any entry's `key` matches the current dispatch (same full mode variant — `repo`, `elsewhere-software`, or `elsewhere-non-software` — plus same case-insensitive normalized focus hint plus same `topic_surface_hash`), skip the dispatch and pass the cached `result` to the consolidated grounding summary. Mode variants must match exactly: `elsewhere-software` and `elsewhere-non-software` are distinct domains and must not cross-reuse. Note in the summary: "Reusing prior web research from this session — say 're-research' to refresh."
37On `re-research` override, delete the matching entry and dispatch fresh.

Reuse check

Before dispatching web-researcher, resolve the scratch root (the parent of <scratch-dir>) in bash and list sibling run-id directories — refinement loops within a session may legitimately reuse another run's cache by topic, not run-id:

SCRATCH_DIR="<absolute scratch-dir resolved in Phase 1>"
SCRATCH_ROOT="$(dirname "$SCRATCH_DIR")"
find "$SCRATCH_ROOT" -maxdepth 2 -name 'web-research-cache.json' -type f 2>/dev/null

find exits 0 with empty output when no cache files exist, so the first-run case does not abort the reuse-check step.

Read each matching file. If any entry's key matches the current dispatch (same full mode variant — repo, elsewhere-software, or elsewhere-non-software — plus same case-insensitive normalized focus hint plus same topic_surface_hash), skip the dispatch and pass the cached result to the consolidated grounding summary. Mode variants must match exactly: elsewhere-software and elsewhere-non-software are distinct domains and must not cross-reuse. Note in the summary: "Reusing prior web research from this session — say 're-research' to refresh."

On re-research override, delete the matching entry and dispatch fresh.

Raw lines 23 to 38
Starts an agent dispatching :25
Starts an agent dispatch :35
39## Append after fresh dispatch
41After a fresh dispatch, append the new result to the current run's cache file at `<scratch-dir>/web-research-cache.json` using the absolute path from Phase 1 (create directory and file if needed). The next invocation in the session can reuse it via the `find` listing above.

Append after fresh dispatch

After a fresh dispatch, append the new result to the current run's cache file at <scratch-dir>/web-research-cache.json using the absolute path from Phase 1 (create directory and file if needed). The next invocation in the session can reuse it via the find listing above.

Raw lines 39 to 42
Starts an agent dispatch :39
43## Topic surface hash
45`topic_surface_hash` hashes the user-supplied content the web research is grounded on. That content is:
46- **Elsewhere modes (`elsewhere-software`, `elsewhere-non-software`):** the user's topic prompt plus any Phase 0.4 intake answers (the actual subject the agent is researching). The two sub-modes are keyed separately — a reclassification between software and non-software for the same topic hash must force a fresh dispatch, since the research domain differs.
47- **Repo mode:** the focus hint plus a stable repo discriminator. This keeps the cache key meaningful when focus is empty — two bare-prompt invocations in the same repo legitimately share research, but the key still differentiates repos. Since cache files from every repo's runs now live under the shared OS-temp root, a bare basename like `app` or `frontend` would collide across unrelated repos. Resolve the discriminator with this fallback chain and hash the result (first 8 hex chars of sha256 is sufficient):
48 1. `git remote get-url origin` — stable across machines, correct for collaborators on the same remote.
49 2. `git rev-parse --show-toplevel` — absolute repo path; machine-local but always available in a git checkout.
50 3. The current working directory's absolute path — last resort when not in a git repo.
52Normalize before hashing: lowercase, collapse whitespace. (The repo discriminator hash is computed from the raw command output; only the focus hint and topic text are normalized.)

Topic surface hash

topic_surface_hash hashes the user-supplied content the web research is grounded on. That content is:

  • **Elsewhere modes (elsewhere-software, elsewhere-non-software):** the user's topic prompt plus any Phase 0.4 intake answers (the actual subject the agent is researching). The two sub-modes are keyed separately — a reclassification between software and non-software for the same topic hash must force a fresh dispatch, since the research domain differs.
  • Repo mode: the focus hint plus a stable repo discriminator. This keeps the cache key meaningful when focus is empty — two bare-prompt invocations in the same repo legitimately share research, but the key still differentiates repos. Since cache files from every repo's runs now live under the shared OS-temp root, a bare basename like app or frontend would collide across unrelated repos. Resolve the discriminator with this fallback chain and hash the result (first 8 hex chars of sha256 is sufficient):
  • git remote get-url origin — stable across machines, correct for collaborators on the same remote.
  • git rev-parse --show-toplevel — absolute repo path; machine-local but always available in a git checkout.
  • The current working directory's absolute path — last resort when not in a git repo.

Normalize before hashing: lowercase, collapse whitespace. (The repo discriminator hash is computed from the raw command output; only the focus hint and topic text are normalized.)

Raw lines 43 to 53
Starts an agent dispatch :46
54## Degradation
56If the cache file is unreachable across invocations on the current platform (filesystem isolation, sandboxing, ephemeral working directory), degrade to "no reuse, dispatch every time." Note the limitation in the consolidated grounding summary and proceed without reuse rather than inventing a capability the platform may not have.

Degradation

If the cache file is unreachable across invocations on the current platform (filesystem isolation, sandboxing, ephemeral working directory), degrade to "no reuse, dispatch every time." Note the limitation in the consolidated grounding summary and proceed without reuse rather than inventing a capability the platform may not have.

Raw lines 54 to 56
Starts an agent dispatch :56