feat(miner): persist resolved policy verdicts across discover runs - #5516
Conversation
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
gittensory-ui | 7ab8e0a | Commit Preview URL Branch Preview URL |
Jul 13 2026, 12:48 AM |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #5516 +/- ##
=======================================
Coverage 94.77% 94.78%
=======================================
Files 565 566 +1
Lines 44964 45023 +59
Branches 14675 14675
=======================================
+ Hits 42614 42673 +59
Misses 1616 1616
Partials 734 734
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
|
Tip 🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩 ✅ Gittensory review result - approve/merge recommendedReview updated: 2026-07-13 00:35:49 UTC
✅ Suggested Action - Approve/Merge
Review summary Blockers
Nits — 6 non-blocking
Review context
Contributor next steps
Signal definitions
[BETA] Chat with GittensoryAsk Gittensory a question about this PR directly in a comment — grounded only in the same cached, public-safe facts shown above, never a new claim.
Full command reference: https://gittensory.aethereal.dev/docs/gittensory-commands 🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed 💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →. Checked by Gittensory, a quiet PR intelligence layer for OSS maintainers.
|
Add a local cache (policy-verdict-cache.js) keyed by repo + the ETag of whichever doc (AI-USAGE.md or CONTRIBUTING.md) decided the verdict. fetchRepoDoc now surfaces the ETag it used alongside doc content, so resolveRepoAiPolicy can skip resolveAiPolicyVerdict outright once a same-run conditional-GET (#4842) confirms the deciding doc's ETag hasn't moved -- reusing the prior verdict is exactly as correct as recomputing it, since both only run against the identical doc text. A cache miss (cold cache, changed ETag, or a different doc becoming decisive) always falls through to a fresh resolution and re-caches the result. Same fail-open discipline as the doc cache: any cache read or write failure degrades to "resolve fresh" rather than affecting discovery, and discover-cli.js opens the store in its own try/catch so a corrupt/unwritable cache DB can never abort a run. Closes #4843
…t repo A bare owner/repo is not a safe cache key across tenants: two different forge hosts (#4784's per-tenant apiBaseUrl) can each have their own unrelated repo of the same name, and if their policy docs happened to produce the same ETag string, a verdict resolved against one host's docs could be incorrectly served for the other's. Key the cache by `${apiBaseUrl}::${repoFullName}` instead, mirroring policy-doc-cache.js's own precedent of keying on the full request URL rather than a bare path. Renames the store's column/field from repo_full_name to repo_scope to reflect that the value is now a caller-owned composite key, not a plain repo identifier -- the store itself stays opaque to what the key represents, same as before.
6423305 to
7ab8e0a
Compare
|
Fixed the cross-host cache-key issue: the policy-verdict cache is now keyed by `${apiBaseUrl}::${repoFullName}` instead of a bare `owner/repo`, matching `policy-doc-cache.js`'s own precedent of keying on the full request URL. Renamed the store's column/field from `repo_full_name` to `repo_scope` to reflect that it's now a caller-owned composite key. Added a dedicated regression test proving two different tenant forge hosts with the same `owner/repo` (and even a colliding ETag string) get independent cache entries. Full local gate re-run clean; force-pushed the rebased branch. |
Summary
policy-verdict-cache.js, a local cache of resolvedAiPolicyVerdictobjects keyed by repo + the ETag of whichever doc (AI-USAGE.md or CONTRIBUTING.md) decided the verdict, following the samelocal-store.js/schema-version.jsconventions as every other store in this package.fetchRepoDoc(opportunity-fanout.js) now returns{content, etag}instead of bare content, soresolveRepoAiPolicycan see the ETag of whichever doc it fetched.resolveRepoAiPolicychecks the verdict cache before callingresolveAiPolicyVerdict: a hit requires BOTH the decisive doc name and its ETag to match the cached entry (guards against a repo whose decisive doc changes between runs, e.g. AI-USAGE.md going from absent to present); a miss always resolves fresh and re-caches.discover-cli.jsopens the store in its own try/catch so a corrupt/unwritable cache DB can't abort a run.Test plan
npx vitest run test/unit test/contract— 780 files / 15197 tests passing, 0 regressions (one pre-existing unrelated flake ingithub-graphql-cache.test.tsreproduced only under full-suite parallel load, confirmed passing in isolation and untouched by this diff)npm run build --workspace @jsonbored/gittensory-miner(node --checkover every lib file, including the new one)npx tsc --noEmitcleannpm run docs:drift-check && npm run manifest:drift-check && npm run engine-parity:drift-check && npm run miner:env-reference:checknpm audit --audit-level=moderate— 0 vulnerabilitiesCloses #4843