3.9 KiB
3.9 KiB
Implementation Playbook
This guide shows how to add features without breaking the current architecture.
General Workflow
- Read the slice README.
- Identify whether the behavior is domain, application, presentation, or repository state.
- Add or change the feature-owned model.
- Update
LocalDataStateonly if a new persisted collection is needed. - Route all writes through
LocalRepository. - Add focused tests.
- Update docs when behavior changes across slices.
Example Feature: Add A New Captured Fact Type
Suppose you want shares and manual capture to support a new fact type:
communicationStyle.
Files To Change
Domain:
lib/features/share_intake/domain/share_models.dart- add enum value to
CapturedFactType
- add enum value to
lib/features/people/domain/person_models.dart- ensure any switch over
CapturedFactTypehandles the new value
- ensure any switch over
Extraction and suggestions:
lib/features/share_intake/domain/share_capture_draft_suggester.dartlib/core/llm/llm_service.dartlib/core/llm/captured_fact_draft_parser.dart
Persistence:
lib/app/data/relationship_repository_share.dart- ensure
_applyFactDraftToFactsstores the new type correctly
- ensure
lib/app/state/local_data_state.dart- usually no change needed because facts already store
CapturedFactType
- usually no change needed because facts already store
UI:
lib/features/share_intake/presentation/share_capture_review_sheet.dartlib/features/share_intake/presentation/share_inbox_view.dartlib/features/people/presentation/people_view_detail.dart
AI digest:
lib/features/ai_digest/application/anonymized_llm_context_builder.dart- update
_factTypeLabel
- update
Tests:
test/features/share_intake/share_capture_draft_suggester_test.darttest/core/llm/captured_fact_draft_parser_test.darttest/features/local/local_repository_test.darttest/features/ai_digest/anonymized_llm_context_builder_test.dart
Rules
- Add enum values at the end unless there is a strong reason to reorder.
- Keep
fromJsonfallback behavior. - Add tests for unknown or missing values when changing parsing behavior.
- Do not make LLM output the only way to create the new type. Provide a local fallback or review UI path.
Example Feature: Add A New Share Source Parser
Suppose you want better Telegram parsing.
Files:
- Add
lib/features/share_intake/domain/telegram_share_parser.dart. - Update
SharePayloadParser._normalizeSourceApp. - Update
SharePayloadParser._parseSourceMetadata. - Add tests in
test/features/share_intake/.
Parser expectations:
- Return message text without source prefix noise.
- Extract display name only when the pattern is strong.
- Extract stable source IDs only when they are provided by the source.
- Leave unknown timestamps null.
- Never throw on malformed input.
Repository expectations:
- Exact identity match can auto-link only when unambiguous.
- Near matches should route to Share Inbox.
- Source profile links should be stable across follow-up shares.
Example Feature: Sync A New Entity
Suppose AI suggestion drafts need REST sync.
Files:
docs/api/openapi.yamllib/integrations/backend/models/backend_models.dart- generated backend model files
lib/integrations/backend/backend_gateway_rest.dartlib/integrations/backend/backend_gateway_fake.dartlib/integrations/backend/sync_envelope_validator.dartlib/app/data/relationship_repository_ai_digest.dart- tests under
test/integrations/backendandtest/features/sync
Design choices to document:
- entity type string in
ChangeEnvelope - create/update/delete semantics
- conflict behavior
- whether rejected changes are user-repairable
- privacy implications
Review Checklist Before Shipping
flutter analyze- focused tests for touched slices
- full
flutter testwhen practical - manual Settings smoke test for config/debug actions
- manual share simulation test after share changes
- physical-device test after native share, notification, or background changes