Skip to content

Commit 8bc83ac

Browse files
committed
Taught the lint harness to police itself
1 parent f263ef9 commit 8bc83ac

File tree

15 files changed

+432
-167
lines changed

15 files changed

+432
-167
lines changed

.clang-tidy

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ HeaderFilterRegex: '^(include|src|libgitledger)/.*\.(h|c)$'
1515
CheckOptions:
1616
- key: readability-identifier-naming.TypedefCase
1717
value: lower_case
18-
- key: readability-identifier-naming.TypedefSuffix
19-
value: '_t'
2018
- key: readability-identifier-naming.StructCase
2119
value: lower_case
2220
- key: readability-identifier-naming.UnionCase
@@ -79,7 +77,5 @@ CheckOptions:
7977
value: 'false'
8078
- key: performance-no-automatic-move.AllowedTypes
8179
value: ''
82-
- key: portability-restrict-system-includes.Includes
83-
value: '*'
8480
- key: misc-misplaced-const.CheckPrimitiveCasts
8581
value: 'true'

.editorconfig

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,13 @@ indent_size = 4
1414
indent_style = space
1515
indent_size = 2
1616

17+
[*.md]
18+
trim_trailing_whitespace = false
19+
1720
[Makefile]
1821
indent_style = tab
19-
indent_size = 4
22+
indent_size = tab
23+
tab_width = 4
2024

2125
[*.sh]
2226
indent_style = space

.github/workflows/ci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ jobs:
7575
# tools/lint/run_clang_tidy.sh filters compile_commands.json to exclude test TU entries
7676
run: make tidy
7777

78+
- name: Validate activity log schema
79+
run: tools/lint/validate_activity_log.sh
80+
7881
windows-msvc:
7982
name: MSVC (Windows)
8083
runs-on: windows-latest

.markdownlint.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ MD013:
22
line_length: 240
33
code_blocks: false
44
tables: false
5+
MD041: true
56
MD024:
67
siblings_only: true
78
MD029:

ACTIVITY.log.jsonl

Lines changed: 43 additions & 42 deletions
Large diffs are not rendered by default.

ACTIVITY.schema.json

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema#",
3+
"oneOf": [
4+
{
5+
"type": "object",
6+
"required": [
7+
"timestamp",
8+
"branches",
9+
"activity",
10+
"prs"
11+
],
12+
"properties": {
13+
"timestamp": {
14+
"type": "string"
15+
},
16+
"branches": {
17+
"type": "array",
18+
"items": {
19+
"type": "string"
20+
}
21+
},
22+
"activity": {
23+
"type": "array",
24+
"items": {
25+
"type": "string"
26+
}
27+
},
28+
"prs": {
29+
"type": "array",
30+
"items": {
31+
"type": "string",
32+
"pattern": "^https?://"
33+
}
34+
}
35+
},
36+
"additionalProperties": false
37+
},
38+
{
39+
"type": "object",
40+
"required": [
41+
"who",
42+
"what",
43+
"where",
44+
"when",
45+
"why",
46+
"how",
47+
"protip"
48+
],
49+
"properties": {
50+
"who": {
51+
"type": "string"
52+
},
53+
"what": {
54+
"type": "string"
55+
},
56+
"where": {
57+
"type": "array",
58+
"items": {
59+
"type": "string"
60+
}
61+
},
62+
"when": {
63+
"type": "string",
64+
"pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(?:\\.\\d+)?Z$"
65+
},
66+
"why": {
67+
"type": "string"
68+
},
69+
"how": {
70+
"type": "string"
71+
},
72+
"protip": {
73+
"type": "string"
74+
}
75+
},
76+
"additionalProperties": false
77+
}
78+
]
79+
}

AGENTS.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,16 @@ ACTIVITY.log.jsonl
5656

5757
Each line is a JSON object. No merging. No overwriting. No sorting. No reordering. End it with a `\n`.
5858

59-
***APPEND*** to this file, for example:
59+
***APPEND*** to this file. Use the helper to keep the schema compliant:
6060

6161
```bash
62-
echo "<message>" >> ACTIVITY.log.jsonl
62+
tools/log_activity.py \
63+
--who AGENT \
64+
--what "Describe the work" \
65+
--where path/to/file \
66+
--why "Explain the reason" \
67+
--how "Explain the process" \
68+
--protip "Share something useful"
6369
```
6470

6571
Some of you may choke on that, since I know, it's hard to escape quotes and write JSON to the command line. But you'll get the hang of it.
@@ -69,7 +75,7 @@ Required keys:
6975
- `who` (your name, AGENT)
7076
- `what` (did you do?)
7177
- `where` (files, etc)
72-
- `when` (timestamp POSIX)
78+
- `when` (timestamp RFC 3339 – the helper writes this for you)
7379
- `why` (and if you leave this out, may God have mercy on your stack trace)
7480
- `how` (discuss your work)
7581
- `protip` (leave some wisdom for the next AGENT who reads this file)

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ set(CMAKE_C_EXTENSIONS OFF)
77
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
88

99
if(MSVC)
10-
set(PROJECT_WARNING_FLAGS /W4 /WX)
10+
set(PROJECT_WARNING_FLAGS /W4 /WX /we4244 /we4267 /we4456 /we4457 /we4458 /we4459)
1111
else()
1212
# Keep Unix builds strict and hide unintended symbol exports.
1313
set(PROJECT_WARNING_FLAGS -Wall -Wextra -Werror -Wpedantic -Wshadow -Wconversion -fvisibility=hidden)

Makefile

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
.PHONY: all test cmake meson both test-cmake test-meson test-both clean format format-check tidy lint tidy-build \
22
host-cmake host-meson host-both host-test-cmake host-test-meson host-test-both \
3-
host-format-check host-tidy host-lint container-format-check container-tidy container-lint
3+
host-format-check host-tidy host-lint container-format-check container-tidy container-lint \
4+
activity-validate
45

56
all: both
67

@@ -124,12 +125,10 @@ tidy-build:
124125
tools/lint/run_clang_tidy.sh $(CLANG_TIDY)
125126

126127
markdownlint:
127-
@files="$(shell git ls-files '*.md')"; \
128-
if [ -z "$$files" ]; then \
129-
echo "markdownlint: no markdown files found"; \
130-
else \
131-
$(MARKDOWNLINT) $(MARKDOWNLINT_ARGS) $$files; \
132-
fi
128+
@files="$(shell git ls-files '*.md')"; if [ -z "$$files" ]; then echo "markdownlint: no markdown files found"; else $(MARKDOWNLINT) $(MARKDOWNLINT_ARGS) $$files; fi
129+
130+
activity-validate:
131+
./tools/lint/validate_activity_log.sh
133132

134133
clean:
135134
rm -rf build build-debug build-release build-tidy meson-debug meson-release meson-* compile_commands.json

0 commit comments

Comments
 (0)