share push: add --branch to scope the context-DAG push to one branch#171
Merged
Conversation
Context DAGs are stored one ref per branch at refs/h5i/context/<branch>, but share push shipped every branch's DAG via a wildcard refspec. Add --branch [<name>] to narrow the context push to a single branch's ref (or the current git branch when passed bare), so pushing one code branch no longer leaks the reasoning of unrelated branches. Only the context refs are scoped; the SHA-keyed global refs (notes/ast/objects) and shared refs (msg/env) still push in full. Scoped push skips the legacy whole-workspace refs. Pure, unit-tested helpers context_push_refspec + validate_ctx_branch_name in cli_routing.rs (rejects refspec metacharacters). 5 cli_integration tests cover named/bare scoping, unscoped regression, contextless-branch skip, and invalid-name rejection. MANUAL.md + man page updated.
Extend --branch beyond context so a scoped push sends only the h5i
material linked to that branch, like git push:
- notes: only provenance for commits reachable from the branch
- objects: only manifests whose branch field matches
AST/msg/env/memory still push in full (AST is content-addressed and
deduplicated; the rest are genuinely cross-branch).
notes and objects are single aggregate refs shared by every branch, so
a scoped push must not force a filtered subset (that would delete other
branches' data on the remote). Instead it fetches the remote ref and
unions only this branch's entries onto it, then pushes a fast-forward
-- non-destructive to other branches.
New testable lib helpers:
- repository::copy_scoped_notes_onto (overlays reachable-commit notes
onto a remote-seeded dest ref; git2 handles notes fan-out)
- objects::build_branch_scoped_merge (base manifests union local
branch manifests, descends from base)
Tests: 6 lib unit tests (filtering + non-destructive base preservation +
empty cases) and 2 cli_integration tests (leak-prevention on a fresh
remote; non-destructive over a pre-seeded remote). MANUAL.md + man page
updated.
Previously `share push` pushed every branch's material unless --branch was given. Flip it: with no flag the push now scopes to the current git branch (context + notes + objects), matching git-push intuition. Add --all-branches to opt back into the full push (first sync / CI), and make it conflict with --branch. Notes reachability falls back from refs/heads/<branch> to HEAD so a detached checkout (common in CI) still scopes to its history instead of pushing nothing. Tests: replace push_without_branch_pushes_all_context_refs with push_all_branches_pushes_every_context_ref; add push_defaults_to_current_branch and push_branch_conflicts_with_all_branches. The two exact-OID pull roundtrip tests now push --all-branches (the scoped default rebuilds a per-branch union notes commit with a different OID by design).
Extend branch scoping past notes/objects to the two remaining
branch-linked refs:
- msg: only messages tagged with the branch travel (sends auto-tag the
current branch; replies inherit the thread's). The agent roster
always travels in full.
- env: only envs whose parent_branch matches travel — their
manifests/policies/events (env meta) AND their code branches
(refs/h5i/env/code/*). Their evidence captures (objects tagged with
the env's own code branch) are carried too, by env_id, so the
cross-clone review loop keeps its evidence.
memory stays full: it is a cumulative full-state snapshot chain whose
facts are branch-independent (kept-local on pull, no clean union).
A generic scoped_merge_push in the push handler drives the
non-destructive fetch+union+FF for objects/msg/env-meta. New lib
helpers: msg::build_branch_scoped_merge, env::build_branch_scoped_merge,
env::scoped_code_branch_refs, env::local_env_ids_for_branch (pub);
objects::build_branch_scoped_merge gains an also_env_ids param.
Tests: lib unit tests for msg/env scoping (filter + non-destructive base
+ empty) and objects env-evidence-by-env_id; a msg scoped-push
cli_integration test. The two cross-clone msg_integration sync tests now
push --all-branches (a review's branch tag differs from the git branch).
MANUAL.md + man page updated.
Drop the structural dimension: the ast.rs module (SemanticAst/AstDiff/ similarity/hashing), the refs/h5i/ast object store, semantic blame (blame --mode ast), the AST structural diff command (h5i recall diff), the --ast commit flag, and the python parser plugin + its discovery/ subprocess machinery. AST went unused and supporting all languages is impractical. Removed: - src/ast.rs and plugin/h5i-py-parser.py (deleted) - repository.rs: H5I_AST_REF, ast_parser plumbing in commit(), AST harvest, blame_by_ast, make_ast_parser, diff_ast, load_ast_at_commit, save_ast_to_sidecar, load_ast_blob, parser-script discovery + subprocess helpers, and their tests - blame.rs: BlameMode (line-only now), the is_semantic* fields, dead BlameEntry/H5iBlameEntry structs - metadata.rs: H5iCommitRecord.ast_hashes (old notes still deserialize — serde ignores unknown fields, verified by env_integration fixtures) - error.rs: the Ast variant; main.rs: Commands::Diff, blame --mode, --ast, refs/h5i/ast in push/pull/patterns; mcp.rs blame mode; server.rs ast_file_count badge; storage.rs + cli_routing recall-diff - docs: CLAUDE.md, MANUAL.md, man page, skill blame stays (line-based, AI-provenance-annotated). Existing refs/h5i/ast on clones/remotes are simply orphaned (harmless; no longer synced). All suites green (lib 872, cli 79, env 101, msg 37, objects 25, +others); clippy clean with and without --no-default-features.
Follow-up to the AST removal — update all docs/ pages and the MANUAL source they derive from: - MANUAL.md: drop AST from the share-push ref lists, the h5i_blame MCP mode param, and the (now-uncreated) ast/ init-dir note - docs/manual/index.html: regenerated from MANUAL.md via scripts/gen_manual.py - docs/index.html + docs/features/index.html: drop 'structural (AST)' from the dimensions tagline - docs/guides/git-blame-for-ai-code: remove the AST-mode FAQ (incl. JSON-LD), the --mode ast example, the reformat-survival callout, and the stale ✨ semantic column in the sample output - docs/blog/from-git-blame-to-ai-blame: remove the 'AST-mode blame' section No AST/--mode ast/refs/h5i/ast references remain anywhere under docs/.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.