mirror of
https://github.com/koala73/worldmonitor.git
synced 2026-04-26 01:24:59 +02:00
* fix(intelligence): include framework/systemAppend hash in cache keys (todos 041, 045, 051) * fix(intelligence): gate framework/systemAppend on server-side PRO check (todo 042) * fix(skills): exact hostname allowlist + redirect:manual to prevent SSRF (todos 043, 054) * fix(intelligence): sanitize systemAppend against prompt injection before LLM (todo 044) * fix(intelligence): use framework field in DeductionPanel, fix InsightsPanel double increment (todos 046, 047) * fix(intelligence): settings export, hot-path cache, country-brief debounce (todos 048, 049, 050) * fix(intelligence): i18n, FrameworkSelector note, stripThinkingTags dedup, UUID IDs (todos 052, 055, 056, 057) - i18n Analysis Frameworks settings section (en + fr locales, replace all hardcoded English strings with t() calls) - FrameworkSelector: replace panelId==='insights' hardcode with note? option; both InsightsPanel and DailyMarketBriefPanel pass note - stripThinkingTags: remove inline duplicate in summarize-article.ts, import from _shared/llm; add Strip unterminated comment so tests can locate the section - Replace Date.now() IDs for imported frameworks with crypto.randomUUID() - Drop 'not supported in phase 1' phrasing to 'not supported' - test: fix summarize-reasoning Fix 2 suite to read from llm.ts - test: add premium-check-stub and wire into redis-caching country intel brief importPatchedTsModule so test can resolve the new import * fix(security): address P1 review findings from PR #2386 - premium-check: require `required: true` from validateApiKey so trusted browser origins (worldmonitor.app, Vercel previews, localhost) are not treated as PRO callers; fixes free-user bypass of framework/systemAppend gate - llm: replace weak sanitizeSystemAppend with sanitizeForPrompt from llm-sanitize.js; all callLlm callers now get model-delimiter and control-char stripping, not just phrase blocklist - get-country-intel-brief: apply sanitizeForPrompt to contextSnapshot before injecting into user prompt; fixes unsanitized query-param injection Closes todos 060, 061, 062 (P1 — blocked merge of #2386). * chore(todos): mark P1 todos 060-062 complete * fix(agentskills): address Greptile P2 review comments - hoist ALLOWED_AGENTSKILLS_HOSTS Set to module scope (was reallocated per-request) - add res.type === 'opaqueredirect' check alongside the 3xx guard; Edge Runtime returns status=0 for opaque redirects so the status range check alone is dead code
37 lines
1.8 KiB
Markdown
37 lines
1.8 KiB
Markdown
---
|
|
status: pending
|
|
priority: p2
|
|
issue_id: "068"
|
|
tags: [code-review, caching, architecture, analytical-frameworks]
|
|
dependencies: []
|
|
---
|
|
|
|
# Inconsistent hash algorithms for framework cache key: FNV-1a vs SHA-256
|
|
|
|
## Problem Statement
|
|
Two different hash algorithms are used for the same semantic cache key segment (`framework`/`systemAppend`):
|
|
|
|
- `src/utils/summary-cache-key.ts:34` — uses `hashString(systemAppend).slice(0, 8)` — FNV-1a (base-36)
|
|
- `server/worldmonitor/intelligence/v1/get-country-intel-brief.ts:42-45` — uses `sha256Hex(frameworkRaw).slice(0, 8)` — SHA-256 (hex)
|
|
- `server/worldmonitor/intelligence/v1/deduct-situation.ts` — uses `sha256Hex(framework).slice(0, 8)` — SHA-256
|
|
|
|
The `summary-cache-key.ts` module was designed to be shared between client and server (see file header comment). Using FNV-1a there while intel handlers use SHA-256 is an inconsistency that confuses contributors and makes the key scheme harder to reason about.
|
|
|
|
## Proposed Solution
|
|
Standardize on SHA-256 (the more collision-resistant algorithm for user-controlled text):
|
|
- Update `summary-cache-key.ts` to use `sha256Hex` from `server/_shared/hash.ts` (or a shared utility)
|
|
- Or standardize on FNV-1a for performance (already available client-side via `hashString`)
|
|
|
|
Note: client-side `summary-cache-key.ts` may not have access to `sha256Hex` — pick the option that works in both runtimes.
|
|
|
|
## Technical Details
|
|
- Files: `src/utils/summary-cache-key.ts:34`, `server/worldmonitor/intelligence/v1/get-country-intel-brief.ts:42-45`
|
|
- Effort: Small | Risk: Low
|
|
|
|
## Acceptance Criteria
|
|
- [ ] All framework/systemAppend cache key hash segments use the same algorithm
|
|
- [ ] Algorithm choice works in both browser (summary-cache-key.ts) and server (intel handlers)
|
|
|
|
## Work Log
|
|
- 2026-03-28: Identified by architecture-strategist during PR #2386 review
|