Skip to content

version 1.0 - #69

Merged
frap129 merged 19 commits into
mainfrom
dev
Sep 3, 2026
Merged

version 1.0#69
frap129 merged 19 commits into
mainfrom
dev

Conversation

@frap129

@frap129 frap129 commented Sep 3, 2026

Copy link
Copy Markdown
Owner

No description provided.

frap129 added 19 commits August 29, 2026 21:50
Internal LRU-bounded per-session map with tick-stamped recency, optional
eviction protection via isEvictable predicate, clamped bounds, and the
ensure/touch/evict/ids/setMax/reset surface. No callers yet; siblings
#64/#65/#66 migrate the session store, rule delivery, and file
observation context onto it.

Closes #63
Replace the inline tick/scan/delete eviction loop with the shared
BoundedSessionMap used as a recency and eviction oracle; stateMap
remains the authoritative value store. The facade stays unclamped:
setMax keeps the raw limit, so a limit of 0 drains the store to
empty on the next upsert (pinned by a characterization test).

Closes #64
Replace the inline tick/scan/delete eviction loop with the shared
BoundedSessionMap used as a recency and eviction oracle; states
remains the authoritative value store. Sessions with an in-flight
operation are protected via the isEvictable predicate, and the
operation tail is removed before the post-settle eviction scan so
protection ends exactly when the turn settles.

Closes #65
Replace the inline tick/scan/delete eviction loop with the shared
BoundedSessionMap used as a recency and eviction oracle; sessions
remains the authoritative value store. Stamping happens on record
(ensure) and on read-for-matching (touch), with monotonic
per-session retention of repeated paths unchanged.

Closing sweep: no inline eviction scan loops remain in any caller;
BoundedSessionMap stays internal.

Closes #66
Refs #62
Contract revision of the shared module introduced in #62/#63: the map now
owns per-session values, so the three call sites no longer pair it with a
parallel authoritative Map. Removes the duplicated reconcile loop that
the oracle composition forced onto every caller.

- Add unstamped get() and make touch() return the stamped value, letting
  callers read values through the map instead of shadow maps.
- Allow max 0 (construction and setMax) so SessionStore keeps its
  unclamped setMax facade; callers wanting at-least-one semantics clamp
  >= 1 explicitly at their own call sites (RuleDelivery,
  FileObservationContext).
- Update the pinned prototype-surface and max-0 tests accordingly.

The per-entry cost is one tick number (recency metadata) per session.

Refs #62, Refs #63
SessionStore's BoundedSessionMap<SessionState> is now the single store;
delete the shadow Map and the reconcile loop that synced it.

Delete dead code: the tick counter and SessionState.lastUpdated. Eviction
is map-driven, and no production code reads lastUpdated — only test
mutators touched it, and upsert immediately overwrote them. Removing it
narrows the exported SessionState interface; snapshots remain structurally
compatible for readers.

Closes #64 (simplification follow-up)
…rectly

DefaultRuleDelivery's BoundedSessionMap<DeliveryState> is now the single
store; delete the shadow Map and the reconcile loop. Clamps the bound
>= 1 explicitly at construction to keep the at-least-one semantics the
map no longer enforces.

Closes #65 (simplification follow-up)
FileObservationContext's BoundedSessionMap<ObservationSession> is now the
single store; delete the shadow Map and the reconcile loop. getForMatching
reads through touch(), which returns the stamped value. Clamps the bound
>= 1 explicitly to keep at-least-one semantics.

Closing sweep of the deduplication: no reconcile loops, shadow maps,
oracle callbacks, or while-size eviction scans remain outside the shared
map; the module stays internal (no utils.ts re-export, no api-surface
additions, package surface untouched).

Closes #66 (simplification follow-up), Refs #62
…sionMap

Remove the stale lastUpdated field from the documented SessionState shape
and the 'tagged with lastUpdated for age tracking' pruning note; eviction
is now owned by the composed BoundedSessionMap, per rule 11 (stale
references removed in the same change as the behavior change). Sync the
README Project Structure description of bounded-session-map.ts.
The rule snapshot fixture in the snapshot-cloning test was missing the
required name field of RuleSnapshot, a latent type error that tsc never
sees because tsconfig excludes test files.
Two callers duplicated the Math.max(1, options.maxSessions ?? 100)
clamp idiom at their construction sites. Fold the clamp into the map
as a minBound option: the bound clamps to at least minBound in the
constructor, setMax, and reset. SessionStore keeps an unclamped bound
so setMax(0) can drain the store to empty.
Replace the hand-rolled Math.max(1, ...) clamp at both call sites with
the map's minBound option, eliminating the duplicated bound-clamping
idiom between RuleDelivery and FileObservationContext.
setMax, ids, get, and reset are thin delegates over BoundedSessionMap.
Add a comment stating the facade's purpose: preserving the seam used by
src/index.ts (setSessionStateLimit and the runtime test hooks).
The class's per-method JSDoc already documents ensure/touch/get
behavior; the module header comment added nothing.
…efactor

- Rule 10: drop src/utils.ts glob (now a facade), add runtime-context.ts
  and runtime-chat.ts where env parsing and part extraction live; reference
  only parseEnvBoolean (isTruthyEnvValue no longer exists).
- Rule 11: cover AGENTS.md and CONTEXT.md in globs and bullets; call out
  stale directory listings.
- Rule 12: replace superseded utils.ts split bullet with the facade rule
  enforced by api-surface.typecheck.ts.
Restructure server source into rules/, delivery/, session/, runtime/,
detection/, and shared/; entry points and dist outputs stay in place.

- Split the delivery engine behind the unchanged createRuleDelivery
  factory into per-session state + operation serialization
  (delivery-state), history seeding and admission persistence
  (delivery-ledger), and transient dispatch presence/turn tracking
  (delivery-transient); codec and raw history port stay adjacent
- Split the runtime orchestrator: client adapter (history reads,
  no-reply admission persistence, tool-ID/MCP queries) and tool-hook
  evaluation flow (PreToolUse/PostToolUse, blocker, side-effects,
  matched-Hook queuing) extracted; the orchestrator slims to
  composition + hook-flow handlers
- Consolidate message-paths and message-context into
  session/message-extraction (coverage is the union of both suites)
- Delete the src/utils.ts compatibility facade; TUI data layer and
  sidebar import real server modules
- Rename behavior suites to the flows they exercise:
  runtime/orchestration.test.ts and
  session/file-observation-history-parts.test.ts
- Path-update api-surface.typecheck.ts; private-type leak checks intact
- Sync README project structure and AGENTS.md architecture notes;
  entry-level suites keep behavior-guard content (import paths only)

Closes #68
@frap129
frap129 merged commit 154d8d9 into main Sep 3, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant