Skip to content

chore(python): import refract-py into clients/python and check it against this tree's CLI - #42

Merged
zz-plant merged 32 commits into
mainfrom
chore/import-refract-py
Oct 13, 2026
Merged

zz-plant merged 32 commits into
mainfrom
chore/import-refract-py

Conversation

@zz-plant

Copy link
Copy Markdown
Collaborator

This is step 3 of docs/repositories.md. It's stacked on #41, which is stacked on #40.

Import

git subtree add brings refract-org/refract-py's main into clients/python with all 29 of its commits, the same way #37 imported the apps. git blame on the imported files leads back to their original commits. The package keeps its name (refract-py), its refract import, Hatch, its AGPL-3.0 licence and its subprocess behaviour.

Checks

  • python.yml:

    • builds the CLI from the same commit
    • builds and installs the adapter's wheel on Python 3.10 (the floor pyproject.toml declares) and 3.12 (what the old CI ran)
    • imports all three modules from that install
    • runs pytest against the CLI it built

    It runs on changes to the adapter, the CLI, the schema and docs/examples. The imported workflow installed the CLI from npm, so a flag change here was never tested against it.

  • tests/test_engine_contract.py:

    • parses every captured engine event in docs/examples/ and checks that event and analyzer identity survive: IDs, revision IDs, text, fact provenance
    • checks every flag that analyze() and export() pass against the built CLI's --help

    A fake CLI whose help lacks --flatten fails it with AssertionError: --flatten.

A packaging bug the move exposed

The wheel contained only src/refract. refract_eval.py and refract_langchain.py, which the docs import (from refract_langchain import RefractLoader, from refract_eval import …), were missing for anyone who pip installed it; they only worked from a checkout. only-include now ships both. In a fresh environment the wheel imports all three.

Install target

pip install "git+https://github.com/refract-org/refract.git#subdirectory=clients/python"

I tested this against this branch (@chore/import-refract-py) in a fresh Python 3.12 environment, and it installs refract and refract_eval. The command is now in the README, the docs site, the Colab notebook and the adapter's README. The old refract-py.git URL still installs its last version.

The docs' notebook page used RefractClient, RefractDocumentLoader, three exception classes and model_dump(), none of which the adapter has. It now uses Refract, RefractLoader, RefractError and as_frame=True.

Verification

  • Root gate: build, biome ci packages/, typecheck, check:boundaries, test (409 passed, including a layout test for clients/python), check:examples and check:release --pack all pass.
  • apps/docs: lint, tests (103) and build pass.
  • clients/python: 32 passed. One existing test was skipped because it needs networkx, which isn't installed here.

🤖 Generated with Claude Code

zz-plant and others added 30 commits May 15, 2026 22:30
- feat: create AGENTS.md with build/test commands and conventions
- ci: add GitHub Actions workflow (pytest on push)
- test: expand from 3 to 21 tests (dataclasses, edge cases, _find_binary)
- fix: _find_binary checks for npx/node before fallback
- fix: _run catches FileNotFoundError with helpful install message
- docs: add Integrations section to README (pandas, Jupyter, LangChain)
- fix: event_type → eventType in README code example
- chore: update opencode.json with skills and permissions
- feat: src/refract_eval.py — map events to eval records
  (build_leakage_benchmark, check_provenance, score_retrieval_quality,
   build_recency_benchmark)
…PyPI

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…nd demo animation

- docs/assets/refract-py-pkg.png, captioned "refract-py package listing
  on PyPI", is a made-up PyPI page: `pip install refract-py`, v0.2.0,
  Python 3.11+, MIT and Apache-2.0 licences, "2.3k weekly downloads" and
  42 stars. refract-py has never been on PyPI, and pyproject.toml says
  0.1.0, Python >=3.10, AGPL-3.0. It contradicted the install line
  directly below it, which says the package is not on PyPI.
- docs/assets/refract-py-cli.png showed an IPython session whose DataFrame
  had "event" values of edit/revert and an "editor" column of decimals;
  analyze() returns neither.
- docs/assets/refract-py-demo.gif was a generated animation of a code
  snippet beside four boxes with row counts (13, 21, 29, 37) that no
  call produces.

The image files are left in docs/assets; only the README embeds go.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EpGaiBuSk5nCSV2hKyD6PN
…-g3mj8p

docs: remove the README's fabricated PyPI card, notebook screenshot and demo animation
to_networkx's docstring promised citation edges. It adds a "cites" edge
for any fact detail containing "url=". No analyzer emits a citation URL
as a fact (citation facts carry "type=added" and the like), so at brief
and detailed depth the graph holds revision transitions only; at
forensic depth the full_wikitext_before/after facts match, and each
becomes a node holding a revision's whole wikitext. The docstring says
so. compute_survival_records handles sentence events, not claim events;
its docstring now says how spans are matched and censored.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EpGaiBuSk5nCSV2hKyD6PN
…-g3mj8p

docs: say what to_networkx and compute_survival_records build
pyproject.toml declares AGPL-3.0, but without a LICENSE file GitHub lists
the repo as unlicensed, which reads as all rights reserved.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
chore: add the AGPL-3.0 license file pyproject already declares
git-subtree-dir: clients/python
git-subtree-mainline: d5fc1f3
git-subtree-split: 2de93c6
… CLI, and ship its two modules

The previous commit imports refract-org/refract-py into clients/python with
its history. This one makes it part of the repository.

python.yml builds the CLI from the same commit, builds and installs the
adapter's wheel on Python 3.10 (the floor pyproject declares) and 3.12, and
runs pytest against that CLI; the imported workflow installed the CLI from
npm. It runs on changes to the adapter, the CLI, the schema and
docs/examples. tests/test_engine_contract.py parses the engine output in
docs/examples keeping event and analyzer identity, and checks every flag
analyze() and export() pass against the built CLI's help: a fake CLI
without --flatten fails it.

Building the wheel showed it held only src/refract: refract_eval and
refract_langchain, which the docs import, were missing for anyone who
installed it. The wheel now includes both, and imports from a fresh
environment.

The install target is
pip install "git+https://github.com/refract-org/refract.git#subdirectory=clients/python",
in the README, the docs site and the Colab notebook. The notebook page used
RefractClient, RefractDocumentLoader, model_dump() and three exception
classes the adapter does not have; it uses what the adapter exports.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Base automatically changed from chore/docs-deploy-from-monorepo to main October 13, 2026 02:00
@zz-plant
zz-plant merged commit 08bb7b7 into main Oct 13, 2026
6 checks passed
@zz-plant
zz-plant deleted the chore/import-refract-py branch October 13, 2026 02:04
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