gitoria

ident

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commitf07658c7f07658c7ident: home page shows the account once (account bar removed, the user menu carries email, Sign out, Sign out everywhere); wildcard origins https://*.domain for apps on many subdomains; gates follow (WIP: gates not re-run after the last edits)mref07658c7/tests/realdata-compare.py

5.6 KB

  1. #!/usr/bin/env python3
  2. # tests/realdata-compare.py (ident mission 009, from gitoria's mission 002): compare two tests/realdata-baseline.mjs
  3. # outputs. Masks only what is not the app's output:
  4. # every file "at":<ms> (the seed's request time), "since":<ms> (a session's sign-in time), "who":<hex> (the connection), "site":"<file:l:c>" and Child@<line>:<col> (source positions of
  5. # View nodes / mount keys: they move when lines move), ?v=<hash> and hl-shell-<hash> (hl:web's content hashes of the modules, the worker's cache name)
  6. # 'w-' files (the writes) what is random or a clock per run: new mpackdb ids, rids / codes / pick ids / hashes (hex),
  7. # API keys and secrets, invite tokens, new short ids, millisecond times, "YYYY-MM-DD HH:MM" stamps, six-digit codes;
  8. # the stored state (w-store) is compared line by line, sorted after masking
  9. # '-module-' files (the browser half) count as the same when their own code is the same with every source position
  10. # masked and every imported name it uses is the same kind with the same body (moving a static to another
  11. # file changes the module's tables, not the behaviour); `var x=` ↔ `const x=` is masked (the `let` step).
  12. # python3 tests/realdata-compare.py <dirA> <dirB> [-v] → counts + the differing files; exit 1 on a real difference
  13. import os, re, sys, difflib
  14. a, b = sys.argv[1], sys.argv[2]; verbose = '-v' in sys.argv
  15. masks = [(re.compile(r'\\"at\\":\d+'), r'\"at\":T'), (re.compile(r'"at":\d+'), '"at":T'),
  16. (re.compile(r'\\"site\\":\\"[^"\\]*\\"'), r'\"site\":S'), (re.compile(r'"site":"[^"]*"'), '"site":S'),
  17. (re.compile(r'\?v=[0-9a-f]+'), '?v=H'), (re.compile(r'hl-shell-[0-9a-f]+'), 'hl-shell-H'), (re.compile(r'([A-Z]\w*)@\d+:\d+'), r'\1@L:C'),
  18. (re.compile(r'(\\?"since\\?":)\d+'), r'\1T'), (re.compile(r'(\\?"who\\?":\\?")[0-9a-f]+'), r'\1W')]
  19. wmasks = [(re.compile(r'pk_[0-9a-f]{32}'), 'pk_KEY'), (re.compile(r'sk_[0-9a-f]{48}'), 'sk_SECRET'), (re.compile(r'\b0m[0-9a-z]{10}\b'), 'ID'), (re.compile(r'\b[0-9a-f]{64}\b'), 'H64'), (re.compile(r'\b[0-9a-f]{48}\b'), 'H48'),
  20. (re.compile(r'\b[0-9a-f]{32}\b'), 'H32'),
  21. (re.compile(r'\b1[789]\d{11}\b'), 'MS'), (re.compile(r'\d{4}-\d{2}-\d{2} \d{2}:\d{2}'), 'TIME'),
  22. (re.compile(r'(?<![\d.])\d{6}(?![\d.])'), 'CODE'), (re.compile(r'(shortId\\?":\\?"|class="shortid">)[0-9a-z]{5}'), r'\1SHORT')]
  23. POS = re.compile(r'[\w-]+\.hl:\d+:\d+|[A-Z]\w*@\d+:\d+|\b(?:var|const) (?=\w+=)')
  24. def moduleParts(t):
  25. t = re.sub(r'\?v=[0-9a-f]+', '?v=H', t)
  26. kinds, own = {}, []
  27. lines = t.split('\n'); i = 0
  28. while i < len(lines):
  29. l = lines[i]
  30. m = re.match(r'\$_\d+\.(\w+)=(.*)$', l)
  31. if m:
  32. if re.match(r'\(\)=>_\d+\(', m.group(2)): kinds.setdefault(m.group(1), ('stub', ''))
  33. else:
  34. body = [m.group(2)]
  35. while not lines[i].endswith('}));') and not (lines[i].endswith(';') and lines[i] is l and '=>{' not in l):
  36. i += 1; body.append(lines[i])
  37. kinds[m.group(1)] = ('fn', POS.sub('P', re.sub(r'\$_\d+', '$_N', '\n'.join(body))))
  38. i += 1; continue
  39. if l.startswith('import{') and '/__hl/hl-runtime.js' in l: i += 1; continue
  40. if re.match(r'const \$_\d+=\{\};$', l) or re.match(r'const \w+=\$_\d+\.\w+;$', l) or re.match(r'const \w+=\(\)=>_\d+\(2,', l):
  41. m2 = re.match(r'const (\w+)=\(\)=>_\d+\(2,', l)
  42. if m2: kinds[m2.group(1)] = ('plugin', '')
  43. i += 1; continue
  44. own.append(POS.sub('P', re.sub(r'\$_\d+', '$_N', l))); i += 1
  45. return kinds, '\n'.join(own)
  46. def sameModule(x, y):
  47. kx, ox = moduleParts(x); ky, oy = moduleParts(y)
  48. if ox != oy: return False
  49. words = set(re.findall(r'\b\w+\b', ox))
  50. return all(kx.get(n) == ky.get(n) for n in words & (set(kx) | set(ky)))
  51. # mission 010: Hybriel 0f396652's hl:web registers its own routes FIRST and one more (/__hl/up); the seed lists them, so the
  52. # route entries are compared as a set without /__hl/up (the answers themselves are compared byte for byte, line for line)
  53. ROUTE = re.compile(r'\{\\?"kind\\?":\\?"function\\?",\\?"pattern\\?":\\?"([^"\\]*)\\?"\}')
  54. def routes(t):
  55. found = ROUTE.findall(t)
  56. return re.sub(r',\]', ']', re.sub(r'\[,', '[', re.sub(r',{2,}', ',', ROUTE.sub('', t)))) + ' ROUTES ' + ' '.join(sorted(r for r in found if r != '/__hl/up'))
  57. def norm(t, w, store=False):
  58. t = routes(t)
  59. for r, s in masks: t = r.sub(s, t)
  60. if w:
  61. for r, s in wmasks: t = r.sub(s, t)
  62. if store: t = '\n'.join(sorted(t.split('\n')))
  63. return t
  64. skip = {'0000-server-log'}
  65. fa, fb = sorted(f for f in os.listdir(a) if f not in skip), sorted(f for f in os.listdir(b) if f not in skip)
  66. if fa != fb: print('FILE LISTS DIFFER', sorted(set(fa) ^ set(fb))[:20]); sys.exit(1)
  67. same = masked = modules = 0; bad = []
  68. for f in fa:
  69. x, y = open(os.path.join(a, f), errors='replace').read(), open(os.path.join(b, f), errors='replace').read()
  70. if x == y: same += 1; continue
  71. w = '-w-' in f; st = f.endswith('-w-store')
  72. if norm(x, w, st) == norm(y, w, st): masked += 1; continue
  73. if '-module-' in f and sameModule(x, y): modules += 1; continue
  74. bad.append(f)
  75. if verbose:
  76. print('==== DIFF', f)
  77. for l in list(difflib.unified_diff(norm(x, w, st).split('\n'), norm(y, w, st).split('\n'), lineterm='', n=0))[:12]: print(' ', l[:300])
  78. reads = sum(1 for f in fa if '-w-' not in f)
  79. 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')
  80. for f in bad[:40]: print(' DIFF', f)
  81. sys.exit(1 if bad else 0)

Branches

Latest commits

  • f07658c7ident: home page shows the account once (account bar removed, the user menu carries email, Sign out, Sign out everywhere); wildcard origins https://*.domain for apps on many subdomains; gates follow (WIP: gates not re-run after the last edits)mre
  • f2c43bbbtheme: sync from layouts 4994037 (list rows stack, td word-keep, heading code, edited tap target)mre
  • 6d4f996esessions last 99 years (creator 2026-10-23: logins never expire; only sign out ends them)mre
  • 029eb5e5deploy: security gate (tests/security.mjs)mre
  • d3c065a8security audit (SI): uploadMax 0, Secure __Host- cookie behind https, headers on function routes/files, page CSP+referrer meta, app/identity caps, tests/security.mjs, reportmre
  • 5561a0cbreport I4-mobilemre
  • 4ca2ed20404 page in the shell (viewport, status 404, way home); phone: account actions live in the user menu so the open menu covers nothing; mobile gate; signoutall waits for a cold startmre
  • 9baad745tests: browser gate waits for the reloaded document (offline reload race under CPU throttle); HL_CPU_THROTTLE knobmre
  • b96796bdtests: wait for hydration before real clicks after a navigation (H2)mre
  • 9722964fre-vendor Hybriel 5406d146 (hl:web batches 9+10: #72 emits while the socket is closed delivered after reconnect, browser boot linear, faster list appends; contains int 6–14 + m406)mre
  • c9b196c9tests/iplimit: wait for the welcome form itself after B's first login (identities list renders before it); mission 017 reportmre
  • 72e0f587ident#26: identity page with "Used in" (app, since, last use, Notif. chip, empty state); lastLogin recorded at exchange; gates + lisbeth E2E; mission 016 reportmre
  • 94576fbcident#26 WIP: identity page /identity/:iid with "Used in" (app, since, last use, Notif. chip), lastLogin recorded at exchange, "Used in…" link on the identities list; apps gate 4b, e2e-usedin.mjsmre
  • 349cb502tests/invites: wait for hydration on the code page before entering the code (native GET submit raced the welcome form); mission 015 reportmre
  • d1bf4720tests: no hard-coded ports — every gate's ports and fixture origins come from <GATE>_PORT / _CHROME env (defaults unchanged; Bob/fixture origins follow, selector cookie name too)mre
  • 6280c92fre-vendor Hybriel 6f8a0689 (int 6–11: streaming cursors, #203 index heal + close() fix, fd403 listDir/cursor fds, hl:time browser side, hl:web batches 5+6)mre
  • 147744bftests/migration: the fixture app origin follows MIGRATION_GATE_TESTAPP_PORT (oldstore-009 OLD_TESTAPP)mre
  • 48cd36bctests/migration: ports from env (MIGRATION_GATE_PORT, MIGRATION_GATE_TESTAPP_PORT); 8395/8396 were taken by a foreign servermre
  • 3d9b2fd8docker-compose: nofile 65536 (Hybriel int 6+ boot opened >1024 files in the tracker)mre
  • 19b7e3c3deploy: backup copies index files first and *.mpack data last (hot-copy skew, hybriel #203)mre