Commit Graph

12 Commits

Author SHA1 Message Date
John Dvorak 1bc92e1f7d fix: CDP extraction concurrency + topology ID remapping + predicate completeness
CDP protocol fixes:
- session.ts: getDocumentRootNodeId() now pushes {depth:-1} full DOM tree
  (was shallow default, causing querySelectorAll to find zero nodes)
- extraction.ts: serialize resolveSelector calls (was concurrent Promise.all,
  CDP DOM.querySelectorAll is not safe for concurrent calls on same session)

Topology ID mismatch fixes (critical — backendNodeId vs solver subject ID):
- extraction.ts: add remapTopologyIds() — builds Map<backendNodeId,solverId>
  from world.subjects.domNodeId/ids, remaps all 6 topology arrays +
  clipping.subjectId + scroll.containerId
- topology.ts: createsStackingContext() now checks contain:paint|layout
  (both create stacking contexts per CSS spec, was missing)
- topology.ts: evaluateInStackingContext() handles unary (no reference)

Predicate completeness:
- predicates.ts: 3 new evaluators — intersects, touches, hasGap (indices 31-33)
- predicates.ts: escapeClippingChainOf replaced indeterminate stub with
  deterministic 2-ary evaluator (overflow + clip chain + ancestry checks)
- predicates.ts: attachedToScrollContainer arity 1→2, checks reference match
- predicates.ts: 7 aliases + 4 alignment aliases promoted to BUILTIN_PREDICATES

DSL grammar fixes:
- grammar.ts: isKeywordThatCanBePredicate() extended with all missing keywords
- lower-to-canonical.ts: add TopologyAssertion lowering (was silently dropped)
- compiler.ts: add intersects/touches/hasGap relation codes
- validator.ts: add option sets for new predicates
- lexer.ts: add intersects/touches/hasGap token kinds

Safety + infrastructure:
- joins.ts: MAX_CARTESIAN_TUPLES=100,000 guard with descriptive error
- extraction.ts: computeRequiredFacts() registers defaults + broadens topology gate
- package.json: add missing imhotep-state dependency to imhotep-playwright

Tests:
- 9 new predicate tests (intersects, touches, hasGap, escapeClippingChainOf)
- Convert stale separatedFrom/contains GAP tests to working assertions
- Add computeRequiredFacts topology gating tests (public.test.ts)
2026-05-22 10:20:06 -07:00
John Dvorak 654becabc6 chore: remove dead makeNotImplementedPredicate helper
All 27 BUILTIN_PREDICATES now have real evaluators. The
makeNotImplementedPredicate factory and its IMH_FEATURE_NOT_YET_IMPLEMENTED
path were the last remaining NYI scaffolding — no caller existed for it.
IMH_FEATURE_NOT_YET_IMPLEMENTED diagnostic code kept in the taxonomy
as a future fallback, but no evaluator produces it.
2026-05-21 20:15:40 -07:00
John Dvorak 35c5dbd153 fix: add missing predicate evaluators and BUILTIN_PREDICATES entries
- CRITICAL: escapeClippingChainOf now has an evaluator (returns indeterminate
  with clear diagnostic — full implementation requires fragment-level bounds
  analysis). Previously parsed but silently produced IMH_EVALUATOR_MISSING.
- attachedToScrollContainer added to BUILTIN_PREDICATES with evaluator
  (checks world.topology.scrollContainerOf). Was only in legacy engine.
- aspectRatio added to BUILTIN_PREDICATES with evaluator (compares
  width/height ratio against min/max bounds). Was only in legacy engine.
- Fix all BUILTIN_PREDICATES index references shifted by new entries
  (beside 17→20, nextTo 18→21, adjacent 19→22, touching 20→23,
  near 21→24, under 22→25, within 23→26, separatedFrom 16→18,
  inStackingContext 15→17).
- Register attachedToScrollContainer, escapeClippingChainOf, aspectRatio
  in registerDefaultPredicates.
- Zero NYI/not-implemented predicates remain in the registry.
2026-05-21 20:10:17 -07:00
John Dvorak 16dcf42762 fix: propagate operand metrics through boolean connectives
- evaluateAnd: carry left metrics on left-fail short-circuit,
  carry right metrics on right fail/indeterminate
- evaluateOr: carry left metrics on left-pass short-circuit,
  carry right metrics on right pass, merge both on double-fail
- evaluateNot: carry operand metrics when operand passes
  (so not fails with diagnostic context), carry on indeterminate
- evaluateImplies: carry consequent metrics on fail/indeterminate

This ensures compound formula failures preserve measured geometry
context (gap, dimensions, direction) rather than presenting empty
diagnostics to users investigating layout contract violations.
2026-05-21 17:14:00 -07:00
John Dvorak 5830d5861e fix: resolve inStackingContext arity/semantics mismatch
- Change BUILTIN_PREDICATES[15] arity from 1 to 2 to match binary usage
  in the FOL compiler and topology engine
