Skip to content

feat: attribute-driven self-assembling SystemPromptBuilder#11

Merged
thomasluizon merged 1 commit into
mainfrom
feature/attribute-driven-prompt-builder
Mar 21, 2026
Merged

feat: attribute-driven self-assembling SystemPromptBuilder#11
thomasluizon merged 1 commit into
mainfrom
feature/attribute-driven-prompt-builder

Conversation

@thomasluizon

Copy link
Copy Markdown
Owner

Summary

  • Replace monolithic 800-line SystemPromptBuilder with attribute-driven self-assembling architecture
  • [AiAction], [AiField], [AiRule], [AiExample] attributes on command classes carry all AI prompt metadata
  • ActionDiscoveryService scans Application assembly via reflection at startup (singleton, cached)
  • 12 IPromptSection classes compose the prompt in Order sequence
  • Capabilities rendered at Order 150 (near top), schema/rules/examples at Order 900 (bottom)
  • SuggestBreakdownAction metadata-only class for the action with no MediatR command
  • Re-adds reminderEnabled/reminderMinutesBefore to AiAction (lost during prior refactor)
  • Adding a new AI action = decorating ONE command class, zero other file changes

Test plan

  • dotnet build succeeds (0 warnings, 0 errors)
  • All 282 unit tests pass
  • Manual test: send chat messages, verify AI responds correctly
  • Verify new action discovery: all 7 actions appear in prompt capabilities + schema
  • Test reminder: "exam tomorrow at 5pm, remind me 30 min before" creates with reminder enabled

🤖 Generated with Claude Code

Replace monolithic 800-line static SystemPromptBuilder with a modular
architecture where AI action metadata lives on command classes via
C# attributes.

Application layer:
- Add [AiAction], [AiField], [AiRule], [AiExample] attributes
- Decorate all 6 existing commands + SuggestBreakdownAction metadata class
- Re-add reminderEnabled/reminderMinutesBefore to AiAction model

Infrastructure layer:
- ActionDiscoveryService scans Application assembly via reflection (singleton)
- IPromptSection interface with Order-based assembly
- 12 section classes (Static, Dynamic, Auto) compose the prompt
- ActionCapabilitiesSection (Order 150) renders capabilities near top
- ActionSchemaSection (Order 900) auto-generates schema, rules, examples
- Static facade preserves backward compat for existing callers

Adding a new AI action = decorating ONE command class, zero other changes.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@thomasluizon
thomasluizon merged commit d4d1cac into main Mar 21, 2026
1 check passed
@thomasluizon
thomasluizon deleted the feature/attribute-driven-prompt-builder branch March 21, 2026 07:10
thomasluizon added a commit that referenced this pull request Jun 27, 2026
…es a soft-delete leak) (#11) (#263)

* feat(api): undo backend — restore endpoints + sub-habit cascade soft-delete (#11)

Soft-delete already exists (sync tombstones); this adds the missing Restore. POST /api/{habits,goals,tags}/{id}/restore (IgnoreQueryFilters + ownership + sub-habit cascade). DeleteHabitCommand now cascade-soft-deletes the sub-habit subtree (closes a leak where a deleted parent's children stayed visible in aggregates). HabitHierarchy helper. 8 EF-filter leak tests covering every log-reading query shape + cascade + preservation.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* fix(api): address #263 review — concurrency-retry + pay-gate-aware restore

- Add IConcurrencyRetryable to RestoreHabitCommand + RestoreTagCommand (match RestoreGoalCommand): a DbUpdateConcurrencyException during the restore save is now retried by ConcurrencyRetryBehavior instead of surfacing as HTTP 500.
- RestoreHabit + RestoreTag controllers use result.ToPayGateAwareResult(...) + ProducesResponseType(403), matching RestoreGoal — no hand-written pay-gate block.
- Scope RestoreHabitCommand hydration to deleted habits (&& h.IsDeleted): excludes the live set. Kept the deleted subtree rather than HabitId-only, since cascade restore needs the descendants.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.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.

1 participant