Skip to content

l0.DependencyControl.FeedInventory

FeedInventory = require "l0.DependencyControl.FeedInventory"
local FeedInventory = require("l0.DependencyControl.FeedInventory")

FeedInventory

Enumerates the feeds DependencyControl knows about — from the user config, installed packages, and its official trust lists — each tagged with the sources it was found through and its trust status, for the Manage Feeds UI. gather is network-free; crawl additionally discovers transitively-advertised feeds through an injected feed loader, bounding untrusted expansion.

Constructor

feedInventory = FeedInventory config, feedTrust, feedLoader
local feedInventory = FeedInventory(config, feedTrust, feedLoader)
param type description
config ConfigView The global config view; its c holds extraFeeds/trustedFeeds/macros/modules, fetchUntrustedFeeds, and feedCrawlLimits.
feedTrust FeedTrust The trust model, for the official feeds and trust/block queries.
feedLoader FeedLoader Loads feeds during a crawl and holds the feed cache read for last-fetch times.

Instance methods

gather

feedInventory\gather!
feedInventory:gather()

Gathers the known feeds from config, installed packages, and the official trust lists. Fetches nothing.

Returns:

getPackagesSourcedFrom

feedInventory\getPackagesSourcedFrom feedUrl
feedInventory:getPackagesSourcedFrom(feedUrl)

Returns the namespaces of installed packages that effectively update from the given feed URL.

param type description
feedUrl string The feed URL to check.

Returns:

  • namespaces string[] — Sorted namespaces whose effective source is that feed.

crawl

feedInventory\crawl!
feedInventory:crawl()

Fetches feeds and discovers transitively-advertised ones by crawling the knownFeeds graph out from the config-derived feeds; untrusted expansion is bounded, so check stats.truncated for incomplete results.

Returns:

  • feeds FeedInventoryEntry[] — The known feeds, enriched with what the crawl discovered.
  • stats FeedCrawlStats — What the crawl explored and where it stopped short.

Class methods

getEffectiveSource

FeedInventory.getEffectiveSource pkg, modulesSection
FeedInventory.getEffectiveSource(pkg, modulesSection)

The feed a package effectively updates from: its remembered currentSource (resolved), falling back to its override (userFeed) or declared feed.

param type description
pkg table An installed package's config entry.
modulesSection table The modules config section, for resolving a provider currentSource.

Returns:

  • url string? — The feed the package updates from, or nil when it declares none.

Fields

field type description
defaultCrawlLimits FeedCrawlLimits The built-in crawl budgets, used for any budget the config doesn't set (and the config's own default).

Enums

FeedProvenance

member value description
OfficialDepCtrl "official-depctrl" DependencyControl's own feed
OfficialKnown "official-known" a feed advertised in DependencyControl's own feed's knownFeeds
UserExtra "user-extra" a feed in the user's extraFeeds (a discovery root)
PackageDeclared "package-declared" the feed an installed package declares for its own updates
PackageOverride "package-override" an installed package's per-package userFeed override
DependencyAdvertised "dependency-advertised" a feed advertised in an installed package's requiredModules
TransitiveKnown "transitive-known" a feed advertised in another fetched feed's knownFeeds (crawl only)

FeedCrawlLimit

member value description
PerFeed "per-feed" the cap on how many untrusted feeds one feed may contribute
PerRoot "per-root" the per-subtree budget for untrusted expansion
Depth "depth" the crawl-depth limit; a feed at this depth is left unfetched

Types

FeedInventoryEntry

A reachable feed with the sources it was discovered through and its trust status.

field type description
url string The feed URL.
provenance FeedProvenance[] The sources this feed was found through, in a stable order (empty for a feed present only in trustedFeeds).
packages string[] Sorted namespaces of installed packages that declare, override to, or advertise this feed (empty when none).
advertisedBy string[] Sorted URLs of fetched feeds that list this feed in their knownFeeds (crawl only).
trustStatus FeedTrustStatus The feed's trust status.
blockedBy? BlockedFeedEntry The block entry matching this feed when trustStatus is blocked (carries the reason and official/user flag).
fetched? boolean True when crawl successfully read this feed; nil for gather (offline) or a feed the crawl couldn't reach.
lastFetchedAt? integer Unix time this feed was last successfully fetched into the persistent cache; nil if it was never cached.
inUse? boolean True when this feed is the effective update source (override else declared feed) of an installed package.
inTrustedFeeds? boolean True when the feed is in the user's trustedFeeds — a trust-only listing that grants trust without acting as a discovery source.

FeedCrawlLimits

The crawl budgets, keyed by FeedCrawlLimit; a missing key falls back to a built-in default.

FeedCrawlTruncation

A budget the crawl hit, with enough context to act on it (block a feed, file a report).

field type description
limit FeedCrawlLimit Which budget was hit.
limitValue integer The configured value of that budget.
feed string The feed being processed when the limit hit (the advertiser for per-feed/per-root, the unfetched feed itself for depth).
root string The config-derived feed whose subtree this occurred in.
depth integer The crawl depth of feed (0 for a config-derived root).
route string[] The feed URLs from root to feed inclusive — how the crawl reached it.
dropped integer How many advertised feeds this event left unexplored (0 for depth, whose single unfetched feed is feed).
droppedUrls string[] The dropped feed URLs, capped to a sample when dropped exceeds it; empty for depth.

FeedCrawlStats

What a crawl explored and where it stopped short.

field type description
fetched integer How many feeds had their knownFeeds read.
truncated boolean Whether any budget was hit (a quick "results incomplete?" check).
truncations FeedCrawlTruncation[] Each budget hit, in crawl order, for surfacing or acting on.