* refactor(scheduler): centralize refresh intervals, add VisibilityHub, tiered flush
- Add REFRESH_INTERVALS map in base.ts (34 entries) with all refresh intervals
including forecasts and correlationEngine that were missing from original PR
- Replace all hardcoded interval literals in App.ts with REFRESH_INTERVALS constants
while preserving all conditions added since the PR was submitted (pizzint SITE_VARIANT
guard, oil energy-complex condition, firms shouldRefreshFirms, temporalBaseline and
intelligence shouldRefreshIntelligence guards)
- Add VisibilityHub to runtime.ts: single visibilitychange listener that fans out to
all registered poll loops, eliminating N duplicate document listeners
- Update RefreshScheduler to use shared VisibilityHub instance per scheduler
- Add tiered stagger to flushStaleRefreshes: sorts stale tasks by interval (highest
frequency first), first 4 flush at 100ms steps, remainder at 300ms steps
- Use local constants in flushStaleRefreshes body so new Function() test harness works
- Update flush-stale-refreshes test to verify new 100ms fast-tier stagger behavior
Co-authored-by: Bigwar6868 <bigwar6868@users.noreply.github.com>
* fix(scheduler): remove dead statics, fix noUncheckedIndexedAccess, add missing tests
- refresh-scheduler.ts: remove private static readonly FLUSH_STAGGER_FAST_MS/SLOW/FAST_COUNT
declarations that were shadowed by local consts in flushStaleRefreshes; use for...of loop
to avoid noUncheckedIndexedAccess TS2532 on stale array indexing; proper TS annotation
on stale array satisfies noImplicitAny (matches noUncheckedIndexedAccess tsconfig)
- flush-stale-refreshes.test.mjs: add stripTSAnnotations() before new Function() so the
inline type annotation on stale survives the test harness; add slow-tier stagger test
verifying 6 services produce [0,100,200,300,400,700] (index 4+ at 300ms)
- smart-poll-loop.test.mjs: add VisibilityHub describe suite with 6 tests covering
subscribe/fan-out, unsubscribe callback, auto-remove DOM listener on last unsub,
multi-subscriber fan-out, destroy cleanup, and N-subscribers → 1 DOM listener
* fix(scheduler): correct stagger comment and add visibilityHub integration tests
P3: comment said "first 4 tasks at 100ms gaps" but the condition covers 4
gaps (5 tasks benefit from fast tier); corrected to reflect actual behavior.
P2: add integration tests that pass a fake hub into startSmartPollLoop and
assert subscribe() fires once on start and unsubscribe() fires once on stop(),
and that no direct DOM listener is added when a hub is provided.
---------
Co-authored-by: Elie Habib <elie.habib@gmail.com>
Co-authored-by: Bigwar6868 <bigwar6868@users.noreply.github.com>
* feat: harness engineering P0 - linting, testing, architecture docs
Add foundational infrastructure for agent-first development:
- AGENTS.md: agent entry point with progressive disclosure to deeper docs
- ARCHITECTURE.md: 12-section system reference with source-file refs and ownership rule
- Biome 2.4.7 linter with project-tuned rules, CI workflow (lint-code.yml)
- Architectural boundary lint enforcing forward-only dependency direction (lint-boundaries.mjs)
- Unit test CI workflow (test.yml), all 1083 tests passing
- Fixed 9 pre-existing test failures (bootstrap sync, deploy-config headers, globe parity, redis mocks, geometry URL, import.meta.env null safety)
- Fixed 12 architectural boundary violations (types moved to proper layers)
- Added 3 missing cache tier entries in gateway.ts
- Synced cache-keys.ts with bootstrap.js
- Renamed docs/architecture.mdx to "Design Philosophy" with cross-references
- Deprecated legacy docs/Docs_To_Review/ARCHITECTURE.md
- Harness engineering roadmap tracking doc
* fix: address PR review feedback on harness-engineering-p0
- countries-geojson.test.mjs: skip gracefully when CDN unreachable
instead of failing CI on network issues
- country-geometry-overrides.test.mts: relax timing assertion
(250ms -> 2000ms) for constrained CI environments
- lint-boundaries.mjs: implement the documented api/ boundary check
(was documented but missing, causing false green)
* fix(lint): scan api/ .ts files in boundary check
The api/ boundary check only scanned .js/.mjs files, missing the 25
sebuf RPC .ts edge functions. Now scans .ts files with correct rules:
- Legacy .js: fully self-contained (no server/ or src/ imports)
- RPC .ts: may import server/ and src/generated/ (bundled at deploy),
but blocks imports from src/ application code
* fix(lint): detect import() type expressions in boundary lint
- Move AppContext back to app/app-context.ts (aggregate type that
references components/services/utils belongs at the top, not types/)
- Move HappyContentCategory and TechHQ to types/ (simple enums/interfaces)
- Boundary lint now catches import('@/layer') expressions, not just
from '@/layer' imports
- correlation-engine imports of AppContext marked boundary-ignore
(type-only imports of top-level aggregate)