Skip to content

feat: add schematic map reference inventory#257

Merged
duncanleo merged 2 commits into
mainfrom
codex/schematic-system-map-data
May 26, 2026
Merged

feat: add schematic map reference inventory#257
duncanleo merged 2 commits into
mainfrom
codex/schematic-system-map-data

Conversation

@duncanleo

@duncanleo duncanleo commented May 24, 2026

Copy link
Copy Markdown
Member

Summary

  • add a deterministic mrtdown-site Map*.tsx inventory extractor for schematic map Phase 1 planning
  • commit the initial reference inventory for the nine known hard-coded system map snapshots, including viewBox, layer order, interaction ids, station ids, and raw path geometry ids
  • add an operational topology derivation helper that computes active lines, service revisions, stations, and adjacent station segments from canonical data at a timestamp
  • document the 2025-04 baseline comparison and the distinction between operational graph coverage and displayed future or under-construction schematic coverage

Validation

  • npm run check

Summary by CodeRabbit

Release Notes

  • Documentation

    • Added comprehensive documentation for Phase 1 schematic map reference inventory, including snapshot summaries with map dimensions and element counts, and operational topology checks.
  • Chores

    • Added automated tooling for generating schematic map inventory and deriving operational topology from service revisions at specified timestamps.

Review Change Stack

@coderabbitai

coderabbitai Bot commented May 24, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@duncanleo, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 33 minutes and 49 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: b056984a-1376-4f5d-a4a7-f8ac851f2ebc

📥 Commits

Reviewing files that changed from the base of the PR and between 45d4e36 and a717c38.

📒 Files selected for processing (2)
  • docs/schematic-map-reference-inventory.md
  • scripts/schematic-map-topology.mjs
📝 Walkthrough

Walkthrough

This pull request adds Phase 1 schematic map reference infrastructure: a documentation page, an inventory generation CLI script that scans and analyzes map components to produce structured snapshots with element counts and layer ordering, and a topology derivation CLI script that computes service coverage at a specific timestamp and optionally validates against the inventory.

Changes

Schematic Map Reference Inventory and Topology Tools

Layer / File(s) Summary
Phase 1 Reference Inventory Documentation
docs/schematic-map-reference-inventory.md
Explains how the inventory JSON is generated and how topology is derived, includes a snapshot summary table across multiple effective dates with counts of map elements (line groups, labels, nodes, station IDs), records initial findings on target dates and map-frame dimensions, and documents an operational topology check with coverage review notes.
Inventory Script: CLI Setup and Utilities
scripts/schematic-map-inventory.mjs
Argument parser supporting --site-dir, --write, and --help flags; helper functions to derive effective date from Map<Mon><YYYY> component filenames; and utilities to parse SVG attributes and deduplicate arrays.
Inventory Script: SVG Parsing and Summarization
scripts/schematic-map-inventory.mjs
Core SVG tag regex scanner that maintains a tag stack to identify the root group depth, extracts and categorizes ids into line groups/segments, labels, nodes, station codes, and geometry, computes per-tag element counts, and produces an ordered layer array.
Inventory Script: Orchestration and Output
scripts/schematic-map-inventory.mjs
Directory scan and parallel parsing of Map*.tsx files sorted by effective date; inventory metadata generation with first-target date detection; and CLI main flow that outputs the structured JSON to stdout or a specified file.
Topology Script: CLI Setup and Helpers
scripts/schematic-map-topology.mjs
Argument parsing with required --at timestamp validation; helper functions to extract and normalize timestamps (supports YYYY-MM and YYYY-MM-DD); usage rendering; and activity-duration checks for lines, stations, and service revisions.
Topology Script: Data Loading and Comparison
scripts/schematic-map-topology.mjs
Filesystem-backed JSON loading filtered to .json files for line, station, and service data; stable segment key/ID generation between station pairs; and inventory comparison logic that detects missing derived segments and station IDs not covered by a map snapshot.
Topology Script: Topology Building and Main Flow
scripts/schematic-map-topology.mjs
Core topology derivation that computes active stations from code date ranges, selects service revisions active at the target instant, aggregates active station IDs and derives segment adjacency across consecutive stations in revisions, producing sorted coverage arrays; CLI main orchestration; and runtime guard with error handling.

Sequence Diagram(s)

