fticket 0.1.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 (47) hide show
  1. fticket-0.1.0/.github/workflows/gitleaks.yml +15 -0
  2. fticket-0.1.0/.github/workflows/publish.yml +32 -0
  3. fticket-0.1.0/.python-version +1 -0
  4. fticket-0.1.0/LICENSE +21 -0
  5. fticket-0.1.0/PKG-INFO +73 -0
  6. fticket-0.1.0/README.md +55 -0
  7. fticket-0.1.0/pyproject.toml +70 -0
  8. fticket-0.1.0/src/fticket/__init__.py +122 -0
  9. fticket-0.1.0/src/fticket/__main__.py +8 -0
  10. fticket-0.1.0/src/fticket/_html.py +925 -0
  11. fticket-0.1.0/src/fticket/claims.py +239 -0
  12. fticket-0.1.0/src/fticket/cli.py +853 -0
  13. fticket-0.1.0/src/fticket/clock.py +23 -0
  14. fticket-0.1.0/src/fticket/config.py +110 -0
  15. fticket-0.1.0/src/fticket/core.py +586 -0
  16. fticket-0.1.0/src/fticket/dashboard.py +585 -0
  17. fticket-0.1.0/src/fticket/db.py +74 -0
  18. fticket-0.1.0/src/fticket/deps.py +340 -0
  19. fticket-0.1.0/src/fticket/errors.py +139 -0
  20. fticket-0.1.0/src/fticket/events.py +30 -0
  21. fticket-0.1.0/src/fticket/history.py +64 -0
  22. fticket-0.1.0/src/fticket/py.typed +0 -0
  23. fticket-0.1.0/src/fticket/queries.py +612 -0
  24. fticket-0.1.0/src/fticket/resources.py +459 -0
  25. fticket-0.1.0/src/fticket/scheduler.py +47 -0
  26. fticket-0.1.0/src/fticket/schema.py +210 -0
  27. fticket-0.1.0/src/fticket/state_machine.py +76 -0
  28. fticket-0.1.0/src/fticket/tickets.py +133 -0
  29. fticket-0.1.0/src/fticket/transitions.py +457 -0
  30. fticket-0.1.0/src/fticket/types.py +331 -0
  31. fticket-0.1.0/tests/conftest.py +61 -0
  32. fticket-0.1.0/tests/factories.py +128 -0
  33. fticket-0.1.0/tests/test_claims.py +608 -0
  34. fticket-0.1.0/tests/test_claims_concurrency.py +100 -0
  35. fticket-0.1.0/tests/test_cli.py +1291 -0
  36. fticket-0.1.0/tests/test_dashboard.py +961 -0
  37. fticket-0.1.0/tests/test_deps.py +265 -0
  38. fticket-0.1.0/tests/test_events.py +580 -0
  39. fticket-0.1.0/tests/test_latency.py +193 -0
  40. fticket-0.1.0/tests/test_orphans.py +184 -0
  41. fticket-0.1.0/tests/test_queries.py +610 -0
  42. fticket-0.1.0/tests/test_resources.py +527 -0
  43. fticket-0.1.0/tests/test_scheduler.py +273 -0
  44. fticket-0.1.0/tests/test_schema.py +233 -0
  45. fticket-0.1.0/tests/test_tickets.py +182 -0
  46. fticket-0.1.0/tests/test_transitions.py +277 -0
  47. fticket-0.1.0/uv.lock +303 -0
@@ -0,0 +1,15 @@
1
+ name: gitleaks
2
+ on:
3
+ push:
4
+ pull_request:
5
+ jobs:
6
+ scan:
7
+ runs-on: ubuntu-latest
8
+ steps:
9
+ - uses: actions/checkout@v4
10
+ with:
11
+ fetch-depth: 0
12
+ - name: Run gitleaks (full history)
13
+ run: |
14
+ curl -sSL https://github.com/gitleaks/gitleaks/releases/download/v8.24.3/gitleaks_8.24.3_linux_x64.tar.gz | tar xz gitleaks
15
+ ./gitleaks git . --no-banner --redact --exit-code 1
@@ -0,0 +1,32 @@
1
+ name: publish
2
+ on:
3
+ release:
4
+ types: [published]
5
+ permissions:
6
+ contents: read
7
+ jobs:
8
+ build:
9
+ runs-on: ubuntu-latest
10
+ steps:
11
+ - uses: actions/checkout@v4
12
+ - uses: astral-sh/setup-uv@v5
13
+ - run: uv build
14
+ - run: uvx twine check dist/*
15
+ - uses: actions/upload-artifact@v4
16
+ with:
17
+ name: dist
18
+ path: dist/
19
+ publish:
20
+ needs: build
21
+ runs-on: ubuntu-latest
22
+ environment:
23
+ name: pypi
24
+ url: https://pypi.org/p/fticket
25
+ permissions:
26
+ id-token: write
27
+ steps:
28
+ - uses: actions/download-artifact@v4
29
+ with:
30
+ name: dist
31
+ path: dist/
32
+ - uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1 @@
1
+ 3.13
fticket-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Foad Kesheh
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.
fticket-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,73 @@
1
+ Metadata-Version: 2.4
2
+ Name: fticket
3
+ Version: 0.1.0
4
+ Summary: Factory Ticket System (FTS): transactional coordination core for the AI software factory
5
+ Project-URL: Repository, https://github.com/fmktech/fticket
6
+ Project-URL: Issues, https://github.com/fmktech/fticket/issues
7
+ Author-email: Foad Kesheh <foad@fmktech.com.br>
8
+ License-Expression: MIT
9
+ License-File: LICENSE
10
+ Keywords: agents,coordination,leases,sqlite,task-queue,ticketing
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Operating System :: OS Independent
14
+ Classifier: Programming Language :: Python :: 3.13
15
+ Classifier: Typing :: Typed
16
+ Requires-Python: >=3.13
17
+ Description-Content-Type: text/markdown
18
+
19
+ # fticket — Factory Ticket System (FTS)
20
+
21
+ Transactional coordination core for the AI software factory: task status, claims,
22
+ dependencies, resource leases, and history in one SQLite file (WAL, single writer,
23
+ one `BEGIN IMMEDIATE` transaction per operation). Task folders stay immutable-path
24
+ artifact storage; FTS owns all control-plane state. Zero runtime dependencies.
25
+
26
+ ## Install
27
+
28
+ ```bash
29
+ uv sync # dev
30
+ uv pip install . # as a library
31
+ ```
32
+
33
+ ## Quickstart
34
+
35
+ ```python
36
+ from fticket import FTS, Mode
37
+
38
+ FTS.init_db("factory.db", stages=["code", "review", "qa", "deploy"]) # create schema first
39
+ fts = FTS("factory.db")
40
+
41
+ t = fts.create_ticket(title="build parser", stage="code", folder_path="tasks/0001")
42
+ claim = fts.claim("code", worker_id="coder-1") # atomic, race-free
43
+ fts.start(claim.ticket.id, "coder-1") # claimed -> in_progress
44
+ fts.acquire(resource="staging", ticket_id=t.id, worker_id="coder-1", mode=Mode.EXCLUSIVE)
45
+ fts.complete(t.id, "coder-1") # records reached_stage
46
+ fts.advance(t.id, "coder-1", to_stage="review") # done -> queued @ review
47
+ fts.tick() # expire TTLs, promote waitlists
48
+ ```
49
+
50
+ ## CLI
51
+
52
+ `fts <cmd> --db factory.db` — read commands work on a read-only database.
53
+
54
+ | | |
55
+ |---|---|
56
+ | `init` | create schema, seed config + stages |
57
+ | `board` / `show <id>` / `dag` / `queues` | board grid, ticket detail + history, dependency DAG, queue depths |
58
+ | `why <id>` / `triage` / `stats` / `doctor` | stuck-ticket root cause, dead-letter + orphans, AC16 metrics, health checks |
59
+ | `create` / `claim` / `renew` / `start` / `complete` / `advance` | ticket lifecycle |
60
+ | `transition` / `reject` / `dead-letter` / `revive` | generic edge, bounce, operator kill, un-kill |
61
+ | `add-dep` / `acquire` / `release` / `register-resource` | dependencies and resource leases |
62
+ | `tick` / `scheduler` | one sweep pass / loop until Ctrl-C |
63
+ | `events` | poll/tail the event stream |
64
+ | `config get\|set` | tunables (`bounce_limit`, `claim_ttl_ms`, ...) |
65
+ | `serve` | read-only web dashboard |
66
+
67
+ ## Dashboard
68
+
69
+ ```bash
70
+ fts serve --db factory.db --port 8377
71
+ ```
72
+
73
+ Read-only, bound to `127.0.0.1` only, GET-only, no external assets.
@@ -0,0 +1,55 @@
1
+ # fticket — Factory Ticket System (FTS)
2
+
3
+ Transactional coordination core for the AI software factory: task status, claims,
4
+ dependencies, resource leases, and history in one SQLite file (WAL, single writer,
5
+ one `BEGIN IMMEDIATE` transaction per operation). Task folders stay immutable-path
6
+ artifact storage; FTS owns all control-plane state. Zero runtime dependencies.
7
+
8
+ ## Install
9
+
10
+ ```bash
11
+ uv sync # dev
12
+ uv pip install . # as a library
13
+ ```
14
+
15
+ ## Quickstart
16
+
17
+ ```python
18
+ from fticket import FTS, Mode
19
+
20
+ FTS.init_db("factory.db", stages=["code", "review", "qa", "deploy"]) # create schema first
21
+ fts = FTS("factory.db")
22
+
23
+ t = fts.create_ticket(title="build parser", stage="code", folder_path="tasks/0001")
24
+ claim = fts.claim("code", worker_id="coder-1") # atomic, race-free
25
+ fts.start(claim.ticket.id, "coder-1") # claimed -> in_progress
26
+ fts.acquire(resource="staging", ticket_id=t.id, worker_id="coder-1", mode=Mode.EXCLUSIVE)
27
+ fts.complete(t.id, "coder-1") # records reached_stage
28
+ fts.advance(t.id, "coder-1", to_stage="review") # done -> queued @ review
29
+ fts.tick() # expire TTLs, promote waitlists
30
+ ```
31
+
32
+ ## CLI
33
+
34
+ `fts <cmd> --db factory.db` — read commands work on a read-only database.
35
+
36
+ | | |
37
+ |---|---|
38
+ | `init` | create schema, seed config + stages |
39
+ | `board` / `show <id>` / `dag` / `queues` | board grid, ticket detail + history, dependency DAG, queue depths |
40
+ | `why <id>` / `triage` / `stats` / `doctor` | stuck-ticket root cause, dead-letter + orphans, AC16 metrics, health checks |
41
+ | `create` / `claim` / `renew` / `start` / `complete` / `advance` | ticket lifecycle |
42
+ | `transition` / `reject` / `dead-letter` / `revive` | generic edge, bounce, operator kill, un-kill |
43
+ | `add-dep` / `acquire` / `release` / `register-resource` | dependencies and resource leases |
44
+ | `tick` / `scheduler` | one sweep pass / loop until Ctrl-C |
45
+ | `events` | poll/tail the event stream |
46
+ | `config get\|set` | tunables (`bounce_limit`, `claim_ttl_ms`, ...) |
47
+ | `serve` | read-only web dashboard |
48
+
49
+ ## Dashboard
50
+
51
+ ```bash
52
+ fts serve --db factory.db --port 8377
53
+ ```
54
+
55
+ Read-only, bound to `127.0.0.1` only, GET-only, no external assets.
@@ -0,0 +1,70 @@
1
+ [project]
2
+ name = "fticket"
3
+ version = "0.1.0"
4
+ description = "Factory Ticket System (FTS): transactional coordination core for the AI software factory"
5
+ readme = "README.md"
6
+ license = "MIT"
7
+ license-files = ["LICENSE"]
8
+ authors = [{ name = "Foad Kesheh", email = "foad@fmktech.com.br" }]
9
+ keywords = ["sqlite", "ticketing", "coordination", "agents", "task-queue", "leases"]
10
+ classifiers = [
11
+ "Development Status :: 4 - Beta",
12
+ "Intended Audience :: Developers",
13
+ "Operating System :: OS Independent",
14
+ "Programming Language :: Python :: 3.13",
15
+ "Typing :: Typed",
16
+ ]
17
+ requires-python = ">=3.13"
18
+ dependencies = []
19
+
20
+ [project.urls]
21
+ Repository = "https://github.com/fmktech/fticket"
22
+ Issues = "https://github.com/fmktech/fticket/issues"
23
+
24
+ [project.scripts]
25
+ fts = "fticket.cli:main"
26
+
27
+ [dependency-groups]
28
+ dev = [
29
+ "pytest>=8.3",
30
+ "factory-boy>=3.3",
31
+ "mypy>=1.14",
32
+ "ruff>=0.9",
33
+ ]
34
+
35
+ [build-system]
36
+ requires = ["hatchling"]
37
+ build-backend = "hatchling.build"
38
+
39
+ [tool.hatch.build.targets.wheel]
40
+ packages = ["src/fticket"]
41
+
42
+ [tool.pytest.ini_options]
43
+ testpaths = ["tests"]
44
+ addopts = "-q"
45
+ markers = [
46
+ "slow: long-running concurrency/latency tests",
47
+ ]
48
+
49
+ [tool.mypy]
50
+ strict = true
51
+ python_version = "3.13"
52
+ files = ["src", "tests"]
53
+ warn_unreachable = true
54
+
55
+ [[tool.mypy.overrides]]
56
+ module = "factory.*"
57
+ ignore_missing_imports = true
58
+
59
+ [tool.ruff]
60
+ line-length = 100
61
+ target-version = "py313"
62
+
63
+ [tool.ruff.lint]
64
+ select = ["E", "F", "W", "I", "UP", "B", "SIM", "TID252"]
65
+
66
+ [tool.ruff.lint.flake8-tidy-imports]
67
+ ban-relative-imports = "parents"
68
+
69
+ [tool.hatch.build.targets.sdist]
70
+ exclude = ["prd-*.md", ".ffactory/"]
@@ -0,0 +1,122 @@
1
+ """FTS — Factory Ticket System (§10 public surface).
2
+
3
+ Re-exports the facade (`FTS`), the clock protocol, every public StrEnum and value
4
+ dataclass (`types`), and the full error hierarchy (`errors`), so callers import from the
5
+ package root. Names are listed in `__all__` for explicit re-export under mypy --strict.
6
+ """
7
+
8
+ from fticket.clock import Clock, SystemClock
9
+ from fticket.core import FTS
10
+ from fticket.errors import (
11
+ ClaimExpired,
12
+ ClaimFenced,
13
+ ConfigError,
14
+ Contended,
15
+ DependencyCycle,
16
+ DuplicateFolder,
17
+ FTSError,
18
+ FTSStageWarning,
19
+ IllegalTransition,
20
+ LeaseUpgradeUnsupported,
21
+ NotClaimOwner,
22
+ NotFound,
23
+ ReadOnlyError,
24
+ ResourceModeError,
25
+ ResourceNotFound,
26
+ ResourceOrderViolation,
27
+ SelfDependency,
28
+ TicketNotFound,
29
+ )
30
+ from fticket.types import (
31
+ AcquireResult,
32
+ BounceRate,
33
+ Claim,
34
+ ClaimResult,
35
+ CycleTimeStats,
36
+ Dag,
37
+ DagEdge,
38
+ DagNode,
39
+ Dependency,
40
+ DoctorCheck,
41
+ DoctorCheckId,
42
+ DoctorReport,
43
+ Event,
44
+ EventType,
45
+ Grant,
46
+ HistoryKind,
47
+ HistoryRow,
48
+ Kind,
49
+ LeaseView,
50
+ Mode,
51
+ ModePolicy,
52
+ OrphanReport,
53
+ ResourceBlock,
54
+ ResourceState,
55
+ StageDepth,
56
+ Status,
57
+ StuckReason,
58
+ Ticket,
59
+ TicketDetail,
60
+ TickReport,
61
+ WaitView,
62
+ WhyCategory,
63
+ )
64
+
65
+ __all__ = [
66
+ "FTS",
67
+ "Clock",
68
+ "SystemClock",
69
+ # enums
70
+ "Status",
71
+ "Kind",
72
+ "Mode",
73
+ "ModePolicy",
74
+ "Grant",
75
+ "HistoryKind",
76
+ "EventType",
77
+ "WhyCategory",
78
+ "DoctorCheckId",
79
+ # value dataclasses
80
+ "Dependency",
81
+ "Ticket",
82
+ "ClaimResult",
83
+ "Claim",
84
+ "AcquireResult",
85
+ "HistoryRow",
86
+ "Event",
87
+ "TickReport",
88
+ "StageDepth",
89
+ "ResourceBlock",
90
+ "BounceRate",
91
+ "CycleTimeStats",
92
+ "DagNode",
93
+ "DagEdge",
94
+ "Dag",
95
+ "LeaseView",
96
+ "WaitView",
97
+ "ResourceState",
98
+ "OrphanReport",
99
+ "TicketDetail",
100
+ "StuckReason",
101
+ "DoctorCheck",
102
+ "DoctorReport",
103
+ # errors
104
+ "FTSError",
105
+ "NotFound",
106
+ "TicketNotFound",
107
+ "ResourceNotFound",
108
+ "IllegalTransition",
109
+ "DependencyCycle",
110
+ "SelfDependency",
111
+ "NotClaimOwner",
112
+ "ClaimExpired",
113
+ "ClaimFenced",
114
+ "ResourceModeError",
115
+ "LeaseUpgradeUnsupported",
116
+ "ResourceOrderViolation",
117
+ "DuplicateFolder",
118
+ "Contended",
119
+ "ConfigError",
120
+ "ReadOnlyError",
121
+ "FTSStageWarning",
122
+ ]
@@ -0,0 +1,8 @@
1
+ """`python -m fticket` entry point -> `cli.main` (§8). [CLI wave 2]"""
2
+
3
+ import sys
4
+
5
+ from fticket.cli import main
6
+
7
+ if __name__ == "__main__":
8
+ sys.exit(main())