flanes 0.3.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. flanes-0.3.0/CONTRIBUTING.md +75 -0
  2. flanes-0.3.0/LICENSE +21 -0
  3. flanes-0.3.0/MANIFEST.in +4 -0
  4. flanes-0.3.0/PKG-INFO +187 -0
  5. flanes-0.3.0/README.md +151 -0
  6. flanes-0.3.0/docs/guide.md +1535 -0
  7. flanes-0.3.0/examples/README.md +30 -0
  8. flanes-0.3.0/examples/agent_workflow.py +186 -0
  9. flanes-0.3.0/examples/cli_workflow.sh +81 -0
  10. flanes-0.3.0/examples/multi_machine.md +135 -0
  11. flanes-0.3.0/fla/__init__.py +85 -0
  12. flanes-0.3.0/fla/agent_sdk.py +338 -0
  13. flanes-0.3.0/fla/budgets.py +157 -0
  14. flanes-0.3.0/fla/cas.py +365 -0
  15. flanes-0.3.0/fla/cli.py +2011 -0
  16. flanes-0.3.0/fla/completions.py +277 -0
  17. flanes-0.3.0/fla/embeddings.py +125 -0
  18. flanes-0.3.0/fla/evaluators.py +224 -0
  19. flanes-0.3.0/fla/gc.py +256 -0
  20. flanes-0.3.0/fla/git_bridge.py +288 -0
  21. flanes-0.3.0/fla/mcp_server.py +365 -0
  22. flanes-0.3.0/fla/plugins.py +77 -0
  23. flanes-0.3.0/fla/project.py +165 -0
  24. flanes-0.3.0/fla/remote.py +430 -0
  25. flanes-0.3.0/fla/repo.py +1247 -0
  26. flanes-0.3.0/fla/serializable.py +124 -0
  27. flanes-0.3.0/fla/server.py +482 -0
  28. flanes-0.3.0/fla/state.py +1218 -0
  29. flanes-0.3.0/fla/templates.py +150 -0
  30. flanes-0.3.0/fla/web/app.js +292 -0
  31. flanes-0.3.0/fla/web/index.html +35 -0
  32. flanes-0.3.0/fla/web/style.css +271 -0
  33. flanes-0.3.0/fla/workspace.py +836 -0
  34. flanes-0.3.0/flanes.egg-info/PKG-INFO +187 -0
  35. flanes-0.3.0/flanes.egg-info/SOURCES.txt +58 -0
  36. flanes-0.3.0/flanes.egg-info/dependency_links.txt +1 -0
  37. flanes-0.3.0/flanes.egg-info/entry_points.txt +2 -0
  38. flanes-0.3.0/flanes.egg-info/requires.txt +16 -0
  39. flanes-0.3.0/flanes.egg-info/top_level.txt +1 -0
  40. flanes-0.3.0/pyproject.toml +77 -0
  41. flanes-0.3.0/setup.cfg +4 -0
  42. flanes-0.3.0/setup.py +20 -0
  43. flanes-0.3.0/tests/test_cas.py +125 -0
  44. flanes-0.3.0/tests/test_cli.py +448 -0
  45. flanes-0.3.0/tests/test_concurrent_agents.py +494 -0
  46. flanes-0.3.0/tests/test_edge_cases.py +141 -0
  47. flanes-0.3.0/tests/test_git_bridge.py +260 -0
  48. flanes-0.3.0/tests/test_integration.py +449 -0
  49. flanes-0.3.0/tests/test_limit_fixes.py +199 -0
  50. flanes-0.3.0/tests/test_limits_edge_cases.py +154 -0
  51. flanes-0.3.0/tests/test_phase1_fixes.py +323 -0
  52. flanes-0.3.0/tests/test_phase2.py +212 -0
  53. flanes-0.3.0/tests/test_phase5.py +482 -0
  54. flanes-0.3.0/tests/test_phase6.py +617 -0
  55. flanes-0.3.0/tests/test_phase7.py +717 -0
  56. flanes-0.3.0/tests/test_remote_sync.py +313 -0
  57. flanes-0.3.0/tests/test_repository.py +240 -0
  58. flanes-0.3.0/tests/test_state_manager.py +126 -0
  59. flanes-0.3.0/tests/test_stress.py +412 -0
  60. flanes-0.3.0/tests/test_workspace_manager.py +150 -0