sequenceDiagram
  participant Inventory as Inventory<br/>Generator
  participant MapDir as Map Component<br/>Directory
  participant Topology as Topology<br/>Derivation
  participant DataDir as Service Data<br/>Directory
  participant Comparison as Inventory<br/>Comparison
  
  rect rgba(100, 150, 200, 0.5)
    note over Inventory,MapDir: Snapshot Generation
    Inventory->>MapDir: scan Map*.tsx files
    MapDir-->>Inventory: filenames + content
    Inventory->>Inventory: extract date, parse SVG
    Inventory->>Inventory: count elements, categorize ids
    Inventory-->>Inventory: produce inventory JSON
  end
  
  rect rgba(150, 200, 100, 0.5)
    note over Topology,DataDir: Topology Derivation
    Topology->>DataDir: load line, station, service
    DataDir-->>Topology: JSON entities
    Topology->>Topology: compute active at --at time
    Topology->>Topology: aggregate stations & segments
    Topology-->>Topology: produce topology JSON
  end
  
  rect rgba(200, 150, 100, 0.5)
    note over Comparison: Optional Validation
    Comparison->>Comparison: compare derived vs inventory
    Comparison-->>Comparison: report mismatches
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 New tools to map the transit maze,
Snapshots freeze the service days,
Topology flows through revisions past,
Inventory and coverage at last! 🗺️

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title clearly and concisely summarizes the main change: adding schematic map reference inventory documentation and tooling as described in the PR objectives.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/schematic-system-map-data

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@duncanleo
duncanleo force-pushed the codex/schematic-system-map-data branch 2 times, most recently from 3383693 to 0dd85bf Compare May 24, 2026 16:59
@duncanleo
duncanleo force-pushed the codex/schematic-system-map-data branch from 0dd85bf to 45d4e36 Compare May 25, 2026 16:54
@duncanleo duncanleo changed the title feat: add canonical schematic system maps feat: add schematic map reference inventory May 25, 2026
@duncanleo
duncanleo marked this pull request as ready for review May 25, 2026 16:57

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Nitpick comments (1)
scripts/schematic-map-inventory.mjs (1)

259-259: 💤 Low value

Consider clarifying the deterministic timestamp.

Using new Date(0) produces a 1970 epoch date, which is intentional for deterministic output. However, generatedAt suggests the actual generation time. Consider adding a brief comment or renaming to baselineTimestamp to clarify the intent.

-    generatedAt: new Date(0).toISOString(),
+    generatedAt: new Date(0).toISOString(), // fixed for deterministic output
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@scripts/schematic-map-inventory.mjs` at line 259, The property generatedAt
currently set to new Date(0).toISOString() is misleading because it uses the
epoch as a deterministic baseline; update the code to either rename the property
(e.g., baselineTimestamp or deterministicTimestamp) or add an inline comment
next to generatedAt explaining that new Date(0) is intentional to produce a
deterministic epoch timestamp for reproducible output (reference the generatedAt
property and the new Date(0).toISOString() call so you change the correct spot).
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/schematic-map-reference-inventory.md`:
- Around line 64-65: The doc has a mismatch for the 2025-04 map: Line 31 states
214 line segments but the section text states 213 station-to-station ids; update
the 2025-04 segment-count so both places match or add a clear sentence
explaining why one segment is excluded from the station-to-station id count
(e.g., a non-station connector, loop, or metadata-only segment). Locate
occurrences of "2025-04", the "214" count on line 31, and the phrase "213
station-to-station ids" and either change the numeric value to be consistent or
append the explanatory note referencing "station-to-station ids" so the
discrepancy is documented.

In `@scripts/schematic-map-topology.mjs`:
- Around line 60-64: Add a fail-fast validation that enforces --inventory and
--effective-date are provided together: if one of options.inventory or
options.effectiveDate is set but the other is missing, throw a descriptive Error
(e.g. "'--inventory' and '--effective-date' must be provided together") so
comparison cannot be silently disabled; apply the same check in both places
referenced around the current options.at validation and the duplicate block at
the later location (lines ~293-300).
- Around line 83-89: The timestamp() function currently normalizes some date
forms and then calls Date.parse(normalized), which will treat ISO-like strings
without a timezone (e.g. "2025-04-01T00:00:00") as local time and produce
non-deterministic results; update timestamp() to detect ISO datetime strings
that include time but lack a timezone designator (match patterns like
/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+\-]\d{2}:\d{2})?$/ and
reject when the timezone part is missing) and throw/return an error indicating a
missing timezone instead of calling Date.parse, then only call
Date.parse(normalized) for inputs that either were normalized with an explicit
timezone or already include a timezone designator; ensure the check is applied
inside the timestamp function before parsing.

---

Nitpick comments:
In `@scripts/schematic-map-inventory.mjs`:
- Line 259: The property generatedAt currently set to new Date(0).toISOString()
is misleading because it uses the epoch as a deterministic baseline; update the
code to either rename the property (e.g., baselineTimestamp or
deterministicTimestamp) or add an inline comment next to generatedAt explaining
that new Date(0) is intentional to produce a deterministic epoch timestamp for
reproducible output (reference the generatedAt property and the new
Date(0).toISOString() call so you change the correct spot).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: db59d076-dc00-43cc-818b-20b293e9edd5

📥 Commits

Reviewing files that changed from the base of the PR and between 8cd4772 and 45d4e36.

📒 Files selected for processing (4)
  • docs/schematic-map-reference-inventory.json
  • docs/schematic-map-reference-inventory.md
  • scripts/schematic-map-inventory.mjs
  • scripts/schematic-map-topology.mjs

Comment thread docs/schematic-map-reference-inventory.md Outdated
Comment thread scripts/schematic-map-topology.mjs
Comment thread scripts/schematic-map-topology.mjs
@duncanleo
duncanleo merged commit 96c66bb into main May 26, 2026
2 checks passed
@duncanleo
duncanleo deleted the codex/schematic-system-map-data branch May 26, 2026 15:40
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