Skip to content

Feat: Stop expiring sessions on time - #904

Merged
huang195 merged 1 commit into
rossoctl:mainfrom
huang195:feat/no-session-expiry
Sep 8, 2026
Merged

huang195 merged 1 commit into
rossoctl:mainfrom
huang195:feat/no-session-expiry

Conversation

@huang195

@huang195 huang195 commented Sep 8, 2026

Copy link
Copy Markdown
Member

Sessions were dropped after 30 minutes idle, and it read as data loss: traffic someone was looking at vanished because they stepped away, not because anything overflowed. The default is now never.

Why the timer was safe to remove

Nothing about it was load-bearing. Memory is bounded by max_sessions (100) × max_events (500), and a session that stops being used is evicted oldest-used-first once max_sessions is exceeded.

What it bought was hygiene — raw prompts not lingering in memory — which is still available by setting session.ttl explicitly. That's why the knob stays rather than being deleted: a cluster operator may want it, and existing configs that set it behave exactly as before.

The change is one gate

All four expiry paths (View, ListSessions, the active-session lookup, Cleanup) route through isExpired, so ttl <= 0 returning false disables it everywhere consistently. The reaper is no longer started in that case either — the interval is ttl/2 clamped to one second, so it would have woken every second forever to find nothing.

Two things that would have been quietly wrong

  • The startup log printed ttl=0s, which reads like a misconfiguration rather than the default. Now expiry=never, or the duration when set.
  • authbridge/CLAUDE.md documented "a default cap of 100 events per session" — it has been 500 since the cap was raised. The IBAC note also listed "session expiry" as a way LastIntent() returns nil without saying expiry is now off by default. Both corrected.

docs/laptop-service.md now explains what actually makes traffic disappear (the two size caps), since "it was there and now it's gone" is the confusion this started from.

Verified

  • sessions backdated 72h idle survive View, ListSessions and an explicit Cleanup, at ttl=0 and at a negative ttl
  • an explicitly configured 30m still expires
  • the size caps still bound both events and sessions
  • New(0, ...) does not panic; Close is idempotent
  • a real proxy logs expiry=never by default and expiry=30m0s with session.ttl set
  • 53 authlib packages, both binaries and abctl build, vet and test clean

Assisted-By: Claude (Anthropic AI) [email protected]

Sessions were dropped after 30 minutes idle, and it read as data loss: traffic someone
was looking at vanished because they stepped away, not because anything overflowed. The
default is now never.

Nothing about the timer was load-bearing. Memory is bounded by max_sessions (100) x
max_events (500), and a session that stops being used is evicted by the oldest-used rule
once max_sessions is exceeded. What the timer bought was hygiene — raw prompts not
lingering in memory — which is still available by setting session.ttl explicitly. That is
why the knob stays rather than being deleted: a cluster operator may well want it, and
existing configs that set it behave exactly as before.

The change is one gate. All four expiry paths (View, ListSessions, the active-session
lookup, and Cleanup) route through isExpired, so `ttl <= 0` returning false disables it
everywhere consistently. The reaper is also no longer started in that case: the interval
is ttl/2 clamped to one second, so it would have woken every second forever to find
nothing.

Two things that would have been quietly wrong:

  - The startup log printed "ttl=0s", which reads like a misconfiguration rather than the
    default. It now logs expiry=never, or the duration when one is set.
  - authbridge/CLAUDE.md documented "a default cap of 100 events per session". It has been
    500 since the cap was raised, and the IBAC note listed "session expiry" as a way
    LastIntent() returns nil without saying that expiry is now off by default. Both
    corrected.

docs/laptop-service.md now explains what actually makes traffic disappear — the two size
caps — since "it was there and now it is gone" was the confusion this started from.

