Repository navigation
[workspace-migration] refactor: rename REPO/REPO_DIR/_REPO → WORKSPACE in 7 files (name-lies cleanup, no behavior change) - #1333
liususan091219 wants to merge 1 commit into
Conversation
…PACE where the value is workspace, not repo [workspace-migration] Pure variable rename — 60 insertions, 60 deletions, no behavior change. 7 sites where a variable was named REPO (or REPO_DIR / _REPO / repo_resolved) but its value came from resolve_workspace() / resolveWorkspace() / WORKSPACE_DIR.resolve(). Misleading names made it hard to reason about path safety during the v3 workspace-contract audit — readers thought "REPO" meant repo root and missed that workspace-anchored state was actually being constructed. Renames: - src/agent-api.py:496-498 repo_resolved → workspace_resolved (3 uses) - src/send_allowlist.py:51+ _REPO → _WORKSPACE (5 uses) - src/slack-bridge.py:59+ REPO → WORKSPACE (12 uses) - src/dm-result.py:38,187 REPO → WORKSPACE (2 uses) - src/discord-bridge.py:59+ REPO → WORKSPACE (16 uses) - src/telegram-bridge.py:37+ REPO → WORKSPACE (15 uses) - src/task-bridge.ts:18+ REPO_DIR → WORKSPACE_DIR (7 uses) src/discord-bridge.py L3685-3687 also has a comment referencing "REPO" by name explaining why dm-result.py is resolved via __file__ — comment updated to "WORKSPACE" to stay accurate; the historical reference to PR #762 is preserved. Not touched: - src/agent-api.py:93 REPO_DIR = Path(__file__).parent.parent — actual repo path, kept - scripts/{presenter-mode,query-conversation,results-health}.sh — audit-tagged as cosmetic but they're part of PR #1276 (5-scripts workspace-anchor fix), where the rename happens alongside the path fix. - 81 other "cosmetic" audit findings — different bug classes (LLM prose, test fixtures writing to real workspace, dual-read patterns) not addressable by simple rename. Verification: - `git diff --stat`: 60 +, 60 - (pure substitution). - `grep -wE '\b(REPO|REPO_DIR|_REPO|repo_resolved)\b'` on the 7 files: 0 stray refs. - `npx tsc --noEmit`: clean. - Word-boundary substitution via `re.sub(r'\bREPO\b', ...)` so docstring "the repo" / "repo_root" / "REPO_DIR-elsewhere" wouldn't be touched. Refs v3 workspace-contract audit, P3 cosmetic batch (88 sites flagged, 7 renamable).
chetanunadkat
left a comment
There was a problem hiding this comment.
Reviewed the rename. The 4 files agent-api.py, send_allowlist.py, slack-bridge.py, task-bridge.ts are clean — every renamed REPO/_REPO is resolve_workspace()-derived and all paths (tasks/, results/, state/, etc.) are genuine workspace state. Faithful rename, no behavior change. ✅
REPO → WORKSPACE at the same three .env-read sites that #1274 ("read .env from source tree, not workspace") is fixing as a bug:
discord-bridge.py—env_file = REPO / ".env"→ here becomesWORKSPACE / ".env"dm-result.py—REPO / ".env"telegram-bridge.py—load_dotenv(REPO / ".env")
.env lives in the source-tree root, not the workspace, so WORKSPACE / ".env" is the wrong target (#1274's point: these silently fail to load DISCORD_BOT_TOKEN / TEAM_TIER_OWNER / the Telegram token). The two PRs touch these exact lines with opposite intent:
- #1274 fixes the path (workspace → source tree), which makes the
REPOname honest. - #1333 renames the variable (
REPO → WORKSPACE), cementing the workspace path.
They can't both land cleanly:
- #1274 first → this PR then renames a now-source-tree
REPOtoWORKSPACE(reverse name-lie + re-breaks.envloading). - #1333 first → #1274 must rebase onto the new
WORKSPACEname.
Suggest: drop the 3 .env sites from this rename (leave them to #1274, which makes REPO honest by pointing it at the source tree), or land #1274 first and rebase. The other 4 files are unaffected either way.
(Cold review from the Sutando proactive loop — context: verified against current main + #1274's diff.)
|
LGTM — pure rename, +60/-60, zero behavior change. The name-truth audit is exactly the kind of cleanup that's easy to put off until a future debugger spends an hour tracing Strong points:
One thing to verify post-merge (non-blocking): Excellent maintenance PR — costs nothing to land, makes every future audit cheaper. 👍 |
|
LGTM — verified the "no behavior change" claim holds across all 7 files. Since this renames the variable at its definition (
Per-file convention is preserved (module-private |
|
Closing per Susan 2026-05-29 — Qingyun is redesigning the workspace migration approach. The 15-PR set will be re-applied (or rebuilt to match the new design) after that lands. Branch is preserved; can be reopened or cherry-picked when ready. |
Summary
Pure variable rename. 60 insertions, 60 deletions. No behavior change, no logic touched — every line is just
s/\bREPO\b/WORKSPACE/.7 sites where a variable was named
REPO/REPO_DIR/_REPO/repo_resolvedbut its value came fromresolve_workspace()/resolveWorkspace()/WORKSPACE_DIR.resolve(). The misleading names made the v3 workspace-contract audit harder than it should have been — readers (humans and LLMs running cwd-resolution audits) had to trace eachREPOback to its assignment site to discover it actually held workspace state. After this PRWORKSPACEmeans workspace,REPO_DIRmeans repo, and you can tell which from the name alone.Renames
src/agent-api.py:496-498repo_resolvedworkspace_resolvedsrc/send_allowlist.py:51+_REPO_WORKSPACEsrc/slack-bridge.py:59+REPOWORKSPACEsrc/dm-result.py:38, 187REPOWORKSPACEsrc/discord-bridge.py:59+REPOWORKSPACEsrc/telegram-bridge.py:37+REPOWORKSPACEsrc/task-bridge.ts:18+REPO_DIRWORKSPACE_DIRsrc/discord-bridge.py:L3685-3687also has a comment referring to "REPO" by name when explaining whydm-result.pyis resolved via__file__— comment updated to read "WORKSPACE" so it stays in sync with the variable; the historical reference to PR #762 is preserved verbatim.What is NOT renamed
src/agent-api.py:93REPO_DIR = Path(__file__).parent.parent— the name is accurate (it actually holds the repo path). Kept as-is.scripts/{presenter-mode,query-conversation,results-health}.sh— audit-flagged as cosmetic but these are part of PR [workspace-migration] fix(scripts): 5 sh scripts read/write workspace state, not repo (P1 batch) #1276 (5-scripts workspace-anchor fix), where the rename happens alongside the actual path fix. Bundling there keeps the test+script change together.workspace/notes/cwd-audit-v3-2026-05-27.md.Verification
npx tsc --noEmitclean.Method
Word-boundary regex substitution:
re.sub(r'\b{OLD}\b', '{NEW}', src). This ensures docstring/comment text like "the repo" / "repo_root" / "REPO_DIR-elsewhere" (legitimate) wasn't touched. Each file was eyeballed before substitution to confirm no other identifier collides with the rename token.Refs v3 workspace-contract audit, P3 cosmetic batch (88 sites flagged in audit; 7 are simple variable-name-lies addressable by rename — this PR. The rest fall under PR #1276 or remain in the audit backlog as their own bug classes).
🤖 Generated with Claude Code