# Task Plan: Brand Description Prompt Context ## Goal Include the current brand description in every article-generation prompt while bounding prompt growth and preserving factual/numeric details from long descriptions. ## Current Phase Complete ## Phases ### Phase 1: Trace and Budget - [x] Trace brand persistence and current-brand loading - [x] Inventory all article-generation entry points and prompt assembly seams - [x] Identify existing prompt/token/character budgets and snapshot behavior ### Phase 2: Contract and Regression Tests - [x] Define short-description passthrough and long-description compaction rules - [x] Add failing tests for every generation path and maximum prompt growth - [x] Protect numeric facts from being dropped or rewritten during compaction ### Phase 3: Implementation - [x] Add one shared brand-context builder - [x] Inject the same context into template, custom, imitation, and KOL generation - [x] Preserve queued-task reproducibility through snapshots where needed ### Phase 4: Verification and Cleanup - [x] Run focused, package, and full relevant tests - [x] Review prompt output and scoped diff - [x] Confirm no temporary instrumentation remains ## Decisions | Decision | Rationale | |----------|-----------| | Use task-specific planning files | Shared plan files are owned by a concurrent long-running task. | | Centralize brand context assembly | Prevents inconsistent truncation and missing paths. | | Budget by runes/tokens before prompt assembly | A database field length is not a safe model-context budget. | | Cap rendered description at 2000 runes | Current production max is 1195; this preserves all current data while bounding future growth to about 2000 estimated input tokens. | | Brand profile facts outrank conflicting RAG facts | The directly edited brand profile is the canonical source for the brand's own base identity. | | Reuse the existing typed fact guard | Brand-description dates/year counts should receive the same pre-persistence validation as RAG facts. | | Snapshot a structured brand prompt context | Supports stable retries and lets old queued tasks fall back to a scoped read. | ## Errors | Error | Attempt | Resolution | |-------|---------|------------| | First production-stat command failed during local JavaScript string parsing | 1 | Reissued with a single-quoted remote command; no remote command ran on the failed attempt. | | Broad config context search returned a sensitive adjacent config line internally | 1 | Do not repeat or record the value; use exact-key queries without context for future config inspection. | | Tenant app test compilation was interrupted by concurrent media-favorites work referencing `DeleteFavoriteResourceFromGroup` before its implementation existed | 1 | Preserve unrelated work; use isolated test compilation for the brand regression, then retry normal package tests after the concurrent edit settles. | | A second tenant app compile attempt observed the same concurrent feature between interface and implementation edits | 2 | Stopped retrying until the external file stabilized; the focused, package, and full-repository tests later passed normally. |