Verified: sessions backdated 72h idle survive View, ListSessions and an explicit
Cleanup at ttl=0 and at a negative ttl; an explicitly configured 30m still expires; the
size caps still bound both events and sessions; New(0, ...) does not panic and Close is
idempotent. A real proxy logs expiry=never by default and expiry=30m0s with session.ttl
set. 53 authlib packages, both binaries and abctl build, vet and test clean.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Hai Huang <[email protected]>
@coderabbitai

coderabbitai Bot commented Sep 8, 2026

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 48 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 6570997c-42cb-4211-829e-98960cd9ab46

📥 Commits

Reviewing files that changed from the base of the PR and between c219af3 and caf38e4.

📒 Files selected for processing (8)
  • authbridge/CLAUDE.md
  • authbridge/authlib/config/config.go
  • authbridge/authlib/session/no_expiry_test.go
  • authbridge/authlib/session/store.go
  • authbridge/cmd/authbridge-cpex/main.go
  • authbridge/cmd/authbridge-envoy/main.go
  • authbridge/cmd/authbridge-proxy/main.go
  • authbridge/docs/laptop-service.md

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@evaline-ju evaline-ju left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small, well-scoped default flip. The failure mode being fixed — sessions vanishing while someone was reading them because they stepped away, not because anything overflowed — was silent user-facing data loss, and the timer was never what bounded memory (max_sessions × max_events is). Keeping session.ttl available for operators who want the hygiene, while moving the default to what a laptop user actually expects, is the right tradeoff.

The single-gate approach (ttl <= 0 → false in isExpired) is clean — all four expiry paths funnel through it. Reaper is skipped when nothing can expire; Close stays idempotent via sync.Once. Tests cover the axes that matter: never-expire on 0 and negative TTL across View/ListSessions/Cleanup with a 72h idle backdate, explicit TTL still works, no panic on New(0) + double-Close, and size caps still bound the store without the timer. Two collateral doc fixes (100 → 500 events, expiry no longer listed as a LastIntent() nil cause) belong in this PR.

Author: huang195 (MEMBER — maintainer)
Areas reviewed: Go source, Go tests, Markdown docs
Agent/IDE config (.claude/.vscode): none
Commits: 1, signed-off: yes
CI status: 18/18 passing

ttlDesc = ttl.String()
}
slog.Info("session tracking enabled",
"expiry", ttlDesc, "maxEvents", maxEvents, "maxSessions", maxSessions)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: The startup log key was renamed from ttl to expiry. Any operator dashboard, alert, or grep matching the previous ttl= field on this line will silently stop firing — one field-name change is harder to spot than one value shape change. Consider keeping the key as "ttl" and only letting the value flip between a duration (ttl=30m0s) and "never" (ttl=never). Same pattern in authbridge-envoy/main.go and authbridge-cpex/main.go.

@huang195
huang195 merged commit ea46eb1 into rossoctl:main Sep 8, 2026
24 checks passed
@huang195
huang195 deleted the feat/no-session-expiry branch September 8, 2026 21:53
@github-project-automation github-project-automation Bot moved this from New/ToDo to Done in Rossoctl Issue Prioritization Sep 8, 2026
esnible added a commit to esnible/cortex that referenced this pull request Sep 9, 2026
Review from huang195, all three findings reproduced and fixed.

must-fix — the ANSI-styled "gone" cell. bubbles v1.0.0 renderRow does
runewidth.Truncate(value, col.Width, "…") BEFORE styling, and runewidth
is not ANSI-aware. Reproduced against the pinned deps: styleWarn.Render
("gone") is "\x1b[93mgone\x1b[0m", which runewidth measures as 11
against the ACTIVE column's width of 8, so Truncate returns
"\x1b[93mgon…" — the label reads "gon…" and the closing reset is
stripped, bleeding the colour into every later cell. bubbles v1.0.0 has
no per-cell styling, so no column width makes a styled cell viable. Now
plain "gone", matching the unstyled "●" beside it.

