Fix subscripted-variable false positives; finalize plugin metadata

verify-calculations.sh mistook subscripted/numbered variables (x_1, x1,
3x_1) for bare numeric equations, flagging e.g. "x_1 = 0" as the false
claim "1 = 0". The single-letter variable regex only excluded adjacent
letters, not trailing digits/underscores, and the prose segment
extractor could start a fresh match right after such a break, mining a
free digit out of the identifier.

Also carries over the author/repository metadata and the SSH-vs-HTTP
install note for the Forgejo marketplace (DISABLE_HTTP_GIT blocks the
https URL; the ssh:// path has no /forgejo/ segment).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
boyreau 2026-11-08 12:22:18 +01:00
commit f672241e9c
4 changed files with 38 additions and 5 deletions

View file

@ -2,7 +2,7 @@
"name": "claude-math",
"description": "Marketplace à plugin unique : claude-math.",
"owner": {
"name": "claude-math"
"name": "zo"
},
"plugins": [
{

View file

@ -2,5 +2,9 @@
"name": "claude-math",
"description": "Exercices calibrés et correction pour un cours de mathématiques pour la cryptographie : génération de séries progressives, notation du cours, suivi de progression, et vérification automatique des calculs arithmétiques/modulaires tapés dans les messages.",
"version": "1.0.0",
"author": {
"name": "zo"
},
"repository": "https://zospace.freeboxos.fr/forgejo/zo/claude-math",
"keywords": ["maths", "cryptographie", "arithmétique", "exercices"]
}

View file

@ -19,10 +19,23 @@ vérification automatique des calculs tapés dans les messages.
> d'un message). Voir [Se passer de Nix](#se-passer-de-nix) pour l'adapter.
```bash
/plugin marketplace add <url-de-ce-dépôt>
/plugin marketplace add https://zospace.freeboxos.fr/forgejo/zo/claude-math
/plugin install claude-math@claude-math
```
L'instance Forgejo refuse actuellement le git en HTTP (`DISABLE_HTTP_GIT`), si
bien que l'URL ci-dessus ne sert qu'à consulter le dépôt. Pour que
`/plugin marketplace add` fonctionne en HTTPS, passer `DISABLE_HTTP_GIT =
false` dans `app.ini` ; sinon, installer par SSH :
```bash
/plugin marketplace add ssh://forgejo@zospace.freeboxos.fr/zo/claude-math
/plugin install claude-math@claude-math
```
Noter que le chemin diffère entre les deux protocoles : le segment `/forgejo/`
est celui du reverse-proxy web et n'existe pas côté SSH.
Le dépôt est à la fois le plugin (`.claude-plugin/plugin.json`) et une
marketplace à entrée unique (`.claude-plugin/marketplace.json`), donc les deux
commandes suffisent.

View file

@ -185,9 +185,20 @@ MATH_RUN = re.compile(r'(?:[0-9]|\bmod\b|\bphi\b|\bgcd\b|\blcm\b|[+\-*/^()≡=,%
def extract_segments(line):
"""Pull the mathematical runs out of a line that also carries prose, so
`Euler's theorem gives 8^6 mod 15 = ... = 4 mod 15.` still gets checked
instead of being skipped because the sentence as a whole won't parse."""
instead of being skipped because the sentence as a whole won't parse.
A letter breaks a run (so identifiers don't get read as arithmetic), but
a digit/underscore right after it doesn't - so for `x_1 = 0` the `_`
broke the run and the following `1` started a *new* one, mining the
bogus standalone claim `1 = 0` out of a variable name. A run that starts
right after a letter/digit/underscore is such a fragment, chopped out of
a longer identifier, not a real standalone number - discard it instead
of checking it."""
segments = []
for m in MATH_RUN.finditer(line):
start = m.start()
if start > 0 and re.match(r'[a-zA-Z0-9_]', line[start - 1]):
continue
seg = m.group(0).strip(' ,;:.')
if not seg or not re.search(r'≡|=', seg):
continue
@ -284,8 +295,13 @@ def verify_claim(line):
# meaningless and slow enough to blow the hook's timeout.
if re.search(r'[a-zA-Z]{2,}', re.sub(r'\b(mod|phi|gcd|lcm)\b', '', body)):
return ('skip', None)
if len(parts) == 2 and re.search(r'(?<![a-zA-Z])[a-zA-Z](?![a-zA-Z])', body):
var = re.search(r'(?<![a-zA-Z])[a-zA-Z](?![a-zA-Z])', body).group(0)
# A trailing digit/underscore must also break the match (not just a
# trailing letter), so a subscripted name like `x_1` or `x1` isn't
# mistaken for the lone variable `x` with its subscript silently
# dropped. A LEADING digit is fine and must stay allowed: `2x` is
# ordinary coefficient notation for `2*x`.
if len(parts) == 2 and re.search(r'(?<![a-zA-Z])[a-zA-Z](?![a-zA-Z0-9_])', body):
var = re.search(r'(?<![a-zA-Z])[a-zA-Z](?![a-zA-Z0-9_])', body).group(0)
if var in ('e', 'I', 'N', 'S', 'O'):
return ('skip', None)
try: