Skip to content

fix(generate-data): make compute_vitals snapshot enrichment reachable#119

Merged
4444J99 merged 1 commit into
mainfrom
fix/generate-data-snapshot-enrichment
May 24, 2026
Merged

fix(generate-data): make compute_vitals snapshot enrichment reachable#119
4444J99 merged 1 commit into
mainfrom
fix/generate-data-snapshot-enrichment

Conversation

@4444J99
Copy link
Copy Markdown
Owner

@4444J99 4444J99 commented May 24, 2026

Fixes the dead-code bug in the local generate-system-data.py (the data-pipeline "extend" item).

compute_vitals returned its base dict via return { ... }, so the snapshot-enrichment block after it (organism / omega / promotion_pipeline) was unreachable dead code that also referenced an undefined vitals. Changed the early return { to vitals = { so the enrichment runs and the existing trailing return vitals returns the enriched object.

Test plan

  • python3 -m py_compile — syntax OK
  • functional test: with a snapshot, compute_vitals now includes organism/omega/promotion_pipeline; without one, the base dict is returned unchanged

Scope note: the dashboard's empty Sprint / Flagship / Praxis sections are produced by the external sibling generator (praxis-portfolio-generate.py), not this script — populating those remains gated on that out-of-repo pipeline. Likewise essays.json adding the-organ-chain-reset is gated: its entries mirror the external public-process blog (the URL probe was inconclusive/403), so hand-adding risks a broken link; it should be regenerated by the sibling generator.

https://claude.ai/code/session_01PW9DnyVijUNmUJ4qMfgpHn


Generated by Claude Code

Summary by Sourcery

Bug Fixes:

  • Ensure compute_vitals no longer returns early so snapshot enrichment data is included when available.

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
@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented May 24, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Adjusts 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

Change Details Files
Ensure compute_vitals builds a vitals dict that can be enriched before returning, instead of returning early.
  • Replace the early literal dict return with an assignment to a vitals variable
  • Rely on the existing trailing return vitals to return the (potentially) enriched snapshot-aware vitals data
  • Eliminate the previous unreachable enrichment block that referenced an undefined vitals variable by making it executable
scripts/generate-system-data.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

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

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@4444J99 4444J99 merged commit b3e1880 into main May 24, 2026
3 checks passed
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

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 = {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

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:

  1. Incorrect Data Lookups: The variables code_files and test_files (lines 103-104) are fetched from the top-level canonical object instead of the computed section (c). This causes them to always fall back to estimated values even when data is present in the source JSON.
  2. Missing Keys: automated_tests and documentation_words (lines 98-99) appear to be missing from the system-metrics.json schema, also leading to constant fallback values.
  3. Logic Nesting: The enrichment for omega and promotion_pipeline (lines 136-139) is nested inside the if "system" in snapshot block. If a snapshot contains these keys but lacks a system key, they will be incorrectly skipped.
  4. Falsy Fallback: The use of the or operator in "words": c.get("total_words_numeric") or doc_words (line 121) will cause the script to use the default doc_words value if the actual word count is explicitly 0.
  5. Variable Shadowing: The variable sys (line 129) shadows the imported sys module, which is a maintainability risk.

Consider refactoring these lookups to ensure the generated vitals.json accurately reflects the system state.

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.

2 participants