CI could not see it: with no TTY lipgloss's profile is Ascii, Render
returns bare "gone", and truncation is a no-op. Every other test here
asserts on Rows() data, never on View(). Closed that gap with a test
that forces a colour profile, renders View(), and asserts the label
survives — verified to fail against the styled cell.

suggestion — migrateSession deleted the source unconditionally, so when
newID was already cached the default bucket was discarded with no
migration and no tombstone. Reachability is contrived, but it was the
one remaining unrecoverable-deletion path in a file that exists to
remove them. Now returns early, leaving reconcileGone to tombstone the
source so the events stay viewable.

nit — the tombstone loop keyed off m.events, which can hold an empty
slice: snapshotLoadedMsg assigns m.events[id] unconditionally, so
drilling into a session with no events yet creates the key. That
rendered "id — 0 — gone", advertising retained events that do not
exist. Skipped when there is nothing cached, per this file's own
rationale — the tombstone is justified by holding the only copy.

Also narrowed the rekey detection (CodeRabbit, same lines): "default
vanished and one unfamiliar id appeared" is equally what an eviction of
default plus an unrelated new session looks like, and migrating then
files events under a session they never belonged to. Now also requires
the list to be the same size and to have contained "default". Neither
is proof, so the failure mode is a missed migration rather than a wrong
one — declining leaves the events tombstoned under the old id.

On the PR body's "time-based expiry was never involved": correct as of
today but not when rossoctl#870 was filed, since the ttl default became never
only in rossoctl#904. Noted for whoever closes rossoctl#870; no code change.

Refs rossoctl#870

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Ed Snible <[email protected]>
cwiklik added a commit that referenced this pull request Oct 8, 2026
Review found the extproc response-body rows describing a path the shipped
Kubernetes config does not take. ext_proc asks Envoy for ResponseBodyMode
BUFFERED via a runtime mode override, and neither the chart's envoy-config
nor the operator's envoy.yaml.tmpl raises per_connection_buffer_limit_bytes
or per_request_buffer_limit_bytes — so Envoy's own 1 MiB default applies
first, and its docs for BUFFERED say the downstream system gets an error
past the limit. On that path a 2 MiB response never reaches the listener:
Envoy answers 500 itself, ext_proc sees ResponseHeaders without
end_of_stream and then EOF, and appendBoundedBody is never called. The
stream-end flush still runs the response phase, on an empty buffer, so the
event records a 200 with no error and the plugin reports length zero.

The truncation rows are still worth having — they cover the config that
raised the limit above the body, the only one where appendBoundedBody runs
— so they now say so, and say what the shipped path does instead. A
two-column table in the file comment carries that split for both
directions, including the request side's no-row gap.

Rather than leave the corrected prose as another unverified claim, pin it:
TestDivergence_InboundResponseBodyCapOnShippedEnvoy asserts the 200 with an
empty digest against reverseproxy's 502, driven by a new
envoyAbortsResponseBody knob that ends the stream after ResponseHeaders.
The empty digest rather than a nil plugin event is the point — nil would
also pass if the response phase had been skipped, which is the opposite
bug.

Two guards close holes the review found. An errorCode with an empty
errorKind is fatal, because an empty kind asserts the event carried no
error at all and nothing would have compared the code. And refusedPreRunBy
is derived from the rows' own pipelineRan instead of hand-written per
fixture, so the two cannot disagree; declaring it is fatal.

Also corrects the body-size citation from #904 to #864 and replaces the
line-number references with symbol names.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: cwiklik <[email protected]>
omerboehm pushed a commit to s-and-p-team/cortex that referenced this pull request Oct 13, 2026
Closes rossoctl#987.

