Conversation
🏷️ Automatic Labeling SummaryThis PR has been automatically labeled based on the files changed and PR metadata. Applied Labels: size-xs Label Categories
For more information, see |
🔍 Lighthouse Performance Audit
📥 Download full Lighthouse report Budget Compliance: Performance budgets enforced via |
…and myndigheter skill update - scripts/fetch-statskontoret.ts: new 30-day TTL cache wrapper over StatskontoretClient for agentic workflows (fetchStatskontoretCached, isStatskontoretCacheFresh, statskontoretSourceKeys). Falls back to stale cache on network failure for resilience. - tests/statskontoret-feasibility-contract.test.ts: 14 new Vitest contract tests asserting Statskontoret inventory provides myndighets- forteckning coverage for agencies named in implementation-feasibility.md files, plus full module API and cache behaviour tests. - tests/statskontoret-inventory.test.ts: extend existing test to verify the new cachedFetch entry in indicators-inventory.json. - analysis/statskontoret/indicators-inventory.json: add clients.cachedFetch field pointing to fetch-statskontoret.ts with 30-day TTL annotation. - .github/skills/myndigheter-monitoring/SKILL.md: add Statskontoret Data Integration section with dataset table, CLI/module usage examples, data-provenance rule, and reference links. Agent-Logs-Url: https://github.com/Hack23/riksdagsmonitor/sessions/d959ecd8-dfb3-4bf4-beec-a17db50ac538 Co-authored-by: pethers <1726836+pethers@users.noreply.github.com>
🔍 Lighthouse Performance Audit
📥 Download full Lighthouse report Budget Compliance: Performance budgets enforced via |
Agent-Logs-Url: https://github.com/Hack23/riksdagsmonitor/sessions/d959ecd8-dfb3-4bf4-beec-a17db50ac538 Co-authored-by: pethers <1726836+pethers@users.noreply.github.com>
🔍 Lighthouse Performance Audit
📥 Download full Lighthouse report Budget Compliance: Performance budgets enforced via |
🔍 Lighthouse Performance Audit
📥 Download full Lighthouse report Budget Compliance: Performance budgets enforced via |
🔍 Lighthouse Performance Audit
📥 Download full Lighthouse report Budget Compliance: Performance budgets enforced via |
| it('every feasibility file that names an agency also has a matching committee ' + | ||
| 'in at least one Statskontoret dataset', () => { | ||
| // Collect all committees covered across all datasets. | ||
| const coveredCommittees = new Set<string>(); | ||
| for (const dataset of Object.values(inv.datasets)) { | ||
| for (const committee of dataset.committees ?? []) { | ||
| coveredCommittees.add(committee); | ||
| } | ||
| } | ||
|
|
||
| // Files mentioning agencies related to FiU or KU should be coverable. | ||
| // This is a structural sanity check, not a per-file enforcement. | ||
| expect(coveredCommittees.has('FiU')).toBe(true); | ||
| expect(coveredCommittees.has('KU')).toBe(true); | ||
| }); |
| - [Statskontoret Indicators Inventory](../../analysis/statskontoret/indicators-inventory.json) | ||
| - [fetch-statskontoret.ts](../../scripts/fetch-statskontoret.ts) — 30-day cache module | ||
| - [statskontoret-client.ts](../../scripts/statskontoret-client.ts) — HTTP client library |
| # List all available download links for the authority register (30-day cache) | ||
| tsx scripts/fetch-statskontoret.ts # (import fetchStatskontoretCached) | ||
|
|
||
| # CLI: discover downloadable files for a source | ||
| tsx scripts/statskontoret-fetch.ts discover --source myndighetsforteckning | ||
|
|
| * | ||
| * ### Cache behaviour | ||
| * - Cache root: `analysis/data/statskontoret/<sourceKey>/cache/` | ||
| * - TTL: 30 days (configurable via `CacheTtlMs`) |
| const source = getStatskontoretSource(sourceKey); | ||
| const filePath = cacheFilePath(sourceKey, cacheRoot); | ||
| const now = new Date().toISOString(); | ||
|
|
||
| // --- Cache hit --- | ||
| const cached = readCacheEntry(filePath); | ||
| if (cached !== undefined && isCacheFresh(cached.fetchedAt, cacheTtlMs)) { | ||
| const cacheAgeMs = Date.now() - new Date(cached.fetchedAt).getTime(); | ||
| return { | ||
| sourceKey, | ||
| sourceTitle: source.title, | ||
| sourceUrl: source.url, | ||
| links: cached.links, | ||
| cachedAt: cached.fetchedAt, | ||
| fetchedAt: cached.fetchedAt, | ||
| fromCache: true, | ||
| cacheAgeMs, | ||
| }; | ||
| } | ||
|
|
||
| // --- Cache miss or stale: fetch from origin --- | ||
| const client = new StatskontoretClient(clientConfig); | ||
| let links: StatskontoretDownloadLink[]; | ||
| let fetchedAt: string; | ||
|
|
||
| try { | ||
| links = await client.discoverDownloads(sourceKey); | ||
| fetchedAt = now; | ||
| writeCacheEntry(filePath, { fetchedAt, sourceKey, links }); | ||
| } catch (error) { |
| it('for every implementation-feasibility.md that names a Swedish agency, ' + | ||
| 'the inventory provides myndighetsforteckning coverage', () => { | ||
| // Since myndighetsforteckning covers ALL Swedish government bodies by | ||
| // definition, one dataset entry suffices for all named agencies. | ||
| const missingCoverage: string[] = []; | ||
|
|
||
| for (const filePath of feasibilityFiles) { | ||
| const content = fs.readFileSync(filePath, 'utf-8'); | ||
| const mentioned = extractAgencyMentions(content, KNOWN_AGENCIES); | ||
|
|
||
| if (mentioned.length === 0) continue; // file mentions no known agencies → skip | ||
|
|
||
| // The inventory MUST contain myndighetsforteckning to cover any named agency. | ||
| if (!inv.datasets['myndighetsforteckning']) { | ||
| missingCoverage.push( | ||
| `${path.relative(REPO_ROOT, filePath)} mentions ${mentioned.join(', ')} but inventory has no myndighetsforteckning`, | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| expect( | ||
| missingCoverage, | ||
| `Statskontoret inventory is missing myndighetsforteckning coverage for:\n${missingCoverage.join('\n')}`, | ||
| ).toHaveLength(0); | ||
| }); |
|
@copilot apply changes based on the comments in this thread |
🔍 Lighthouse Performance Audit
📥 Download full Lighthouse report Budget Compliance: Performance budgets enforced via |
- scripts/fetch-statskontoret.ts: stamp `fetchedAt` after the network call completes (not before) so provenance reflects retrieval time; reuse the same value as `cachedAt` in the returned payload. Fix module-doc comment that said `CacheTtlMs` (now `cacheTtlMs`). - .github/skills/myndigheter-monitoring/SKILL.md: remove fake `tsx scripts/fetch-statskontoret.ts` invocation (module is library, not CLI); replace with `list-sources` command on the actual CLI wrapper. Fix relative reference paths from `../../` to `../../../` so they resolve from `.github/skills/myndigheter-monitoring/` to the repo root. - tests/statskontoret-feasibility-contract.test.ts: split the global per-file coverage test so it now (a) asserts at least one feasibility file references a known agency (no longer vacuous) and (b) records per-file coverage and reports any uncovered files. Rename the committee-coverage test to reflect that it is a global structural check, not a per-file assertion. Agent-Logs-Url: https://github.com/Hack23/riksdagsmonitor/sessions/a2f9326c-b982-4c1d-80ef-66b79b4fe7a9 Co-authored-by: pethers <1726836+pethers@users.noreply.github.com>
🔍 Lighthouse Performance Audit
📥 Download full Lighthouse report Budget Compliance: Performance budgets enforced via |
www.statskontoret.sealready in all 11news-*.mdworkflows (no change needed)scripts/fetch-statskontoret.tswith 30-day TTL cache wrapper overStatskontoretClientanalysis/statskontoret/indicators-inventory.jsonto reference newcachedFetchmodule.github/skills/myndigheter-monitoring/SKILL.mdwith Statskontoret integration sectiontests/statskontoret-feasibility-contract.test.ts— contract tests asserting inventory coverage and module API behaviourtests/statskontoret-inventory.test.tsto verifycachedFetchinventory entryCACHE_TTL_MScacheTtlMsnotCacheTtlMs)tsx fetch-statskontoret.tsCLI command from SKILL.md../../../not../../)