|
| 1 | +# 20-ai-context-side-load |
| 2 | + |
| 3 | +## Purpose |
| 4 | + |
| 5 | +This note defines the concrete v1 side-load layer for Codex Workspace. |
| 6 | + |
| 7 | +The goal is to make the existing layered context model operational by generating small, disposable `L0` and `L1` summaries under `cache/context/` without changing the canonical source-of-truth rule. |
| 8 | + |
| 9 | +This note is implementation-specific. It does not replace [07-context-cache-and-retrieval.md](07-context-cache-and-retrieval.md). |
| 10 | + |
| 11 | +## Scope |
| 12 | + |
| 13 | +V1 covers: |
| 14 | + |
| 15 | +- workspace-level summaries |
| 16 | +- one repo-level summary target: `workspace-hub` |
| 17 | +- provenance metadata in `sources.json` |
| 18 | +- a dry-run-first generator script |
| 19 | +- one Workspace Hub read path for repo-detail side-load freshness and file-open actions |
| 20 | + |
| 21 | +V1 does not cover: |
| 22 | + |
| 23 | +- tracked side-load files |
| 24 | +- automatic regeneration during bootstrap or release checks |
| 25 | +- task-bundle generation |
| 26 | +- summary writes from Workspace Hub |
| 27 | +- broad per-repo rollout across every repo in `repos/` |
| 28 | + |
| 29 | +## Canonical versus generated context |
| 30 | + |
| 31 | +The split stays explicit: |
| 32 | + |
| 33 | +- tracked docs, manifests, and repo files remain canonical |
| 34 | +- generated side-load files under `cache/context/` are disposable working summaries |
| 35 | + |
| 36 | +If generated summaries disagree with tracked repo truth, regenerate or ignore the cache. |
| 37 | + |
| 38 | +## Generated layout |
| 39 | + |
| 40 | +V1 generates only these paths: |
| 41 | + |
| 42 | +```text |
| 43 | +cache/context/ |
| 44 | +├── workspace/ |
| 45 | +│ ├── abstract.md |
| 46 | +│ ├── overview.md |
| 47 | +│ └── sources.json |
| 48 | +└── repos/ |
| 49 | + └── workspace-hub/ |
| 50 | + ├── abstract.md |
| 51 | + ├── overview.md |
| 52 | + └── sources.json |
| 53 | +``` |
| 54 | + |
| 55 | +Agent-job bundles under `cache/context/agents/jobs/` remain a separate local artifact path created by `tools/scripts/init-agent-job-bundle.sh`. |
| 56 | + |
| 57 | +## Generator |
| 58 | + |
| 59 | +Use: |
| 60 | + |
| 61 | +```bash |
| 62 | +tools/scripts/generate-context-cache.sh --workspace |
| 63 | +tools/scripts/generate-context-cache.sh --workspace --print |
| 64 | +tools/scripts/generate-context-cache.sh --workspace --run |
| 65 | +tools/scripts/generate-context-cache.sh --repo workspace-hub --run |
| 66 | +``` |
| 67 | + |
| 68 | +Behavior: |
| 69 | + |
| 70 | +- dry-run by default |
| 71 | +- `--print` shows the generated content on stdout |
| 72 | +- `--run` writes files into `cache/context/` |
| 73 | +- `--repo <name>` resolves a repo name under `repos/` and rejects unsafe path input |
| 74 | + |
| 75 | +## Chat handover protocol |
| 76 | + |
| 77 | +Use this when starting a fresh chat that needs repo-aware handover context. |
| 78 | + |
| 79 | +Recommended sequence: |
| 80 | + |
| 81 | +1. treat tracked docs as canonical and start with the relevant handover or README surface |
| 82 | +2. refresh the side-load cache if the session is broad, new, or likely to re-read workspace context repeatedly |
| 83 | +3. let the chat use generated `abstract.md` and `overview.md` as the fast entry layer |
| 84 | +4. fall back to tracked docs, manifests, and repo files for any real decision or ambiguity |
| 85 | +5. regenerate or ignore the cache if Workspace Hub reports the side-load state as `stale` or `missing` |
| 86 | + |
| 87 | +Practical operator flow: |
| 88 | + |
| 89 | +```bash |
| 90 | +tools/scripts/generate-context-cache.sh --workspace --run |
| 91 | +tools/scripts/generate-context-cache.sh --repo workspace-hub --run |
| 92 | +``` |
| 93 | + |
| 94 | +Then start the chat with a handover instruction such as: |
| 95 | + |
| 96 | +> Read `docs/HANDOVER.md` first for the current workspace state. Use generated side-load files under `cache/context/` only as a compact entry layer, and treat tracked docs and repo files as canonical. |
| 97 | +
|
| 98 | +For repo-specific work, point the chat at the relevant repo README or handover note as well as the repo side-load cache when it exists. |
| 99 | + |
| 100 | +## Source set |
| 101 | + |
| 102 | +### Workspace |
| 103 | + |
| 104 | +- `README.md` |
| 105 | +- `AGENTS.md` |
| 106 | +- `docs/07-context-cache-and-retrieval.md` |
| 107 | +- `docs/08-first-run-and-updates.md` |
| 108 | +- `docs/09-new-repo-baseline.md` |
| 109 | +- `repos/workspace-hub/README.md` |
| 110 | + |
| 111 | +### Repo: `workspace-hub` |
| 112 | + |
| 113 | +- `repos/workspace-hub/README.md` |
| 114 | +- optional `repos/workspace-hub/AGENTS.md` |
| 115 | +- optional `repos/workspace-hub/.workspace/project.json` |
| 116 | + |
| 117 | +## Summary contracts |
| 118 | + |
| 119 | +### `abstract.md` |
| 120 | + |
| 121 | +Use this as the `L0` entry check. |
| 122 | + |
| 123 | +It should stay small enough for quick relevance decisions and answer: |
| 124 | + |
| 125 | +- what this workspace or repo is |
| 126 | +- what kind of surface it is |
| 127 | +- the main runtime or entrypoint |
| 128 | +- the main constraint or warning |
| 129 | + |
| 130 | +### `overview.md` |
| 131 | + |
| 132 | +Use this as the `L1` planning summary. |
| 133 | + |
| 134 | +It should stay compact enough for planning and answer: |
| 135 | + |
| 136 | +- major directories or surfaces |
| 137 | +- main commands |
| 138 | +- runtime assumptions |
| 139 | +- main rules |
| 140 | +- next canonical docs to open when more detail is needed |
| 141 | + |
| 142 | +## Provenance contract |
| 143 | + |
| 144 | +Each `sources.json` file uses this structure: |
| 145 | + |
| 146 | +```json |
| 147 | +{ |
| 148 | + "version": 1, |
| 149 | + "scope": "workspace", |
| 150 | + "target": "workspace", |
| 151 | + "generatedAt": "2026-04-10T12:00:00Z", |
| 152 | + "generator": { |
| 153 | + "path": "tools/scripts/generate-context-cache.sh" |
| 154 | + }, |
| 155 | + "inputs": [ |
| 156 | + { |
| 157 | + "path": "README.md", |
| 158 | + "role": "workspace-readme", |
| 159 | + "bytes": 14786, |
| 160 | + "mtimeMs": 1775858522000.0, |
| 161 | + "sha256": "..." |
| 162 | + } |
| 163 | + ], |
| 164 | + "outputs": [ |
| 165 | + { |
| 166 | + "path": "cache/context/workspace/abstract.md", |
| 167 | + "role": "abstract" |
| 168 | + } |
| 169 | + ] |
| 170 | +} |
| 171 | +``` |
| 172 | + |
| 173 | +Rules: |
| 174 | + |
| 175 | +- `sha256` is stored for provenance and debugging |
| 176 | +- freshness checks compare current file existence and recorded `mtimeMs` |
| 177 | +- output freshness depends on `abstract.md`, `overview.md`, and `sources.json` all existing |
| 178 | + |
| 179 | +## Workspace Hub behavior |
| 180 | + |
| 181 | +Workspace Hub consumes repo side-load data only during repo-detail hydration. |
| 182 | + |
| 183 | +It does not load side-load metadata during the base-summary discovery path. |
| 184 | + |
| 185 | +The details panel should show: |
| 186 | + |
| 187 | +- `missing` when no valid repo side-load cache exists |
| 188 | +- `fresh` when all declared inputs still exist, `mtimeMs` values still match, and required outputs exist |
| 189 | +- `stale` when an input changed or disappeared, or a required output file is missing |
| 190 | + |
| 191 | +The Hub can open the generated `abstract.md`, `overview.md`, and `sources.json` files directly through the existing generic open-path route. |
| 192 | + |
| 193 | +## Practical rule |
| 194 | + |
| 195 | +Use the side-load layer to reduce repeated high-signal doc loading, not to replace tracked workspace guidance. |
0 commit comments