Repository navigation
Conversation
…haracters (Graphify-Labs#2821) Review follow-ups on the rebased Graphify-Labs#2830: - indent continuation lines in explain/get_node so a rationale cannot pose as a sibling field - strip bidi/zero-width characters; treat U+2028, U+2029 and NEL as line breaks - keep the shared control-char regex unchanged; the C1 range applies to rationale only - ignore non-string rationale values; clamp a negative max_chars - list --rationale in the main help text Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
|
Thanks for the pull request, @yotamleo. A maintainer will review it soon. Want to talk it through while it is in review? Come join us on our Discord server. For longer-form discussion there is also GitHub Discussions. A couple of things that speed up review: make sure the test suite passes on Python 3.10 and 3.13, and that the change keeps extraction deterministic. |
There was a problem hiding this comment.
Graphify reviewed this change.
No issues found by static checks — no coupling regressions or blocking issues in the code graph. That is not the same as safe to merge: see what was not checked.
Not checked: tests were not run; formal verification proved 0 of 6 changed function(s) (3 sampled, not proven, 3 not verified).
Formal verification. PR-changed functions: 3/6 verified (0 proven, 3 may-equivalent, 0 distinguished) · 3 not verified (3 vacuous).
Not verified on this run: dispatch\_command (vacuous: never exercised), \_build\_server (vacuous: never exercised), \_render\_query (vacuous: never exercised).
Graphify review — findings
Adds an opt-in --rationale flag to graphify query and graphify explain that shows a node's stored rationale. Query appends it as a single-line WHY suffix capped at 512 chars, and explain prints an indented Rationale: block that keeps paragraphs up to 2048 chars; without the flag, output is unchanged. Introduces sanitize_rationale and indent_continuation, which strip control, bidi and zero-width characters, mark truncation with ..., and indent continuation lines so multi-line text can't pose as a sibling field, while sanitize_label keeps its existing behaviour. Threads include_rationale through _subgraph_to_text and _query_graph_text into the rendered output and documents the flag in the help text.
Review partial — this diff was larger than one review pass covers, so later files were not reviewed; some findings may be missing.
Analysis details — impact, health, verification
Impact & health
Graphify review
Impact — 2377 functions depend on the 689 functions this change touches.
Health — this change adds coupling hotspots:
- worse:
to_json()— 87 callers, 11 callees - worse:
dispatch_command()— 5 callers, 136 callees - worse:
main()— 111 callers, 3 callees - worse:
_query_graph_text()— 49 callers, 5 callees - worse:
_subgraph_to_text()— 31 callers, 4 callees - worse:
_build_server()— 6 callers, 19 callees
Verification — 2377 functions in the blast radius were not formally verified this run (proofs are advisory here).
Gate & verification
graphify gate
PASS — objectively clean (no health regressions, tests not run — proofs not run this pass (advisory)). Grounded, not self-assessed.
Advisory (not blocking):
- verification_scope: 1719 function(s) in the blast radius were not formally verified this run
Test selection
Test selection
96 of 432 test file(s) selected (22%) via static blast radius.
tests/test_affected_cli.py— impacttests/test_agents_platform.py— impacttests/test_atomic_writes.py— impacttests/test_benchmark.py— impacttests/test_benchmark_raw_graph.py— impacttests/test_benchmark_real_query.py— impacttests/test_build.py— impacttests/test_build_located_semantic_identity.py— impacttests/test_build_merge_dedup_scope.py— impacttests/test_build_merge_hyperedges_and_prune.py— impacttests/test_build_merge_shrink_guard.py— impacttests/test_callflow_html.py— impacttests/test_carried_hyperedge_remap.py— impacttests/test_chunking.py— impacttests/test_cli_export.py— impacttests/test_cloud_cta.py— impacttests/test_codebuddy.py— impacttests/test_community_labels_skill.py— impacttests/test_compact_graph_json.py— impacttests/test_confidence.py— impacttests/test_corrupt_graph_json.py— impacttests/test_cross_extension_reexport_self_cycle.py— impacttests/test_dedup.py— impacttests/test_dedup_shrink_refuses_force_write.py— impacttests/test_devin.py— impacttests/test_dotnet.py— impacttests/test_explain_cli.py— impact, changed-testtests/test_explain_same_file_tie.py— impacttests/test_export.py— impacttests/test_export_control_characters.py— impacttests/test_export_direction.py— impacttests/test_extract.py— impacttests/test_extract_cli.py— impacttests/test_file_label_disambiguation.py— impacttests/test_global_add_tag_inference.py— impacttests/test_global_graph.py— impacttests/test_go_qualified_resolution.py— impacttests/test_god_nodes_cli.py— impacttests/test_god_nodes_exclude_hubs.py— impacttests/test_hollow_chunks_arm_shrink_guard.py— impacttests/test_hook_guard_token_match.py— impacttests/test_hook_out_of_project_paths.py— impacttests/test_hook_strict.py— impacttests/test_html_script_breakout.py— impacttests/test_html_theme.py— impacttests/test_hyperedge_roundtrip.py— impacttests/test_hypergraph.py— impacttests/test_incomplete_build_guard.py— impacttests/test_ingest.py— impacttests/test_ingest_url_type.py— impact- … and 46 more
Selection is safe under the controlled-regression assumption; always-run tests + a periodic full run are the backstops. Advisory — it never changes the check verdict.
Docs that may be stale (advisory)
docs/superpowers/plans/2026-05-04-incremental-updates-dedup.md§ Task 4: Incremental updates — semantic cache + manifest in __main__.py (lines 603-911): references changed symbols_run
Formal verification
No difference found (not proven): No behavior difference found in \_run\_cli (not a proof).
The verifier ran both versions of \_run\_cli on many inputs and saw identical behavior every time. Strong evidence the change is safe, but evidence, not a proof.
Guarantee: Empirical: differential testing (both versions run on many generated inputs). A divergence on an untested input remains possible, so this is 'no counterexample found', not 'proven equivalent'.
Note: An input the sampler did not try could still differ.
Could not verify: Could not verify dispatch\_command.
The verifier did not have enough to check dispatch\_command, so it is saying so rather than guessing. No false assurance is the whole point.
Guarantee: No guarantee either way, this is an honest abstention, not a pass.
Note: Reason: no capturable inputs from the test suite; property tier: not verifiable: all 40 sampled inputs raised on both versions — the function never executed, so 'no divergence' would be vacuous (mostly SystemExit — names the real obstacle, not a sampling gap)
Could not verify: Could not verify \_build\_server.
The verifier did not have enough to check \_build\_server, so it is saying so rather than guessing. No false assurance is the whole point.
Guarantee: No guarantee either way, this is an honest abstention, not a pass.
Note: Reason: no capturable inputs from the test suite; property tier: not verifiable: all 40 sampled inputs raised on both versions — the function never executed, so 'no divergence' would be vacuous (mostly ValueError — names the real obstacle, not a sampling gap)
No difference found (not proven): No behavior difference found in \_query\_graph\_text (not a proof).
The verifier ran both versions of \_query\_graph\_text on many inputs and saw identical behavior every time. Strong evidence the change is safe, but evidence, not a proof.
Guarantee: Empirical: differential testing (both versions run on many generated inputs). A divergence on an untested input remains possible, so this is 'no counterexample found', not 'proven equivalent'.
Note: An input the sampler did not try could still differ.
Could not verify: Could not verify \_render\_query.
The verifier did not have enough to check \_render\_query, so it is saying so rather than guessing. No false assurance is the whole point.
Guarantee: No guarantee either way, this is an honest abstention, not a pass.
Note: Reason: no capturable inputs from the test suite; property tier: not verifiable: all 223 sampled inputs raised on both versions — the function never executed, so 'no divergence' would be vacuous (mostly TypeError — names the real obstacle, not a sampling gap)
No difference found (not proven): No behavior difference found in \_subgraph\_to\_text (not a proof).
The verifier ran both versions of \_subgraph\_to\_text on many inputs and saw identical behavior every time. Strong evidence the change is safe, but evidence, not a proof.
Guarantee: Empirical: differential testing (both versions run on many generated inputs). A divergence on an untested input remains possible, so this is 'no counterexample found', not 'proven equivalent'.
Note: An input the sampler did not try could still differ.
· 1 grounded finding(s) anchored inline below; 5 more finding(s) on lines outside this diff (see the check run).
|
Replying to the review's findings that sit outside the diff (the coupling list in the check run):
No signature changes for existing callers, so no change pushed. The "docs that may be stale" entry points at an older plan file that does not mention these flags. |
Resolves the serve.py and test_security.py conflicts: keeps v8's _query_name_refusal block and redact_secrets tests alongside the include_rationale kwarg and sanitize_rationale tests. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…and drop append-rationale.py (#3323) ## Summary `graphify query` and `graphify explain` now print a node's rationale natively with `--rationale` (upstream Graphify-Labs/graphify#4576, merged-clean). Until a release ships it, himmel carries it on the `yotamleo-org/graphify` fork, installed by commit sha the way qmd is. - Fork `himmel-main` is `02e7e4a9b2eeb4570fa2e926a5f44bdebde4690d`: fork PR 14 lands the #4576 change, fork PR 15 stamps the build `0.9.93+himmel.1`. Both were judged and merged through the fork-adapter flow. - `scripts/lib/graphify-bin.sh`: `_graphify_fork_ref` (sha pin, `GRAPHIFY_FORK_REF` overrides), `_graphify_version` returns the stamp, `_graphify_spec` builds `graphifyy[extras] @ git+https://github.com/yotamleo-org/graphify@<sha>`. `GRAPHIFY_VERSION` set still selects the PyPI `==` form. `_graphify_version_lt` sorts `+himmel.N` newer than the same base, and the installed-version regexes keep the `+himmel.N` part. - `scripts/upstreams.json`: graphify row gains a `fork` block and drops `version_pin` (qmd precedent), so the drift bumper reports it SKIP (manual). - `scripts/graphify/leg-graph.sh` passes `--rationale` right after the question for `query` and `explain`; `rank-why-how.py` reads the ` WHY ` suffix on the NODE line. `append-rationale.py` and its rows are removed. - Pin readers follow the stamp: `scripts/cloud/setup-env.sh` (installs the fork ref), `scripts/cloud/parity-probe.sh`, `scripts/vm/upgrade-path-guest.sh`. ## Proof - RED first: `test-leg-graph-rationale.sh` showed 9 failures before the wrapper change; the new `test-graphify-bin.sh` rows failed 7 against the old resolver. - Real install from the git ref: `_graphify_stage_install` on the real network installed `graphify` and `graphify-mcp`; `graphify --version` reads `0.9.93+himmel.1`, and the mcp and openai imports work. The fork's own `ci.yml` never runs on PRs into `himmel-main`, so this and the resolver tests are the proof the fork build installs. - On `scripts/graphify/fixtures/rationale-graph.json` with the real fork build: `test-leg-graph-rationale.sh` ALL PASS (T5: 2 of 5 answers carry the reason text) and `test-anchor-seeds.sh` ALL PASS. - Impacted suites run green: `test-graphify-bin.sh`, `test-leg-graph.sh`, `test-leg-graph-rationale.sh`, `test-anchor-seeds.sh`, `test-semantic-seeds.sh`, `test-retrieval-eval.sh`, `cloud/test-setup-env.sh`, `cloud/test-parity-probe.sh`, `test-check-plugin-drift.sh`, `upstreams/test-apply-drift-bump.sh`, `upstreams/test-resync-fork.sh`, `upstreams/test-drift-fix-cadence.sh`, `upstreams/test-upstream-watch-cadence.sh`, `upstreams/test-apply-tool-upgrade.sh`, `ci/test-fork-drift-issue.sh`, `vm/test-upgrade-path-stage.sh`, `test-himmel-update.sh`, `-versions`, `-drift`, `-tools`. ## Residual risk A graphify older than the pin (the station has 0.9.92) does not know `--rationale`. `leg-graph.sh` probes `graphify --help` and omits the flag then, so answers lose the rationale text (the old behaviour) instead of failing, until the station updates to the fork build (`himmel-update --only graphify`, per the station-follows-main rule). `test-leg-graph.sh` T1b covers the degrade. Touches `scripts/lib/` (a `ci-trust-paths.txt` pattern): trust-reviewed GO. ## Ticket coverage - Comment on upstream issue Graphify-Labs/graphify#2821: done - Sync the yotamleo-org/graphify fork with upstream and land #4576 on `himmel-main` through the fork-adapter flow: done - Bump himmel's graphify pin to the fork commit: done - Make the wrapper pass `--rationale` and remove `append-rationale.py` with its test rows: done - Prove it on `scripts/graphify/fixtures/rationale-graph.json`: done 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Sonnet 5.5 <[email protected]>
Merge upstream v8 26818d0 into fix/2821-render-rationale without rebasing or rewriting the PR branch. Preserve exact-case node lookup, parallel-edge evidence, standalone CLI help and both sides' regression tests while retaining opt-in rationale. Adapt the rationale tests to call real registered MCP 1.x and 2.x handlers and inspect the tools' wire-schema aliases. Production MCP registration remains unchanged. New standalone-help assertions failed before restoring --rationale in the shared usage strings. Verification: full pytest 9173 passed, 18 skipped, 1 xfailed; MCP 1.30 protocol checks 3 passed; ruff check . and git diff --check passed. Pyright was not re-run: classifier-denied under pytest-only operator authorization. Its earlier direct run reported 417 errors across 96 files, not proven against a baseline. Verification scope was explicitly narrowed to pytest plus ruff; no clean type-check claim is made. Platforms tested: linux Security reviewed: manual — bounded rationale output, terminal controls, strict MCP booleans, continuation indentation and unchanged default output Co-Authored-By: Claude Code <[email protected]>
|
Note 🤖 gpt-6.1-sol responding on behalf of yotamleo Merged current Local verification: 9,173 passed, 18 skipped, 1 xfailed; MCP 1.30 protocol checks: 3 passed; Ruff clean. Rationale tests now support the MCP 1.x and 2.x handler/schema APIs. Pyright reports 417 errors across 96 files, unchanged between runs but not compared against an upstream baseline. Bandit findings remain tolerated by upstream CI; pip-audit reports no known vulnerabilities in CI's installed default environment. |
|
Agent work: stage finished Client: Mode: Stage: Recovery: Claim projection returned HTTP404; no dependent writes or background requests started. Stop and release own reservation. Scope in this repository: |
Fixes #2821. Supersedes #2830, which has been conflicting with
v8since 2026-08-20; this is that change rebased onto currentv8, with the original commit and author kept.What
graph.jsonstores arationaleon semantic nodes, butquery,get_nodeandexplainnever printed it. This adds it, opt-in:graphify query ... --rationaleandgraphify explain ... --rationaleinclude_rationaleonquery_graphandget_node(strict boolean)queryappendsWHY <text>after the NODE line;explainandget_nodeprintRationale: <text>The text is untrusted corpus/LLM output, so it goes through
sanitize_rationale()ingraphify/security.py:\x80-\x9f), bidi overrides and zero-width characters strippedquery(cap 512), multi-line forexplain/get_node(cap 2048), explicit...marker when cappedDegree:,Node:)Changes on top of #2830
The first commit is #2830 rebased onto
v8(conflicts incli.py,serve.py,tests/test_explain_cli.py,tests/test_serve.py; the new--seed,_resolve_single_nodeandattrssuffix are preserved). The second commit is review hardening:_CONTROL_CHAR_REis left as onv8; the C1 range applies to rationale only, sosanitize_labelbehaviour does not change--rationalelisted in the main help textBefore / after
Fixture: a small graph with rationale on two semantic nodes.
Before (
v8),graphify query "halt narrowing token" --graph g.json:graphify explain "completes-ticket line and Ticket coverage" --graph g.json --rationaleprints no Rationale line (the flag is ignored).After, with
--rationale:Without the flag the output is identical to
v8. A node whose rationale contains ESC, BEL and\x9bbytes, a newline and a ~1200-char tail prints with the control bytes stripped; thequeryWHY is collapsed to one line.Tests
tests/test_security.py,tests/test_query_cli.py,tests/test_explain_cli.py,tests/test_serve.py; the flag/kwarg does not exist onv8, so they fail there.pytest tests/: 8418 passed, 14 skipped, 1 deselected.tests/test_extract.py::test_collect_files_from_dir, is an environment artifact, not related to this diff: it fails only when the checkout sits under a hidden directory (here.worktrees/), becausecollect_filesskips hidden path components. It passes on a cleanv8copy outside a hidden path, and this PR does not touchextract.py.ruff check .clean.pyright graphifyreports 498 errors on bothv8and this branch (no new ones).