Repository navigation
feat: add the requirement-ID convention, lint and schemas - #397
brendanjryan wants to merge 71 commits into
Conversation
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1a21846aaf
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| "required": ["status", "timestamp", "reference"], | ||
| "additionalProperties": true, | ||
| "properties": { | ||
| "status": { "type": "string", "minLength": 1 }, |
There was a problem hiding this comment.
Restrict receipt status to success
When validating a Receipt, this definition accepts any nonempty status, including "failed" or "pending". That contradicts specs/core/draft-httpauth-payment-01.md's Receipt Status Semantics section, which requires status to be "success" and communicates failures through HTTP errors instead. Consequently, consumers of this schema, including the ServerVerifyResult receipt reference, can accept failure receipts as valid protocol values. Use const: "success" here so schema validation enforces that invariant.
AGENTS.md reference: AGENTS.md:L69-L69
Useful? React with 👍 / 👎.
Spec Preview
|
There was a problem hiding this comment.
I re-reviewed after the latest commit and didn't find any new bugs. A human should still sign off, because this sets a requirement-ID convention for every draft and publishes a schema that now differs from upstream mpp-tools on purpose.
What was reviewed:
- Both points from my earlier review are fixed.
segments()now resetscurrentafter an IAL, and the newtest_line_after_ial_is_a_new_blockcovers that case. Challenge and Credential now haveadditionalProperties: true, and schemas/README.md records why. - I checked the tempo-charge -01 IALs, including the indented ones on list items. Each one sits on the line right after its paragraph or item, and the numbers run 001 onward in order.
Extended reasoning...
The change adds a requirement-ID rule to STYLE.md and AGENTS.md, a new warn-only lint with pytest coverage, a Makefile lint step, and a 534-line JSON Schema under a paymentauth.org $id. It also renames and tags the Tempo charge draft as -01. It touches no auth, crypto or runtime code, only specs, docs and tooling. The follow-up commit fixes both of my earlier findings, and the Receipt status const change probably answers the other bot's inline comment on that line. I'm deferring rather than approving because the change is large and sets a repo-wide convention. The published schema also now intentionally differs from its upstream source, and maintainers should decide that.
There was a problem hiding this comment.
My two earlier points are fixed in the latest commits and I didn't find any new bugs. This PR publishes a new schema and bumps the Tempo charge draft to -01, so a human should still look at it.
segments()now setscurrent = Noneafter an IAL, so text right after a tagged block becomes its own segment.- Challenge and Credential now allow extra members, and schemas/README.md lists both differences from mpp-tools.
- In the draft, the tags and the table-cell memo rule moving to prose as req-tempo-charge-044 only add IAL lines; the normative wording is unchanged.
- I didn't run the lint or the tests; this was a read-only review.
Extended reasoning...
The change adds a requirement-ID convention (STYLE.md, AGENTS.md) and a Python lint with tests wired into make lint. It also adds a 534-line JSON Schema published under a paymentauth.org $id and renames the Tempo charge draft to version -01 with requirement tags. None of it touches auth, crypto or other security-sensitive runtime code; it is spec tooling and documentation. I deferred because of the size, the new public schema, and the draft version bump, which spec maintainers should decide on. Other bots' inline comments on the schema and the lint were posted before the last commit, and I couldn't confirm independently that they were addressed.
| # A line holding only an IAL, which applies to the block above it. | ||
| IAL_LINE = re.compile(r"^\s*\{:[^}]*\}\s*$") | ||
| # A tab after a space in a line's indentation (see lint_file). | ||
| MIXED_INDENT = re.compile(r"^[ \t]*(?:> ?)*[ \t]* \t") |
There was a problem hiding this comment.
Medium: MIXED_INDENT regex backtracks quadratically on long whitespace lines
MIXED_INDENT in scripts/lint_requirements.py puts two [ \t]* quantifiers around a group that matches nothing on whitespace.
Full finding
MIXED_INDENT in scripts/lint_requirements.py puts two [ \t]* quantifiers around a group that matches nothing on whitespace. On a run of spaces or tabs with no space followed by a tab, Python's re tries every split of the run before it fails. lint_file applies the regex to every body line with no length limit, so one long whitespace line makes each lint run quadratic.
Valid? React with 👍 / 👎.
| id_lines: dict[str, list[int]] = defaultdict(list) | ||
| for number in range(start, len(lines) + 1): | ||
| for found_id in SOURCE_ID.findall(lines[number - 1]): | ||
| id_lines[found_id].append(number) |
There was a problem hiding this comment.
Informational: Requirement lint rescans a whole line for every repeated ID mention
lint_file calls in_braces once for every mention of a requirement ID on a line, and each call rescans all of that line's mentions from the start. A line with N mentions of one ID, none inside braces, therefore costs N squared substring searches. This defeats the near-linear design the in_braces docstring claims.
Valid? React with 👍 / 👎.
… and type ChallengeIdInput
| def in_braces(line: str, text: str) -> bool: | ||
| """Whether text occurs after a { with no } in between, as an IAL or ALD writes it. | ||
|
|
||
| Each mention looks up the last { and } before it by binary search, so a run of | ||
| unclosed braces or many ID mentions on one line stays near linear. | ||
| """ | ||
| if "{" not in line: | ||
| return False | ||
| opens, closes = brace_positions(line) | ||
| pos = 0 | ||
| while (found := line.find(text, pos)) >= 0: | ||
| opened = bisect.bisect_left(opens, found) | ||
| closed = bisect.bisect_left(closes, found) | ||
| if opened and (not closed or opens[opened - 1] > closes[closed - 1]): | ||
| return True | ||
| pos = found + 1 | ||
| return False |
There was a problem hiding this comment.
Medium (trigger unconfirmed): Requirement lint rescans a whole line per distinct ID, so cost is…
lint_file calls in_braces once for each distinct req- ID on a source line, and in_braces scans the whole line with str.find each time. A line of length L with K distinct IDs therefore costs O(K*L), quadratic in the line length, although the in_braces docstring promises near-linear behaviour.
Full finding
Requirement lint rescans a whole line per distinct ID, so cost is quadratic
lint_file calls in_braces once for each distinct req- ID on a source line, and in_braces scans the whole line with str.find each time. A line of length L with K distinct IDs therefore costs O(K*L), quadratic in the line length, although the in_braces docstring promises near-linear behaviour.
Valid? React with 👍 / 👎.
… look up braced IDs in one pass
| @functools.lru_cache(maxsize=64) | ||
| def brace_positions(line: str) -> tuple[tuple[int, ...], tuple[int, ...]]: | ||
| """The positions of every { and every } in a line, in order. | ||
|
|
||
| Cached, so a line with many ID mentions is scanned once rather than once per mention. | ||
| Only brace positions are kept, so memory grows with the braces, not the line length. | ||
| """ | ||
| opens = tuple(i for i, char in enumerate(line) if char == "{") | ||
| closes = tuple(i for i, char in enumerate(line) if char == "}") | ||
| return opens, closes | ||
|
|
||
|
|
||
| @functools.lru_cache(maxsize=64) | ||
| def braced_ids(line: str) -> frozenset[str]: | ||
| """The requirement IDs written somewhere in a line after a { with no } in between. | ||
|
|
||
| One pass over the line's IDs, cached, so checking every distinct ID on a long line | ||
| costs one scan of it rather than one per ID. | ||
| """ | ||
| opens, closes = brace_positions(line) | ||
| found: set[str] = set() | ||
| for match in SOURCE_ID.finditer(line): | ||
| at = match.start() | ||
| opened = bisect.bisect_left(opens, at) | ||
| closed = bisect.bisect_left(closes, at) | ||
| if opened and (not closed or opens[opened - 1] > closes[closed - 1]): | ||
| found.add(match.group(1)) | ||
| return frozenset(found) |
There was a problem hiding this comment.
Medium: Requirement lint's 64-entry line cache thrashes, making the lint quadratic
lint_requirements.py caches braced_ids and brace_positions in 64-entry LRU caches keyed by the line text, but lint_file visits lines ID by ID. When more than 64 distinct lines share the same braced IDs, every lookup misses and rescans the whole line. The lint then costs O(L·K²) instead of the linear time the docstring promises.
Valid? React with 👍 / 👎.
| if tag == "section": | ||
| for child in el: | ||
| if child.tag == "name": | ||
| items.append(Item("heading", words("".join(child.itertext())), anchor=anchor)) | ||
| else: | ||
| walk(child, items) |
There was a problem hiding this comment.
Low: Requirement lint misses requirement IDs on inline spans in headings
lint_requirements.py never inspects anchors nested inside a section's name element. A span IAL in a heading, such as *control*{: #req-tempo-charge-999}, therefore produces no item and is skipped as an already-anchored ID. If every real requirement is tagged, --strict reports nothing, unlike the same span IAL in a paragraph or table cell.
Valid? React with 👍 / 👎.
| found = [ | ||
| n | ||
| for n in id_lines.get(req_id, []) | ||
| if n not in code_lines and in_braces(loud[n - 1], req_id) | ||
| ] | ||
| if not found or any(n >= item.start for n in found): | ||
| return None | ||
| before = [n for n in found if not ALD_LINE.match(lines[n - 1])] | ||
| if before: | ||
| return before[-1] | ||
| # Only in ALDs: the IALs that reference them place the ID, so check those instead. | ||
| names = {ALD_NAME.match(lines[n - 1]).group(1) for n in found} | ||
| refs = sorted(n for name in names for n in ald_refs.get(name, [])) | ||
| if not refs or any(n >= item.start for n in refs): | ||
| return None | ||
| return refs[-1] |
There was a problem hiding this comment.
Informational: Requirement lint takes quadratic time when many blocks share one ID
lint_file's written_before helper rebuilds a filtered list over every source line naming a block's requirement ID, calling in_braces on each, once per anchored block. N blocks anchored by the same ID cost N^2 in_braces calls, and replaced_ids repeats the pattern. At N=8000 this measured 74x the cost of a same-size draft with distinct IDs.
Valid? React with 👍 / 👎.
| CONDITION = re.compile( | ||
| r"^\W*(?:if|when|whenever|unless|for|only|except|where|while|after|before|once|until|during|provided|otherwise|on|upon)\b", | ||
| re.IGNORECASE, |
There was a problem hiding this comment.
Low: Requirement lint misses table conditions that start with unlisted words
In lint_file, a table cell whose presence marker ends in a colon or period is flagged only when the next word is on the CONDITION list. Cells such as REQUIRED: in pull mode or OPTIONAL. Under version 2 the field holds a hash state a condition but pass the lint, even with --strict.
Valid? React with 👍 / 👎.
| for number, line in enumerate(lines, start=1): | ||
| self.first.append(len(self.words)) | ||
| for word in WORD.findall(line): | ||
| self.positions[word].append(len(self.words)) | ||
| self.words.append(word) | ||
| self.line_of.append(number) |
There was a problem hiding this comment.
Low: Requirement lint maps rules onto HTML comment text, hiding leading IALs
SourceMap indexes every word in the Markdown source, including HTML comments that kramdown-rfc never renders. When a block comment before a rule repeats the rule's opening words, the rule maps to the comment's line. A requirement ID written before the rule then looks like it follows it, and strict mode reports nothing.
Valid? React with 👍 / 👎.
| ald = ALD_NAME.match(line) | ||
| if ald: | ||
| # An ALD only defines attributes; it tags a block when an IAL names it. If | ||
| # some IAL names it and its ID still isn't an anchor, the block also set an | ||
| # ID of its own, and kramdown kept only that one. Unused ALDs stay quiet, and | ||
| # so does one whose ID anchors every block whose IAL names it: where the ALD | ||
| # is defined says nothing about which block uses it. | ||
| users = [bisect.bisect_left(starts, n) - 1 for n in ald_refs.get(ald.group(1), [])] | ||
| if users and all(u >= 0 and texts[u].anchor == req_id for u in users): | ||
| continue | ||
| if ald.group(1) in ald_uses: | ||
| report.error( | ||
| number, | ||
| f"{req_id} in ALD {ald.group(1)} is replaced by another ID on the block that uses it", | ||
| ) | ||
| continue |
There was a problem hiding this comment.
Informational: Requirement lint rebuilds an ALD's referencing blocks for every ID on it
In lint_file's ALD branch, the requirement lint rebuilds the list of blocks that reference an ALD once for each requirement ID on that ALD line, although the list depends only on the ALD name. An ALD with K IDs referenced by R IALs costs K×R bisects. That is 7x to 18x slower than computing the list once per name.
Valid? React with 👍 / 👎.
| def quiet_at(req_id: str, number: int) -> bool: | ||
| """Whether this occurrence of a quiet ID is in code or a comment, not an IAL.""" | ||
| return number in code_lines or req_id not in loud[number - 1] |
There was a problem hiding this comment.
Informational: Requirement lint's quiet_at rescans the whole line per ID, quadratic time
lint_file calls quiet_at once for every distinct quiet requirement ID on a source line, and quiet_at substring-scans the whole blanked line each time. One line holding K IDs inside an HTML comment therefore costs O(K*L) work. The PR removed this pattern from in_braces through braced_ids but left it in quiet_at.
Valid? React with 👍 / 👎.
| for number, raw in enumerate(lines, start=1): | ||
| if number >= start and mixed_indent(raw): | ||
| # kramdown-rfc expands tabs before kramdown reads the draft and warns that | ||
| # "undefined behavior will ensue": a tab after spaces lands on a column the | ||
| # author rarely meant, even in a code block. | ||
| report.error(number, "tab after a space in the indentation; indent with spaces") |
There was a problem hiding this comment.
Low: lint_requirements --strict fails on tab indentation that STYLE.md doesn't list
With --strict, lint_requirements.py exits 1 when a body line, including one in a code block, has a tab after a space in its indentation. STYLE.md's list of strict failures and the module docstring both leave this check out. The failure summary calls it a requirement ID problem and points to a STYLE.md section that doesn't describe it.
Valid? React with 👍 / 👎.
| "required": ["url"], | ||
| "additionalProperties": false, | ||
| "properties": { | ||
| "url": { "type": "string", "pattern": "^http://127\\.0\\.0\\.1:[0-9]+$", "not": { "pattern": "[\r\n\u0085\u2028\u2029]" } } |
There was a problem hiding this comment.
Low (exposure unconfirmed): HttpServerInfo url pattern accepts port 0 and ports above 65535
The HttpServerInfo schema checks the url's port only with [0-9]+. It accepts http://127.0.0.1:0, http://127.0.0.1:65536 and longer digit strings, none of which a client can connect to.
Valid? React with 👍 / 👎.
| "HeaderOutput": { | ||
| "type": "object", | ||
| "required": ["header"], | ||
| "additionalProperties": false, | ||
| "properties": { | ||
| "header": { "type": "string" } | ||
| } |
There was a problem hiding this comment.
Low (exposure unconfirmed): HeaderOutput schema accepts header values with CR, LF and control characters
$defs.HeaderOutput in the new protocol schema types the formatter's header result as any string. The schema therefore accepts Challenge, Credential and Receipt header values that the core draft's ABNF forbids, including values with CRLF or control characters. The FieldValue definition the same file adds to block CR and LF is not applied to it.
Valid? React with 👍 / 👎.
tempoxyz-bot
left a comment
There was a problem hiding this comment.
👁️ Cyclops Review — 8 findings.
- **Low (trigger unconfirmed) · unverified:** Schema README says 'HTA\`' instead of 'HTAB'
- **Low (trigger unconfirmed) · unverified:** Table-cell lint reports a presence marker followed by a description starting with…
- **Low (trigger unconfirmed) · unverified:** DateTime rejects valid offset leap seconds
- **Medium (trigger unconfirmed) · unverified:** Requirement lint misreads a {{req-...}} cross-reference as a second or detached requirement…
- **Low (trigger unconfirmed) · unverified:** Challenge schema accepts strings that cannot be UTF-8
- **Informational · unverified:** Blocking test times kramdown-rfc subprocess render against a 2 s wall-clock bound
- **Low (trigger unconfirmed) · unverified:** Chained ALDs bypass detached-ID checks
- **Low (trigger unconfirmed) · unverified:** Table-cell keyword check flags quoted keyword names that the paragraph check ignores
| `^[a-z][a-z0-9-]*$`. | ||
| - Challenge allows extra members whose names are lowercase RFC 9110 | ||
| tokens (`propertyNames`) and whose values are `ParamValue` strings | ||
| (no control characters but HTA`): custom parameters are auth-params |
There was a problem hiding this comment.
Low (trigger unconfirmed) · unverified: Schema README says 'HTA`' instead of 'HTAB'
The added schemas/README.md line 37 describes ParamValue as '(no control characters but HTA)'. The schema's own ParamValue description says 'no control characters but HTAB'. The README line has a typo plus a stray unmatched backtick, so readers see a meaningless 'HTA' where the allowed character (horizontal tab) should be named.
Full finding
The added schemas/README.md line 37 describes ParamValue as '(no control characters but HTA)'. The schema's own ParamValue description says 'no control characters but HTAB'. The README line has a typo plus a stray unmatched backtick, so readers see a meaningless 'HTA' where the allowed character (horizontal tab) should be named. Impact is documentation clarity only. Fix: change 'HTA`' to 'HTAB'.
Valid? React with 👍 / 👎.
| CONDITION = re.compile( | ||
| r"^\W*(?:if|when|whenever|unless|for|only|except|where|while|after|before|once|until|during|provided|otherwise|on|upon)\b", | ||
| re.IGNORECASE, | ||
| ) |
There was a problem hiding this comment.
Low (trigger unconfirmed) · unverified: Table-cell lint reports a presence marker followed by a description starting with…
What the code owes: STYLE.md lets a table cell use a bare REQUIRED/OPTIONAL/RECOMMENDED that ends its clause, followed by a description ('OPTIONAL. Defaults to 0', 'OPTIONAL: Units consumed', which the lint's own test treats as fine, E5). Only a marker that opens a condition ('REQUIRED: if ...') should be reported.
Full finding
Table-cell lint reports a presence marker followed by a description starting with 'On-' (or 'For', 'Only', ...) as a conditional rule
What the code owes: STYLE.md lets a table cell use a bare REQUIRED/OPTIONAL/RECOMMENDED that ends its clause, followed by a description ('OPTIONAL. Defaults to 0', 'OPTIONAL: Units consumed', which the lint's own test treats as fine, E5). Only a marker that opens a condition ('REQUIRED: if ...') should be reported. How it breaks: lint_requirements.py removes the marker with PRESENCE_MARKER and tests what is left against CONDITION. CONDITION is ^\W*(?:if|when|whenever|unless|for|only|except|where|while|after|before|once|until|during|provided|otherwise|on|upon)\b compiled with re.IGNORECASE. The final \b also matches before a hyphen, and IGNORECASE matches capitalized words that start a new description. The HEAD commit added on/upon. Concrete trigger in the repo: specs/methods/tempo/draft-tempo-session-00.md:1566 has the cell 'OPTIONAL: On-chain transaction hash (present on settlement/close)'. After the marker is removed, ' On-chain ...' matches on\b, so the check at E2 reports 'keyword in a table cell; state the rule in a tagged paragraph'. The cell right above it, 'OPTIONAL: Units consumed ...', has the same structure and passes. The same false positive hits any description starting with For/Only/Once/Where/After/Before/During/Until/While/Otherwise. Impact: make lint and the new CI step print, and annotate, a spurious problem for tempo-session today. Once that draft is tagged and checked with --strict, the lint fails on text the convention allows, forcing authors to reword legitimate cells and making the lint look unreliable. Tests only use lowercase condition words followed by a space, so nothing catches this. Not shown: the rendered output was not run here (no kramdown-rfc in the sandbox). The conclusion assumes kramdown-rfc keeps the cell text 'OPTIONAL: On-chain ...' as written, which holds for plain text with a single hyphen. Fix: only accept a condition word followed by whitespace (replace the final \b with (?=\s)). Better, also match condition words case-sensitively in lowercase, since a condition continues the marker's clause ('REQUIRED: if ...') while a capitalized word starts a description. Add regression tests for 'OPTIONAL: On-chain transaction hash' and 'OPTIONAL. For display only'.
Valid? React with 👍 / 👎.
| "description": "RFC 3339 date-time, as the core draft requires for Challenge expires and Receipt timestamp. format: date-time is an annotation by default in JSON Schema 2020-12, so the pattern enforces it in every validator (RE2-compatible; T and Z are case-insensitive per RFC 3339 section 5.6). The date branch checks each month's length and allows February 29 only in Gregorian leap years (RFC 3339 section 5.7). Second 60 (a leap second) falls at 23:59:60 UTC on the last day of a month (February 28 only outside leap years) (RFC 3339 section 5.7): with offset Z or +00:00/-00:00 the pattern accepts exactly that. With any other offset the pattern rejects second 60: a pattern cannot tie the local time to its offset, and MPP implementations write timestamps in UTC.", | ||
| "type": "string", | ||
| "format": "date-time", | ||
| "pattern": "^(?:(?:[0-9]{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12][0-9]|3[01])|(?:0[469]|11)-(?:0[1-9]|[12][0-9]|30)|02-(?:0[1-9]|1[0-9]|2[0-8]))|(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:[02468][048]|[13579][26])00)-02-29)[Tt](?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:\\.[0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])|(?:(?:[0-9]{4}-(?:(?:0[13578]|1[02])-31|(?:0[469]|11)-30)|(?:[0-9]{2}(?:[02468][1235679]|[13579][01345789])|(?:[02468][1235679]|[13579][01345789])00)-02-28)|(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:[02468][048]|[13579][26])00)-02-29)[Tt]23:59:60(?:\\.[0-9]+)?(?:[Zz]|[+-]00:00))$", "not": { "pattern": "[\r\n\u0085\u2028\u2029]" } |
There was a problem hiding this comment.
Low (trigger unconfirmed) · unverified: DateTime rejects valid offset leap seconds
The DateTime regex only accepts second 60 at local 23:59:60 with a zero offset, although the drafts permit generic RFC3339 expires and timestamps. A valid representation such as 2016-12-31T18:59:60-05:00 is rejected, breaking valid Challenge or Receipt interoperability. Broaden leap-second handling for offset-adjusted local times or make UTC a normative protocol requirement.
Valid? React with 👍 / 👎.
| @functools.lru_cache(maxsize=None) | ||
| def braced_ids(line: str) -> frozenset[str]: | ||
| """The requirement IDs written somewhere in a line after a { with no } in between. | ||
|
|
||
| One pass over the line's IDs, cached, so checking every distinct ID on a long line | ||
| costs one scan of it rather than one per ID. | ||
| """ | ||
| opens, closes = brace_positions(line) | ||
| found: set[str] = set() | ||
| for match in SOURCE_ID.finditer(line): | ||
| at = match.start() | ||
| opened = bisect.bisect_left(opens, at) | ||
| closed = bisect.bisect_left(closes, at) | ||
| if opened and (not closed or opens[opened - 1] > closes[closed - 1]): | ||
| found.add(match.group(1)) | ||
| return frozenset(found) | ||
|
|
||
|
|
||
| def in_braces(line: str, text: str) -> bool: | ||
| """Whether text occurs after a { with no } in between, as an IAL or ALD writes it. | ||
|
|
||
| A requirement ID is looked up in braced_ids, so the whole ID must match, not a prefix | ||
| of a longer one. Other text is found mention by mention, each looking up the last { | ||
| and } before it by binary search, so a run of unclosed braces stays near linear. | ||
| """ | ||
| if "{" not in line: | ||
| return False | ||
| if SOURCE_ID.fullmatch(text): | ||
| return text in braced_ids(line) | ||
| opens, closes = brace_positions(line) | ||
| pos = 0 | ||
| while (found := line.find(text, pos)) >= 0: | ||
| opened = bisect.bisect_left(opens, found) | ||
| closed = bisect.bisect_left(closes, found) | ||
| if opened and (not closed or opens[opened - 1] > closes[closed - 1]): | ||
| return True | ||
| pos = found + 1 | ||
| return False |
There was a problem hiding this comment.
Medium (trigger unconfirmed) · unverified: Requirement lint misreads a {{req-...}} cross-reference as a second or detached requirement…
What goes wrong: in_braces/braced_ids (scripts/lint_requirements.py:652-689) count a requirement ID as written in an IAL or ALD whenever any '{' precedes it with no '}' in between. kramdown-rfc's cross-reference syntax '{{req-tempo-charge-010}}' meets that test, although it renders as <xref target=...> and sets no anchor. flatten (216-237) adds nothing for the xref, so only the source-line scan sees it.
Full finding
Requirement lint misreads a {{req-...}} cross-reference as a second or detached requirement ID
What goes wrong: in_braces/braced_ids (scripts/lint_requirements.py:652-689) count a requirement ID as written in an IAL or ALD whenever any '{' precedes it with no '}' in between. kramdown-rfc's cross-reference syntax '{{req-tempo-charge-010}}' meets that test, although it renders as <xref target=...> and sets no anchor. flatten (216-237) adds nothing for the xref, so only the source-line scan sees it.
In the occurrence loop (883-935), an anchored ID's occurrence is skipped only when the block starting before that line has the same anchor. An xref on a non-first line of another tagged paragraph therefore falls through. It passes in_braces and KRAMDOWN_ID, and is not reported as rendered text because it is an anchor. It is then appended to lost[owner] for the enclosing paragraph. The final loop (978-1016) merges it with that paragraph's own ID and reports two errors: 'more than one requirement ID (req-...-010, req-...-042)' and 'duplicate ID req-...-010 (first on line N)'. An xref on the first line of a paragraph whose predecessor has a different anchor gets the else branch instead: '... is not directly after a paragraph or list item'.
Concrete trigger: change 'See {{split-payments}} for rationale.' in the tagged req-tempo-charge-042 paragraph (draft-tempo-charge-00.md:797-799) to 'See {{req-tempo-charge-010}} for rationale.'. This is valid kramdown-rfc that xml2rfc resolves, and the draft already uses '{{anchor}}' xrefs throughout. The lint then emits both spurious errors above.
Impact: test_lint_requirements.py:362-365 runs --strict on tempo-charge, and the 'Test scripts' step (pr-check.yml:85-86) has no continue-on-error. A correct edit that cites a requirement by its new anchor therefore fails the PR check, and the warn-mode lint gives misleading annotations on every other draft. This is a CI gate false positive (integrity and availability of the merge gate). There is no confidentiality or privilege impact.
Preconditions: an author xrefs a requirement anchor, which STYLE.md (55-58) presents as a citable ID and does not forbid. The repository does not do this today.
Missing evidence: this was not executed, because kramdown-rfc and python3 are not installed in this environment. The trace assumes kramdown-rfc renders '{{id}}' as an empty <xref target="id"/> and the paragraph IAL as anchor="id".
Fix: drop '{{...}}' xref occurrences before the ID scans. For example, blank '{{...}}' spans in the 'loud' text and test in_braces against loud. Or require the brace that opens an ID occurrence to be an IAL or ALD opener ('{:' not followed by ':', or a header '{#'). Add a test with '{{req-x-001}}' in a later tagged paragraph, on both its first and a later line.
Valid? React with 👍 / 👎.
| "pattern": "^[^\u0000-\u0008\u000A-\u001F\u007F]*$", "not": { "pattern": "[\r\n]" } | ||
| }, |
There was a problem hiding this comment.
Low (trigger unconfirmed) · unverified: Challenge schema accepts strings that cannot be UTF-8
ParamValue omits the UTF-16 surrogate range from its exclusions. A decoded credential can therefore contain an escaped lone surrogate such as \uD800 in challenge.realm and still validate, despite the protocol's RFC 3629 requirement. Realm participates in Challenge binding, so conforming implementations may reject, replace, or differently encode the same accepted value, producing interoperability failures or input-triggered exceptions.
Full finding
ParamValue omits the UTF-16 surrogate range from its exclusions. A decoded credential can therefore contain an escaped lone surrogate such as \uD800 in challenge.realm and still validate, despite the protocol's RFC 3629 requirement. Realm participates in Challenge binding, so conforming implementations may reject, replace, or differently encode the same accepted value, producing interoperability failures or input-triggered exceptions. Reject U+D800 through U+DFFF and apply a shared Unicode-scalar constraint to protocol strings.
Valid? React with 👍 / 👎.
| def test_long_paragraph_is_linear(self, tmp_path): | ||
| import time | ||
| spec = write_spec(tmp_path, "Clients MUST x\n" + "word " * 20 + "\n" * 0 + ("more text\n" * 40000)) | ||
| start = time.perf_counter() | ||
| lint_file(spec) | ||
| assert time.perf_counter() - start < 2 |
There was a problem hiding this comment.
Informational · unverified: Blocking test times kramdown-rfc subprocess render against a 2 s wall-clock bound
Mechanism: test_long_paragraph_is_linear (scripts/test_lint_requirements.py:340-345) is meant to show that the Python scanning is linear. It wraps the whole lint_file(spec) call in perf_counter and asserts it finishes in under 2 s. lint_file calls render() first (scripts/lint_requirements.py:721-737), and render() runs kramdown-rfc with subprocess.run (lines 158-195).
Full finding
Mechanism: test_long_paragraph_is_linear (scripts/test_lint_requirements.py:340-345) is meant to show that the Python scanning is linear. It wraps the whole lint_file(spec) call in perf_counter and asserts it finishes in under 2 s. lint_file calls render() first (scripts/lint_requirements.py:721-737), and render() runs kramdown-rfc with subprocess.run (lines 158-195). So the timed region includes Ruby interpreter startup, loading the kramdown-rfc gems, parsing and converting a 40,001-line (~400 KB) paragraph to XML, ElementTree parsing, and then the Python work. Trigger: any CI run where the GitHub-hosted runner is slow or loaded, or a slower Ruby/kramdown-rfc build in the Docker image. Impact: the test runs in the 'Test scripts' pytest step, which has no continue-on-error (.github/workflows/pr-check.yml:85-86). A timing overrun fails build-and-check and the CI gate on PRs that don't touch the lint, and the test still doesn't isolate the linearity it claims to check. Other render-including timing tests use 10-20 s bounds (lines 800-807, 843-853), which makes the 2 s bound the outlier. Missing evidence: actual timings of this test on GitHub-hosted runners. This sandbox has no Ruby, kramdown-rfc or Python, so neither the flake rate nor the current margin could be measured. Remediation options: (a) render once outside the timer and time only the post-render Python steps (for example monkeypatch lint_requirements.render to return pre-rendered XML, or time extract() plus the SourceMap and lint passes); (b) assert a growth ratio between two input sizes instead of an absolute bound; or (c) give the render-including bound the same generous margin as the other render tests.
Valid? React with 👍 / 👎.
| refs = sorted(n for name in names for n in ald_refs.get(name, [])) | ||
| if not refs or any(n >= item.start for n in refs): | ||
| return None |
There was a problem hiding this comment.
Low (trigger unconfirmed) · unverified: Chained ALDs bypass detached-ID checks
ALD chaining is supported, but ald_refs records only direct non-ALD IAL references (E5/E6/E8). A draft can define ALD a with #req-..., define ALD b referencing a, then place {: b} before a normative paragraph. Kramdown anchors the paragraph, but written_before finds no direct reference to a, returns None, and strict mode counts it as correctly tagged (E7/E9/E10).
Full finding
ALD chaining is supported, but ald_refs records only direct non-ALD IAL references (E5/E6/E8). A draft can define ALD a with #req-..., define ALD b referencing a, then place {: b} before a normative paragraph. Kramdown anchors the paragraph, but written_before finds no direct reference to a, returns None, and strict mode counts it as correctly tagged (E7/E9/E10). This defeats the direct-after invariant and makes source associations consumed by tests and gap reports fragile. Compute transitive ALD-to-IAL reachability and test an indirect pre-block reference.
Valid? React with 👍 / 👎.
| for item in items: | ||
| if item.kind != "row": | ||
| continue | ||
| for cell in item.cells: | ||
| text = PRESENCE_MARKER.sub("", cell) | ||
| if KEYWORD.search(text) or (text != cell and CONDITION.match(text)): | ||
| report.error(item.start, "keyword in a table cell; state the rule in a tagged paragraph") | ||
| break |
There was a problem hiding this comment.
Low (trigger unconfirmed) · unverified: Table-cell keyword check flags quoted keyword names that the paragraph check ignores
Mechanism: the lint's own rule (scripts/lint_requirements.py:54-61) is that a keyword in double quotes is named, not used. Item.is_requirement applies that rule by running QUOTED_KEYWORDS.sub before KEYWORD.search (lines 136-138). The table-cell loop (lines 969-976) never applies QUOTED_KEYWORDS.
Full finding
Mechanism: the lint's own rule (scripts/lint_requirements.py:54-61) is that a keyword in double quotes is named, not used. Item.is_requirement applies that rule by running QUOTED_KEYWORDS.sub before KEYWORD.search (lines 136-138). The table-cell loop (lines 969-976) never applies QUOTED_KEYWORDS. It strips a leading presence marker with PRESENCE_MARKER, then runs KEYWORD.search on the raw cell text. table_rows/flatten (lines 278-298) keep the quote characters, so a cell that only names a keyword is reported as 'keyword in a table cell; state the rule in a tagged paragraph'. That counts as a problem, and --strict exits 1 (lines 1096-1104).
Trigger: a Markdown table cell such as | level | "MUST" | Absolute requirement |, or a description cell like Set to "OPTIONAL" when .... A quoted marker in the Required column, "OPTIONAL", also misses PRESENCE_MARKER because that pattern is anchored at ^, so it is flagged too.
Impact: strict mode fails, and CI shows a spurious annotation, for a table that names a keyword without using it. The advice also contradicts itself. If the author follows it and moves the text into a paragraph, that paragraph is not a requirement, because is_requirement strips the quoted name. Adding an ID then triggers '<id> is on text with no BCP 14 keyword; drop the ID or restore the keyword' (lines 995-999, STYLE.md:76-77). Rewording to drop the quotes is the only way to pass.
Preconditions and missing evidence: no draft at this revision has a table cell that quotes a keyword (tempo-charge's cells are bare markers, lines 155-172), so nothing in CI is affected today. The failure applies to drafts tagged later and checked with --strict. kramdown-rfc was not available here, so the rendered cell text was not confirmed at runtime. Whether kramdown renders straight quotes or curly quotes, the quote characters are non-alphanumeric, so KEYWORD still matches.
Remediation: in the table loop, compute unquoted = QUOTED_KEYWORDS.sub("", cell), then text = PRESENCE_MARKER.sub("", unquoted). Use text != unquoted in the CONDITION guard. Add a test that a quoted keyword in a cell is not reported.
Valid? React with 👍 / 👎.
Context
Adds the requirement-ID convention, its lint and protocol schemas, so automated tooling can check invariants on the specs. Tagging the drafts themselves happens in separate PRs, starting with tempo-charge in #407.
Summary
{: #req-<draft>-<nnn>}block IAL after each normative paragraph or list item; AGENTS.md points to itscripts/lint_requirements.py+ tests: reports untagged requirements, duplicate, malformed, detached and out-of-order IDs; warn-only by default,--strictexits 1; added tomake lintschemas/protocol.schema.json: copied from tempoxyz/mpp-toolsconformance/schemas/with$idunderhttps://paymentauth.org/schemas/, plusschemas/README.md--stricttest that keeps it tagged, moved to feat(tempo-charge): tag every requirement with an ID #407, which stacks on this PRscripts/check.shdoesn't call the lint because that file is executable and would need an unsigned commit--strictfailures, because new rules take the next free numberrequestas an object), not the base64url wire formmake lint,make test(95 passed),make check(rfclint passes; the "Duplicate word" messages also appear on main