Skip to content

Add project phase tracking and firm knowledge context for agents#100

Merged
zinkh merged 1 commit into
mainfrom
claude/agent-training-arch-data-1f6pqp
Jul 23, 2026
Merged

Add project phase tracking and firm knowledge context for agents#100
zinkh merged 1 commit into
mainfrom
claude/agent-training-arch-data-1f6pqp

Conversation

@zinkh

@zinkh zinkh commented Jul 23, 2026

Copy link
Copy Markdown
Owner

Summary

This PR introduces project phase history tracking (ESQ/APS/APD/PC/PRO/DCE/ACT/VISA/DET/AOR) and exposes firm-specific benchmarks to AI agents via a new firm_knowledge context scope. Architects can now track which mission phase each project is in, view phase transition history, and agents can reference real historical data (phase durations, price catalogs, DPGF costs, CCTP templates) when making recommendations.

Key Changes

Database & Schema

  • New table project_phase_history — tracks phase transitions with entered_at and exited_at timestamps
  • Added migration file and updated schema.sql with RLS policies
  • Indexed on (tenant_id, project_id) for efficient queries

Backend API (server.ts)

  • GET /api/projects/:id/phase-history — fetch all phase transitions for a project
  • POST /api/projects/:id/phase — set current phase (auto-closes previous phase, logs activity)
  • Validates phase exists and prevents redundant transitions

Agent Context & System Prompt

  • Added firm_knowledge to AgentContextScope type
  • New context builder functions:
    • summarizePhaseBenchmarks() — averages phase durations (min 2 samples per phase)
    • summarizeCostHistory() — aggregates DPGF item prices by designation/unit
  • Agent system prompt now includes:
    • Phase duration benchmarks from completed phases
    • Price catalog (articles_type) limited to 40 rows
    • Historical DPGF costs (top 30 by frequency)
    • CCTP excerpts (5 max, 2000 chars each)
  • Gated behind firm_knowledge scope — agents without it don't pay token cost

Frontend UI (ProjectDetail.tsx)

  • New phase selector showing all 10 mission phases as toggleable buttons
  • Current phase highlighted in primary color
  • Phase history timeline below selector showing entry/exit dates
  • Fetches and displays phase history on project load
  • Calls handleSetPhase() to update via API

Types & Localization

  • Added ProjectPhaseHistoryEntry interface
  • Added firm_knowledge to agent config UI with descriptive label
  • Added French/English translations for phase UI labels

Implementation Details

  • Phase transitions are atomic: exiting old phase and entering new phase happen in sequence
  • Minimum 2 completed phases required before averaging (prevents single-sample bias)
  • Cost history aggregates by designation|unite key to group variants
  • CCTP excerpts truncated to 2000 chars to control token usage
  • All firm_knowledge data is tenant-isolated via RLS
  • Activity logging records phase changes for audit trail

https://claude.ai/code/session_01Ruo4H7HxCTkiNKX9wweHt9

Adds real phase-by-phase mission tracking (ESQ/APS/.../AOR) per project
via a new project_phase_history table and a small tracker UI on
ProjectDetail, then wires that history plus the firm's price catalog,
DPGF cost history, and CCTP excerpts into a new opt-in "firm_knowledge"
agent context scope so AI agent suggestions reflect the cabinet's own
track record instead of generic architectural knowledge.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ruo4H7HxCTkiNKX9wweHt9
@zinkh
zinkh merged commit 05f52e7 into main Jul 23, 2026
1 check passed
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