fix(generate-data): make compute_vitals snapshot enrichment reachable#119
Conversation
compute_vitals returned the base dict via `return { ... }`, leaving the
snapshot-enrichment block (organism/omega/promotion_pipeline) after it as
dead code — it never ran, and it referenced an undefined `vitals`.
Assign the dict to `vitals` instead so the enrichment runs and the
existing trailing `return vitals` returns it.
Verified: py_compile + a functional test (with a snapshot, vitals now
includes organism/omega/promotion_pipeline; without one, the base dict
is returned unchanged).
Note: the dashboard's Sprint/Flagship/Praxis sections are populated by
the external sibling generator (praxis-portfolio-generate.py), not this
script, so they remain gated on that pipeline.
https://claude.ai/code/session_01PW9DnyVijUNmUJ4qMfgpHn
Reviewer's guide (collapsed on small PRs)Reviewer's GuideAdjusts compute_vitals in generate-system-data.py so that the vitals dict is assigned and later enriched instead of being returned early, making the snapshot-based enrichment code reachable and fixing an undefined variable reference. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Code Review
This pull request modifies the compute_vitals function in scripts/generate-system-data.py to correctly initialize the vitals dictionary. The reviewer noted that while this change resolves a NameError, there are several underlying data integrity and logic issues in the function, including incorrect data lookups, missing schema keys, improper logic nesting, falsy fallback handling, and variable shadowing. These issues should be addressed to ensure the accuracy of the generated system data.
| test_files = canonical.get("test_files", auto_tests // 5) | ||
|
|
||
| return { | ||
| vitals = { |
There was a problem hiding this comment.
While this change correctly fixes the unreachable code and the NameError, there are several data integrity and logic issues in the compute_vitals function that are now exposed and should be addressed:
- Incorrect Data Lookups: The variables
code_filesandtest_files(lines 103-104) are fetched from the top-levelcanonicalobject instead of thecomputedsection (c). This causes them to always fall back to estimated values even when data is present in the source JSON. - Missing Keys:
automated_testsanddocumentation_words(lines 98-99) appear to be missing from thesystem-metrics.jsonschema, also leading to constant fallback values. - Logic Nesting: The enrichment for
omegaandpromotion_pipeline(lines 136-139) is nested inside theif "system" in snapshotblock. If a snapshot contains these keys but lacks asystemkey, they will be incorrectly skipped. - Falsy Fallback: The use of the
oroperator in"words": c.get("total_words_numeric") or doc_words(line 121) will cause the script to use the defaultdoc_wordsvalue if the actual word count is explicitly0. - Variable Shadowing: The variable
sys(line 129) shadows the importedsysmodule, which is a maintainability risk.
Consider refactoring these lookups to ensure the generated vitals.json accurately reflects the system state.
Fixes the dead-code bug in the local
generate-system-data.py(the data-pipeline "extend" item).compute_vitalsreturned its base dict viareturn { ... }, so the snapshot-enrichment block after it (organism / omega / promotion_pipeline) was unreachable dead code that also referenced an undefinedvitals. Changed the earlyreturn {tovitals = {so the enrichment runs and the existing trailingreturn vitalsreturns the enriched object.Test plan
python3 -m py_compile— syntax OKcompute_vitalsnow includesorganism/omega/promotion_pipeline; without one, the base dict is returned unchangedhttps://claude.ai/code/session_01PW9DnyVijUNmUJ4qMfgpHn
Generated by Claude Code
Summary by Sourcery
Bug Fixes: