Skip to content

Stage 8.3: migrate analysis rules-leg compute to C# authority (+ CI guard alignment) - #13

Draft
IvanCodesDev wants to merge 3 commits into
mainfrom
cursor/stage-8-3-analysis-authority-2ca6
Draft

Stage 8.3: migrate analysis rules-leg compute to C# authority (+ CI guard alignment)#13
IvanCodesDev wants to merge 3 commits into
mainfrom
cursor/stage-8-3-analysis-authority-2ca6

Conversation

@IvanCodesDev

Copy link
Copy Markdown
Owner

Stage 8.3 — analysis rules-leg compute moves to C#

Per commit 026da51 ("the compute leg itself moves in Stage 8.3") and the V2.0 §4.2 roadmap inferred from backend/NuGet.Config and Stage 8.1/8.2 conventions.

What changed

  • C# (ForgeX.Api): new POST /api/v1/analysis-tasks (mounted only with AnalysisTasks:Provider=postgres) executes the deterministic rules leg via ForgeX.Analytics and persists to forgex.node_analysis_tasks with the exact UPSERT cadence, field semantics, and RLS GUC contract of server/services/postgres-analysis.js. Terminal snapshot + full events returned on 201. Stage 8.1 history/SSE read endpoints serve C#-computed tasks unchanged. AnalysisTasks:TaskTtlMs (default 3600000) mirrors Node TASK_TTL_MS. New UpsertAsync on PostgresAnalysisTaskRepository, new create DTOs in ForgeX.Contracts.
  • Node: new ANALYSIS_AUTHORITY=node|csharp switch (default node). In csharp mode, non-AI task creation on POST /api/analyze proxies to the sidecar (ownership/rate-limit checks stay local; hashed tenant/owner context headers; ANALYSIS_AUTHORITY_TIMEOUT_MS, sidecar failure → 502) and adopts the terminal snapshot via TaskStore.adopt, so existing result/poll/SSE-replay routes work as-is. AI narration legs (Partner SSO / OpenAI-compatible) and quota degradation stay in Node; provider credentials never leave the Node process.
  • Tests: tests/analysis-authority.test.js (28 checks: proxy contract, credential stripping, hashed context headers, adopted-task read routes, node-mode zero sidecar calls, sidecar-unavailable 502, config guards) added to the main chain.
  • CI guard alignment (pre-existing reds on main): the zero-PackageReference grep and security-audit.js check failed ever since Stage 8.1 sanctioned Npgsql — replaced with a per-project pinned allowlist (config/dependency-policy.jsonallowedDotnetPackages, currently only Npgsql 9.0.3 in ForgeX.Infrastructure) shared via new tools/verify-dotnet-packages.js; also fixed the stale ESLint no-undef in tools/capture-readme-screenshots.js and two Prettier-only engine TS warnings.

Rollback

Set ANALYSIS_AUTHORITY=node (or unset — it is the default). Behavior is then bit-identical to pre-migration; no schema or data migration is involved, and rows written by C# remain readable by Node.

Test evidence

npm run check (openapi/lint/format/frontend typecheck+tests/full npm test) green; npm run dotnet:build 0 warnings 0 errors; npm run dotnet:analytics 955/955; npm run dotnet:openapi-runtime 10 paths; security audit 12/12. Live end-to-end against PostgreSQL verified: C#-executed task served by Node SSE/poll/result, survives Node restart, served by C# read endpoints, and dual-run Node-vs-C# persisted reports are byte-identical except taskId.

Open in Web Open in Cursor 

cursoragent and others added 3 commits August 24, 2026 12:59
- C# POST /api/v1/analysis-tasks executes the deterministic rules leg via
  ForgeX.Analytics and persists to forgex.node_analysis_tasks with the exact
  UPSERT cadence/field semantics of server/services/postgres-analysis.js,
  so Stage 8.1 history/SSE read endpoints serve C#-computed tasks unchanged
- Node gains ANALYSIS_AUTHORITY=node|csharp rollback switch (default node);
  csharp mode proxies non-AI task creation to the sidecar with hashed
  tenant/owner context and adopts the terminal snapshot into TaskStore,
  keeping AI narration legs and provider credentials in Node
- tests/analysis-authority.test.js (28 checks) added to the main test chain

Co-authored-by: Ivan <2006ivanwong@gmail.com>
…ale lint/format

- Replace the zero-PackageReference grep (red since Npgsql landed) with a
  per-project pinned allowlist in config/dependency-policy.json, shared by
  the new tools/verify-dotnet-packages.js and tools/security-audit.js
- Grant browser globals (incl. Event) to tools/capture-readme-screenshots.js
  whose page.evaluate() callbacks run in the browser
- Prettier-format the two engine TS files (modifier order only)

Co-authored-by: Ivan <2006ivanwong@gmail.com>
…elog

Co-authored-by: Ivan <2006ivanwong@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants