Skip to content

Commit cccf00d

Browse files
authored
Merge pull request #884 from microsasa/fix/881-fs-utils-architecture-docs-8d3a954f2e76e964
docs: add `_fs_utils.py` to architecture Components table (#881)
2 parents 6a4c564 + 7fb9986 commit cccf00d

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

src/copilot_usage/docs/architecture.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ Monorepo containing Python CLI utilities that share tooling, CI, and common depe
3939
| `report.py` | Rich-formatted terminal output — summary tables (with Model Calls and User Msgs columns), live view, premium request breakdown. Shows raw counts and `~`-prefixed premium cost estimates for live/active sessions; historical post-shutdown views display exact API-provided numbers. |
4040
| `render_detail.py` | Session detail rendering — extracted from report.py. Displays event timeline, per-event metadata, and session-level aggregates. |
4141
| `_formatting.py` | Shared formatting utilities — `format_duration()` and `format_tokens()` with doctest-verified examples. Used by report.py and render_detail.py. |
42+
| `_fs_utils.py` | Shared filesystem/caching utilities — `lru_insert` (LRU eviction for module-level `OrderedDict` caches) and `safe_file_identity` (returns `(mtime_ns, size)` for robust cache-invalidation; returns `None` on any `OSError`). Used by `parser.py` and `vscode_parser.py`. |
4243
| `pricing.py` | Model pricing registry — multiplier lookup, tier categorization. Multipliers are used for `~`-prefixed cost estimates in live/active views (`render_live_sessions`, `render_cost_view`); historical post-shutdown views use exact API-provided numbers exclusively. |
4344
| `logging_config.py` | Loguru setup — stderr warnings only, no file output. Uses a `_PatcherRecord` TypedDict to type-check the emoji-injection patcher without importing the unresolvable `loguru.Record` type at runtime. Called once from CLI entry point. |
4445
| `vscode_parser.py` | VS Code Copilot Chat log parser — discovers log files per platform (macOS/Windows/Linux), parses `ccreq:` lines with regex, aggregates into `VSCodeLogSummary`. |

tests/test_docs.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,32 @@ def test_since_last_shutdown_documents_premium_cost_estimate() -> None:
145145
)
146146

147147

148+
def test_components_table_lists_all_modules() -> None:
149+
"""Every .py module in src/copilot_usage/ (excluding __init__.py and the
150+
docs/ subdirectory) must appear in the ### Components table in
151+
architecture.md."""
152+
pkg_dir = Path(__file__).parents[1] / "src" / "copilot_usage"
153+
on_disk = {p.name for p in pkg_dir.glob("*.py") if p.name != "__init__.py"}
154+
components_section_match = re.search(
155+
r"^###\s+Components\b.*?(?=^#{1,6}\s+|\Z)",
156+
_ARCH_MD,
157+
re.MULTILINE | re.DOTALL,
158+
)
159+
assert components_section_match, (
160+
"Could not find the '### Components' section in architecture.md"
161+
)
162+
components_section = components_section_match.group(0)
163+
# Extract backtick-quoted module names from rows in the Components table only.
164+
in_table = set(
165+
re.findall(r"^\|\s*`([^`]+\.py)`\s*\|", components_section, re.MULTILINE)
166+
)
167+
missing = on_disk - in_table
168+
assert not missing, (
169+
f"Modules missing from the ### Components table in "
170+
f"architecture.md: {sorted(missing)}"
171+
)
172+
173+
148174
def test_architecture_detect_resume_lists_all_indicators() -> None:
149175
"""The _detect_resume() description in architecture.md must mention the
150176
three true resume indicators and the separately-tracked turn_start event."""

0 commit comments

Comments
 (0)