@@ -0,0 +1,75 @@
1
+ # Contributing to Fla
2
+
3
+ ## Development Setup
4
+
5
+ ```bash
6
+ # Clone the repository
7
+ git clone https://github.com/glimish/fla.git
8
+ cd fla
9
+
10
+ # Install in development mode with all dev dependencies
11
+ pip install -e ".[dev]"
12
+ ```
13
+
14
+ ## Running Tests
15
+
16
+ ```bash
17
+ # Run all tests
18
+ python -X utf8 -m pytest tests/ -v
19
+
20
+ # Run fast tests only (skip stress/slow)
21
+ python -X utf8 -m pytest tests/ -v -m "not stress and not slow"
22
+
23
+ # Run a specific test file
24
+ python -X utf8 -m pytest tests/test_cli.py -v
25
+ ```
26
+
27
+ ## Linting and Type Checking
28
+
29
+ ```bash
30
+ # Lint
31
+ ruff check fla/ tests/
32
+
33
+ # Check formatting
34
+ ruff format --check fla/ tests/
35
+
36
+ # Auto-format
37
+ ruff format fla/ tests/
38
+
39
+ # Type check
40
+ mypy fla/
41
+ ```
42
+
43
+ ## Code Style
44
+
45
+ - Python 3.10+ (use `X | Y` union syntax, not `Union[X, Y]`)
46
+ - Max line length: 100 characters (configured in `pyproject.toml`)
47
+ - Linting: ruff with `E, F, W, I, N, UP` rules
48
+ - No unused imports or variables
49
+
50
+ ## Pull Request Guidelines
51
+
52
+ 1. Fork the repo and create a branch from `main`
53
+ 2. Write tests for new functionality
54
+ 3. Run the full test suite and ensure it passes
55
+ 4. Run `ruff check` and `mypy` with no new errors
56
+ 5. Write a clear PR description explaining the change and why
57
+
58
+ ## Architecture
59
+
60
+ See the [Architecture section in README.md](README.md#architecture) for an overview.
61
+ The codebase is organized into layers:
62
+
63
+ - **CLI / Agent SDK** (`cli.py`, `agent_sdk.py`) - User-facing interfaces
64
+ - **Repository** (`repo.py`) - High-level operations
65
+ - **Managers** (`workspace.py`, `state.py`) - Domain logic
66
+ - **Content Store** (`cas.py`) - Content-addressed storage
67
+ - **SQLite** - Persistence layer (WAL mode)
68
+
69
+ ## Reporting Issues
70
+
71
+ Please file issues on GitHub with:
72
+ - Steps to reproduce
73
+ - Expected vs actual behavior
74
+ - Python version and OS
75
+ - Fla version (`fla --version`)
flanes-0.3.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Kim Ranzani - Glimish
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,4 @@
1
+ include LICENSE README.md CONTRIBUTING.md
2
+ recursive-include examples *
3
+ recursive-include docs *
4
+ recursive-include fla/web *.html *.css *.js
flanes-0.3.0/PKG-INFO ADDED
@@ -0,0 +1,187 @@
1
+ Metadata-Version: 2.4
2
+ Name: flanes
3
+ Version: 0.3.0
4
+ Summary: Fla: Feature Lanes for Agents - version control for agentic AI systems
5
+ Author: Kim Ranzani (Glimish)
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/glimish/fla
8
+ Project-URL: Repository, https://github.com/glimish/fla
9
+ Project-URL: Issues, https://github.com/glimish/fla/issues
10
+ Project-URL: Documentation, https://github.com/glimish/fla/tree/main/docs
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Programming Language :: Python :: 3.13
18
+ Classifier: Topic :: Software Development :: Version Control
19
+ Requires-Python: >=3.10
20
+ Description-Content-Type: text/markdown
21
+ License-File: LICENSE
22
+ Provides-Extra: dev
23
+ Requires-Dist: pytest>=7.0; extra == "dev"
24
+ Requires-Dist: pytest-cov>=4.0; extra == "dev"
25
+ Requires-Dist: ruff>=0.4; extra == "dev"
26
+ Requires-Dist: mypy>=1.10; extra == "dev"
27
+ Provides-Extra: s3
28
+ Requires-Dist: boto3>=1.26; extra == "s3"
29
+ Provides-Extra: gcs
30
+ Requires-Dist: google-cloud-storage>=2.0; extra == "gcs"
31
+ Provides-Extra: remote
32
+ Requires-Dist: boto3>=1.26; extra == "remote"
33
+ Requires-Dist: google-cloud-storage>=2.0; extra == "remote"
34
+ Dynamic: license-file
35
+ Dynamic: requires-python
36
+
37
+ # Fla: Feature Lanes for Agents
38
+
39
+ **Version Control for Agentic AI Systems**
40
+
41
+ [![Tests](https://github.com/glimish/fla/actions/workflows/test.yml/badge.svg)](https://github.com/glimish/fla/actions/workflows/test.yml)
42
+ [![Python 3.10+](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/downloads/)
43
+ [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](LICENSE)
44
+
45
+ Version control designed from the ground up for AI agents. Replaces git's line-diff model with intent-based snapshots, physically isolated workspaces, and evaluation gating.
46
+
47
+ ## Why Fla?
48
+
49
+ Git assumes a single human making small, curated edits. AI agents break every part of that model.
50
+
51
+ | | Git | Fla |
52
+ |---|---|---|
53
+ | **Unit of work** | Line diffs | Full world-state snapshots |
54
+ | **Change metadata** | Free-text commit message | Structured intent + agent identity |
55
+ | **Quality gate** | CI runs after merge | Evaluation gating before accept |
56
+ | **Parallel agents** | Branch conflicts | Physically isolated workspaces |
57
+ | **Cost tracking** | None | Per-transition token/API accounting |
58
+
59
+ ## Quick Demo
60
+
61
+ ```bash
62
+ cd my-project
63
+ fla init
64
+ # Writes files, then commits in one step:
65
+ fla commit --prompt "Add auth module" \
66
+ --agent-id coder-1 --agent-type feature_dev --auto-accept
67
+
68
+ # Create isolated feature lane
69
+ fla lane create feature-auth
70
+
71
+ # Work in isolation, promote back to main
72
+ fla promote --workspace feature-auth --target main --auto-accept
73
+
74
+ # Query history
75
+ fla history --lane main
76
+ ```
77
+
78
+ Or use the Python SDK:
79
+
80
+ ```python
81
+ from fla.agent_sdk import AgentSession
82
+
83
+ session = AgentSession(
84
+ repo_path="./my-project",
85
+ agent_id="coder-alpha",
86
+ agent_type="feature_developer",
87
+ )
88
+
89
+ with session.work("Add authentication module", tags=["auth"], auto_accept=True) as w:
90
+ (w.path / "auth.py").write_text("def authenticate(): ...")
91
+ w.record_tokens(tokens_in=2000, tokens_out=1200)
92
+ # On exit: snapshots -> proposes -> accepts (or rejects on exception)
93
+ ```
94
+
95
+ See [`examples/`](examples/) for runnable demos.
96
+
97
+ ## Installation
98
+
99
+ ```bash
100
+ pip install fla
101
+
102
+ # Optional: remote storage backends
103
+ pip install fla[s3] # Amazon S3 (boto3)
104
+ pip install fla[gcs] # Google Cloud Storage
105
+ ```
106
+
107
+ ## Core Concepts
108
+
109
+ **World States:** Immutable snapshots of the entire project. Agents propose new world states, not diffs.
110
+
111
+ **Intents:** Structured metadata for every change: the instruction, who issued it, cost tracking, and semantic tags.
112
+
113
+ **Transitions:** Proposals to move from one state to another. Must be *evaluated* before acceptance.
114
+
115
+ **Lanes:** Isolated workstreams. Work is *promoted* into a target lane through evaluation, not merged.
116
+
117
+ **Workspaces:** Main workspace is the repo root (git-style). Feature lanes get physically isolated directories under `.fla/workspaces/`.
118
+
119
+ ## Architecture
120
+
121
+ ```
122
+ +--------------------------------------------------+
123
+ | CLI / Agent SDK |
124
+ | (fla commands / AgentSession API) |
125
+ +--------------------------------------------------+
126
+ | Repository |
127
+ | (propose, accept, promote, restore, etc) |
128
+ +--------------------+-----------------------------+
129
+ | WorkspaceManager | WorldStateManager |
130
+ | (isolation, | (states, transitions, |
131
+ | locking, | lanes, history, trace, |
132
+ | materialization) | conflict detection) |
133
+ +--------------------+-----------------------------+
134
+ | Content-Addressed Store |
135
+ | (SHA-256 blobs + trees, dedup, integrity) |
136
+ +--------------------------------------------------+
137
+ | SQLite |
138
+ | (WAL mode, single-file database) |
139
+ +--------------------------------------------------+
140
+ ```
141
+
142
+ ## Key Features
143
+
144
+ - **Git-style main:** repo root IS the main workspace. Files stay where you expect them.
145
+ - **Physical isolation:** feature workspaces are real directories. Parallel agents can't stomp on each other.
146
+ - **Smart incremental updates:** workspace sync writes only changed files, not the entire tree.
147
+ - **Cross-platform locking:** atomic `mkdir` locking works on Linux, macOS, and Windows.
148
+ - **Conflict detection:** promote finds path-level collisions without content merging.
149
+ - **Evaluators:** run pytest, ruff, or custom checks as gates before accepting transitions.
150
+ - **Cost tracking:** per-transition token usage, wall time, and API call counts.
151
+ - **Git bridge:** `fla export-git` / `fla import-git` for CI integration.
152
+ - **Remote storage:** S3/GCS-backed sync for team collaboration.
153
+ - **MCP server:** expose Fla as tools for LLM integration via Model Context Protocol.
154
+ - **REST API:** `fla serve` starts a multi-threaded HTTP API.
155
+ - **Garbage collection:** `fla gc` removes rejected states and unreachable objects.
156
+
157
+ ## Documentation
158
+
159
+ - **[User Guide](docs/guide.md):** comprehensive reference for all features
160
+ - **[Examples](examples/):** runnable demo scripts
161
+ - **[Contributing](CONTRIBUTING.md):** development setup and guidelines
162
+
163
+ ## Workspace Layout
164
+
165
+ ```
166
+ my-project/
167
+ +-- .fla/
168
+ | +-- config.json
169
+ | +-- store.db # SQLite database
170
+ | +-- main.json # main workspace metadata
171
+ | +-- workspaces/
172
+ | +-- feature-auth/ # isolated feature workspace
173
+ | +-- feature-auth.json
174
+ +-- app.py # YOUR FILES AT REPO ROOT
175
+ +-- lib/
176
+ ```
177
+
178
+ ## Running Tests
179
+
180
+ ```bash
181
+ pip install -e ".[dev]"
182
+ python -X utf8 -m pytest tests/ -v
183
+ ```
184
+
185
+ ## License
186
+
187
+ [MIT](LICENSE)
flanes-0.3.0/README.md ADDED
@@ -0,0 +1,151 @@
1
+ # Fla: Feature Lanes for Agents
2
+
3
+ **Version Control for Agentic AI Systems**
4
+
5
+ [![Tests](https://github.com/glimish/fla/actions/workflows/test.yml/badge.svg)](https://github.com/glimish/fla/actions/workflows/test.yml)
6
+ [![Python 3.10+](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/downloads/)
7
+ [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](LICENSE)
8
+
9
+ Version control designed from the ground up for AI agents. Replaces git's line-diff model with intent-based snapshots, physically isolated workspaces, and evaluation gating.
10
+
11
+ ## Why Fla?
12
+
13
+ Git assumes a single human making small, curated edits. AI agents break every part of that model.
14
+
15
+ | | Git | Fla |
16
+ |---|---|---|
17
+ | **Unit of work** | Line diffs | Full world-state snapshots |
18
+ | **Change metadata** | Free-text commit message | Structured intent + agent identity |
19
+ | **Quality gate** | CI runs after merge | Evaluation gating before accept |
20
+ | **Parallel agents** | Branch conflicts | Physically isolated workspaces |
21
+ | **Cost tracking** | None | Per-transition token/API accounting |
22
+
23
+ ## Quick Demo
24
+
25
+ ```bash
26
+ cd my-project
27
+ fla init
28
+ # Writes files, then commits in one step:
29
+ fla commit --prompt "Add auth module" \
30
+ --agent-id coder-1 --agent-type feature_dev --auto-accept
31
+
32
+ # Create isolated feature lane
33
+ fla lane create feature-auth
34
+
35
+ # Work in isolation, promote back to main
36
+ fla promote --workspace feature-auth --target main --auto-accept
37
+
38
+ # Query history
39
+ fla history --lane main
40
+ ```
41
+
42
+ Or use the Python SDK:
43
+
44
+ ```python
45
+ from fla.agent_sdk import AgentSession
46
+
47
+ session = AgentSession(
48
+ repo_path="./my-project",
49
+ agent_id="coder-alpha",
50
+ agent_type="feature_developer",
51
+ )
52
+
53
+ with session.work("Add authentication module", tags=["auth"], auto_accept=True) as w:
54
+ (w.path / "auth.py").write_text("def authenticate(): ...")
55
+ w.record_tokens(tokens_in=2000, tokens_out=1200)
56
+ # On exit: snapshots -> proposes -> accepts (or rejects on exception)
57
+ ```
58
+
59
+ See [`examples/`](examples/) for runnable demos.
60
+
61
+ ## Installation
62
+
63
+ ```bash
64
+ pip install fla
65
+
66
+ # Optional: remote storage backends
67
+ pip install fla[s3] # Amazon S3 (boto3)
68
+ pip install fla[gcs] # Google Cloud Storage
69
+ ```
70
+
71
+ ## Core Concepts
72
+
73
+ **World States:** Immutable snapshots of the entire project. Agents propose new world states, not diffs.
74
+
75
+ **Intents:** Structured metadata for every change: the instruction, who issued it, cost tracking, and semantic tags.
76
+
77
+ **Transitions:** Proposals to move from one state to another. Must be *evaluated* before acceptance.
78
+
79
+ **Lanes:** Isolated workstreams. Work is *promoted* into a target lane through evaluation, not merged.
80
+
81
+ **Workspaces:** Main workspace is the repo root (git-style). Feature lanes get physically isolated directories under `.fla/workspaces/`.
82
+
83
+ ## Architecture
84
+
85
+ ```
86
+ +--------------------------------------------------+
87
+ | CLI / Agent SDK |
88
+ | (fla commands / AgentSession API) |
89
+ +--------------------------------------------------+
90
+ | Repository |
91
+ | (propose, accept, promote, restore, etc) |
92
+ +--------------------+-----------------------------+
93
+ | WorkspaceManager | WorldStateManager |
94
+ | (isolation, | (states, transitions, |
95
+ | locking, | lanes, history, trace, |
96
+ | materialization) | conflict detection) |
97
+ +--------------------+-----------------------------+
98
+ | Content-Addressed Store |
99
+ | (SHA-256 blobs + trees, dedup, integrity) |
100
+ +--------------------------------------------------+
101
+ | SQLite |
102
+ | (WAL mode, single-file database) |
103
+ +--------------------------------------------------+
104
+ ```
105
+
106
+ ## Key Features
107
+
108
+ - **Git-style main:** repo root IS the main workspace. Files stay where you expect them.
109
+ - **Physical isolation:** feature workspaces are real directories. Parallel agents can't stomp on each other.
110
+ - **Smart incremental updates:** workspace sync writes only changed files, not the entire tree.
111
+ - **Cross-platform locking:** atomic `mkdir` locking works on Linux, macOS, and Windows.
112
+ - **Conflict detection:** promote finds path-level collisions without content merging.
113
+ - **Evaluators:** run pytest, ruff, or custom checks as gates before accepting transitions.
114
+ - **Cost tracking:** per-transition token usage, wall time, and API call counts.
115
+ - **Git bridge:** `fla export-git` / `fla import-git` for CI integration.
116
+ - **Remote storage:** S3/GCS-backed sync for team collaboration.
117
+ - **MCP server:** expose Fla as tools for LLM integration via Model Context Protocol.
118
+ - **REST API:** `fla serve` starts a multi-threaded HTTP API.
119
+ - **Garbage collection:** `fla gc` removes rejected states and unreachable objects.
120
+
121
+ ## Documentation
122
+
123
+ - **[User Guide](docs/guide.md):** comprehensive reference for all features
124
+ - **[Examples](examples/):** runnable demo scripts
125
+ - **[Contributing](CONTRIBUTING.md):** development setup and guidelines
126
+
127
+ ## Workspace Layout
128
+
129
+ ```
130
+ my-project/
131
+ +-- .fla/
132
+ | +-- config.json
133
+ | +-- store.db # SQLite database
134
+ | +-- main.json # main workspace metadata
135
+ | +-- workspaces/
136
+ | +-- feature-auth/ # isolated feature workspace
137
+ | +-- feature-auth.json
138
+ +-- app.py # YOUR FILES AT REPO ROOT
139
+ +-- lib/
140
+ ```
141
+
142
+ ## Running Tests
143
+
144
+ ```bash
145
+ pip install -e ".[dev]"
146
+ python -X utf8 -m pytest tests/ -v
147
+ ```
148
+
149
+ ## License
150
+
151
+ [MIT](LICENSE)