reqstool-python-decorators 0.1.0__tar.gz → 1.0.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.
- reqstool_python_decorators-1.0.0/.claude/settings.json +15 -0
- reqstool_python_decorators-1.0.0/.github/workflows/build-docs.yml +18 -0
- reqstool_python_decorators-1.0.0/.github/workflows/build.yml +95 -0
- {reqstool_python_decorators-0.1.0 → reqstool_python_decorators-1.0.0}/.github/workflows/check-semantic-pr.yml +4 -1
- {reqstool_python_decorators-0.1.0 → reqstool_python_decorators-1.0.0}/.github/workflows/lint.yml +8 -4
- reqstool_python_decorators-1.0.0/.github/workflows/release.yml +139 -0
- {reqstool_python_decorators-0.1.0 → reqstool_python_decorators-1.0.0}/.gitignore +2 -1
- reqstool_python_decorators-1.0.0/.mcp.json +8 -0
- reqstool_python_decorators-1.0.0/.reqstool-ai.yaml +32 -0
- reqstool_python_decorators-1.0.0/CONTRIBUTING.md +39 -0
- {reqstool_python_decorators-0.1.0 → reqstool_python_decorators-1.0.0}/PKG-INFO +1 -1
- reqstool_python_decorators-1.0.0/docs/reqstool/reqstool_config.yml +11 -0
- reqstool_python_decorators-1.0.0/docs/reqstool/requirements.yml +45 -0
- reqstool_python_decorators-1.0.0/docs/reqstool/software_verification_cases.yml +20 -0
- reqstool_python_decorators-1.0.0/openspec/openspecui.hooks.ts +108 -0
- reqstool_python_decorators-1.0.0/openspec/specs/decorator-definitions/spec.md +15 -0
- reqstool_python_decorators-1.0.0/openspec/specs/decorator-processing/spec.md +15 -0
- reqstool_python_decorators-1.0.0/openspec/specs/yaml-export/spec.md +15 -0
- reqstool_python_decorators-1.0.0/scripts/generate_annotations.py +17 -0
- {reqstool_python_decorators-0.1.0 → reqstool_python_decorators-1.0.0}/src/reqstool_python_decorators/decorators/decorators.py +6 -0
- {reqstool_python_decorators-0.1.0 → reqstool_python_decorators-1.0.0}/src/reqstool_python_decorators/processors/decorator_processor.py +9 -0
- reqstool_python_decorators-1.0.0/tests/e2e/reqstool_decorators/test_process_e2e.py +46 -0
- {reqstool_python_decorators-0.1.0 → reqstool_python_decorators-1.0.0}/tests/unit/reqstool_decorators/processors/test_processors.py +24 -0
- reqstool_python_decorators-1.0.0/tests/unit/reqstool_decorators/test_decorators.py +68 -0
- reqstool_python_decorators-0.1.0/.github/workflows/build.yml +0 -42
- reqstool_python_decorators-0.1.0/.github/workflows/check_release.yml +0 -11
- reqstool_python_decorators-0.1.0/.github/workflows/publish_pypi_prod.yml +0 -37
- reqstool_python_decorators-0.1.0/.github/workflows/publish_pypi_test.yml +0 -35
- reqstool_python_decorators-0.1.0/CONTRIBUTING.md +0 -25
- reqstool_python_decorators-0.1.0/tests/unit/reqstool_decorators/test_decorators.py +0 -59
- {reqstool_python_decorators-0.1.0 → reqstool_python_decorators-1.0.0}/.python-version +0 -0
- {reqstool_python_decorators-0.1.0 → reqstool_python_decorators-1.0.0}/LICENSE +0 -0
- {reqstool_python_decorators-0.1.0 → reqstool_python_decorators-1.0.0}/README.md +0 -0
- {reqstool_python_decorators-0.1.0 → reqstool_python_decorators-1.0.0}/docs/antora-playbook.yml +0 -0
- {reqstool_python_decorators-0.1.0 → reqstool_python_decorators-1.0.0}/docs/antora.yml +0 -0
- {reqstool_python_decorators-0.1.0 → reqstool_python_decorators-1.0.0}/docs/modules/ROOT/nav.adoc +0 -0
- {reqstool_python_decorators-0.1.0 → reqstool_python_decorators-1.0.0}/docs/modules/ROOT/pages/index.adoc +0 -0
- {reqstool_python_decorators-0.1.0 → reqstool_python_decorators-1.0.0}/docs/modules/ROOT/pages/installation.adoc +0 -0
- {reqstool_python_decorators-0.1.0 → reqstool_python_decorators-1.0.0}/docs/modules/ROOT/pages/usage.adoc +0 -0
- {reqstool_python_decorators-0.1.0 → reqstool_python_decorators-1.0.0}/pyproject.toml +0 -0
- {reqstool_python_decorators-0.1.0 → reqstool_python_decorators-1.0.0}/renovate.json5 +0 -0
- {reqstool_python_decorators-0.1.0 → reqstool_python_decorators-1.0.0}/src/reqstool_python_decorators/__init__.py +0 -0
- {reqstool_python_decorators-0.1.0 → reqstool_python_decorators-1.0.0}/src/reqstool_python_decorators/decorators/__init__.py +0 -0
- {reqstool_python_decorators-0.1.0 → reqstool_python_decorators-1.0.0}/src/reqstool_python_decorators/processors/__init__.py +0 -0
- {reqstool_python_decorators-0.1.0 → reqstool_python_decorators-1.0.0}/tests/e2e/__init__.py +0 -0
- {reqstool_python_decorators-0.1.0 → reqstool_python_decorators-1.0.0}/tests/e2e/reqstool_decorators/__init__.py +0 -0
- {reqstool_python_decorators-0.1.0 → reqstool_python_decorators-1.0.0}/tests/integration/__init__.py +0 -0
- {reqstool_python_decorators-0.1.0 → reqstool_python_decorators-1.0.0}/tests/integration/reqstool_decorators/__init__.py +0 -0
- {reqstool_python_decorators-0.1.0 → reqstool_python_decorators-1.0.0}/tests/resources/test_decorators/requirements_decorators.py +0 -0
- {reqstool_python_decorators-0.1.0 → reqstool_python_decorators-1.0.0}/tests/resources/test_decorators/svc_decorators.py +0 -0
- {reqstool_python_decorators-0.1.0 → reqstool_python_decorators-1.0.0}/tests/unit/conftest.py +0 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extraKnownMarketplaces": {
|
|
3
|
+
"reqstool-ai": {
|
|
4
|
+
"source": {
|
|
5
|
+
"source": "github",
|
|
6
|
+
"repo": "reqstool/reqstool-ai"
|
|
7
|
+
},
|
|
8
|
+
"autoUpdate": true
|
|
9
|
+
}
|
|
10
|
+
},
|
|
11
|
+
"enabledPlugins": {
|
|
12
|
+
"reqstool@reqstool-ai": true,
|
|
13
|
+
"reqstool-openspec@reqstool-ai": true
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
name: Build Docs
|
|
2
|
+
on:
|
|
3
|
+
workflow_dispatch:
|
|
4
|
+
pull_request:
|
|
5
|
+
paths:
|
|
6
|
+
- "docs/**"
|
|
7
|
+
push:
|
|
8
|
+
branches:
|
|
9
|
+
- main
|
|
10
|
+
paths:
|
|
11
|
+
- "docs/**"
|
|
12
|
+
|
|
13
|
+
permissions:
|
|
14
|
+
contents: read
|
|
15
|
+
|
|
16
|
+
jobs:
|
|
17
|
+
build:
|
|
18
|
+
uses: reqstool/.github/.github/workflows/common-build-docs.yml@a4203a58cec87861655512b6b277a859db385796 # 1.1.0
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
name: Build PyPI
|
|
2
|
+
on:
|
|
3
|
+
workflow_call:
|
|
4
|
+
inputs:
|
|
5
|
+
ref:
|
|
6
|
+
description: "Branch, tag or SHA to build. Empty = the caller's ref."
|
|
7
|
+
required: false
|
|
8
|
+
type: string
|
|
9
|
+
default: ""
|
|
10
|
+
artifact-name:
|
|
11
|
+
description: >
|
|
12
|
+
Name to upload the build output under. The release flow runs this
|
|
13
|
+
workflow twice in one run -- once on the branch, once on the tag -- and
|
|
14
|
+
upload-artifact rejects a duplicate name.
|
|
15
|
+
required: false
|
|
16
|
+
type: string
|
|
17
|
+
default: "dist"
|
|
18
|
+
workflow_dispatch:
|
|
19
|
+
push:
|
|
20
|
+
branches:
|
|
21
|
+
- main
|
|
22
|
+
pull_request:
|
|
23
|
+
types:
|
|
24
|
+
- opened
|
|
25
|
+
- reopened
|
|
26
|
+
- synchronize
|
|
27
|
+
|
|
28
|
+
permissions:
|
|
29
|
+
contents: read
|
|
30
|
+
|
|
31
|
+
jobs:
|
|
32
|
+
linting:
|
|
33
|
+
name: Reuse linting job
|
|
34
|
+
uses: ./.github/workflows/lint.yml
|
|
35
|
+
|
|
36
|
+
build:
|
|
37
|
+
needs: linting
|
|
38
|
+
runs-on: ubuntu-latest
|
|
39
|
+
strategy:
|
|
40
|
+
fail-fast: false
|
|
41
|
+
matrix:
|
|
42
|
+
reqstool-source: [pypi, main]
|
|
43
|
+
steps:
|
|
44
|
+
# Full history and tags: hatch-vcs derives the version from git state, so a
|
|
45
|
+
# shallow clone would build the wrong number rather than fail.
|
|
46
|
+
- name: Check out source repository
|
|
47
|
+
uses: actions/checkout@v7.0.1
|
|
48
|
+
with:
|
|
49
|
+
persist-credentials: false
|
|
50
|
+
fetch-depth: 0
|
|
51
|
+
fetch-tags: true
|
|
52
|
+
ref: ${{ inputs.ref || github.ref }}
|
|
53
|
+
- name: Set up Python
|
|
54
|
+
uses: actions/setup-python@v7.1.0
|
|
55
|
+
with:
|
|
56
|
+
python-version: "3.13.17"
|
|
57
|
+
- name: Install dependencies
|
|
58
|
+
# renovate: datasource=pypi depName=hatch
|
|
59
|
+
run: pip install hatch==1.18.1
|
|
60
|
+
- name: Run tests
|
|
61
|
+
run: hatch run dev:pytest --junitxml=build/junit.xml --cov=reqstool_python_decorators --cov-report=xml:build/coverage.xml
|
|
62
|
+
- name: Build project
|
|
63
|
+
run: hatch build
|
|
64
|
+
- name: Self-apply own decorator processor to own src/tests
|
|
65
|
+
# Relies on `hatch build` (above) not cleaning build/ -- annotations.yml lands
|
|
66
|
+
# alongside the junit/coverage output from the "Run tests" step, and
|
|
67
|
+
# reqstool_config.yml expects to find both there. If hatch build ever starts
|
|
68
|
+
# cleaning build/, move the pytest output dir outside of it.
|
|
69
|
+
run: hatch run dev:python scripts/generate_annotations.py
|
|
70
|
+
- name: Install reqstool
|
|
71
|
+
uses: reqstool/.github/.github/actions/install-reqstool@a4203a58cec87861655512b6b277a859db385796 # 1.1.0
|
|
72
|
+
with:
|
|
73
|
+
reqstool-source: ${{ matrix.reqstool-source }}
|
|
74
|
+
- name: Validate reqstool spec completeness
|
|
75
|
+
# not yet available in the latest PyPI release; supplementary to (not a
|
|
76
|
+
# replacement for) the `reqstool status --fail-if-incomplete` gate below, which
|
|
77
|
+
# is the actual required check on the pypi leg
|
|
78
|
+
if: matrix.reqstool-source == 'main'
|
|
79
|
+
uses: reqstool/.github/.github/actions/validate-reqstool@a4203a58cec87861655512b6b277a859db385796 # 1.1.0
|
|
80
|
+
- name: Run reqstool status
|
|
81
|
+
# Required gate on both matrix legs -- fails the build unless every
|
|
82
|
+
# requirement is implemented and verified.
|
|
83
|
+
uses: reqstool/.github/.github/actions/reqstool-status@a4203a58cec87861655512b6b277a859db385796 # 1.1.0
|
|
84
|
+
with:
|
|
85
|
+
fail-if-incomplete: "true"
|
|
86
|
+
# Upload artifacts for later use
|
|
87
|
+
- name: Upload Artifacts
|
|
88
|
+
if: matrix.reqstool-source == 'pypi'
|
|
89
|
+
uses: actions/upload-artifact@v7.0.2
|
|
90
|
+
with:
|
|
91
|
+
name: ${{ inputs.artifact-name || 'dist' }}
|
|
92
|
+
path: dist/
|
|
93
|
+
|
|
94
|
+
validate-openspec:
|
|
95
|
+
uses: reqstool/.github/.github/workflows/common-validate-openspec.yml@a4203a58cec87861655512b6b277a859db385796 # 1.1.0
|
|
@@ -5,6 +5,9 @@ on:
|
|
|
5
5
|
pull_request_target:
|
|
6
6
|
types: [opened, edited, synchronize, reopened]
|
|
7
7
|
|
|
8
|
+
permissions:
|
|
9
|
+
pull-requests: read
|
|
10
|
+
|
|
8
11
|
jobs:
|
|
9
12
|
check:
|
|
10
|
-
uses: reqstool/.github/.github/workflows/check-semantic-pr.yml@
|
|
13
|
+
uses: reqstool/.github/.github/workflows/common-check-semantic-pr.yml@a4203a58cec87861655512b6b277a859db385796 # 1.1.0
|
{reqstool_python_decorators-0.1.0 → reqstool_python_decorators-1.0.0}/.github/workflows/lint.yml
RENAMED
|
@@ -3,18 +3,22 @@ on:
|
|
|
3
3
|
workflow_dispatch:
|
|
4
4
|
workflow_call:
|
|
5
5
|
|
|
6
|
+
permissions:
|
|
7
|
+
contents: read
|
|
8
|
+
|
|
6
9
|
jobs:
|
|
7
10
|
linting:
|
|
8
11
|
runs-on: ubuntu-latest
|
|
9
12
|
steps:
|
|
10
13
|
- name: Check out source repository
|
|
11
|
-
uses: actions/checkout@
|
|
14
|
+
uses: actions/checkout@v7.0.1
|
|
12
15
|
- name: Set up Python
|
|
13
|
-
uses: actions/setup-python@
|
|
16
|
+
uses: actions/setup-python@v7.1.0
|
|
14
17
|
with:
|
|
15
|
-
python-version: "3.13"
|
|
18
|
+
python-version: "3.13.17"
|
|
16
19
|
- name: Install pip package(s)
|
|
17
|
-
|
|
20
|
+
# renovate: datasource=pypi depName=hatch
|
|
21
|
+
run: pip install hatch==1.18.1
|
|
18
22
|
- name: Run black formatter check
|
|
19
23
|
run: hatch run dev:black --check --verbose src tests
|
|
20
24
|
- name: Run flake8 linter
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
name: Release
|
|
2
|
+
|
|
3
|
+
# The whole release, start to finish. See RELEASING.md in reqstool/.github for
|
|
4
|
+
# what each step does, and for why the release is created as a prerelease rather
|
|
5
|
+
# than a draft.
|
|
6
|
+
|
|
7
|
+
on:
|
|
8
|
+
workflow_dispatch:
|
|
9
|
+
inputs:
|
|
10
|
+
version:
|
|
11
|
+
description: "Version to release (PEP 440, no v prefix), e.g. 0.2.0. Leave empty to auto-detect from Conventional Commits."
|
|
12
|
+
required: false
|
|
13
|
+
type: string
|
|
14
|
+
prerelease:
|
|
15
|
+
description: "Publish as a release candidate instead of a release: verified like any release, but never promoted to latest. The number is chosen for you (0.2.0 -> 0.2.0rc1, then the next)."
|
|
16
|
+
required: false
|
|
17
|
+
type: choice
|
|
18
|
+
options: [none, rc, b, a]
|
|
19
|
+
default: none
|
|
20
|
+
ref:
|
|
21
|
+
description: "Branch to release from. Leave empty for the branch this workflow was dispatched on."
|
|
22
|
+
required: false
|
|
23
|
+
type: string
|
|
24
|
+
force:
|
|
25
|
+
description: "Allow a version that disagrees with the auto-detected one."
|
|
26
|
+
required: false
|
|
27
|
+
type: boolean
|
|
28
|
+
default: false
|
|
29
|
+
dry-run:
|
|
30
|
+
description: "Validate and preview only -- nothing tagged, nothing published."
|
|
31
|
+
required: false
|
|
32
|
+
type: boolean
|
|
33
|
+
default: true
|
|
34
|
+
|
|
35
|
+
concurrency:
|
|
36
|
+
group: release
|
|
37
|
+
cancel-in-progress: false
|
|
38
|
+
|
|
39
|
+
permissions:
|
|
40
|
+
contents: read
|
|
41
|
+
|
|
42
|
+
jobs:
|
|
43
|
+
prepare:
|
|
44
|
+
uses: reqstool/.github/.github/workflows/common-release-prepare.yml@a4203a58cec87861655512b6b277a859db385796 # 1.1.0
|
|
45
|
+
permissions:
|
|
46
|
+
contents: read
|
|
47
|
+
with:
|
|
48
|
+
version-format: pep440
|
|
49
|
+
version: ${{ inputs.version }}
|
|
50
|
+
prerelease: ${{ inputs.prerelease }}
|
|
51
|
+
ref: ${{ inputs.ref }}
|
|
52
|
+
force: ${{ inputs.force }}
|
|
53
|
+
dry-run: ${{ inputs.dry-run }}
|
|
54
|
+
|
|
55
|
+
# The same checks that guard main, called rather than reimplemented, and run
|
|
56
|
+
# before the approval gate so the reviewer approves something already green
|
|
57
|
+
# rather than a version string.
|
|
58
|
+
checks:
|
|
59
|
+
needs: prepare
|
|
60
|
+
if: ${{ !inputs.dry-run }}
|
|
61
|
+
uses: ./.github/workflows/build.yml
|
|
62
|
+
permissions:
|
|
63
|
+
contents: read
|
|
64
|
+
|
|
65
|
+
# THE APPROVAL GATE -- bound to the `stable` environment, so it sits pending
|
|
66
|
+
# until a required reviewer approves it on the run page.
|
|
67
|
+
tag:
|
|
68
|
+
needs: [prepare, checks]
|
|
69
|
+
if: ${{ !inputs.dry-run }}
|
|
70
|
+
uses: reqstool/.github/.github/workflows/common-release-tag.yml@a4203a58cec87861655512b6b277a859db385796 # 1.1.0
|
|
71
|
+
permissions:
|
|
72
|
+
contents: write
|
|
73
|
+
with:
|
|
74
|
+
version: ${{ needs.prepare.outputs.version }}
|
|
75
|
+
version-format: pep440
|
|
76
|
+
ref: ${{ inputs.ref }}
|
|
77
|
+
|
|
78
|
+
# Rebuilt from the tag, which is what gives the artifacts their version:
|
|
79
|
+
# hatch-vcs reads it from git rather than from a version string in the tree.
|
|
80
|
+
build-tagged:
|
|
81
|
+
needs: [prepare, tag]
|
|
82
|
+
uses: ./.github/workflows/build.yml
|
|
83
|
+
permissions:
|
|
84
|
+
contents: read
|
|
85
|
+
with:
|
|
86
|
+
ref: ${{ needs.prepare.outputs.version }}
|
|
87
|
+
artifact-name: dist-tagged
|
|
88
|
+
|
|
89
|
+
assets:
|
|
90
|
+
needs: [prepare, build-tagged]
|
|
91
|
+
uses: reqstool/.github/.github/workflows/common-release-assets.yml@a4203a58cec87861655512b6b277a859db385796 # 1.1.0
|
|
92
|
+
permissions:
|
|
93
|
+
contents: write
|
|
94
|
+
with:
|
|
95
|
+
version: ${{ needs.prepare.outputs.version }}
|
|
96
|
+
artifact: dist-tagged
|
|
97
|
+
|
|
98
|
+
# PyPI is the only step here that cannot be undone: a version can be yanked but
|
|
99
|
+
# never replaced. Publishes release candidates too, with their pre-release
|
|
100
|
+
# identifier -- pip ignores them without --pre, so there is nothing unsafe
|
|
101
|
+
# about it landing on the real index; there is no separate staging index to
|
|
102
|
+
# route them to instead. Matches npm and Maven Central's existing behavior.
|
|
103
|
+
publish-to-pypi:
|
|
104
|
+
needs: [prepare, assets]
|
|
105
|
+
runs-on: ubuntu-latest
|
|
106
|
+
environment:
|
|
107
|
+
name: stable
|
|
108
|
+
url: https://pypi.org
|
|
109
|
+
permissions:
|
|
110
|
+
id-token: write
|
|
111
|
+
steps:
|
|
112
|
+
- uses: reqstool/.github/.github/actions/download-dists@a4203a58cec87861655512b6b277a859db385796 # 1.1.0
|
|
113
|
+
with:
|
|
114
|
+
artifact: dist-tagged
|
|
115
|
+
# Inline, not inside download-dists: nesting this Docker action in a
|
|
116
|
+
# composite action makes GitHub resolve its image against the wrapper's
|
|
117
|
+
# repo. See reqstool/.github#95.
|
|
118
|
+
- uses: pypa/gh-action-pypi-publish@7245906fb61fa33a13554f9d5fb856fe61758086 # v1.14.3
|
|
119
|
+
with:
|
|
120
|
+
attestations: true
|
|
121
|
+
|
|
122
|
+
# Last, deliberately. Everything above can fail, and until this runs nothing
|
|
123
|
+
# resolving "the latest release" can see what was built -- the release is still
|
|
124
|
+
# a prerelease. Promotion itself is one API call against a release that already
|
|
125
|
+
# has its artifacts.
|
|
126
|
+
#
|
|
127
|
+
# The guard is `no job failed`, not the default `every job succeeded`: on a dry
|
|
128
|
+
# run every job above is skipped, which would make plain success() false too --
|
|
129
|
+
# `!inputs.dry-run` is what actually gates this job then, and `no job failed`
|
|
130
|
+
# is what confirms nothing above it errored on a real run.
|
|
131
|
+
promote:
|
|
132
|
+
needs: [prepare, assets, publish-to-pypi]
|
|
133
|
+
if: ${{ !inputs.dry-run && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') }}
|
|
134
|
+
uses: reqstool/.github/.github/workflows/common-release-promote.yml@a4203a58cec87861655512b6b277a859db385796 # 1.1.0
|
|
135
|
+
permissions:
|
|
136
|
+
contents: write
|
|
137
|
+
with:
|
|
138
|
+
version: ${{ needs.prepare.outputs.version }}
|
|
139
|
+
prerelease: ${{ needs.prepare.outputs.prerelease == 'true' }}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# reqstool-ai configuration
|
|
2
|
+
#
|
|
3
|
+
# This file tells reqstool-ai skills where to find your reqstool files
|
|
4
|
+
# and how to generate IDs for new requirements and SVCs.
|
|
5
|
+
#
|
|
6
|
+
# Place this file at: .reqstool-ai.yaml (project root)
|
|
7
|
+
|
|
8
|
+
# Project URN — matches the urn in your reqstool YAML files
|
|
9
|
+
urn: reqstool-python-decorators
|
|
10
|
+
|
|
11
|
+
# Revision string for new requirements and SVCs
|
|
12
|
+
revision: "0.1.0"
|
|
13
|
+
|
|
14
|
+
# System-level reqstool directory (contains the SSOT requirements and SVCs)
|
|
15
|
+
system:
|
|
16
|
+
path: docs/reqstool
|
|
17
|
+
|
|
18
|
+
# Subproject modules — each module imports a subset of requirements/SVCs via filters
|
|
19
|
+
#
|
|
20
|
+
# Required fields per module:
|
|
21
|
+
# path — path to the module's reqstool directory (contains filter files)
|
|
22
|
+
# req_prefix — prefix for requirement IDs belonging to this module (e.g., CORE_)
|
|
23
|
+
# svc_prefix — prefix for SVC IDs belonging to this module (e.g., SVC_CORE_)
|
|
24
|
+
#
|
|
25
|
+
# Add as many modules as your project has. The module name (key) is used in
|
|
26
|
+
# commands like `/reqstool:status core` and `/reqstool:add-req core`.
|
|
27
|
+
modules:
|
|
28
|
+
# Matches the existing DECORATORS_NNN / SVC_DECORATORS_NNN ID convention.
|
|
29
|
+
decorators:
|
|
30
|
+
path: docs/reqstool
|
|
31
|
+
req_prefix: "DECORATORS_"
|
|
32
|
+
svc_prefix: "SVC_DECORATORS_"
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# Contributing to reqstool-python-decorators
|
|
2
|
+
|
|
3
|
+
Thank you for your interest in contributing!
|
|
4
|
+
|
|
5
|
+
For DCO sign-off, commit conventions, and code review process, see the organization-wide [CONTRIBUTING.md](https://github.com/reqstool/.github/blob/main/CONTRIBUTING.md).
|
|
6
|
+
|
|
7
|
+
## Prerequisites
|
|
8
|
+
|
|
9
|
+
- Python 3.13+
|
|
10
|
+
- [Hatch](https://hatch.pypa.io/) (`pip install hatch`)
|
|
11
|
+
- [reqstool](https://github.com/reqstool/reqstool-client) (`pipx install reqstool`)
|
|
12
|
+
- [OpenSpec](https://github.com/Fission-AI/OpenSpec) (`npm install -g @fission-ai/openspec`)
|
|
13
|
+
|
|
14
|
+
## Setup
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
git clone https://github.com/reqstool/reqstool-python-decorators.git
|
|
18
|
+
cd reqstool-python-decorators
|
|
19
|
+
hatch env create
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
If using Claude Code, opening this repo will prompt you to confirm adding the `reqstool-ai`
|
|
23
|
+
marketplace and enabling the `reqstool`/`reqstool-openspec` plugins (configured in
|
|
24
|
+
`.claude/settings.json`) — accept the prompt.
|
|
25
|
+
|
|
26
|
+
Then regenerate the `opsx` slash commands and OpenSpec skills
|
|
27
|
+
(`.claude/commands/opsx/`, `.claude/skills/openspec-*`) — they're CLI-generated tool scaffolding,
|
|
28
|
+
not committed to the repo:
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
openspec update # or: openspec init --tools claude --force
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Build & Test
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
hatch build
|
|
38
|
+
hatch run test
|
|
39
|
+
```
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# yaml-language-server: $schema=https://raw.githubusercontent.com/reqstool/reqstool-client/main/src/reqstool/resources/schemas/v1/reqstool_config.schema.json
|
|
2
|
+
|
|
3
|
+
language: python
|
|
4
|
+
build: hatch
|
|
5
|
+
resources:
|
|
6
|
+
requirements: requirements.yml
|
|
7
|
+
software_verification_cases: software_verification_cases.yml
|
|
8
|
+
manual_verification_results: manual_verification_results.yml
|
|
9
|
+
annotations: ../../build/reqstool/annotations.yml
|
|
10
|
+
test_results:
|
|
11
|
+
- ../../build/**/*.xml
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# yaml-language-server: $schema=https://raw.githubusercontent.com/reqstool/reqstool-client/main/src/reqstool/resources/schemas/v1/requirements.schema.json
|
|
2
|
+
---
|
|
3
|
+
metadata:
|
|
4
|
+
urn: reqstool-python-decorators
|
|
5
|
+
variant: microservice
|
|
6
|
+
title: Reqstool Python Decorators
|
|
7
|
+
url: https://github.com/reqstool/reqstool-python-decorators
|
|
8
|
+
|
|
9
|
+
requirements:
|
|
10
|
+
- id: DECORATORS_001
|
|
11
|
+
title: Decorator definitions
|
|
12
|
+
significance: shall
|
|
13
|
+
description: >-
|
|
14
|
+
The library shall provide Requirements and SVCs decorator factories that attach a
|
|
15
|
+
tuple of string IDs (requirements or svc_ids respectively) to the decorated function,
|
|
16
|
+
async function, or class as an attribute, without altering the decorated callable's
|
|
17
|
+
identity or name.
|
|
18
|
+
categories:
|
|
19
|
+
- functional-suitability
|
|
20
|
+
revision: "0.1.0"
|
|
21
|
+
|
|
22
|
+
- id: DECORATORS_002
|
|
23
|
+
title: Decorator processing
|
|
24
|
+
significance: shall
|
|
25
|
+
description: >-
|
|
26
|
+
The processor shall discover Python source files under a given set of directories,
|
|
27
|
+
parse each file's AST to find functions, async functions, and classes decorated with
|
|
28
|
+
Requirements or SVCs, and group the collected IDs into an implementations/tests
|
|
29
|
+
structure keyed by requirement or SVC ID, with each entry recording the fully
|
|
30
|
+
qualified name and a normalized element kind (FUNCTION/ASYNCFUNCTION mapped to
|
|
31
|
+
METHOD).
|
|
32
|
+
categories:
|
|
33
|
+
- functional-suitability
|
|
34
|
+
revision: "0.1.0"
|
|
35
|
+
|
|
36
|
+
- id: DECORATORS_003
|
|
37
|
+
title: YAML export
|
|
38
|
+
significance: shall
|
|
39
|
+
description: >-
|
|
40
|
+
The processor shall serialize the processed implementations/tests structure to a
|
|
41
|
+
YAML file at the given output path, prefixed with a JSON schema header comment,
|
|
42
|
+
creating any missing parent directories first.
|
|
43
|
+
categories:
|
|
44
|
+
- functional-suitability
|
|
45
|
+
revision: "0.1.0"
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# yaml-language-server: $schema=https://raw.githubusercontent.com/reqstool/reqstool-client/main/src/reqstool/resources/schemas/v1/software_verification_cases.schema.json
|
|
2
|
+
|
|
3
|
+
cases:
|
|
4
|
+
- id: SVC_DECORATORS_001
|
|
5
|
+
requirement_ids: ["DECORATORS_001"]
|
|
6
|
+
title: "Verify Requirements and SVCs attach ID tuples to functions, async functions, and classes"
|
|
7
|
+
verification: automated-test
|
|
8
|
+
revision: "0.1.0"
|
|
9
|
+
|
|
10
|
+
- id: SVC_DECORATORS_002
|
|
11
|
+
requirement_ids: ["DECORATORS_002"]
|
|
12
|
+
title: "Verify file discovery, AST extraction, element-kind mapping, and ID grouping into implementations/tests"
|
|
13
|
+
verification: automated-test
|
|
14
|
+
revision: "0.1.0"
|
|
15
|
+
|
|
16
|
+
- id: SVC_DECORATORS_003
|
|
17
|
+
requirement_ids: ["DECORATORS_003"]
|
|
18
|
+
title: "Verify the exported YAML matches the expected schema-tagged implementations/tests structure"
|
|
19
|
+
verification: automated-test
|
|
20
|
+
revision: "0.1.0"
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
// @reqstool-openspec-hooks: 0.1.1
|
|
2
|
+
import { spawn, ChildProcess } from "child_process";
|
|
3
|
+
import type { OnReadDocumentHookV1 } from "openspecui/hooks";
|
|
4
|
+
|
|
5
|
+
// Minimal MCP client over stdio (JSON-RPC 2.0, newline-delimited).
|
|
6
|
+
// Uses only Node.js built-ins — no npm packages required.
|
|
7
|
+
class McpStdioClient {
|
|
8
|
+
private proc: ChildProcess;
|
|
9
|
+
private buf = "";
|
|
10
|
+
private pending = new Map<
|
|
11
|
+
number,
|
|
12
|
+
{ resolve: (v: unknown) => void; reject: (e: Error) => void }
|
|
13
|
+
>();
|
|
14
|
+
private id = 1;
|
|
15
|
+
readonly ready: Promise<void>;
|
|
16
|
+
|
|
17
|
+
constructor(cwd: string) {
|
|
18
|
+
this.proc = spawn("reqstool", ["mcp"], {
|
|
19
|
+
cwd,
|
|
20
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
21
|
+
});
|
|
22
|
+
this.proc.stdout!.on("data", (chunk: Buffer) => {
|
|
23
|
+
this.buf += chunk.toString();
|
|
24
|
+
let nl: number;
|
|
25
|
+
while ((nl = this.buf.indexOf("\n")) !== -1) {
|
|
26
|
+
const line = this.buf.slice(0, nl).trim();
|
|
27
|
+
this.buf = this.buf.slice(nl + 1);
|
|
28
|
+
if (line) this.handle(line);
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
this.ready = this.init();
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
private handle(line: string) {
|
|
35
|
+
try {
|
|
36
|
+
const msg = JSON.parse(line) as { id?: number; result?: unknown; error?: { message: string } };
|
|
37
|
+
if (msg.id !== undefined) {
|
|
38
|
+
const p = this.pending.get(msg.id);
|
|
39
|
+
if (p) {
|
|
40
|
+
this.pending.delete(msg.id);
|
|
41
|
+
msg.error ? p.reject(new Error(msg.error.message)) : p.resolve(msg.result);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
} catch (e) {
|
|
45
|
+
console.warn("[reqstool-openspec] Skipping non-JSON line from reqstool mcp:", e instanceof Error ? e.message : e);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
private send(method: string, params: unknown, expectReply = true): Promise<unknown> {
|
|
50
|
+
if (!expectReply) {
|
|
51
|
+
this.proc.stdin!.write(JSON.stringify({ jsonrpc: "2.0", method, params }) + "\n");
|
|
52
|
+
return Promise.resolve();
|
|
53
|
+
}
|
|
54
|
+
const id = this.id++;
|
|
55
|
+
return new Promise((resolve, reject) => {
|
|
56
|
+
this.pending.set(id, { resolve, reject });
|
|
57
|
+
this.proc.stdin!.write(JSON.stringify({ jsonrpc: "2.0", id, method, params }) + "\n");
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
private async init(): Promise<void> {
|
|
62
|
+
await this.send("initialize", {
|
|
63
|
+
protocolVersion: "2024-11-05",
|
|
64
|
+
capabilities: { tools: {} },
|
|
65
|
+
clientInfo: { name: "openspecui", version: "1.0" },
|
|
66
|
+
});
|
|
67
|
+
this.send("notifications/initialized", {}, false);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
async enrich(content: string, preset: string): Promise<string> {
|
|
71
|
+
await this.ready;
|
|
72
|
+
const result = (await this.send("tools/call", {
|
|
73
|
+
name: "enrich_document",
|
|
74
|
+
arguments: { content, preset },
|
|
75
|
+
})) as { content: { text: string }[] };
|
|
76
|
+
return result.content[0].text;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
close() {
|
|
80
|
+
this.proc.stdin?.end();
|
|
81
|
+
this.proc.kill();
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
let client: McpStdioClient | null = null;
|
|
86
|
+
|
|
87
|
+
export const onReadDocument: OnReadDocumentHookV1 = async (ctx, read) => {
|
|
88
|
+
if (!client) {
|
|
89
|
+
client = new McpStdioClient(ctx.projectDir);
|
|
90
|
+
ctx.lifecycle.onDispose(() => {
|
|
91
|
+
client?.close();
|
|
92
|
+
client = null;
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const result = await read();
|
|
97
|
+
const preset = `openspec:${ctx.document.kind}`;
|
|
98
|
+
|
|
99
|
+
try {
|
|
100
|
+
const enriched = await client.enrich(result.markdown, preset);
|
|
101
|
+
return { ...result, markdown: enriched, sourceLabel: `reqstool ${preset}` };
|
|
102
|
+
} catch (e) {
|
|
103
|
+
return {
|
|
104
|
+
...result,
|
|
105
|
+
diagnostics: [{ level: "warning", message: `reqstool enrich failed: ${e}` }],
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Decorator Definitions Specification
|
|
2
|
+
|
|
3
|
+
## Purpose
|
|
4
|
+
|
|
5
|
+
Requirement and SVC content is owned by reqstool (single source of truth). This spec references
|
|
6
|
+
reqstool requirement and SVC IDs only; titles and descriptions are injected at read time via
|
|
7
|
+
`reqstool enrich` (or the openspecui hook). See `docs/reqstool/`.
|
|
8
|
+
|
|
9
|
+
## Requirements
|
|
10
|
+
|
|
11
|
+
### Requirement: DECORATORS_001
|
|
12
|
+
The system SHALL implement DECORATORS_001.
|
|
13
|
+
|
|
14
|
+
#### Scenario: SVC_DECORATORS_001
|
|
15
|
+
The system SHALL pass SVC_DECORATORS_001.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Decorator Processing Specification
|
|
2
|
+
|
|
3
|
+
## Purpose
|
|
4
|
+
|
|
5
|
+
Requirement and SVC content is owned by reqstool (single source of truth). This spec references
|
|
6
|
+
reqstool requirement and SVC IDs only; titles and descriptions are injected at read time via
|
|
7
|
+
`reqstool enrich` (or the openspecui hook). See `docs/reqstool/`.
|
|
8
|
+
|
|
9
|
+
## Requirements
|
|
10
|
+
|
|
11
|
+
### Requirement: DECORATORS_002
|
|
12
|
+
The system SHALL implement DECORATORS_002.
|
|
13
|
+
|
|
14
|
+
#### Scenario: SVC_DECORATORS_002
|
|
15
|
+
The system SHALL pass SVC_DECORATORS_002.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# YAML Export Specification
|
|
2
|
+
|
|
3
|
+
## Purpose
|
|
4
|
+
|
|
5
|
+
Requirement and SVC content is owned by reqstool (single source of truth). This spec references
|
|
6
|
+
reqstool requirement and SVC IDs only; titles and descriptions are injected at read time via
|
|
7
|
+
`reqstool enrich` (or the openspecui hook). See `docs/reqstool/`.
|
|
8
|
+
|
|
9
|
+
## Requirements
|
|
10
|
+
|
|
11
|
+
### Requirement: DECORATORS_003
|
|
12
|
+
The system SHALL implement DECORATORS_003.
|
|
13
|
+
|
|
14
|
+
#### Scenario: SVC_DECORATORS_003
|
|
15
|
+
The system SHALL pass SVC_DECORATORS_003.
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# Copyright © LFV
|
|
3
|
+
"""Self-apply the decorator processor to this repo's own src/tests, producing
|
|
4
|
+
build/reqstool/annotations.yml for `reqstool status` to consume."""
|
|
5
|
+
|
|
6
|
+
from reqstool_python_decorators.processors.decorator_processor import DecoratorProcessor
|
|
7
|
+
|
|
8
|
+
if __name__ == "__main__":
|
|
9
|
+
DecoratorProcessor().process_decorated_data(
|
|
10
|
+
# tests/resources holds fixture files with intentionally-fake REQ_*/SVC_* IDs
|
|
11
|
+
# (used by tests/e2e to exercise the processor against real decorator syntax) --
|
|
12
|
+
# excluded here so they don't pollute this repo's own traceability data.
|
|
13
|
+
# tests/integration is omitted entirely: it's currently just empty __init__.py
|
|
14
|
+
# stubs, add it back once real integration tests land there.
|
|
15
|
+
path_to_python_files=["src", "tests/unit", "tests/e2e"],
|
|
16
|
+
output_file="build/reqstool/annotations.yml",
|
|
17
|
+
)
|