gitoria

calendar

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commitedb7c947edb7c947calendar: the sign-in callback keeps the session it finds and signs it in (same cookie, nothing signed out; ident#28); security gate 56+4 failing → 60 passedmreedb7c947/tests/realdata-compare.py

5.3 KB

  1. #!/usr/bin/env python3
  2. # tests/realdata-compare.py (calendar mission 001, copied from notes mission 002 / gitoria mission 002): compare two tests/realdata-baseline.mjs outputs. Masks only what is
  3. # not the app's output:
  4. # every file "at":<ms> (the seed's / offline block's request time, also double-escaped), the port in the echoed Host header, "site":"<file:l:c>" and Child@<line>:<col> (source positions of
  5. # View nodes / mount keys: they move when lines move), ?v=<hash> (hl:web's content hashes of the modules),
  6. # state=<nonce> in the tickets connect redirect (random per click), hl-shell-<hash> (the service worker's
  7. # cache name: a hash of all modules, so it changes with any code change)
  8. # 'w-' files (the writes) the new mpackdb ids, the version stamps (`edited`, ms), the random login tags
  9. # '-module-' files (the browser half: component modules, runtime, client) — a module is the component's own code + tables
  10. # of the statics it imports (a real client-callable function, or a refusing server-only stub naming its
  11. # file). Moving a static to another file changes those tables and the source positions, not the behaviour, so
  12. # a module counts as the same when (1) its own code is the same with every source position masked and (2) every
  13. # imported name its own code uses is the same kind (function / stub), a function with the same body. A
  14. # declaration's keyword is masked too (`var x=` ↔ `const x=`): Hybriel compiles `let x` to `var` and a plain
  15. # declaration to `const` — exactly what the `let` cleanup changes.
  16. # python3 tests/realdata-compare.py <dirA> <dirB> [-v] → counts + the differing files; exit 1 on a real difference
  17. import os, re, sys, difflib
  18. a, b = sys.argv[1], sys.argv[2]; verbose = '-v' in sys.argv
  19. masks = [(re.compile(r'(\\+)"at(\\+)":\d+'), r'\1"at\2":T'), (re.compile(r'calendar\.test:\d+'), 'calendar.test:PORT'), (re.compile(r'"at":\d+'), '"at":T'),
  20. (re.compile(r'\\"site\\":\\"[^"\\]*\\"'), r'\"site\":S'), (re.compile(r'"site":"[^"]*"'), '"site":S'),
  21. (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'),
  22. (re.compile(r'state%3D[0-9a-f]+|state=[0-9a-f]+'), 'state=NONCE')]
  23. 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')]
  24. POS = re.compile(r'[\w-]+\.hl:\d+:\d+|[A-Z]\w*@\d+:\d+|\b(?:var|const) (?=\w+=)')
  25. def moduleParts(t):
  26. t = re.sub(r'\?v=[0-9a-f]+', '?v=H', t)
  27. kinds, own = {}, []
  28. lines = t.split('\n'); i = 0
  29. while i < len(lines):
  30. l = lines[i]
  31. m = re.match(r'\$_\d+\.(\w+)=(.*)$', l)
  32. if m:
  33. if m.group(2).startswith('()=>_55('): kinds.setdefault(m.group(1), ('stub', ''))
  34. else:
  35. body = [m.group(2)]
  36. while not lines[i].endswith('}));') and not (lines[i].endswith(';') and lines[i] is l and '=>{' not in l):
  37. i += 1; body.append(lines[i])
  38. kinds[m.group(1)] = ('fn', POS.sub('P', re.sub(r'\$_\d+', '$_N', '\n'.join(body))))
  39. i += 1; continue
  40. if l.startswith('import{') and '/__hl/hl-runtime.js' in l: i += 1; continue # the runtime helpers the tables use too
  41. if re.match(r'const \$_\d+=\{\};$', l) or re.match(r'const \w+=\$_\d+\.\w+;$', l) or re.match(r'const \w+=\(\)=>_55\(2,', l):
  42. m2 = re.match(r'const (\w+)=\(\)=>_55\(2,', l)
  43. if m2: kinds[m2.group(1)] = ('plugin', '')
  44. i += 1; continue
  45. own.append(POS.sub('P', re.sub(r'\$_\d+', '$_N', l))); i += 1
  46. return kinds, '\n'.join(own)
  47. def sameModule(x, y):
  48. kx, ox = moduleParts(x); ky, oy = moduleParts(y)
  49. if ox != oy: return False
  50. # the names the component's own code takes from the module scope: not `this.x` / `o.x`, not its own methods
  51. # (`async build(…){` — calendar's month view has a method `build`, events-helpers.hl a static `build`)
  52. words = set(re.findall(r'(?<![.\w$])[A-Za-z_]\w*\b', ox)) - set(re.findall(r'\basync (\w+)\(', ox))
  53. return all(kx.get(n) == ky.get(n) for n in words & (set(kx) | set(ky)))
  54. def norm(t, w):
  55. for r, s in masks: t = r.sub(s, t)
  56. if w:
  57. for r, s in wmasks: t = r.sub(s, t)
  58. return t
  59. fa, 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')
  60. if fa != fb: print('FILE LISTS DIFFER', sorted(set(fa) ^ set(fb))[:20]); sys.exit(1)
  61. same = masked = modules = 0; bad = []
  62. for f in fa:
  63. x, y = open(os.path.join(a, f), errors='replace').read(), open(os.path.join(b, f), errors='replace').read()
  64. if x == y: same += 1; continue
  65. w = '-w-' in f
  66. if norm(x, w) == norm(y, w): masked += 1; continue
  67. if '-module-' in f and sameModule(x, y): modules += 1; continue
  68. bad.append(f)
  69. if verbose:
  70. print('==== DIFF', f)
  71. for l in list(difflib.unified_diff(norm(x, w).split('\n'), norm(y, w).split('\n'), lineterm='', n=0))[:12]: print(' ', l[:300])
  72. reads = sum(1 for f in fa if '-w-' not in f)
  73. 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')
  74. for f in bad[:40]: print(' DIFF', f)
  75. sys.exit(1 if bad else 0)

Branches

Latest commits

  • edb7c947calendar: the sign-in callback keeps the session it finds and signs it in (same cookie, nothing signed out; ident#28); security gate 56+4 failing → 60 passedmre
  • bf8cc0fcStyles move into their components: the shell's styles into main.hl, the events and the editors into the month view's Style block; styles.hl keeps only the theme inherit, the accent and the message line; .gitignore ignores a bin symlink too; tests/styles-shots.mjs for the before/after pixel comparemre
  • 5d8579d7README: login.js stays by caramboleyo's explicit rulemre
  • cc759328Merge sb3-standby: calendar deploys through its standbymre
  • f2fcdc6dcalendar: a standby container (port 45015, profile standby, reminder clock off) and a /health page; deploy hands over through standby-swap.sh without a gapmre
  • 229643f7Merge branch 'cal-14'mre
  • 1110b26fcalendar#14: the month name no longer breaks into two lines on a phone (Reminder settings drops to its own row when the header is too narrow), gate checks for one-line title and all header controls on screenmre
  • 490c658aident#31: the selector's sign-in returns to the page the user started on (return attribute = the login callback with next), gate checkmre
  • 18095868calendar: Reminder settings button opens its dialog again (the dialog's open handler still closed the removed user menu and stopped); old e2e and gate scripts use the new headermre
  • 6eee4b5acalendar header: the selector alone top right plus Log out as before the theme missions; Reminder settings back on the month page (WIP: the settings test still fails)mre
  • 0b909decident 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
  • 0c8f9364Merge branch 'sy-sync'mre
  • 9fab1c8fsync components.hybriel 4922f9c into the month view: prev / next 44 px targets, names formatted in UTC (a UTC+12 zone showed the wrong first weekday); the calendar keeps its own language handling (Accept-Language / browser) and the P1/C13 reminder code; gate: 44 px check (SY)mre
  • 27d3e294theme: sync from layouts 4994037 (list rows stack, td word-keep, heading code, edited tap target)mre
  • 2ac9c1bbdeploy: security gate (tests/security.mjs)mre
  • 6b0a2571merge sc-sec (calendar security) with 99-year sessionsmre
  • 92001e52sessions last 99 years (creator 2026-10-23: logins never expire; only sign out ends them)mre
  • 0f76c99dSecurity audit SC: push endpoint SSRF guard, uploadMax 0, Secure cookie, login session rotation + rate limit, event cap, nosniff, security gatemre
  • 2dd53dccP1: one reminder shows once: arm() one at a time, the page skips reminders the server already pushed; push-twice gatemre
  • 3a29760aC13 report (handoff)mre