7.0 KiB
PlotDirector Codex Guide
PlotDirector is an ASP.NET Core .NET 10 MVC/Razor application using Dapper and Microsoft.Data.SqlClient.
This file contains the rules and information needed on most development tasks. Detailed operational procedures are deliberately kept in separate documents. Read those only when the current task requires them.
Repository
- Repository:
/srv/repos/PlotDirector - Solution:
PlotLine.slnx - Web application:
PlotLine/PlotLine.csproj - Regression harness:
PlotLine.Tests/PlotLine.Tests.csproj - Word add-in:
PlotDirector.WordCompanion/ - Development service:
plotdirector-dev - Development site:
https://dev.plotdirector.com/ - Development database:
PlotDirector_Development - Production is a separate host and database. Development work does not authorise production changes.
Tools/andtools/, andDocs/anddocs/, are distinct paths on Linux.
Core Development Rules
- Use Dapper and stored procedures for application database access.
- Do not add inline SQL to application code.
- Do not introduce Entity Framework or EF migrations.
- SQL migrations are forward-only. Never modify an existing numbered migration to repair a live schema.
- PlotDirector must work for arbitrary books and authors. Never add production logic that recognises manuscript-specific names, places, vehicles, objects or relationships.
- Preserve existing user changes in a dirty worktree. Do not revert unrelated changes.
- Never expose or commit passwords, connection strings, API keys, SMTP credentials, Stripe secrets or OpenAI keys.
Context And Discovery Discipline
Context is a finite resource. Repository discovery must be targeted, incremental and evidence-led.
Start from the implementation point most directly related to the requested change and trace dependencies outward only when evidence requires it.
Prefer:
- narrow
rgsearches within likely directories or files; - specific symbols, methods, routes, stored procedures or view names;
- targeted line ranges instead of reading entire large files;
- one or a small number of directly relevant files at a time;
- existing focused documentation when it answers a question more cheaply than rediscovering the architecture from source;
- inspecting callers or dependencies only when relevant to the requested behaviour.
Avoid:
- broad repository-wide searches merely to build general context;
- searching application code, tests and all documentation trees simultaneously unless genuinely necessary;
- very large result limits such as hundreds or thousands of search matches;
- reading many large files in parallel;
- reading entire controllers, services, repositories or SQL files when only a method or section is relevant;
- speculative investigation of adjacent systems;
- repeatedly rereading material already available in the current context;
- loading detailed operational documentation unless the task actually needs it.
Do not attempt to understand the whole application before making a local change.
For broad tasks, identify the primary implementation path first. Expand discovery in stages and only where the previous stage demonstrates that more context is required.
Parallel tool calls are useful for latency but must not be used to load large amounts of speculative context simultaneously.
UI Notifications
Use the shared PlotDirector.toast service for transient feedback. See Docs/Codex/Notifications.md for the API, partial-view usage, and messages that must remain inline. Do not introduce another notification library or page-specific toast host.
Build And Test
Normal build gate:
dotnet build PlotLine.slnx
Full regression harness:
dotnet run --project PlotLine.Tests/PlotLine.Tests.csproj
PlotLine.Tests is an executable regression harness, not a conventional test SDK project. dotnet test is not the normal test gate.
Run build and tests serially. Parallel execution can cause static web asset cache locking.
Use verification proportionate to the change. Do not run unrelated specialist test suites merely for completeness.
Detailed specialist testing instructions are in Docs/Codex/Testing.md.
Database Work
For tasks requiring database inspection, schema changes, migrations or direct development-database access, read Docs/Codex/Database.md.
Do not load that guide for tasks that do not require database work.
Essential rules that always apply:
- The development database is
PlotDirector_Development. - Never assume the database named in appsettings is the effective development database.
- Never restore, reset or overwrite the development database unless explicitly requested and the target has been verified.
- Do not modify database state during a read-only investigation.
- Do not apply SQL during a read-only audit.
Deployment
For tasks that actually require deployment or detailed development-service operations, read Docs/Codex/Deployment.md.
Do not load deployment procedures during ordinary implementation or investigation unless deployment is part of the requested task.
Story Intelligence
For Story Intelligence work, use the existing authoritative documentation:
docs/story-intelligence/single-system-runtime.mdDocs/StoryIntelligence_ExceptionReview.md
Read these only when the task concerns Story Intelligence or behaviour governed by those contracts.
Core invariant: manuscript-specific examples may be used in regression fixtures, but production behaviour must remain generic.
Operational Safety
- Avoid destructive Git commands such as
git reset --hardorgit checkout --unless explicitly requested. - Inspect the worktree before editing and preserve unrelated changes.
- Do not deploy while an import or Story Intelligence analysis is active unless interruption has explicitly been accepted.
- Production changes require explicit production authorisation.
- Prefer reversible, narrowly scoped actions.
Public website separation
The independent public website source is /srv/repos/PlotDirector.Website, repository
PlotDirector.Website. Public editorial pages and the public Problem Solver are
maintained there. Do not duplicate website content edits in this application.
Internal PlotLine project/assembly/namespace identities remain unchanged.
Application Production origin is prepared as https://app.plotdirector.com; cutover
requires explicit approval. Development remains https://dev.plotdirector.com.
See Docs/Separation/Audit.md, Cutover.md and Acceptance.md for measured status.
Application help remains authoritative in PlotLine/Help/Articles. Public help must
be explicitly exported via Tools/PublicContent using an approved URL allowlist and
exact source commit. Never publish internal/unreleased documentation by globbing.
The website consumes versioned artifacts; do not create independently maintained
article copies. See the website Docs/Content.md for publication/consumption commands.
Authentication uses the public brand in every display mode. Authenticated theme
preferences, Data Protection identity, uploads, SQL, subscriptions and users persist.