Skip to content

Record the installed positronic revision in an episode, not the working tree's - #740

Open
v-positronic wants to merge 1 commit into
mainfrom
writer-sha-from-installed-distribution
Open

Record the installed positronic revision in an episode, not the working tree's#740
v-positronic wants to merge 1 commit into
mainfrom
writer-sha-from-installed-distribution

Conversation

@v-positronic

Copy link
Copy Markdown
Collaborator

Fixes Positronic-Robotics/internal#1295.

The defect

An episode's writer.git reads the git state of the working directory. A run's git.positronic reads the git repository that contains site-packages. On a rig that runs an installed wheel from a venv inside a checkout, both name that checkout. Every episode then carries the same stale sha (e1455be2, dirty), and a recording cannot say which code wrote it.

The change

positronic.utils.git.get_package_git_state reads the installed distribution's direct_url.json (PEP 610):

  • A wheel built from a VCS URL records the commit it was built from, dirty: False, the URL, and the requested revision. This is what the rig runs.
  • An editable install records the git state of the checkout it imports from. This is what a developer runs.
  • Any other install records no revision.

DiskEpisodeWriter writes this as writer.git. run_metadata writes it as git.positronic, and writes git.positronic.diff only for an editable checkout. git.current still records the working directory.

writer.git on a wheel carries no branch key. The one reader in the tree (test_episode.py) required commit and dirty; it now requires only those.

Tests

  • test_episode_written_by_an_installed_wheel_records_that_wheel_revision fails on main and passes here.
  • positronic/utils/tests/test_git.py covers the wheel, the editable install, an install with no origin, and run_metadata on a wheel.

Left out

  • The console's own version is not recorded in the episode. That is a platform change.
  • The rules check did not run on this first pass. It is due before merge.

…ng tree's

An episode's `writer.git` and a run's `git.positronic` read the git state
around the process: the working directory, and the repository that contains
`site-packages`. On a rig that runs an installed wheel from a venv inside a
checkout, both name that checkout. Every episode then carries the same stale
sha, and a recording cannot say which code wrote it.

`get_package_git_state` reads the installed distribution's `direct_url.json`
(PEP 610). A wheel built from a VCS URL names the commit it was built from.
An editable install names the checkout it imports from. Any other install
records no revision. `git.current` still records the working directory.

Ticket: Positronic-Robotics/internal#1295 #refs

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c82efaf1a9

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

def git_repo(path: Path) -> str:
path.mkdir(parents=True, exist_ok=True)
env = {'GIT_AUTHOR_NAME': 't', 'GIT_AUTHOR_EMAIL': 't@t', 'GIT_COMMITTER_NAME': 't', 'GIT_COMMITTER_EMAIL': 't@t'}
run = lambda *args: subprocess.run(['git', '-C', str(path), *args], check=True, capture_output=True, env=env) # noqa: E731

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Replace the new lint suppression

Rule grandfathered-violation violated:
The newly added git_repo helper silences E731 with # noqa even though new files must land without suppressions; replace the assigned lambda with a small local def run(...) so Ruff can check the code normally.

AGENTS.md reference: AGENTS.md:L7-L8

Useful? React with 👍 / 👎.

Comment thread positronic/utils/git.py
return get_git_state(workdir=checkout) if checkout is not None else None


def _direct_url(distribution: str) -> dict | None:

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Move _direct_url above its first caller

Rule stranded-definition violated:
_direct_url is defined after both functions that use it, forcing readers to search forward to understand get_package_checkout; place this private helper directly above its first caller.

AGENTS.md reference: AGENTS.md:L7-L8

Useful? React with 👍 / 👎.

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