Skip to content

governance/datasheet: _PROJECT_ROOT path index is off-by-one (parents[4] → parents[3]) #54

@Goldokpa

Description

@Goldokpa

Follow-up from review of #52.

In src/climatevision/governance/datasheet.py:

_PROJECT_ROOT = Path(__file__).resolve().parents[4]
_DEFAULT_OUTPUT_DIR = _PROJECT_ROOT / "outputs" / "datasheets"

The file lives at src/climatevision/governance/datasheet.py. Walking parents:

  • [0] = governance
  • [1] = climatevision
  • [2] = src
  • [3] = repo root
  • [4] = parent of repo root

So _DEFAULT_OUTPUT_DIR lands outside the repo. Should be parents[3].

The existing tests don't catch this because every test passes an explicit tmp_path for output_dir, so the default path is never exercised.

Acceptance criteria:

  • Fix the index in datasheet.py.
  • Add a unit test that calls write_datasheet(sheet) with no output_dir and asserts the resulting path is inside the repo (e.g. under <repo>/outputs/datasheets/). Use monkeypatch on _DEFAULT_OUTPUT_DIR or assert relative-to-repo-root rather than touching the real outputs/ dir.
  • Audit scripts/generate_datasheet.py for the same pattern just in case.

Nice-to-haves (optional, can be split out):

  • scripts/generate_datasheet.py defines logger but only uses print — wire one or the other.
  • _coerce_config could give a friendlier error if the manifest path doesn't exist.
  • Confirm the rendered-markdown output for nested dicts (currently embedded as a JSON code fence) is the intended format.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions