notes
All repositories: gitoria
4.7 KB
#!/usr/bin/env python3# tests/realdata-compare.py (notes mission 002, copied from gitoria mission 002): compare two tests/realdata-baseline.mjs outputs. Masks only what is# not the app's output:# every file "at":<ms> (the seed's request time), "site":"<file:l:c>" and Child@<line>:<col> (source positions of# View nodes / mount keys: they move when lines move), ?v=<hash> (hl:web's content hashes of the modules),# state=<nonce> in the tickets connect redirect (random per click)# 'w-' files (the writes) the new mpackdb ids, the version stamps (`edited`, ms), the random login tags# '-module-' files (the browser half: component modules, runtime, client) — a module is the component's own code + tables# of the statics it imports (a real client-callable function, or a refusing server-only stub naming its# file). Moving a static to another file changes those tables and the source positions, not the behaviour, so# a module counts as the same when (1) its own code is the same with every source position masked and (2) every# imported name its own code uses is the same kind (function / stub), a function with the same body. A# declaration's keyword is masked too (`var x=` ↔ `const x=`): Hybriel compiles `let x` to `var` and a plain# declaration to `const` — exactly what the `let` cleanup changes.# python3 tests/realdata-compare.py <dirA> <dirB> [-v] → counts + the differing files; exit 1 on a real differenceimport os, re, sys, diffliba, b = sys.argv[1], sys.argv[2]; verbose = '-v' in sys.argvmasks = [(re.compile(r'\\"at\\":\d+'), r'\"at\":T'), (re.compile(r'"at":\d+'), '"at":T'),(re.compile(r'\\"site\\":\\"[^"\\]*\\"'), r'\"site\":S'), (re.compile(r'"site":"[^"]*"'), '"site":S'),(re.compile(r'\?v=[0-9a-f]+'), '?v=H'), (re.compile(r'([A-Z]\w*)@\d+:\d+'), r'\1@L:C'),(re.compile(r'state%3D[0-9a-f]+|state=[0-9a-f]+'), 'state=NONCE')]wmasks = [(re.compile(r'\b0m[0-9a-z]{10}\b'), 'ID'), (re.compile(r'\b1[6-9]\d{11}\b'), 'MS'), (re.compile(r'\b[0-9a-f]{32}\b'), 'TAG')]POS = re.compile(r'[\w-]+\.hl:\d+:\d+|[A-Z]\w*@\d+:\d+|\b(?:var|const) (?=\w+=)')def moduleParts(t):t = re.sub(r'\?v=[0-9a-f]+', '?v=H', t)kinds, own = {}, []lines = t.split('\n'); i = 0while i < len(lines):l = lines[i]m = re.match(r'\$_\d+\.(\w+)=(.*)$', l)if m:if m.group(2).startswith('()=>_55('): kinds.setdefault(m.group(1), ('stub', ''))else:body = [m.group(2)]while not lines[i].endswith('}));') and not (lines[i].endswith(';') and lines[i] is l and '=>{' not in l):i += 1; body.append(lines[i])kinds[m.group(1)] = ('fn', POS.sub('P', re.sub(r'\$_\d+', '$_N', '\n'.join(body))))i += 1; continueif l.startswith('import{') and '/__hl/hl-runtime.js' in l: i += 1; continue # the runtime helpers the tables use tooif re.match(r'const \$_\d+=\{\};$', l) or re.match(r'const \w+=\$_\d+\.\w+;$', l) or re.match(r'const \w+=\(\)=>_55\(2,', l):m2 = re.match(r'const (\w+)=\(\)=>_55\(2,', l)if m2: kinds[m2.group(1)] = ('plugin', '')i += 1; continueown.append(POS.sub('P', re.sub(r'\$_\d+', '$_N', l))); i += 1return kinds, '\n'.join(own)def sameModule(x, y):kx, ox = moduleParts(x); ky, oy = moduleParts(y)if ox != oy: return Falsewords = set(re.findall(r'\b\w+\b', ox))return all(kx.get(n) == ky.get(n) for n in words & (set(kx) | set(ky)))def norm(t, w):for r, s in masks: t = r.sub(s, t)if w:for r, s in wmasks: t = r.sub(s, t)return tfa, fb = sorted(f for f in os.listdir(a) if f != '0000-server-log'), sorted(f for f in os.listdir(b) if f != '0000-server-log')if fa != fb: print('FILE LISTS DIFFER', sorted(set(fa) ^ set(fb))[:20]); sys.exit(1)same = masked = modules = 0; bad = []for f in fa:x, y = open(os.path.join(a, f), errors='replace').read(), open(os.path.join(b, f), errors='replace').read()if x == y: same += 1; continuew = '-w-' in fif norm(x, w) == norm(y, w): masked += 1; continueif '-module-' in f and sameModule(x, y): modules += 1; continuebad.append(f)if verbose:print('==== DIFF', f)for l in list(difflib.unified_diff(norm(x, w).split('\n'), norm(y, w).split('\n'), lineterm='', n=0))[:12]: print(' ', l[:300])reads = sum(1 for f in fa if '-w-' not in f)print(f'{len(fa)} files ({reads} reads, {len(fa) - reads} writes): {same} byte-identical, {masked} identical after masking, {modules} browser modules the same (code, imported functions), {len(bad)} DIFFERENT')for f in bad[:40]: print(' DIFF', f)sys.exit(1 if bad else 0)
Branches
Latest commits
- 8762115cnotes: take the components e54f83a (paste as Markdown, text typed before the editor is built is kept, Table button); table lines come from the notes thememre
- ac23e194ident#31: the selector's sign-in returns to the page the user started on (return attribute = the login callback with next), gate checkmre
- 2804f0d3Merge branch 'iw-ident-widget'mre
- 52d8d242notes: e2e script checks Log out and the selector in the header instead of the user menumre
- e5abf7b7notes header: the selector alone top right plus Log out as before the theme missions; the user icon is gonemre
- a2e343aeident selector back in the header (creator 2026-10-24): selector top right signed in and out on phone and desktop, no second Log in button, new gate checks (WIP: gates not re-run after the last edits)mre
- 7a889b82notes: MdEditor with the Table button, typed pipe rows and the theme's table look (components mt-tables); a table note is named by its header words; gate checks that fail on mainmre
- b96c7f70theme: sync from layouts 4994037 (list rows stack, td word-keep, heading code, edited tap target)mre
- 6140e6a0sessions last 99 years (creator 2026-10-23: logins never expire; only sign out ends them)mre
- cb7e6469deploy: security gate (tests/security.mjs)mre
- 774bf34bnotes security: CSRF guard on /api/notes, new session at login, Secure cookie, uploadMax 0, login rate limit, nosniff, face payload check; tests/security.mjs; SN reportmre
- ef18a68fsync components.hybriel 214c318: MdEditor on a phone, two even toolbar rows of 44 px targets, label 15 px, table head 16 px (E2)mre
- c37488b1MN report: alignment updatemre
- 4fb35a0enotes mobile: Delete note and the delete row exactly on the editor's edges; gate asserts 1 pxmre
- 91736270MN report and logmre
- 15667425notes: delete confirmation buttons at most 12rem wide on the desktopmre
- 8f7a6a95gate: MN phone checks (list header gutter, back gap, delete question)mre
- 90c73ed3notes mobile: back link gapmre
- 72bd4f83notes mobile: list header on the gutter, delete confirmation as a question + two equal buttons, Delete note under the editor edgemre
- ba1e73f8notes: a sent edit is done once the server's version is not older, so a second writer's text shows in the first tab; gate: two writers both waysmre