Skip to content

Commit 0335414

Browse files
committed
update specify
1 parent 96442b0 commit 0335414

File tree

6 files changed

+174
-85
lines changed

6 files changed

+174
-85
lines changed

.specify/memory/constitution.md

Lines changed: 116 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,87 +1,141 @@
1-
<!--
2-
Sync Impact Report
3-
Version change: 0.0.0 → 1.0.0
4-
Modified Principles: Principle I – Upstream-First Patching; Principle II – Worktree Hygiene; Principle III – Portable Bash Discipline; Principle IV – Transparent Automation; Principle V – Verification & Release Confidence
5-
Added sections: Operational Constraints; Workflow & Quality Gates
6-
Removed sections: None
7-
Templates requiring updates: .specify/templates/plan-template.md ✅ updated, .specify/templates/spec-template.md ✅ updated, .specify/templates/tasks-template.md ✅ updated
8-
Follow-up TODOs: None
9-
-->
10-
111
# git-cross Constitution
122

3+
**Version**: 1.0
4+
**Last Updated**: 2025-12-01
5+
6+
## Purpose
7+
8+
This constitutional document establishes the core principles governing the design, implementation, and evolution of `git-cross`. These principles ensure the tool remains simple, transparent, and reliable for vendoring parts of git repositories.
9+
1310
## Core Principles
1411

