Skip to content

Document loadedFromSource cache disposition on the request context#563

Merged
kylebernhardy merged 5 commits into
mainfrom
docs/loaded-from-source-context-1571
Jul 3, 2026
Merged

Document loadedFromSource cache disposition on the request context#563
kylebernhardy merged 5 commits into
mainfrom
docs/loaded-from-source-context-1571

Conversation

@kylebernhardy

@kylebernhardy kylebernhardy commented Jul 2, 2026

Copy link
Copy Markdown
Member

Companion docs for HarperFast/harper#1575 (fixes HarperFast/harper#1571), which makes cache disposition observable on caching-table gets via context.loadedFromSource / target.loadedFromSource.

Changes

  • New Observing cache disposition subsection under sourcedFrom() in reference/resources/resource-api.md, documenting the settled semantics verified in the fix: true when the get went to the source (including staleIfError fallbacks to stale data); false for cache hits, onlyIfCached, stale-while-revalidate responses, and dedupe-join waits (with the note that such a "hit" can still take as long as the upstream fetch); last get in a context wins.
  • loadedFromSource listed in both getContext(): Context property references (version-gated "5.1.16+"), cross-linked to the new subsection.
  • Per the decision on Implement wasLoadedFromSource() cache disposition on caching-table resource instances harper#1577 (closed), wasLoadedFromSource() is not implemented and its reference section is removed (commit 0862bda by @kriszyp) — the context/target API is the single supported way to observe disposition.

Note for review

The text says "5.1.16" on the assumption harper#1575 ships in the next 5.1 patch. Hold merging until harper#1575 lands and confirm the actual patch version then.

Generated by an LLM (Claude Fable 5), cross-reviewed by Codex and Gemini; all findings addressed. Includes a commit from @kriszyp.

Companion to HarperFast/harper#1575 (fixes HarperFast/harper#1571):
context.loadedFromSource is now assigned on caching-table gets. Adds an
"Observing cache disposition" section under sourcedFrom with the exact
settled semantics (staleIfError=true, stale-while-revalidate=false,
dedupe-join=false, last get wins) and lists the property in both
getContext() Context references.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Warning

Gemini encountered an error creating the review. You can try again by commenting /gemini review.

@github-actions github-actions Bot temporarily deployed to pr-563 July 2, 2026 16:12 Inactive
@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown

🚀 Preview Deployment

Your preview deployment is ready!

🔗 Preview URL: https://preview.harper-documentation.harperfabric.com/pr-563

This preview will update automatically when you push new commits.

nizzlenitz and others added 2 commits July 2, 2026 10:18
Gemini review: get() returns a plain RecordObject, not a resource
instance, so the method is not reachable where developers would want
it (and the base implementation is an unoverridden stub). Direct
readers to the context / RequestTarget instead.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…nd version-gate the Context entries

Codex review: staleIfError fallbacks serve stale cached data on a
failed source fetch, so "fetched from source" overclaimed freshness;
and the Context list entries needed the 5.1.16+ availability caveat.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown

🚀 Preview Deployment

Your preview deployment is ready!

🔗 Preview URL: https://preview.harper-documentation.harperfabric.com/pr-563

This preview will update automatically when you push new commits.

@github-actions github-actions Bot temporarily deployed to pr-563 July 2, 2026 16:22 Inactive
@kylebernhardy kylebernhardy marked this pull request as ready for review July 2, 2026 17:11
@kylebernhardy kylebernhardy requested a review from a team as a code owner July 2, 2026 17:11
Companion to HarperFast/harper#1577 (fixes HarperFast/harper#1576):
the method now returns the recorded cache disposition on caching-table
resource instances instead of always undefined. Corrects its reference
section and restores the instance-method mention in Observing cache
disposition.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown

🚀 Preview Deployment

Your preview deployment is ready!

🔗 Preview URL: https://preview.harper-documentation.harperfabric.com/pr-563

This preview will update automatically when you push new commits.

