# Trello Card Creation

## Objective

Send records or feedback into a chosen Trello board and list as actionable cards.

A server-side path from an in-app record to a card on a configured Trello board and list, with a stored card reference.

## Before You Begin

This feature is being added to an application that already exists and already
works. Do not scaffold a new project, and do not assume a blank slate.

Inspect the codebase first and establish:

- The existing application structure and where code of this kind already lives.
- The framework and version in use.
- The existing design system — colours, spacing, typography, and component conventions.
- Existing UI components you can reuse instead of writing new ones.
- The existing database structure, if this feature needs to persist anything.
- The existing authentication and authorization system, if this feature is user-scoped.
- Dependencies already installed, so you don't add a library that duplicates one.
- The existing test setup and conventions.

Only start writing code once you understand the above. If the application
already implements part of this feature, extend it rather than replacing it.

## Implementation Instructions

1. Have an administrator choose the board and list during setup, and verify access by performing a real read on both before saving the connection. A board identifier accepted without verification fails on the first real submission.
2. Re-resolve the target list at creation time and handle the case where it has moved, been archived, or been deleted: fall back to a configured default list and raise a configuration warning rather than dropping the card.
3. Compose the card on the server from the originating record, with a link back into the app and only the context a board member is entitled to see. Trello boards are frequently public or widely shared, so treat everything placed on a card as published.
4. Key each submission by the originating record and check for an existing card reference before creating, so retries after a timeout do not scatter duplicate cards across the list.
5. GitHub Issue Creation, GitLab Issue Creation, Linear Issue Creation, Jira Ticket Creation, and Asana Task Creation are siblings. Capture, redaction, deduplication, and reference storage belong to the shared path; this brief owns only Trello's board and list resolution and its field mapping.

## UI and UX Requirements

Match the application's existing design system exactly. Reuse its components,
spacing, and typography. This feature should look like it was always there.

## Responsive Requirements

Works on mobile, tablet, and desktop. Touch targets are large enough to hit on a
phone, and nothing overflows horizontally at 320px.

## Accessibility Requirements

- Fully keyboard navigable.
- Correct semantic elements and ARIA roles.
- Visible focus states.
- Meets WCAG AA contrast.
- Dynamic changes are announced to screen readers.
- Respects prefers-reduced-motion.

## Edge Cases

- Board and list access must be verified at setup rather than assumed. The connected account may see the board but lack permission to add cards, which only surfaces when a real write is attempted.
- Lists are moved, archived, and deleted by board members without telling the app. Detect the missing target, use a configured fallback, and notify an administrator instead of failing the submission silently.
- Retries and double submissions must converge on one card. Persist the created card reference before acknowledging the job and check it on every attempt.
- Labels, members, due dates, and attachments must be resolved against the board at creation time. An unknown label or a member who has left the board should be omitted with a note, not treated as a fatal error.
- A board may be public or shared with people outside the organisation. Never place customer personal data, internal identifiers, credentials, or log excerpts on a card; summarise and link back into the app for the detail.
- The stored credential will expire or be revoked when a member leaves. Distinguish authentication failure from a transient error, hold the queue, and prompt an administrator to reconnect.
- Rate limiting requires exponential backoff with jitter and a bounded retry count, with a dead-letter path for cards that repeatedly fail.
- When Trello is unavailable, record the item in the app and create the card afterwards, so the user sees their submission accepted rather than an error.

## Testing

Exercise the feature end to end in the running application. Cover every edge case
above, then run the existing test suite and confirm nothing regressed.

## Acceptance Criteria

- [ ] Board and list access is verified with a real request before the connection is saved.
- [ ] A moved, archived, or deleted list falls back to a configured default and warns an administrator.
- [ ] Retried submissions produce exactly one card.
- [ ] Labels, members, due dates, and attachments are resolved at creation time and unknown values are omitted rather than fatal.
- [ ] No customer personal data, credentials, or internal identifiers appear on a card.
- [ ] Credential expiry queues submissions and prompts a reconnection.
- [ ] A Trello outage leaves the submission recorded in the app and created later.
- [ ] The feature matches the existing design system.
- [ ] No existing functionality is broken.

## Adaptation Rules

- Match the existing design system. Do not introduce a new colour palette,
  spacing scale, or component library.
- Reuse existing components and utilities wherever they fit.
- Follow the naming, file layout, and code style already present.
- Do not upgrade, replace, or remove existing dependencies to make this
  feature fit. Adapt the feature to the app, not the app to the feature.
- Do not break existing functionality. If a change is genuinely required in
  existing code, make the smallest one that works and say so.
- If something in these instructions conflicts with how the application is
  built, follow the application and explain the deviation.

## Final Verification

Before you report the work as done:

1. Re-read the acceptance criteria above and check each one against what you
   actually built.
2. Run the application and exercise the feature end to end.
3. Run the existing test suite and confirm you have broken nothing.
4. Check the feature on mobile, tablet, and desktop widths.
5. Check keyboard navigation and focus handling.
6. Summarize what changed: files added, files modified, and anything you
   deliberately did differently because of how this application is built.

If any acceptance criterion is unmet, fix it before reporting completion.