15-
### Principle I – Upstream-First Patching
16-
cross exists to mix sparse directories while keeping upstream repositories the source of truth.
12+
### Principle I: Upstream-First Patching
13+
14+
**git-cross SHALL maintain a direct link to upstream repositories through git worktrees.**
15+
16+
- Vendored files originate from real git commits in upstream repositories
17+
- Sparse checkout enables selective vendoring of subdirectories
18+
- Local modifications remain traceable to upstream sources
19+
- Bidirectional sync (pull and push) maintains relationship with upstream
20+
- No duplication of git history in the consuming repository
21+
22+
**Rationale**: Submodules force entire-repo checkouts and create gitlinks instead of real files. git-cross provides physical files while preserving the upstream connection, enabling both local edits and upstream contributions.
23+
24+
### Principle II: Worktree Hygiene
25+
26+
**git-cross SHALL protect worktree cleanliness and prevent data loss.**
27+
28+
- Hidden worktrees (`.git/cross/worktrees/`) store upstream state
29+
- Automatic stashing before pulls preserves local modifications in worktrees
30+
- Commands abort on dirty state when modifications could be lost
31+
- Explicit confirmation required for destructive operations
32+
- `rsync` provides safe, predictable file synchronization
33+
34+
**Rationale**: Developer trust depends on predictable behavior. The tool must never silently discard work or leave repositories in inconsistent states.
35+
36+
### Principle III: Portable Bash Discipline
37+
38+
**git-cross implementation SHALL prioritize portability and maintainability.**
39+
40+
**Current implementation**: `just` + `fish` (complex logic delegated to fish shell scripts)
41+
42+
**Standards**:
43+
- Justfile for command dispatch and workflow orchestration
44+
- Fish shell (≥3.0) for complex string manipulation and conditionals
45+
- POSIX-compatible workflows where possible for broad compatibility
46+
- Clear separation between user-facing commands (Justfile) and internal helpers
47+
- No external dependencies beyond: `git`, `just`, `fish`, `rsync`, core utilities
48+
49+
**Code style**:
50+
- Lower_snake_case for fish functions and variables
51+
- Inline comments for non-obvious logic (especially index calculations)
52+
- Helper functions (`_sync_from_crossfile`, `_resolve_context`) for modularity
53+
- Four-space indentation, grouped exports/constants
54+
55+
**Rationale**: The tool must run on contributor machines (macOS, Linux) without complex installation. `just` provides excellent command-running ergonomics while `fish` handles complex data manipulation cleanly.
56+
57+
### Principle IV: Transparent Automation
58+
59+
**git-cross SHALL make implicit behavior explicit and observable.**
60+
61+
- Commands document themselves via `just help` and `just --list`
62+
- `Crossfile` provides human-readable, reproducible configuration
63+
- `just replay` reconstructs vendoring from `Crossfile` alone
64+
- Operations log actions clearly (what's being fetched, synced, etc.)
65+
- Environment knobs (e.g., `CROSS_NON_INTERACTIVE`) are documented
66+
- `verbose` mode available for debugging
67+
68+
**Auto-save behavior**:
69+
- `use` and `patch` commands automatically append to `Crossfile`
70+
- Idempotent: running same command twice doesn't duplicate entries
71+
- Crossfile structure: plain text, one command per line, comments allowed
72+
73+
**Rationale**: "Magic" automation breeds distrust. Users should understand what the tool does, how to reproduce it, and how to debug it.
1774

18-
- Patch operations MUST preserve remote alias metadata and branch naming derived from `alias/branch/path`, avoiding rewrites that break contribution flows.
19-
- All git interactions inside the script MUST flow through the `_git` wrapper so logging stays verbose and behaviour remains observable.
20-
- Crossfile definitions MUST rely on the `use` and `patch` helpers; custom fetch flows demand documented governance approval inside the feature plan.
75+
### Principle V: Verification & Release Confidence
2176

22-
Rationale: Maintaining upstream-first behaviour keeps external projects healthy and ensures contributors can upstream their improvements without friction.
77+
**git-cross SHALL provide built-in verification mechanisms.**
2378

24-
### Principle II – Worktree Hygiene
25-
Reliable worktrees keep cross trustworthy for both the root repository and every patched remote.
79+
**Testing strategy**:
80+
- Bash test scripts (`test/bash/examples/`) for realistic scenario coverage
81+
- Fixture repositories (`test/fixtures/remotes/`) simulate upstreams
82+
- `test/run-all.sh` orchestrates full test suite
83+
- Tests verify both happy paths and error handling
2684

27-
- The script MUST execute with `set -euo pipefail`, guarding non-fatal lookups with `|| true` so failures are explicit.
28-
- Root and patch worktrees MUST be clean before cross mutates files; violations exit via `say "ERROR: …" <exit>` rather than continuing silently.
29-
- `./cross status --refresh` MUST be the canonical smoke check before distributing changes or releases.
85+
**Pre-release checks**:
86+
- Syntax validation: `just check-deps` verifies required tools
87+
- Example validation: All `examples/Crossfile-*` must execute successfully
88+
- Shellcheck linting (when applicable to wrapper scripts)
89+
- Manual verification of `README` examples
3090

31-
Rationale: Enforcing cleanliness avoids hidden conflicts and gives contributors immediate feedback about repository health.
91+
**Crossfile reproducibility**:
92+
- `just replay` must reconstruct identical state from `Crossfile`
93+
- Version pinning supported via branch/tag specifications
94+
- Hash-based worktree naming prevents collisions
3295

33-
### Principle III – Portable Bash Discipline
34-
Portability protects the script across environments and shell versions.
96+
**Rationale**: Contributors and users need confidence that changes don't break core workflows. Automated testing and clear verification steps enable fearless iteration.
3597

36-
- Implementation MUST target Bash ≥4 syntax, relying on `[[` tests, `local` variables, and other portable constructs.
37-
- Indentation MUST remain four spaces; functions stay lower_snake_case; constants and exported variables stay grouped near the top of the script.
38-
- Direct `git` invocations are forbidden unless a documented exception is granted; `_git` handles instrumentation and future enhancements.
39-
- New external dependencies beyond the established coreutils MUST NOT be introduced without explicit governance approval and documentation.
98+
## Decision Framework
4099

41-
Rationale: A disciplined style ensures the tool remains approachable, reviewable, and easy to extend.
100+
When evaluating new features or changes, assess against these questions:
42101

43-
### Principle IV – Transparent Automation
44-
Users and automations need predictable prompts and output.
102+
1. **Upstream-First**: Does it maintain/improve the upstream relationship?
103+
2. **Hygiene**: Does it protect user data and worktree cleanliness?
104+
3. **Portability**: Does it run on macOS/Linux without exotic dependencies?
105+
4. **Transparency**: Can users understand and reproduce what it does?
106+
5. **Verification**: Can we test it automatically or document manual verification?
45107

46-
- Prompts MUST use the shared `ask` helper and honour `CROSS_NON_INTERACTIVE` so non-interactive runs fail fast and predictably.
47-
- Human-facing output MUST route through `say` to maintain consistent messaging for both humans and AI-assisted tooling.
48-
- Reusable helpers MUST live alongside related utilities and be sourced explicitly to keep automation discoverable.
49-
- Any new environment knob (for example `CROSS_FETCH_DEPTH`) MUST ship with documentation updates in README, plan, and spec artifacts.
108+
**If any answer is "no"**, re-design the feature or document the trade-off explicitly.
50109

51-
Rationale: Clear automation patterns reduce surprises and make integration with other tooling straightforward.
110+
## Extension Points
52111

53-
### Principle V – Verification & Release Confidence
54-
Confidence comes from repeatable verification gates.
112+
The constitution permits controlled extensions:
55113

56-
- `bash -n cross` and `shellcheck cross` MUST pass with zero warnings before any change is merged.
57-
- `./cross status --refresh` MUST succeed for the root and every patch before publishing releases or artifacts.
58-
- New executable variants (e.g., `cross_v<semver>.sh`) MUST mirror the primary `cross` script and be marked executable with `chmod +x`.
59-
- Manual test coverage remains the default; introducing automated suites demands documentation in this constitution, AGENTS, and the Sync Impact Report.
114+
- **Post-hooks**: `cross exec <command>` allows user-defined automation
115+
- **Custom commands**: Users can add recipes to their own `Justfile` that compose `cross` commands
116+
- **Plugin remotes**: Future support for `just <plugin> <cmd>` to delegate to vendored Justfiles
60117

61-
Rationale: Mandatory verification keeps the project reliable even without a large automated test harness.
118+
Extensions MUST NOT violate core principles (e.g., post-hooks cannot bypass worktree hygiene checks).
62119

63-
## Operational Constraints
120+
## Constitutional Amendments
64121

65-
- Git 2.20 or newer is a hard requirement; the script MUST fail fast with actionable guidance when the version check fails.
66-
- cross MUST continue to support sparse checkout and partial fetch workflows, preserving alias-derived branch naming to avoid collisions.
67-
- Crossfile entries MUST keep comments short and aligned, always declaring destinations with the canonical `alias:path [local] [--branch]` syntax.
68-
- Constants and exported environment toggles (for example `CROSS_FETCH_DEPTH`) MUST live near the top of the script with defaults and rationale.
69-
- Remote metadata stored under `.git/cross/` MUST remain backwards compatible; migrations require explicit mention in the plan and the Sync Impact Report.
122+
This document may be amended when:
70123

71-
## Workflow & Quality Gates
124+
1. A principle proves infeasible in practice
125+
2. Ecosystem changes render a principle obsolete (e.g., git internals evolve)
126+
3. Community consensus emerges on a superior approach
72127

73-
- Implementation plans MUST document how they satisfy every principle, including the exact verification commands contributors will run.
74-
- Developers MUST stage outputs with git after running `./cross` so the root repository captures all generated changes.
75-
- Before requesting review, contributors MUST record the results of `bash -n`, `shellcheck`, and `./cross status --refresh`.
76-
- Preparing a release requires copying `cross` to `cross_v<semver>.sh`, updating documentation, and verifying `./cross version --current` reports the new version.
77-
- Feature work MUST avoid adding new dependencies; when new helpers are introduced they MUST include explicit `source` statements and rationale in the plan.
128+
**Amendment process**: Propose changes via issue/PR with:
129+
- Problem statement
130+
- Specific principle(s) affected
131+
- Alternative wording or new principle
132+
- Impact assessment on existing users
78133

79-
## Governance
134+
**Approval**: Requires maintainer consensus + backward compatibility plan or major version bump.
80135

81-
- This constitution supersedes conflicting project guidance; compliance is mandatory for every contribution.
82-
- Amendments require maintainer approval, an updated Sync Impact Report, and a refreshed audit of affected templates.
83-
- Versioning follows Semantic Versioning: MAJOR for principle changes, MINOR for new sections or material expansions, PATCH for clarifications.
84-
- Ratification or amendment MUST capture the verification commands mandated by Principle V as part of the review record.
85-
- Maintainers MUST block merges that omit constitution gates or introduce regressions against these principles.
136+
## Acknowledgments
86137

87-
**Version**: 1.0.0 | **Ratified**: 2025-11-28 | **Last Amended**: 2025-11-28
138+
Principles inspired by:
139+
- Git's own design philosophy (simplicity, transparency, data integrity)
140+
- The Unix philosophy (do one thing well, compose with other tools)
141+
- [Spec-kit](https://github.com/github/spec-kit) governance patterns

specs/001-cross-test-strategy/plan.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@ Build a repeatable automated test strategy for the `cross` CLI that:
1717

1818
## Technical Context
1919

20-
**Language/Version**: Bash 5.x (POSIX-compatible) and Rust 1.75 (for the parallel harness)
21-
**Primary Dependencies**: git ≥2.20, `shellcheck`, Rust crates `assert_cmd`, `predicates`, `tempfile`, `camino`
22-
**Storage**: N/A (tests operate on temporary filesystem directories only)
23-
**Testing**: Bash scripts executed via `test/run-default.sh` plus `cargo test` for Rust harness; both invoked from `test/run-all.sh`
24-
**Target Platform**: macOS and Linux shells with GNU coreutils (matching existing cross usage)
25-
**Project Type**: Single CLI project with dedicated `test/` and `examples/` directories
26-
**Performance Goals**: Full suite completes within 5 minutes on contributor hardware; individual fixtures materialise in <60 seconds
27-
**Constraints**: Tests MUST run in temporary directories outside the repo, avoid network calls by using local git fixtures, honour `_git` wrapper, and configure sparse checkout prior to fetch operations
28-
**Scale/Scope**: Cover every Crossfile in `examples/` plus the documented `use`/`patch` flows, producing consolidated reports in `test/`
20+
**Implementation**: Justfile + Fish shell (December 2025 migration complete)
21+
**Language/Version**: Fish 3.x for complex logic, Bash for test harness
22+
**Primary Dependencies**: `git` ≥2.20, `just` (command runner), `fish` shell, `rsync`
23+
**Testing**: Bash test scripts in `test/bash/examples/` exercising Crossfile-001 through 005
24+
**Target Platform**: macOS and Linux with Homebrew support
25+
**Project Type**: Single CLI tool with `cross` wrapper script and vendorable `Justfile`
26+
**Performance Goals**: Full test suite <5 min; individual patches <60s
27+
**Constraints**: Must be vendorable into user repos, support `cross` command prefix, allow post-hooks via `exec`
28+
**Scale/Scope**: Cover all example Crossfiles plus core use/patch/sync/exec workflows
2929

3030
## Constitution Check
3131

specs/001-cross-test-strategy/quickstart.md

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22

33
## Prerequisites
44
- Git ≥ 2.20
5-
- Bash ≥ 5.0 with coreutils (`mktemp`, `realpath`, `tee`)
6-
- `shellcheck`
7-
- Rust toolchain ≥ 1.75 (for Rust harness)
8-
- `cargo` with crates cached locally (`assert_cmd`, `predicates`, `tempfile`, `camino`)
5+
- `just` (command runner) - install via Homebrew or cargo
6+
- `fish` shell ≥ 3.0
7+
- `rsync`
8+
- Bash ≥ 3.2 (for test harness, macOS default is fine)
9+
- Homebrew (macOS/Linux) for PATH setup
910

1011
## Environment Setup
1112
1. Install dependencies listed above.
@@ -16,18 +17,24 @@
1617
## Running the Suite
1718
```bash
1819
# From repository root
19-
test/run-all.sh
20+
./test/run-all.sh
2021
```
22+
2123
The script performs:
22-
- README default testcase in Bash (`test/bash/default-test.sh`).
23-
- Rust parity harness via `cargo test` under `test/rust/`.
24-
- Alias and patch scenario checks (`test/bash/use-alias.sh`, `test/bash/patch-workflow.sh`).
25-
- Constitution verification commands: `bash -n cross`, `shellcheck cross`, `./cross status --refresh`.
24+
- Example Crossfile tests via `test/bash/examples/crossfile-{001,002,003,005}.sh`
25+
- Each test clones repo, copies `Justfile` and `.env`, runs commands via `./cross`
26+
- Validates expected files exist and sparse checkout works correctly
27+
- Note: Rust harness tests are not yet implemented
28+
29+
**Current status**: Tests require fixture seeding (see Maintenance section)
2630

2731
## Results
2832
- Consolidated output stored in `test/results/verification.json` and human-readable logs in `test/results/*.log`.
2933
- CI must fail if any scenario reports non-zero status, missing files, or mismatched artifact hashes.
3034

3135
## Maintenance
32-
- Update fixtures via `scripts/fixture-tooling/seed-fixtures.sh` when README examples change.
33-
- Document any new environment knobs in README, spec, and plan as required by Principle IV.
36+
- **Fixture seeding**: Run `scripts/fixture-tooling/seed-fixtures.sh` to populate `test/fixtures/remotes/` with content
37+
- Currently missing: needs implementation to create bare repos with `/metal`, `/setup/flux`, `/asciinema` paths
38+
- Update examples in `examples/Crossfile-*` when adding new features
39+
- Copy modified `Justfile` and `.env` to test repos via test scripts
40+
- Document environment knobs (`CROSS_NON_INTERACTIVE`, `CROSS_FETCH_DEPENDENCIES`) per Principle IV

specs/001-cross-test-strategy/research.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,22 @@
11
# Research Notes: cross command test strategy
22

3+
## Implementation Update: 2025-12-01
4+
5+
### Decision: Justfile + Fish Shell implementation
6+
- **Rationale**: Provides excellent command-running ergonomics (`just` list, help) while delegating complex logic to fish. Vendorable into user repos via `import?` directive.
7+
- **Migration completed**: All commands (`use`, `patch`, `sync`, `diff`, `push`, `list`, `status`, `exec`, `replay`) now in Justfile.
8+
- **Trade-offs**: Requires `just` and `fish` as dependencies (added to constitution Principle III).
9+
10+
### Decision: `cross` command prefix in Crossfile
11+
- **Rationale**: Extensibility for future plugin support (e.g., `just <plugin> <cmd>`). Makes git-cross commands explicit vs. potential user recipes.
12+
- **Implementation**: All Crossfile lines start with `cross` (e.g., `cross use`, `cross patch`, `cross exec`).
13+
14+
### Decision: Post-hooks via `cross exec`
15+
- **Rationale**: Delegates flexibility to users rather than hardcoding hook logic. Allows calling user's own Justfile recipes or arbitrary shell commands.
16+
- **Implementation**: `_sync_from_crossfile` helper evaluates `cross exec <command>` lines from Crossfile.
17+
18+
## Original Research (2025-11-28)
19+
320
## Decision: Local git fixtures for examples and regression coverage
421
- **Rationale**: Avoids network dependency while replicating README scenarios, enabling deterministic tests for `bill:/setup/flux` and other aliases. Local bare repositories can be seeded with required directories and commits.
522
- **Alternatives considered**: (a) Hitting live upstreams (rejected: flaky, credentials), (b) Mocking git commands (rejected: misses integration).

specs/001-cross-test-strategy/spec.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,20 @@
22

33
**Feature Branch**: `001-cross-test-strategy`
44
**Created**: 2025-11-28
5-
**Status**: Draft
5+
**Status**: In Progress
6+
**Last Updated**: 2025-12-01
7+
**Implementation**: Justfile + Fish (migration complete)
68
**Input**: User description: "Implement test strategy for core functions in cross especially use and patch and any time later all documented functions and callables from usage documentation."
79

810
## Clarifications
911

12+
### Session 2025-12-01
13+
14+
- Q: How should the tool handle command prefixes in Crossfile? → A: All commands use `cross` prefix for extensibility (e.g., `cross use`, `cross patch`, `cross exec`).
15+
- Q: How should post-hooks be implemented? → A: Via `cross exec <command>` to allow users to call their own Justfile recipes or shell scripts.
16+
- Q: What's the correct location for constitution.md? → A: `.specify/memory/constitution.md` for spec-kit compatibility.
17+
- Q: Should tests handle the Justfile implementation? → A: Yes, test scripts must copy `Justfile` and `.env` to test repositories.
18+
1019
### Session 2025-11-28
1120

1221
- Q: Where must automated cross tests execute relative to the repository? → A: In a temporary directory outside the project workspace.

0 commit comments

Comments
 (0)