@github-actions github-actions Bot temporarily deployed to pr-563 July 2, 2026 17:33 Inactive
…edFromSource (#1576)

wasLoadedFromSource() is an unoverridden stub that always returns
undefined; we've standardized on context.loadedFromSource /
target.loadedFromSource as the way to observe cache disposition
(harper#1576). Remove the reference section and the cross-reference
from the caching-disposition note.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown

🚀 Preview Deployment

Your preview deployment is ready!

🔗 Preview URL: https://preview.harper-documentation.harperfabric.com/pr-563

This preview will update automatically when you push new commits.

kriszyp added a commit to HarperFast/harper that referenced this pull request Jul 3, 2026
wasLoadedFromSource() was declared on ResourceInterface and documented as
reporting cache disposition, but its only implementation was the base-class
stub that always returned undefined — no subclass ever overrode it, and
get() returns a plain RecordObject with no instance methods anyway. We've
standardized on context.loadedFromSource / target.loadedFromSource (this PR)
as the supported way to observe cache disposition, so remove the misleading
interface declaration and stub.

Non-breaking: the method never returned a meaningful value. The only in-repo
callers (OCSP/CRL cert verification) invoke it via `(x as any).?.()` on a
plain record, so they were already reading undefined and are unaffected.

Docs: HarperFast/documentation#563. Closes #1576.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

@kriszyp kriszyp left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Approving — verified line-for-line accurate against harper#1575 / #1577's actual semantics (loadedFromSource / wasLoadedFromSource()). Since it pairs with those core PRs (v5.1-targeted), just land it alongside them and confirm the version marker. Thanks @kylebernhardy!

— 🤖 KrAIs (Kris's review assistant)

kriszyp added a commit to HarperFast/harper that referenced this pull request Jul 3, 2026
…tables (#1575)

* Mirror loadedFromSource onto the request context so it is observable with plain-id gets (#1571)

The cache-disposition flag was only set on the RequestTarget of the get;
with a plain string id the static dispatch mints an internal target the
caller never sees, so Context.loadedFromSource (declared but never
assigned) always read undefined. Now every site that sets the flag on
the target mirrors it onto the context via a shared helper.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* Set cache disposition on cache hits in the loadAsInstance=false get path and ensureLoaded; document exact stale semantics

Review findings (Gemini): the loadAsInstance=false get path and
ensureLoaded() set the flag on source fetch but never wrote false on
cache hits, leaving a stale true on shared contexts; and with
allowStaleWhileRevalidate the flag reads false (the cache-hit
overwrite wins over the synchronous true at fetch start), while
staleIfError fallbacks read true — jsdoc now states both.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* Guard primitive targets in setLoadedFromSource

Instance-API gets on loadAsInstance=false tables can pass a primitive
id as the target; assigning a property on a primitive throws in strict
mode (Codex review). Context mirroring still applies.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* refactor(resources): remove dead wasLoadedFromSource() stub (#1576)

wasLoadedFromSource() was declared on ResourceInterface and documented as
reporting cache disposition, but its only implementation was the base-class
stub that always returned undefined — no subclass ever overrode it, and
get() returns a plain RecordObject with no instance methods anyway. We've
standardized on context.loadedFromSource / target.loadedFromSource (this PR)
as the supported way to observe cache disposition, so remove the misleading
interface declaration and stub.

Non-breaking: the method never returned a meaningful value. The only in-repo
callers (OCSP/CRL cert verification) invoke it via `(x as any).?.()` on a
plain record, so they were already reading undefined and are unaffected.

Docs: HarperFast/documentation#563. Closes #1576.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

---------

Co-authored-by: Kyle Bernhardy <kyle.bernhardy@gmail.com>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Co-authored-by: Kris Zyp <kriszyp@gmail.com>
@kylebernhardy

Copy link
Copy Markdown
Member Author

harper#1575 has merged into v5.1 — this PR is now unblocked pending one check: confirm the next 5.1 patch release number matches the "5.1.16" references in the text (v5.1 was at 5.1.15 when they were written). Comment generated by an LLM (Claude Fable 5).

@kylebernhardy kylebernhardy merged commit a401477 into main Jul 3, 2026
7 checks passed
@kylebernhardy kylebernhardy deleted the docs/loaded-from-source-context-1571 branch July 3, 2026 04:02
@github-actions

github-actions Bot commented Jul 3, 2026

Copy link
Copy Markdown

🧹 Preview Cleanup

The preview deployment for this PR has been removed.

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.

loadedFromSource is unobservable with string-id Table.get() — set on an internal RequestTarget; Context declares it but it is never assigned

3 participants