The parity suite covered one body cap — the 1 MiB inbound request both
shapes share (rossoctl#937). The two adjacent caps are where the shapes actually
DISAGREE, and nothing stated which way each one goes, so neither answer
was a decision and either could move silently:

  direction      extproc    reverseproxy   forwardproxy
  request body   1 MiB      1 MiB          32 MiB
  response body  1 MiB      1 MiB          10 MiB

Two corrections to the issue, both from reading the listeners rather than
the issue's table, and the second one reshaped the work.

The forwardproxy request cap is 32 MiB, not the 10 MiB the issue says —
two separate constants, and only the response one is 10 MiB
(forwardproxy/server.go:59 and :79). The gap is three times wider than
reported, and a Claude Code session produces 5 MiB request bodies
(measured in rossoctl#904), so it is where real traffic lives.

And extproc does NOT reject an oversized response, which is what the
issue's Fix section prescribes. appendBoundedBody (extproc/server.go:1248)
truncates to 1 MiB, logs a WARN and lets the pipeline run on the prefix.
The function's own comment names the consequence: "a JSON body cut short
parses as nothing and the silence would otherwise look like a response
that carried no usage." So on the Kubernetes path a response over 1 MiB
reaches the client intact while its token counts, and therefore its cost,
silently become zero — and the session event, the wire status and the
event's error field all look healthy. The reverse proxy, on the same cap,
refuses with a 502 instead (reverseproxy/server.go:522). Three fixtures,
not the issue's two.

assertDivergence rather than a tolerance in assertParity. rossoctl#987 offered a
fixture field that makes assertParity accept per-listener answers; a field
like that is an escape hatch, in a harness whose own comments exist
because it once passed having compared nothing (parity_test.go:706, :739).
The sibling never calls observationDiff, so there is no pairwise check to
weaken — each leg is pinned absolutely against its own row — and three
guards stop it being used for anything else: every listener in the set
needs a row, the rows must actually disagree (else it fails telling you to
use assertParity), and each row carries a one-line `why`. The undocumented
gap is the issue's real complaint, so the documentation is a run-time
requirement.

Making truncation observable needed a new spy knob. Nothing published what
a plugin was handed on the BUFFERED response path, which is the only place
the silent case shows up at all. RecordResponseBodyDigest publishes length
+ SHA-256; RecordRequestBodyDigest does the same for the request, where
the caps also diverge. A digest and not the bytes because a 2 MiB
expectation literal is unreadable AND because length alone would pass for
any 1 MiB of the body — verified by sabotage: making appendBoundedBody
keep the tail instead of the head fails the digest while the length still
matches, which is exactly the case a length-only assertion would miss. The
fixture body is a repeating 26-byte pattern rather than rossoctl#937's uniform
'x' for the same reason: a prefix and a suffix of all-'x' hash alike.

finalizeObservation now takes the listener name and reads refusedPreRunBy,
because the request-cap fixture refuses pre-run on one leg and runs the
whole pipeline on the other — a shape the fixture-level flag errors on
either way round, which is why this gap was untestable rather than
untested. It is a driver-shape hint, not a comparison weakener:
assertParity still diffs PipelineRan pairwise, so a fixture that set it
and then asked for parity would fail on the divergence it declared. The
extproc driver also stops sending response callbacks for a leg declared
refused, which is transport fidelity — an ImmediateResponse terminates
Envoy's filter chain, so Envoy never calls ext_proc again — and it now
requires that ImmediateResponse, since "no session event" is also what a
listener that quietly forwarded and recorded nothing would produce.

Verified by sabotage, each row proved able to fail: raising extproc's
maxBodySize fails all three fixtures; keeping the truncation's tail fails
the two digests on hash alone; dropping reverseproxy's overLimit branch
fails the fourth fixture's wire status, event status, error kind and its
nil pluginEvents claim at once. The four misuse guards were each tripped
on purpose and then the probe deleted.

This pins the gap and writes it down somewhere executable; it does not
close it. Whether the caps should be UNIFIED is a separate decision, and
one with a cost either way — raising extproc's means raising Envoy's
per_stream_buffer_limit_bytes with it.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: cwiklik <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants