Skip to content

Read the CIT PY notes from the workspace rather than a path that moved - #33

Merged
mspinola merged 1 commit into
mainfrom
claude/local-execution-citpy-data-9f1ed5
Aug 10, 2026
Merged

Read the CIT PY notes from the workspace rather than a path that moved#33
mspinola merged 1 commit into
mainfrom
claude/local-execution-citpy-data-9f1ed5

Conversation

@mspinola

Copy link
Copy Markdown
Owner

What

The /citpy page has been rendering an empty table on local runs. .env pinned
COTMETRICS_CITPY at /Users/matts/code/citpy/data/citrini_outputs; citpy has since moved
under trading_workspace, and nothing said so. CITPY_DIR pointed at a directory that no
longer existed, get_citpy_files_grouped hit its os.path.exists guard and returned {},
and an empty result looks exactly like a generator that has not run yet.

run-local.sh now derives the directory from the sibling layout, the same convention
cotmetrics-config already uses, so it cannot go stale again when a checkout moves. It runs
after .env is sourced, so an explicit COTMETRICS_CITPY still wins.

Why the diff is bigger than that

Resolving the workspace had to be fixed first. _WORKSPACE was $REPO/.., which inside a
worktree is the .claude/worktrees dir, so every sibling lookup missed at once. The notes are
the mild version of that. cotmetrics-config is the serious one: a miss there does not fail,
it falls back to the sample 6-symbol universe and the app comes up looking fine.

git rev-parse --git-common-dir names the main checkout from either place (relative in the
ordinary case, absolute from a worktree), with a fallback for a non-git deploy. .env and
.venv then follow that same checkout, since both describe the machine rather than the branch
and neither follows a worktree. Without those two a worktree run was impossible rather than
merely wrong: it died on the COTDATA_STORE check having never had a chance to read an .env.

Also in here:

  • A COTMETRICS_CITPY that is set but absent now warns. That is the case that was silent.
  • The $COTDATA_STORE/citpy warning became unreachable once the variable is always set, so it
    is now unconditional and reworded as what it actually is: a tripwire against a sync
    recreating a directory nothing reads.
  • Dropped a DEBUG print in citpy.py that dumped the whole grouped-files dict to the log on
    every page load, unterminated, so it ran into the following line.

Verification

Ran the app from a worktree and checked in a browser rather than only in the config:

  • 25 dated rows, newest first, all three links per row (Citrindex / Top Allocations /
    TradingView) resolving under trading_workspace
  • /citpy/view renders the 2026-08-09 Citrindex as a grid, so the path guard in
    citpy_view.py accepts the new location
  • clean startup, no console errors, no tracebacks, HTTP 200

All three resolution branches exercised: relative .git (main checkout), absolute (worktree),
and the no-git fallback.

Scope

run-local.sh only ever runs locally. The deployed unit uses
server-side/launch-cot-analyzer.sh and is untouched. The .env fix is deliberately not in
this PR, since it is gitignored machine-local config; the stale line is commented out on the
one affected machine, and a fresh clone gets the sibling default with no .env entry at all.

No test in this repo references citpy or run-local.sh.

🤖 Generated with Claude Code

The /citpy page has been rendering an empty table locally. .env pinned
COTMETRICS_CITPY at /Users/matts/code/citpy/data/citrini_outputs, citpy has
since moved under trading_workspace, and nothing said so: CITPY_DIR pointed at
a directory that no longer existed, get_citpy_files_grouped hit its
os.path.exists guard, and an empty result looks exactly like a generator that
has not run yet.

Derive the directory from the sibling layout instead, the same convention
cotmetrics-config already uses, so it cannot go stale again when a checkout
moves. It runs after .env is sourced, so an explicit COTMETRICS_CITPY still
wins. A COTMETRICS_CITPY that is set but absent now warns, because that is the
case that was silent. The old $COTDATA_STORE/citpy warning became unreachable
once the variable is always set, so it is now unconditional and reworded as
what it actually is, a tripwire against a sync recreating a directory nothing
reads.

Resolving the workspace needed fixing first. _WORKSPACE was $REPO/.., which
inside a worktree is the .claude/worktrees dir, so every sibling lookup missed
at once. The notes are the mild version of that. cotmetrics-config is the
serious one: a miss there does not fail, it falls back to the sample 6-symbol
universe and the app comes up looking fine. git-common-dir names the main
checkout from either place, with a fallback for a non-git deploy. .env and
.venv follow the same checkout, since both describe the machine rather than
the branch and neither follows a worktree, which is what made a worktree run
impossible rather than merely wrong.

Verified in a browser and not just in the config: 25 dated rows, all three
links per row resolving under trading_workspace, and /citpy/view rendering the
2026-08-09 Citrindex as a grid. run-local.sh only ever runs locally; the
deployed unit uses server-side/launch-cot-analyzer.sh and is untouched.

Also drop a DEBUG print that dumped the whole grouped-files dict to the log on
every page load, unterminated, so it ran into the following line.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@mspinola
mspinola merged commit de5a531 into main Aug 10, 2026
3 checks passed
@mspinola
mspinola deleted the claude/local-execution-citpy-data-9f1ed5 branch August 10, 2026 21:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant