fastpdlc 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.
- fastpdlc-0.1.0/.gitattributes +1 -0
- fastpdlc-0.1.0/.github/workflows/ci.yml +26 -0
- fastpdlc-0.1.0/.github/workflows/publish.yml +54 -0
- fastpdlc-0.1.0/.gitignore +6 -0
- fastpdlc-0.1.0/LICENSE +165 -0
- fastpdlc-0.1.0/PKG-INFO +199 -0
- fastpdlc-0.1.0/README.md +177 -0
- fastpdlc-0.1.0/RELEASING.md +44 -0
- fastpdlc-0.1.0/action.yml +59 -0
- fastpdlc-0.1.0/copier.yml +34 -0
- fastpdlc-0.1.0/examples/quickstart/build/product.generated.json +32 -0
- fastpdlc-0.1.0/examples/quickstart/product/rules/BR-idempotent.md +5 -0
- fastpdlc-0.1.0/examples/quickstart/product/terms/TERM-ledger.md +5 -0
- fastpdlc-0.1.0/examples/quickstart/product/terms/TERM-payment.md +7 -0
- fastpdlc-0.1.0/examples/quickstart/product.config.yaml +17 -0
- fastpdlc-0.1.0/fastpdlc/__init__.py +33 -0
- fastpdlc-0.1.0/fastpdlc/cli.py +55 -0
- fastpdlc-0.1.0/fastpdlc/config.py +61 -0
- fastpdlc-0.1.0/fastpdlc/diagnostics.py +75 -0
- fastpdlc-0.1.0/fastpdlc/engine.py +169 -0
- fastpdlc-0.1.0/fastpdlc/plugin.py +82 -0
- fastpdlc-0.1.0/pyproject.toml +34 -0
- fastpdlc-0.1.0/template/.github/workflows/product-validate.yml.jinja +21 -0
- fastpdlc-0.1.0/template/README.md.jinja +24 -0
- fastpdlc-0.1.0/template/product/rules/BR-example.md.jinja +8 -0
- fastpdlc-0.1.0/template/product/terms/TERM-example.md.jinja +8 -0
- fastpdlc-0.1.0/template/product.config.yaml.jinja +22 -0
- fastpdlc-0.1.0/tests/test_fastpdlc.py +137 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
* text=auto eol=lf
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
on: [push, pull_request]
|
|
3
|
+
|
|
4
|
+
permissions:
|
|
5
|
+
contents: read
|
|
6
|
+
|
|
7
|
+
jobs:
|
|
8
|
+
test:
|
|
9
|
+
runs-on: ubuntu-latest
|
|
10
|
+
strategy:
|
|
11
|
+
fail-fast: false
|
|
12
|
+
matrix:
|
|
13
|
+
python: ["3.10", "3.11", "3.12", "3.13"]
|
|
14
|
+
steps:
|
|
15
|
+
- uses: actions/checkout@v4
|
|
16
|
+
- uses: actions/setup-python@v5
|
|
17
|
+
with: { python-version: "${{ matrix.python }}" }
|
|
18
|
+
- run: pip install -e ".[dev]"
|
|
19
|
+
- name: Unit tests
|
|
20
|
+
run: pytest -q
|
|
21
|
+
- name: Dogfood — the quickstart example must validate
|
|
22
|
+
run: |
|
|
23
|
+
fastpdlc -C examples/quickstart build
|
|
24
|
+
git diff --exit-code examples/quickstart/build/ \
|
|
25
|
+
|| { echo "::error::quickstart bundle is stale — run fastpdlc build"; exit 1; }
|
|
26
|
+
fastpdlc -C examples/quickstart validate
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# Publish FastPDLC to PyPI when a GitHub Release is published.
|
|
2
|
+
#
|
|
3
|
+
# Auth is PyPI Trusted Publishing (OIDC) — no API token is stored anywhere. This
|
|
4
|
+
# needs a ONE-TIME setup on PyPI (see RELEASING.md): add a trusted publisher for
|
|
5
|
+
# project `fastpdlc`, owner `tarvitave`, repo `fastpdlc`, workflow `publish.yml`,
|
|
6
|
+
# environment `pypi`. After that, cutting a Release ships the version on the tag.
|
|
7
|
+
#
|
|
8
|
+
# workflow_dispatch is a manual fallback: `gh workflow run publish.yml -f version=X.Y.Z`
|
|
9
|
+
# publishes the current main (its pyproject version must equal the input).
|
|
10
|
+
name: publish
|
|
11
|
+
|
|
12
|
+
on:
|
|
13
|
+
release:
|
|
14
|
+
types: [published]
|
|
15
|
+
workflow_dispatch:
|
|
16
|
+
inputs:
|
|
17
|
+
version:
|
|
18
|
+
description: "Version to publish — must equal pyproject.toml (e.g. 0.1.0)"
|
|
19
|
+
required: true
|
|
20
|
+
|
|
21
|
+
permissions:
|
|
22
|
+
contents: read
|
|
23
|
+
|
|
24
|
+
jobs:
|
|
25
|
+
pypi:
|
|
26
|
+
runs-on: ubuntu-latest
|
|
27
|
+
environment: pypi
|
|
28
|
+
permissions:
|
|
29
|
+
id-token: write # mint the OIDC token PyPI Trusted Publishing verifies
|
|
30
|
+
steps:
|
|
31
|
+
- uses: actions/checkout@v4
|
|
32
|
+
- uses: actions/setup-python@v5
|
|
33
|
+
with: { python-version: "3.12" }
|
|
34
|
+
|
|
35
|
+
- name: Build sdist + wheel
|
|
36
|
+
run: |
|
|
37
|
+
python -m pip install --upgrade build
|
|
38
|
+
python -m build
|
|
39
|
+
|
|
40
|
+
- name: Requested version must match the package version
|
|
41
|
+
# A mismatch would publish a surprise version — fail loudly instead.
|
|
42
|
+
run: |
|
|
43
|
+
set -euo pipefail
|
|
44
|
+
if [ "${{ github.event_name }}" = "release" ]; then
|
|
45
|
+
want="${GITHUB_REF_NAME#v}"
|
|
46
|
+
else
|
|
47
|
+
want="${{ github.event.inputs.version }}"; want="${want#v}"
|
|
48
|
+
fi
|
|
49
|
+
pkg="$(ls dist/*.whl | sed -E 's/.*fastpdlc-([0-9][^-]*)-.*/\1/')"
|
|
50
|
+
echo "requested=$want package=$pkg (event=${{ github.event_name }})"
|
|
51
|
+
test "$want" = "$pkg" || { echo "::error::requested ($want) != package version ($pkg)"; exit 1; }
|
|
52
|
+
|
|
53
|
+
- name: Publish to PyPI
|
|
54
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
fastpdlc-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
GNU LESSER GENERAL PUBLIC LICENSE
|
|
2
|
+
Version 3, 29 June 2007
|
|
3
|
+
|
|
4
|
+
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
|
5
|
+
Everyone is permitted to copy and distribute verbatim copies
|
|
6
|
+
of this license document, but changing it is not allowed.
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
This version of the GNU Lesser General Public License incorporates
|
|
10
|
+
the terms and conditions of version 3 of the GNU General Public
|
|
11
|
+
License, supplemented by the additional permissions listed below.
|
|
12
|
+
|
|
13
|
+
0. Additional Definitions.
|
|
14
|
+
|
|
15
|
+
As used herein, "this License" refers to version 3 of the GNU Lesser
|
|
16
|
+
General Public License, and the "GNU GPL" refers to version 3 of the GNU
|
|
17
|
+
General Public License.
|
|
18
|
+
|
|
19
|
+
"The Library" refers to a covered work governed by this License,
|
|
20
|
+
other than an Application or a Combined Work as defined below.
|
|
21
|
+
|
|
22
|
+
An "Application" is any work that makes use of an interface provided
|
|
23
|
+
by the Library, but which is not otherwise based on the Library.
|
|
24
|
+
Defining a subclass of a class defined by the Library is deemed a mode
|
|
25
|
+
of using an interface provided by the Library.
|
|
26
|
+
|
|
27
|
+
A "Combined Work" is a work produced by combining or linking an
|
|
28
|
+
Application with the Library. The particular version of the Library
|
|
29
|
+
with which the Combined Work was made is also called the "Linked
|
|
30
|
+
Version".
|
|
31
|
+
|
|
32
|
+
The "Minimal Corresponding Source" for a Combined Work means the
|
|
33
|
+
Corresponding Source for the Combined Work, excluding any source code
|
|
34
|
+
for portions of the Combined Work that, considered in isolation, are
|
|
35
|
+
based on the Application, and not on the Linked Version.
|
|
36
|
+
|
|
37
|
+
The "Corresponding Application Code" for a Combined Work means the
|
|
38
|
+
object code and/or source code for the Application, including any data
|
|
39
|
+
and utility programs needed for reproducing the Combined Work from the
|
|
40
|
+
Application, but excluding the System Libraries of the Combined Work.
|
|
41
|
+
|
|
42
|
+
1. Exception to Section 3 of the GNU GPL.
|
|
43
|
+
|
|
44
|
+
You may convey a covered work under sections 3 and 4 of this License
|
|
45
|
+
without being bound by section 3 of the GNU GPL.
|
|
46
|
+
|
|
47
|
+
2. Conveying Modified Versions.
|
|
48
|
+
|
|
49
|
+
If you modify a copy of the Library, and, in your modifications, a
|
|
50
|
+
facility refers to a function or data to be supplied by an Application
|
|
51
|
+
that uses the facility (other than as an argument passed when the
|
|
52
|
+
facility is invoked), then you may convey a copy of the modified
|
|
53
|
+
version:
|
|
54
|
+
|
|
55
|
+
a) under this License, provided that you make a good faith effort to
|
|
56
|
+
ensure that, in the event an Application does not supply the
|
|
57
|
+
function or data, the facility still operates, and performs
|
|
58
|
+
whatever part of its purpose remains meaningful, or
|
|
59
|
+
|
|
60
|
+
b) under the GNU GPL, with none of the additional permissions of
|
|
61
|
+
this License applicable to that copy.
|
|
62
|
+
|
|
63
|
+
3. Object Code Incorporating Material from Library Header Files.
|
|
64
|
+
|
|
65
|
+
The object code form of an Application may incorporate material from
|
|
66
|
+
a header file that is part of the Library. You may convey such object
|
|
67
|
+
code under terms of your choice, provided that, if the incorporated
|
|
68
|
+
material is not limited to numerical parameters, data structure
|
|
69
|
+
layouts and accessors, or small macros, inline functions and templates
|
|
70
|
+
(ten or fewer lines in length), you do both of the following:
|
|
71
|
+
|
|
72
|
+
a) Give prominent notice with each copy of the object code that the
|
|
73
|
+
Library is used in it and that the Library and its use are
|
|
74
|
+
covered by this License.
|
|
75
|
+
|
|
76
|
+
b) Accompany the object code with a copy of the GNU GPL and this license
|
|
77
|
+
document.
|
|
78
|
+
|
|
79
|
+
4. Combined Works.
|
|
80
|
+
|
|
81
|
+
You may convey a Combined Work under terms of your choice that,
|
|
82
|
+
taken together, effectively do not restrict modification of the
|
|
83
|
+
portions of the Library contained in the Combined Work and reverse
|
|
84
|
+
engineering for debugging such modifications, if you also do each of
|
|
85
|
+
the following:
|
|
86
|
+
|
|
87
|
+
a) Give prominent notice with each copy of the Combined Work that
|
|
88
|
+
the Library is used in it and that the Library and its use are
|
|
89
|
+
covered by this License.
|
|
90
|
+
|
|
91
|
+
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
|
92
|
+
document.
|
|
93
|
+
|
|
94
|
+
c) For a Combined Work that displays copyright notices during
|
|
95
|
+
execution, include the copyright notice for the Library among
|
|
96
|
+
these notices, as well as a reference directing the user to the
|
|
97
|
+
copies of the GNU GPL and this license document.
|
|
98
|
+
|
|
99
|
+
d) Do one of the following:
|
|
100
|
+
|
|
101
|
+
0) Convey the Minimal Corresponding Source under the terms of this
|
|
102
|
+
License, and the Corresponding Application Code in a form
|
|
103
|
+
suitable for, and under terms that permit, the user to
|
|
104
|
+
recombine or relink the Application with a modified version of
|
|
105
|
+
the Linked Version to produce a modified Combined Work, in the
|
|
106
|
+
manner specified by section 6 of the GNU GPL for conveying
|
|
107
|
+
Corresponding Source.
|
|
108
|
+
|
|
109
|
+
1) Use a suitable shared library mechanism for linking with the
|
|
110
|
+
Library. A suitable mechanism is one that (a) uses at run time
|
|
111
|
+
a copy of the Library already present on the user's computer
|
|
112
|
+
system, and (b) will operate properly with a modified version
|
|
113
|
+
of the Library that is interface-compatible with the Linked
|
|
114
|
+
Version.
|
|
115
|
+
|
|
116
|
+
e) Provide Installation Information, but only if you would otherwise
|
|
117
|
+
be required to provide such information under section 6 of the
|
|
118
|
+
GNU GPL, and only to the extent that such information is
|
|
119
|
+
necessary to install and execute a modified version of the
|
|
120
|
+
Combined Work produced by recombining or relinking the
|
|
121
|
+
Application with a modified version of the Linked Version. (If
|
|
122
|
+
you use option 4d0, the Installation Information must accompany
|
|
123
|
+
the Minimal Corresponding Source and Corresponding Application
|
|
124
|
+
Code. If you use option 4d1, you must provide the Installation
|
|
125
|
+
Information in the manner specified by section 6 of the GNU GPL
|
|
126
|
+
for conveying Corresponding Source.)
|
|
127
|
+
|
|
128
|
+
5. Combined Libraries.
|
|
129
|
+
|
|
130
|
+
You may place library facilities that are a work based on the
|
|
131
|
+
Library side by side in a single library together with other library
|
|
132
|
+
facilities that are not Applications and are not covered by this
|
|
133
|
+
License, and convey such a combined library under terms of your
|
|
134
|
+
choice, if you do both of the following:
|
|
135
|
+
|
|
136
|
+
a) Accompany the combined library with a copy of the same work based
|
|
137
|
+
on the Library, uncombined with any other library facilities,
|
|
138
|
+
conveyed under the terms of this License.
|
|
139
|
+
|
|
140
|
+
b) Give prominent notice with the combined library that part of it
|
|
141
|
+
is a work based on the Library, and explaining where to find the
|
|
142
|
+
accompanying uncombined form of the same work.
|
|
143
|
+
|
|
144
|
+
6. Revised Versions of the GNU Lesser General Public License.
|
|
145
|
+
|
|
146
|
+
The Free Software Foundation may publish revised and/or new versions
|
|
147
|
+
of the GNU Lesser General Public License from time to time. Such new
|
|
148
|
+
versions will be similar in spirit to the present version, but may
|
|
149
|
+
differ in detail to address new problems or concerns.
|
|
150
|
+
|
|
151
|
+
Each version is given a distinguishing version number. If the
|
|
152
|
+
Library as you received it specifies that a certain numbered version
|
|
153
|
+
of the GNU Lesser General Public License "or any later version"
|
|
154
|
+
applies to it, you have the option of following the terms and
|
|
155
|
+
conditions either of that published version or of any later version
|
|
156
|
+
published by the Free Software Foundation. If the Library as you
|
|
157
|
+
received it does not specify a version number of the GNU Lesser
|
|
158
|
+
General Public License, you may choose any version of the GNU Lesser
|
|
159
|
+
General Public License ever published by the Free Software Foundation.
|
|
160
|
+
|
|
161
|
+
If the Library as you received it specifies that a proxy can decide
|
|
162
|
+
whether future versions of the GNU Lesser General Public License shall
|
|
163
|
+
apply, that proxy's public statement of acceptance of any version is
|
|
164
|
+
permanent authorization for you to choose that version for the
|
|
165
|
+
Library.
|
fastpdlc-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: fastpdlc
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Product-as-code as a validated graph — for any project.
|
|
5
|
+
Project-URL: Homepage, https://github.com/tarvitave/fastpdlc
|
|
6
|
+
Project-URL: Issues, https://github.com/tarvitave/fastpdlc/issues
|
|
7
|
+
Author: tarvitave
|
|
8
|
+
License-Expression: LGPL-3.0-or-later
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Keywords: docs-as-code,pdlc,product-as-code,product-management,validation
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: License :: OSI Approved :: GNU Lesser General Public License v3 or later (LGPLv3+)
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Topic :: Software Development :: Quality Assurance
|
|
16
|
+
Requires-Python: >=3.10
|
|
17
|
+
Requires-Dist: pydantic>=2.0
|
|
18
|
+
Requires-Dist: pyyaml>=6.0
|
|
19
|
+
Provides-Extra: dev
|
|
20
|
+
Requires-Dist: pytest>=8.0; extra == 'dev'
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
|
|
23
|
+
# FastPDLC
|
|
24
|
+
|
|
25
|
+
**Product-as-code as a validated graph — for any project.**
|
|
26
|
+
|
|
27
|
+
Your product intent — the glossary, the constraints, the business rules, the
|
|
28
|
+
features, the decisions — usually lives as hopeful markdown that quietly rots. FastPDLC
|
|
29
|
+
turns it into **code**: you declare your typed artifacts in one config file, and it
|
|
30
|
+
loads them, enforces the schema and the cross-references, compiles a JSON bundle your
|
|
31
|
+
app or docs can render, and **fails CI when the committed bundle drifts**.
|
|
32
|
+
|
|
33
|
+
It started as the product-as-code engine inside a payments platform and was extracted
|
|
34
|
+
so any team can use it.
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
pip install fastpdlc
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Quickstart
|
|
41
|
+
|
|
42
|
+
1. Describe your artifact types in `product.config.yaml`:
|
|
43
|
+
|
|
44
|
+
```yaml
|
|
45
|
+
product_dir: product
|
|
46
|
+
output: build/product.generated.json
|
|
47
|
+
types:
|
|
48
|
+
- name: terms # a glossary
|
|
49
|
+
dir: terms
|
|
50
|
+
id_prefix: "TERM-" # ids must be TERM-<slug> and match the filename
|
|
51
|
+
required: [id, term, definition]
|
|
52
|
+
fields: [term, definition, see_also]
|
|
53
|
+
references:
|
|
54
|
+
- field: see_also # every see_also must resolve to another term
|
|
55
|
+
to: terms
|
|
56
|
+
- name: rules # the durable invariants
|
|
57
|
+
dir: rules
|
|
58
|
+
id_prefix: "BR-"
|
|
59
|
+
required: [id, title, statement]
|
|
60
|
+
fields: [title, statement]
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
2. Author artifacts as markdown-with-frontmatter under `product/`:
|
|
64
|
+
|
|
65
|
+
```markdown
|
|
66
|
+
---
|
|
67
|
+
id: TERM-payment
|
|
68
|
+
term: Payment
|
|
69
|
+
definition: An instruction to move money between two parties.
|
|
70
|
+
see_also: [TERM-ledger]
|
|
71
|
+
---
|
|
72
|
+
The canonical unit of work in the system.
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
3. Build the bundle and gate it in CI:
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
fastpdlc build # -> build/product.generated.json (commit it)
|
|
79
|
+
fastpdlc validate # schema + graph + staleness; non-zero exit on errors
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## What `validate` enforces
|
|
83
|
+
|
|
84
|
+
Every finding carries a stable `PAC-NNN` code (an API — CI and dashboards match on the
|
|
85
|
+
code, never the prose):
|
|
86
|
+
|
|
87
|
+
| code | meaning |
|
|
88
|
+
|---|---|
|
|
89
|
+
| `PAC-001` | an artifact is missing a required field |
|
|
90
|
+
| `PAC-010` | an id doesn't start with its type's `id_prefix` |
|
|
91
|
+
| `PAC-011` | an id doesn't match its filename |
|
|
92
|
+
| `PAC-012` | a duplicate id within a type |
|
|
93
|
+
| `PAC-020` | a reference field doesn't resolve to a known artifact |
|
|
94
|
+
| `PAC-030` | a field value isn't in the type's allowed set (`enums`) |
|
|
95
|
+
| `PAC-060` | the committed generated bundle is missing or stale |
|
|
96
|
+
|
|
97
|
+
## Config reference
|
|
98
|
+
|
|
99
|
+
Each entry under `types`:
|
|
100
|
+
|
|
101
|
+
- **`name`** — the collection name (and the key in the bundle).
|
|
102
|
+
- **`dir`** — the subdirectory under `product_dir`.
|
|
103
|
+
- **`id_prefix`** *(optional)* — required id prefix; with **`id_matches_filename`**
|
|
104
|
+
(default `true`), the id must equal the filename stem.
|
|
105
|
+
- **`required`** — frontmatter fields that must be present and non-empty (`id` always is).
|
|
106
|
+
- **`fields`** — the fields captured into the bundle.
|
|
107
|
+
- **`enums`** — `field -> [allowed values]`.
|
|
108
|
+
- **`references`** — `[{ field, to }]`: values of `field` must be the id of a `to` artifact.
|
|
109
|
+
|
|
110
|
+
## Extending it — plugins
|
|
111
|
+
|
|
112
|
+
Real projects need more than schema: cross-file checks ("does this `links.code` path
|
|
113
|
+
exist?"), derived bundle fields (reverse edges, rollups), extra generated outputs (a
|
|
114
|
+
runtime catalogue), and their own diagnostic codes. A **plugin** registers those without
|
|
115
|
+
forking the engine — which is how a large project migrates onto FastPDLC with **no loss
|
|
116
|
+
of functionality**:
|
|
117
|
+
|
|
118
|
+
```python
|
|
119
|
+
# product_hooks.py
|
|
120
|
+
from fastpdlc import register
|
|
121
|
+
|
|
122
|
+
def register(reg):
|
|
123
|
+
register("PAC-900", "links.code path does not exist on disk")
|
|
124
|
+
|
|
125
|
+
@reg.validator
|
|
126
|
+
def code_paths_exist(bundle, config, root, report):
|
|
127
|
+
for f in bundle["features"]:
|
|
128
|
+
for path in f.get("code") or []:
|
|
129
|
+
if not (root / path).exists():
|
|
130
|
+
report.add("PAC-900", f"missing {path}", f["_file"])
|
|
131
|
+
|
|
132
|
+
@reg.bundle_transformer
|
|
133
|
+
def reverse_edges(bundle, config, root):
|
|
134
|
+
... # enrich the bundle in place
|
|
135
|
+
|
|
136
|
+
reg.extra_output("build/catalogue.json", render_catalogue) # staleness-gated too
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
```bash
|
|
140
|
+
fastpdlc -p product_hooks.py validate
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
## Start a new repo in one command
|
|
144
|
+
|
|
145
|
+
Scaffold a ready-to-go product-as-code repo (config, example artifacts, and the CI
|
|
146
|
+
gate) with the [copier](https://copier.readthedocs.io) template:
|
|
147
|
+
|
|
148
|
+
```bash
|
|
149
|
+
pipx run copier copy --trust gh:tarvitave/fastpdlc my-product-repo
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
`--trust` lets the template run `fastpdlc build` once so the new repo is valid on its
|
|
153
|
+
first commit.
|
|
154
|
+
|
|
155
|
+
## CI
|
|
156
|
+
|
|
157
|
+
Use the reusable Action — it installs FastPDLC and runs the gate:
|
|
158
|
+
|
|
159
|
+
```yaml
|
|
160
|
+
# .github/workflows/product.yml
|
|
161
|
+
name: product-as-code
|
|
162
|
+
on: [pull_request, push]
|
|
163
|
+
jobs:
|
|
164
|
+
validate:
|
|
165
|
+
runs-on: ubuntu-latest
|
|
166
|
+
steps:
|
|
167
|
+
- uses: actions/checkout@v4
|
|
168
|
+
- uses: tarvitave/fastpdlc@v0.1.0
|
|
169
|
+
with:
|
|
170
|
+
config: product.config.yaml # optional (default)
|
|
171
|
+
plugin: product_hooks.py # optional project checks
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
<details><summary>Prefer plain pip?</summary>
|
|
175
|
+
|
|
176
|
+
```yaml
|
|
177
|
+
- uses: actions/setup-python@v5
|
|
178
|
+
with: { python-version: "3.12" }
|
|
179
|
+
- run: pip install fastpdlc
|
|
180
|
+
- run: fastpdlc validate
|
|
181
|
+
```
|
|
182
|
+
</details>
|
|
183
|
+
|
|
184
|
+
## Used in production
|
|
185
|
+
|
|
186
|
+
FastPDLC is the product-as-code engine of the **pharthing / KibiPay** payments
|
|
187
|
+
platform (39 features, a concept catalogue, and a ~283 KB render bundle). pharthing's
|
|
188
|
+
CI runs `fastpdlc validate` as its sole gate via a plugin that adds domain checks — a
|
|
189
|
+
byte-identical parity test proves nothing was lost in the extraction. That's the
|
|
190
|
+
plugin system above, doing real work.
|
|
191
|
+
|
|
192
|
+
## Releasing
|
|
193
|
+
|
|
194
|
+
Publishing to PyPI is automated via GitHub Releases + Trusted Publishing — see
|
|
195
|
+
[RELEASING.md](RELEASING.md).
|
|
196
|
+
|
|
197
|
+
## License
|
|
198
|
+
|
|
199
|
+
LGPL-3.0-or-later (copyleft, but you can import it as a library without your project inheriting the licence). See [LICENSE](LICENSE).
|
fastpdlc-0.1.0/README.md
ADDED
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
# FastPDLC
|
|
2
|
+
|
|
3
|
+
**Product-as-code as a validated graph — for any project.**
|
|
4
|
+
|
|
5
|
+
Your product intent — the glossary, the constraints, the business rules, the
|
|
6
|
+
features, the decisions — usually lives as hopeful markdown that quietly rots. FastPDLC
|
|
7
|
+
turns it into **code**: you declare your typed artifacts in one config file, and it
|
|
8
|
+
loads them, enforces the schema and the cross-references, compiles a JSON bundle your
|
|
9
|
+
app or docs can render, and **fails CI when the committed bundle drifts**.
|
|
10
|
+
|
|
11
|
+
It started as the product-as-code engine inside a payments platform and was extracted
|
|
12
|
+
so any team can use it.
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
pip install fastpdlc
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Quickstart
|
|
19
|
+
|
|
20
|
+
1. Describe your artifact types in `product.config.yaml`:
|
|
21
|
+
|
|
22
|
+
```yaml
|
|
23
|
+
product_dir: product
|
|
24
|
+
output: build/product.generated.json
|
|
25
|
+
types:
|
|
26
|
+
- name: terms # a glossary
|
|
27
|
+
dir: terms
|
|
28
|
+
id_prefix: "TERM-" # ids must be TERM-<slug> and match the filename
|
|
29
|
+
required: [id, term, definition]
|
|
30
|
+
fields: [term, definition, see_also]
|
|
31
|
+
references:
|
|
32
|
+
- field: see_also # every see_also must resolve to another term
|
|
33
|
+
to: terms
|
|
34
|
+
- name: rules # the durable invariants
|
|
35
|
+
dir: rules
|
|
36
|
+
id_prefix: "BR-"
|
|
37
|
+
required: [id, title, statement]
|
|
38
|
+
fields: [title, statement]
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
2. Author artifacts as markdown-with-frontmatter under `product/`:
|
|
42
|
+
|
|
43
|
+
```markdown
|
|
44
|
+
---
|
|
45
|
+
id: TERM-payment
|
|
46
|
+
term: Payment
|
|
47
|
+
definition: An instruction to move money between two parties.
|
|
48
|
+
see_also: [TERM-ledger]
|
|
49
|
+
---
|
|
50
|
+
The canonical unit of work in the system.
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
3. Build the bundle and gate it in CI:
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
fastpdlc build # -> build/product.generated.json (commit it)
|
|
57
|
+
fastpdlc validate # schema + graph + staleness; non-zero exit on errors
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## What `validate` enforces
|
|
61
|
+
|
|
62
|
+
Every finding carries a stable `PAC-NNN` code (an API — CI and dashboards match on the
|
|
63
|
+
code, never the prose):
|
|
64
|
+
|
|
65
|
+
| code | meaning |
|
|
66
|
+
|---|---|
|
|
67
|
+
| `PAC-001` | an artifact is missing a required field |
|
|
68
|
+
| `PAC-010` | an id doesn't start with its type's `id_prefix` |
|
|
69
|
+
| `PAC-011` | an id doesn't match its filename |
|
|
70
|
+
| `PAC-012` | a duplicate id within a type |
|
|
71
|
+
| `PAC-020` | a reference field doesn't resolve to a known artifact |
|
|
72
|
+
| `PAC-030` | a field value isn't in the type's allowed set (`enums`) |
|
|
73
|
+
| `PAC-060` | the committed generated bundle is missing or stale |
|
|
74
|
+
|
|
75
|
+
## Config reference
|
|
76
|
+
|
|
77
|
+
Each entry under `types`:
|
|
78
|
+
|
|
79
|
+
- **`name`** — the collection name (and the key in the bundle).
|
|
80
|
+
- **`dir`** — the subdirectory under `product_dir`.
|
|
81
|
+
- **`id_prefix`** *(optional)* — required id prefix; with **`id_matches_filename`**
|
|
82
|
+
(default `true`), the id must equal the filename stem.
|
|
83
|
+
- **`required`** — frontmatter fields that must be present and non-empty (`id` always is).
|
|
84
|
+
- **`fields`** — the fields captured into the bundle.
|
|
85
|
+
- **`enums`** — `field -> [allowed values]`.
|
|
86
|
+
- **`references`** — `[{ field, to }]`: values of `field` must be the id of a `to` artifact.
|
|
87
|
+
|
|
88
|
+
## Extending it — plugins
|
|
89
|
+
|
|
90
|
+
Real projects need more than schema: cross-file checks ("does this `links.code` path
|
|
91
|
+
exist?"), derived bundle fields (reverse edges, rollups), extra generated outputs (a
|
|
92
|
+
runtime catalogue), and their own diagnostic codes. A **plugin** registers those without
|
|
93
|
+
forking the engine — which is how a large project migrates onto FastPDLC with **no loss
|
|
94
|
+
of functionality**:
|
|
95
|
+
|
|
96
|
+
```python
|
|
97
|
+
# product_hooks.py
|
|
98
|
+
from fastpdlc import register
|
|
99
|
+
|
|
100
|
+
def register(reg):
|
|
101
|
+
register("PAC-900", "links.code path does not exist on disk")
|
|
102
|
+
|
|
103
|
+
@reg.validator
|
|
104
|
+
def code_paths_exist(bundle, config, root, report):
|
|
105
|
+
for f in bundle["features"]:
|
|
106
|
+
for path in f.get("code") or []:
|
|
107
|
+
if not (root / path).exists():
|
|
108
|
+
report.add("PAC-900", f"missing {path}", f["_file"])
|
|
109
|
+
|
|
110
|
+
@reg.bundle_transformer
|
|
111
|
+
def reverse_edges(bundle, config, root):
|
|
112
|
+
... # enrich the bundle in place
|
|
113
|
+
|
|
114
|
+
reg.extra_output("build/catalogue.json", render_catalogue) # staleness-gated too
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
fastpdlc -p product_hooks.py validate
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
## Start a new repo in one command
|
|
122
|
+
|
|
123
|
+
Scaffold a ready-to-go product-as-code repo (config, example artifacts, and the CI
|
|
124
|
+
gate) with the [copier](https://copier.readthedocs.io) template:
|
|
125
|
+
|
|
126
|
+
```bash
|
|
127
|
+
pipx run copier copy --trust gh:tarvitave/fastpdlc my-product-repo
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
`--trust` lets the template run `fastpdlc build` once so the new repo is valid on its
|
|
131
|
+
first commit.
|
|
132
|
+
|
|
133
|
+
## CI
|
|
134
|
+
|
|
135
|
+
Use the reusable Action — it installs FastPDLC and runs the gate:
|
|
136
|
+
|
|
137
|
+
```yaml
|
|
138
|
+
# .github/workflows/product.yml
|
|
139
|
+
name: product-as-code
|
|
140
|
+
on: [pull_request, push]
|
|
141
|
+
jobs:
|
|
142
|
+
validate:
|
|
143
|
+
runs-on: ubuntu-latest
|
|
144
|
+
steps:
|
|
145
|
+
- uses: actions/checkout@v4
|
|
146
|
+
- uses: tarvitave/fastpdlc@v0.1.0
|
|
147
|
+
with:
|
|
148
|
+
config: product.config.yaml # optional (default)
|
|
149
|
+
plugin: product_hooks.py # optional project checks
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
<details><summary>Prefer plain pip?</summary>
|
|
153
|
+
|
|
154
|
+
```yaml
|
|
155
|
+
- uses: actions/setup-python@v5
|
|
156
|
+
with: { python-version: "3.12" }
|
|
157
|
+
- run: pip install fastpdlc
|
|
158
|
+
- run: fastpdlc validate
|
|
159
|
+
```
|
|
160
|
+
</details>
|
|
161
|
+
|
|
162
|
+
## Used in production
|
|
163
|
+
|
|
164
|
+
FastPDLC is the product-as-code engine of the **pharthing / KibiPay** payments
|
|
165
|
+
platform (39 features, a concept catalogue, and a ~283 KB render bundle). pharthing's
|
|
166
|
+
CI runs `fastpdlc validate` as its sole gate via a plugin that adds domain checks — a
|
|
167
|
+
byte-identical parity test proves nothing was lost in the extraction. That's the
|
|
168
|
+
plugin system above, doing real work.
|
|
169
|
+
|
|
170
|
+
## Releasing
|
|
171
|
+
|
|
172
|
+
Publishing to PyPI is automated via GitHub Releases + Trusted Publishing — see
|
|
173
|
+
[RELEASING.md](RELEASING.md).
|
|
174
|
+
|
|
175
|
+
## License
|
|
176
|
+
|
|
177
|
+
LGPL-3.0-or-later (copyleft, but you can import it as a library without your project inheriting the licence). See [LICENSE](LICENSE).
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# Releasing FastPDLC
|
|
2
|
+
|
|
3
|
+
Publishing is automated: `.github/workflows/publish.yml` builds and uploads to PyPI
|
|
4
|
+
when a GitHub Release is published. Auth is **PyPI Trusted Publishing (OIDC)** — no
|
|
5
|
+
API token is stored in the repo or in Actions secrets.
|
|
6
|
+
|
|
7
|
+
## One-time PyPI setup
|
|
8
|
+
|
|
9
|
+
Do this once, before the first release. It's the only manual step.
|
|
10
|
+
|
|
11
|
+
1. Log in at <https://pypi.org>.
|
|
12
|
+
2. Reserve the project name by creating a **pending publisher** (no upload needed
|
|
13
|
+
first): go to <https://pypi.org/manage/account/publishing/> → *Add a pending
|
|
14
|
+
publisher* and fill in:
|
|
15
|
+
- **PyPI project name:** `fastpdlc`
|
|
16
|
+
- **Owner:** `tarvitave`
|
|
17
|
+
- **Repository name:** `fastpdlc`
|
|
18
|
+
- **Workflow name:** `publish.yml`
|
|
19
|
+
- **Environment name:** `pypi`
|
|
20
|
+
3. (Recommended) In the GitHub repo, create an **Environment** named `pypi`
|
|
21
|
+
(Settings → Environments) so the publish job's `environment: pypi` resolves and
|
|
22
|
+
you can add release protection rules later.
|
|
23
|
+
|
|
24
|
+
That's it — no `PYPI_API_TOKEN`, no `twine` credentials.
|
|
25
|
+
|
|
26
|
+
## Cutting a release
|
|
27
|
+
|
|
28
|
+
1. Bump `version` in `pyproject.toml` (and note changes).
|
|
29
|
+
2. Commit, tag, and push:
|
|
30
|
+
```bash
|
|
31
|
+
git commit -am "release: vX.Y.Z"
|
|
32
|
+
git tag vX.Y.Z
|
|
33
|
+
git push --follow-tags
|
|
34
|
+
```
|
|
35
|
+
3. Publish a **GitHub Release** from that tag (`gh release create vX.Y.Z --generate-notes`).
|
|
36
|
+
That fires `publish.yml`, which asserts the tag matches `pyproject.toml`'s version,
|
|
37
|
+
builds the sdist + wheel, and uploads to PyPI via OIDC.
|
|
38
|
+
4. Verify: `pip install fastpdlc==X.Y.Z`.
|
|
39
|
+
|
|
40
|
+
## Versioning
|
|
41
|
+
|
|
42
|
+
FastPDLC follows semver. Diagnostic **codes are API** — never renumber an existing
|
|
43
|
+
`PAC-NNN` (retire and add). Changing the JSON bundle shape, a config key, or the
|
|
44
|
+
plugin `Registry` surface is a breaking change → bump the major.
|