gitoria

ident

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Branchf3-codestep51e387f2|||PR ident#40 the code step is one component (components/codestep.hl) placed by home.hl and embed.hl; its verify face, setCode, browserZone and verify call exist once (#40.2)mref3-codestep/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

  • 51e387f2|||PR ident#40 the code step is one component (components/codestep.hl) placed by home.hl and embed.hl; its verify face, setCode, browserZone and verify call exist once (#40.2)mre
  • c28bddeeMerge branch 'f2-shell' into mainIdent
  • c3a40ff6|||PR ident#40 one shell for the app and /start (account part off on /start, #40.1); startshell.hl removed; unused signOut faces gone (#40.4)mre
  • 060f3870ident#40.4: use the shell sign-out faces in regression gatesmre
  • 9b94aa6aMerge branch 'f1b-cleanup' into mainIdent
  • edcfce3f|||PR ident#41 ident#43 ident#44 login error page as a component (same status codes and text, pixel-identical), declarations and route wiring cleaned upmre
  • 3ac85995ident#43 ident#44: plain declarations for never-reassigned lets, one envString helper, named route functions and audience rule out of project.hlmre
  • c7eef14aMerge branch 'nv1-navigate' into mainIdent
  • 644f9775|||PR ident#36 navigate() instead of window.location in the shell, start shell and homemre
  • 4ca2f921deploy.sh: tar --hard-dereference so backups hold no hard linksmre
  • 23971fb7ident#49: media queries in the language's @media formmre
  • 73f4f97dident: re-vendor to hybriel day38b (mpackdb store-open fix)mre
  • aa056c03ident: a startup error prints its message before exit 1 (hybriel#247)mre
  • ee37a861ident#G48: gitoria's registration gets the wildcard origin of its repo addresses at load (gate tests/gitoria-origin.mjs)mre
  • dc6d486fident#27: the docs gate expects the new Access entry in the main menumre
  • d277633cident#27: README: identity access and the introspect endpointmre
  • e999b0d3ident#27: the Access tab — one key per identity for all its apps: give access in three steps, the overview matrix, a cell's sheet (since, last use, level, rotate, revoke), the app's check POST /api/introspect, agent identities hidden from the login picker, an inbox icon in the header's icon style (gate: tests/access.mjs)mre
  • 436206fcident#47: deploy.sh runs the sign-in gate on the deploy's own port slot, like the sessionwrites and docs gates (the default 8700 can be taken by another process)mre
  • a4887ea3ident#47: the selector's sign-in frame no longer has a Continue button; the identity row itself is the link (gate tests/signin.mjs fails on the old code)mre
  • d8ec703dident#45: /docs shows docs/IDENT.md (hl:markdown, vendored from ac1ed9da), one Docs entry in the main menu, README for developers only, gates tests/docs.mjs and tests/sessionwrites.mjs in deploy.shmre