- Update evaluator to handle both unary (does element have stacking context)
  and binary (do both elements share the same stacking context) cases
- Binary comparison: both elements must have a valid stacking context
  AND their stackingContextOf values must match
- Aligns predicate semantics with the legacy engine in solver/topology.ts
  and the topology query layer's inStackingContext(graph, subj, ref?) API
2026-05-21 17:10:38 -07:00
John Dvorak 19559b658b feat: implement variable-bound FOL domain resolution for descendants/children
- Extend DomainResolver.resolve() signature to accept optional BindingEnv
  so that parentVar domains can be resolved with runtime variable bindings
- Pass BindingEnv through evaluateForAll/evaluateExists to resolver calls
- Add buildAncestorIndex() to precompute DOM ancestor sets from CDP data
- SelectorDomainResolver now filters descendant domains by the bound parent
  when domain.parentVar is present and ancestor index is available
- Return undefined for parentVar domains when no ancestor index or env
  (prevents silent fallback to global domain resolution)
- Update all test DomainResolver mocks for new resolve interface
- Add 10 unit tests covering ancestor index construction, backward compat,
  descendant filtering, exclusion of non-descendants, empty descendants,
  missing parentVar/env, and no-ancestor-index safety
2026-05-21 17:05:35 -07:00
John Dvorak de12e93cf8 chore: fill CSS contain test gaps + unskip clippedBy e2e test
- Add 4 unit tests in predicates.test.ts for new contain metrics:
  inside hasClippedOverflow (with/without clipping)
  clippedBy clipKind (contain:paint=1, overflow=2)
- Unskip and implement clippedBy e2e test with overflow:hidden container
  in e2e-edge.test.ts (was stale skipped with 'not yet implemented')
2026-05-21 14:44:26 -07:00
John Dvorak 96bcce1ddb feat: implement directional alignment predicate evaluators (no more NYI)
- Replace makeNotImplementedPredicate stubs for leftAlignedWith,
  rightAlignedWith, topAlignedWith, bottomAlignedWith with real
  evaluators delegating to alignedWithPredicate with axis option
- Update logic-engine.test.ts to expect real evaluation results
  instead of IMH_FEATURE_NOT_YET_IMPLEMENTED
2026-05-21 14:36:02 -07:00
John Dvorak 8dae898304 feat: annotate inside/contains overflow metrics with clipping awareness
- insidePredicate: add hasClippedOverflow=1 when reference element
  clips its content (contain:paint or overflow:hidden) and the
  subject overflows beyond the reference bounds
- containsPredicate: same, checking the subject (container) clips
- Reads world.clipping table to determine if the container clips
- Safe when clipping data is absent (unit test fixtures)
2026-05-21 14:11:47 -07:00
John Dvorak c4a3d304ef feat: solver consumes CSS contain:paint for clippedBy diagnostics
- Add Contain=5 to geometry world ClipKind enum (avoids collision with
  topology engine's CONTAIN=3 vs Mask=3)
- Fix CDP isClippingElement() to detect contain:paint (style.contain)
- CDP topology builder sets clipKind=5 for contain:paint, 1 for overflow
- Enrich clippedByPredicate with clipKind metric:
  1=contain:paint, 2=overflow (hidden/scroll/auto)
- Reads world.clipping.clipKind of the reference's clip node
2026-05-21 13:52:28 -07:00
John Dvorak dd64e1e34a v1.1.0: repo polish, CI fixes, version alignment, dead artifact cleanup
Root package: renamed to imhotep-monorepo, fixed broken scripts (test:unit/integration/e2e),
removed inappropriate root deps, fixed build order, updated clean script

CI: branch trigger main->master, npm ci->npm install, GitHub cache URL->Gitea

Docs: replaced scaffolded root README with real project README, added package READMEs
for imhotep/imhotep-playwright/imhotep-dsl/imhotep-core, added RELEASE.md checklist

Version: all 14 packages and root aligned to 1.1.0, CHANGELOG test count fixed (1125)

Metadata: 14 repository URLs github->gitea, 13 package descriptions added,
imhotep-cli exports field added, SECURITY.md updated for Gitea+disclosure email

Quality: noEmitOnError:true in 13 tsconfigs, collapsed duplicate interfaces in public.ts,
clippedBy test->test.skip, fixed broken dynamic import in imhotep index.test.ts,
694 generated src artifacts cleaned, V8 logs removed, .gitignore updated
2026-05-21 10:10:11 -07:00
John Dvorak 92deb689cd v1.1.0: pooled runtime, 959 tests, production hardening (0 squash) 2025-08-15 10:00:00 -07:00