Skip to content

Commit ba77023

Browse files
authored
ft(pre-commit) (#5)
* stricter manifest typing * linting
1 parent 0ddde4a commit ba77023

File tree

15 files changed

+411
-258
lines changed

15 files changed

+411
-258
lines changed

.github/workflows/doc-drift.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
- name: Set up Python
1616
uses: actions/setup-python@v5
1717
with:
18-
python-version: "3.10"
18+
python-version: '3.10'
1919

2020
- name: Install Python dependencies
2121
run: |

.github/workflows/lint.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
- name: Set up Python
1616
uses: actions/setup-python@v5
1717
with:
18-
python-version: "3.10"
18+
python-version: '3.10'
1919

2020
- name: Install Python dependencies
2121
run: |
@@ -25,14 +25,17 @@ jobs:
2525
- name: Set up Node
2626
uses: actions/setup-node@v4
2727
with:
28-
node-version: "20"
28+
node-version: '20'
2929

3030
- name: Install Node dependencies
3131
run: npm install
3232

3333
- name: Lint Python (Ruff)
3434
run: ruff check tools
3535

36+
- name: Pre-commit hooks
37+
run: pre-commit run --all-files
38+
3639
- name: Validate Schema (AJV Strict)
3740
run: npm run lint:schema
3841

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
- name: Set up Python
1616
uses: actions/setup-python@v5
1717
with:
18-
python-version: "3.10"
18+
python-version: '3.10'
1919

2020
- name: Install dependencies
2121
run: |

.pre-commit-config.yaml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
---
2+
repos:
3+
- repo: 'https://github.com/rbubley/mirrors-prettier'
4+
rev: 'v3.7.4'
5+
hooks:
6+
- id: 'prettier'
7+
types: [text]
8+
additional_dependencies:
9+
- 'prettier@3.5.3'
10+
- 'prettier-plugin-sort-json@4.1.1'
11+
- 'prettier-plugin-toml@2.0.5'
12+
pass_filenames: true
13+
args:
14+
[
15+
'--log-level=warn',
16+
'--check',
17+
'--config=.prettierrc.cjs',
18+
'--ignore-path=.prettierignore',
19+
]
20+
- repo: 'https://github.com/codespell-project/codespell'
21+
rev: 'v2.4.1'
22+
hooks:
23+
- id: 'codespell'
24+
exclude: '^(package-lock.json|src/test/openutau-ustx/bulaomeng.ustx.yaml|src/test/kustomization/labels.json|src/test/bun-lock/bun.lock.json|src/bin/.*)$'
25+
args:
26+
[
27+
'--ignore-words-list',
28+
'crate,ninjs,ans,specif,seh,specifid,deriver,isnt,tye,forin,dependees,rouge,interm,fo,wast,nome,statics,ue,aack,gost,inout,provId,handels,bu,testng,ags,edn,aks,te,decorder,provid,branche,alse,nd,mape,wil,clude,wit,flate,omlet,THIRDPARTY,NotIn,notIn,CopyIn,Requestor,requestor,re-use,ofo,abl,dout,foto,vor,wel,NAM,BRIN,everyTime,afterAll,beforeAll,ontainer',
29+
]
30+
- repo: 'https://github.com/astral-sh/ruff-pre-commit'
31+
rev: 'v0.9.1'
32+
hooks:
33+
- id: ruff
34+
args: ['--fix']

.prettierrc.cjs

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/** @type {import('prettier').Config} */
2+
module.exports = {
3+
// pre-commit.ci fails without `require.resolve()`.
4+
plugins: [
5+
require.resolve('prettier-plugin-sort-json'),
6+
require.resolve('prettier-plugin-toml'),
7+
],
8+
semi: false,
9+
singleQuote: true,
10+
trailingComma: 'all',
11+
jsonRecursiveSort: true,
12+
jsonSortOrder: JSON.stringify({
13+
'/^[^\\d+]/': 'none',
14+
'/^\\d+/': 'none',
15+
}),
16+
overrides: [
17+
{
18+
files: '*.jsonc',
19+
options: {
20+
trailingComma: 'none',
21+
},
22+
},
23+
{
24+
files: 'schema/**/*.json',
25+
options: {
26+
jsonRecursiveSort: true,
27+
jsonSortOrder: JSON.stringify({
28+
$schema: null,
29+
$id: null,
30+
$comment: null,
31+
$ref: null,
32+
'/^\\$.*/': null,
33+
'/^[^\\d+]/': 'none',
34+
'/^\\d+/': 'none',
35+
if: null,
36+
then: null,
37+
else: null,
38+
}),
39+
},
40+
},
41+
],
42+
}

CONTRIBUTING.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# KYA Manifest — Developer Notes (v0.1.0-alpha)
22

33
## Validation pipeline
4+
45
1. JSON Schema validation against https://w3id.org/kya/v1/schema.
56
2. JSON-LD expansion using a documentLoader that maps https://w3id.org/kya/v1 to the local context file.
67
3. Policy checks:
@@ -10,7 +11,9 @@
1011
- embedded vs referenced VC rules.
1112

1213
## JSON-LD context ordering
14+
1315
Use:
16+
1417
- https://www.w3.org/2018/credentials/v1
1518
- https://w3id.org/security/data-integrity/v2
1619
- https://w3id.org/security/suites/ed25519-2020/v1
@@ -19,10 +22,12 @@ Use:
1922
Putting the KYA context last avoids protected-term redefinition failures in common processors.
2023

2124
## Fixtures
25+
2226
- 02-minimal.json: smallest conforming manifest for debugging.
2327
- 01-full.json: comprehensive manifest exercising optional sections and VC embedding/referencing.
2428

2529
## Versioning policy
30+
2631
Treat `schema/kya-manifest.schema.json` and `schema/context.jsonld` as normative. When adding or
2732
changing fields, update the schema, context, and `schema_human.md` together. The spec HTML and
2833
vocab are informative and may lag unless a change is breaking or user-facing.

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ lint: ## Run lint/format checks
3131
@for file in $(EXAMPLES); do \
3232
$(PYTHON) $(LINTER) $$file; \
3333
done
34+
pre-commit run --all-files
3435
npm run lint
3536

3637
lint-fix: ## Auto-fix formatting issues

SECURITY.md

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,23 @@
11
# Security Policy
22

33
## Supported Versions
4+
45
Only the latest major version of the KYA Manifest Standard is supported for security updates.
56

6-
| Version | Supported |
7-
| ------- | ------------------ |
8-
| 0.1.x | ✅ Yes |
9-
| < 0.1 | ❌ No |
7+
| Version | Supported |
8+
| ------- | --------- |
9+
| 0.1.x | ✅ Yes |
10+
| < 0.1 | ❌ No |
1011

1112
## Reporting a Vulnerability
13+
1214
For now you may open a public issue on GitHub. In the future, we may set up a private disclosure process.
1315

1416
If you discover a security flaw in the future or wish to do so privately for the KYA schema, linter, or protocol logic, please report it privately via:
17+
1518
- **Email:** security@cph.ai
1619
- **PGP Key:**
20+
1721
```
1822
-----BEGIN PGP PUBLIC KEY BLOCK-----
1923
@@ -28,7 +32,8 @@ gCavPDCBUexEAwEIB4h+BBgWCgAmFiEEX/sM/XNyAq4vACSzRtkRt7ZG5dsFAmly
2832
OldhhZKB8iQJ8mcBAKgjSk53AlbC8h5ruTvbSFhAJkipoAB93W06Ygu+QPoB
2933
=AkD3
3034
-----END PGP PUBLIC KEY BLOCK-----
31-
````
35+
```
36+
3237
- PGP Fingerprint: `5FFB0CFD737202AE2F0024B346D911B7B646E5DB`
3338

3439
Please include a detailed description of the vulnerability and a proof-of-concept if possible. We aim to acknowledge all reports within 48 hours.

package-lock.json

Lines changed: 56 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@
44
"devDependencies": {
55
"ajv": "^8.17.1",
66
"ajv-formats": "^3.0.1",
7-
"prettier": "3.2.5"
7+
"prettier": "^3.5.3",
8+
"prettier-plugin-sort-json": "^4.1.1",
9+
"prettier-plugin-toml": "^2.0.5"
810
},
911
"scripts": {
1012
"lint:schema": "node tools/ajv-validate-schema.js",
11-
"format": "prettier --write README.md schema/**/*.json examples/**/*.json spec/**/*.html .github/workflows/*.yml",
12-
"lint": "prettier --check README.md schema/**/*.json examples/**/*.json spec/**/*.html .github/workflows/*.yml"
13+
"format": "prettier --config .prettierrc.cjs --ignore-path .prettierignore --write README.md schema/**/*.json examples/**/*.json spec/**/*.html .github/workflows/*.yml",
14+
"lint": "prettier --config .prettierrc.cjs --ignore-path .prettierignore --check README.md schema/**/*.json examples/**/*.json spec/**/*.html .github/workflows/*.yml"
1315
}
1416
}

0 commit comments

Comments
 (0)