Commit 34dc2de
proof(xml-7-44): discharge Xml744.Attribute proof debts (#80)
## Summary
Discharges the two `PROOF_TODO`-marked sites in `Xml744.Attribute` that
blocked the toolkit's build on Idris2 0.8.0.
1. **`attrName`** used `decEq (isValidName s) True` — `decEq` for `Bool`
is not in scope with the current imports. Replaced with `with
(isValidName s) proof prf`, which binds `prf : isValidName s = True`
directly in the matched branch and discharges `MkAttrName`'s
auto-implicit.
2. **`unsafeAttrName`** was `cast (MkAttrName s)` — never compiled (no
matching `Cast` instance; `MkAttrName` requires the validity proof to
construct). Now takes the proof as an auto-implicit: `(s : String) ->
{auto prf : isValidName s = True} -> AttrName`, so it can only be called
on strings whose validity Idris2 can verify at elaboration time. `Refl`
discharges for any literal — matching the existing doc "use only for
known-good literals".
## Knock-on changes (still in `Xml744.Attribute`)
- `wAttr` routed through `unsafeAttrName ("w:" ++ n)`. Signature bumped
to `(n : String) -> {auto prf : isValidName ("w:" ++ n) = True} ->
String -> XmlAttr` so callers' literal `n` lets the elaborator reduce
both the concatenation and `isValidName` to `True`. All four existing
call sites (`wAttr "id"`, `"author"`, `"date"`, `"initials"`) discharge
automatically.
- `isNameStartChar`, `isNameChar`, `isValidName` promoted from `export`
to `public export` so cross-module callers see the definitions for
elaboration-time reduction.
## Verification
```
$ idris2 -p contrib Xml744/Attribute.idr
1/3: Building Xml744.Escape (Xml744/Escape.idr)
2/3: Building Xml744.Text (Xml744/Text.idr)
3/3: Building Xml744.Attribute (Xml744/Attribute.idr)
Xml744.Attribute> :total Xml744.Attribute.attrName --> is total
Xml744.Attribute> :total Xml744.Attribute.unsafeAttrName --> is total
Xml744.Attribute> :total Xml744.Attribute.wAttr --> is total
[+ attr / renderAttr / getAttrValue / id / name / value — all total]
```
`grep -E
'assert_total|assert_smaller|believe_me|%unsafe|PROOF_TODO|idris_crash|partial
' src/Xml744/Attribute.idr` → no matches.
Toolkit build now advances `3/6 → 4/6`. Element still red on its own
parallel debts (see below).
## Out of scope — known follow-ups in `Xml744.Element`
- `tagName` uses the same `decEq` form (fix: `with proof`).
- `unsafeTagName` uses the same `cast (MkTagName s)` placeholder (fix:
auto-implicit proof).
- `render` / `renderPretty.go` fail totality due to mutual recursion
through `[XmlNode]` — needs explicit termination, e.g. Nat fuel.
Stacks on top of #79 (`proof-debt/xml744-escape-totality`); base is
`main` per [[feedback_stacked_pr_orphan_trap_github]], so the diff is
cumulative until #79 lands, then this rebases to a single-file change.
## Test plan
- [ ] CI green
- [ ] `idris2 --build idris2-ecosystem/xml-toolkit/xml-7-44.ipkg` builds
modules 1–3 cleanly (verified locally)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 3305c92 commit 34dc2de
1 file changed
Lines changed: 33 additions & 15 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
13 | 19 | | |
14 | 20 | | |
15 | 21 | | |
| 22 | + | |
16 | 23 | | |
17 | 24 | | |
18 | 25 | | |
19 | | - | |
20 | | - | |
| 26 | + | |
| 27 | + | |
21 | 28 | | |
22 | 29 | | |
23 | 30 | | |
| |||
28 | 35 | | |
29 | 36 | | |
30 | 37 | | |
31 | | - | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
32 | 44 | | |
33 | 45 | | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
39 | 55 | | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
| 56 | + | |
| 57 | + | |
44 | 58 | | |
45 | 59 | | |
46 | 60 | | |
| |||
77 | 91 | | |
78 | 92 | | |
79 | 93 | | |
80 | | - | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
81 | 99 | | |
82 | | - | |
| 100 | + | |
83 | 101 | | |
84 | 102 | | |
85 | 103 | | |
| |||
0 commit comments