chore: architecture docs, tests consolidated under Tests/, coverage floor 54.7% → 68% - #116
Merged
Merged
Conversation
Owner
Author
|
Architecture review follow-up implemented in commit 90d19c0. Changes made:
Verification:
These are documentation/docstring corrections only; no strategy, market-data, risk, or execution behavior changed. PR #117 has also been rebased onto this new #116 head. |
Two structural changes, no runtime behaviour touched. docs/ — the folder held only Superpowers session artefacts. Those are now gitignored and untracked (kept on disk), matching the existing .superpowers/ rule, and docs/ carries a committed architecture set instead: docs/README.md index and reading order docs/hld/ one high-level design for the whole repository docs/lld/ 12 low-level designs, one per component docs/adr/ 11 decision records for choices already in force The ADRs are retrospective: they record why the safety model looks the way it does (typed order outcomes, the two-flag live gate, the per-strategy size multiplier, host-owned gates around the LLM agents), which is the part that is expensive to reconstruct later. Tests/ — every test file and test conftest moved into a top-level Tests/ tree mirroring the source layout, so runtime folders hold only runtime code. Each mirrored folder for a spaced-name source folder carries a conftest.py that puts the SOURCE folder on sys.path, never the test folder, preserving the narrow import scope the co-located conftests had. Path anchors now resolve from the repository root. Updated for the new paths: the CI workflow (both jobs), pyproject (Ruff per-file-ignores and coverage omit), README.md, CLAUDE.md, AGENTS.md and the per-folder Readmes. CLAUDE.md and AGENTS.md remain byte-identical after the "What this project is" marker, as test_repository_policy requires. Verified by exact count rather than by a green run: 487 master + 26 market-data-health + 1089 pytest = 1602, before and after. Also green: ruff, mypy (53 files), compileall, bandit, pre-commit config validation, the branch-enabled coverage run (71.4%, floor 54.7%) with zero Tests/ files leaking into the report, and the per-module coverage policy gate. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The 54.7% floor was the branch-enabled baseline MAT-110 measured before the gate was installed. Coverage has grown to 71.4% since, so a floor 17 points below actual was no longer stopping erosion -- roughly 3,100 statements could have lost their tests without the build noticing. Raised to 70.0, which leaves ~1.4 points of real headroom against the measured 71.4%. The per-module budgets are unchanged: 90% for the safety/data-safety tier, 80% per broker adapter. On the local-vs-CI question: neo_api_client and pyotp are installed locally but are NOT in CI's verify job. That does not move the number -- CI already enforces and passes the 80% budget on kotak_execution.py without the Kotak SDK, because the adapters are tested through injected doubles rather than the real client. Updated everywhere the floor is stated so they cannot drift: pyproject, test_repository_policy's assertion, check_coverage_thresholds' docstring, README.md, CLAUDE.md, AGENTS.md and docs/lld/testing-and-ci.md. The two agent guides remain byte-identical after the shared marker. Documented the one-way rule next to the setting: this floor only ever moves UP, and only after a run shows headroom. Lowering it to make a red build pass defeats the gate. Verified locally: coverage report exits 0 at the new floor (71.4%), the per-module policy gate passes, ruff clean, and the policy suite passes with the updated assertion. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…ocal run The previous commit set the floor to 70.0 on a locally measured 71.4%. CI reports 69.1%, so the build failed by 0.9 points. The floor is now 68.0, which leaves ~1.1 points of headroom against the number that actually gates the build. My reasoning in the previous commit was wrong and is worth recording. I argued the missing broker SDKs could not move the total, because CI already enforces and passes the 80% budget on kotak_execution.py without neo_api_client. That holds for the ADAPTER, but not for everything the SDK gates: CI's verify job runs "1082 passed, 7 skipped" where a local run with neo_api_client and pyotp installed runs 1089 passed, 0 skipped. Those 7 tests are worth ~2.3 points of overall coverage. Enforcing a per-module budget says nothing about the modules outside that dict. So the rule is now written next to the setting and in both agent guides: judge this floor from CI, never from a local run, because a developer machine with the optional broker SDKs installed reads about 2 points high. CI deliberately installs core + dev + ai + codex-ai only -- Kotak's official tag pins older pandas/requests and cannot share the audited core environment -- so the hosted number is the honest one. Still a +13.3 point improvement on the 54.7% baseline, and the one-way rule stands: only move it UP, and only after a CI run shows headroom. Note the restructure itself was never in question in that failed run: CI collected 487 master + 26 market-data-health + 1089 (1082 passed, 7 skipped) across both Python 3.12 and 3.13, matching the pre-move counts exactly, and both broker-dependency jobs passed. Only fail_under was wrong. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Clarify restart limits, startup versus shutdown exposure scope, shared synchronization boundaries, and CPR code-owned invariants. Co-authored-by: Codex <codex@openai.com>
Co-authored-by: Codex <codex@openai.com>
DoRmAmMu1997
force-pushed
the
chore/docs-and-tests-restructure
branch
from
August 10, 2026 15:43
3ad55b1 to
68ac534
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two structural changes plus a gate tightening. No runtime behaviour is touched ? no strategy, execution, market-data or risk code changed.
1.
docs/is now a real architecture setThe folder held only Superpowers session artefacts (a plan and a spec from one July session, already stale). Those are now gitignored and untracked ? kept on disk, matching the existing
.superpowers/rule that had simply missed this subtree.In their place:
docs/README.mddocs/hld/system-overview.mddocs/lld/docs/adr/The ADRs are retrospective and carry the part that is expensive to reconstruct later ? why an acknowledgement is never treated as a fill, why live trading needs two flags, why the size multiplier is deliberately not global, why the LLM agents own judgement but never sizing or stops. Each one states the options actually considered and what was given up.
The division of labour against existing docs:
README.mdstays operator setup,CLAUDE.md/AGENTS.mdstay agent rules, per-folder Readmes stay folder-local.docs/answers "how does this fit together, and why".2. Every test now lives under
Tests/, mirroring the source tree36 test files and 4 conftests moved. Runtime folders now contain only runtime code ?
Dependencies/previously showed 13 test files against 15 runtime modules.Every
__file__anchor was rewritten to resolve from the repository root. Each mirrored folder for a spaced-name source folder carries aconftest.pythat puts the source folder onsys.path? never the test folder ? so tests exercise the same import resolution the runner uses.That narrow scoping is deliberate and is why a flat
Tests/was rejected:Signal Generators/CPR AI Agent/conftest.pyinserts only that agent's directory precisely so a test cannot resolve an import production would fail on. One flat conftest would have erased that property for every strategy at once.Two rules for new tests, documented in the README and
CLAUDE.md/AGENTS.md: mirror the source path, and keep the filename unique repository-wide (pytest keys modules by basename ? there are no__init__.pyfiles).3. Coverage floor raised 54.7% ? 68%
54.7% was the baseline measured before the gate was installed. Hosted CI now measures 69.1%, so the final floor is 68%: a 13.3-point improvement with about 1.1 points of headroom against the environment that actually enforces the gate.
A local machine with
neo_api_clientandpyotpinstalled runs seven optional tests that CI's core environment skips and reads about 71.4%. Those tests affect modules outside the broker-adapter threshold table, so passing the adapter's separate 80% budget does not make the repository-wide totals equivalent. The floor must therefore be judged from hosted CI, not from a developer machine with extra optional SDKs.The floor is documented as one-way: it only ever moves up, and only after a hosted CI run shows headroom.
Verification
Counts were compared exactly, not just checked for green ? a silently uncollected test still looks like a passing build.
unittestmasterunittestmarket-data-healthpytestAlso green locally: ruff, mypy (53 files), compileall, bandit, pre-commit config validation, the branch-enabled coverage run at the new 68% floor, and the per-module policy gate. Verified separately that zero
Tests/files leak into the coverage report ? theomitpatterns needed bothTests/*andTests/**/*because Coverage.py's*does not cross a path separator.CLAUDE.mdandAGENTS.mdremain byte-identical after the## What this project ismarker, astest_repository_policyrequires.Note before merging
Tests/test_sl_hunting_schema.pydiffers betweenmainand the unmergedfeat/sl-hunting-knowledge-v4dbranch. That PR will hit a rename-vs-edit conflict on the file's new path ? straightforward to resolve, but worth sequencing deliberately.Follow-up (not in this PR, to keep it surgical)
test_repository_policy.pyalready fails the build on stale worker-roster claims inREADME.md,CLAUDE.md,AGENTS.mdand the master file. Extending that staleness gate to coverdocs/hld/is recorded as an open item in ADR-0011.?? Generated with Claude Code