# Check-in function specification

This is the deterministic check-in function Anthony calls the "check-in agent." It validates a member's entries, saves one Eastern calendar day, and returns the updated streak and card. It does not use a language model, prescribe a workout, or run an autonomous coach.

## Inputs and completion

The authenticated member supplies today's entries. The server supplies the member identity, creator, active round, protein target, Eastern date, and effective strength schedule. A client cannot choose another member or backdate a check-in.

| Entry | Daily rule |
| --- | --- |
| Protein | Whole grams from 0 to 1,000; completion requires at least the member's target. Zero is a valid incomplete entry. |
| Movement | Confirm 8,000 steps **or** record at least 30 minutes of moderate cardio. Cardio accepts whole minutes from 0 to 1,440. |
| Sleep | Confirm at least 7 hours. |
| Strength | Track sessions toward the weekly strength goal. It never blocks daily completion. |

Default strength guidance uses Monday, Wednesday, and Friday. Members can choose their training weekdays. Changes take effect on the next Eastern calendar day and do not rewrite an earned day. The weekly strength count covers the Eastern Monday–Sunday week. Strength is a weekly training goal, not a fourth requirement for the daily consistency check-in.

Protein, movement, and sleep complete the day on both training and recovery days. Members can also record strength. Workout guidance is expandable. The regimen library documents the creator's base challenge and template variations; these are not a daily AI coach or a medical prescription.

## Save transaction

1. Authenticate the member and validate the submitted types and ranges.
2. Resolve today's date in `America/New_York` and find an active round.
3. Resolve the schedule effective for that day and calculate completion on the server.
4. Upsert the member's single daily check-in. Saving again edits today instead of adding another day.
5. On a genuinely completed save, evaluate the one-time free-round award in the same database transaction.
6. Return the saved entries, current streak, tier, round progress, deadline, and reward state. The client renders the card from that response.

Incomplete entries can be saved. They do not advance the streak. Today's entries can be edited until midnight Eastern. An edit may remove today's completion, but an already earned free-round award remains. Historical completed days are retained when the new scheduling rules are introduced; they are not recalculated against a newly chosen schedule.

## Time and continuity

- The boundary is midnight Eastern, including daylight saving changes. The server returns the absolute deadline; the browser shows a countdown and the equivalent local time.
- Each 14-day round permits two grace days. A missed daily check-in after its deadline uses an available grace day and preserves the consistency count. Further missed days break the streak. There are no backdated entries.
- Grace dates contribute to the consistency count but are reported separately from actually completed dates. A grace date is never recorded or displayed as a completed workout or completed check-in.
- Planned recovery is actually completed when protein, movement, and sleep are met. It does not consume a grace day.
- Streaks are calculated from persisted days on read; a delayed reminder job cannot keep an expired streak alive.
- An expired round retains its final card. A late paid renewal starts a new streak chain.
- Ember, Spark, Steady, and Locked use the consistency count, including allowed grace days. The day-seven free-round award is evaluated only when an actual completed check-in is saved, not from a reminder or passive page read.
- Trailing grace preserves the last earned card. It does not advance the card or award a reward without a subsequent actual completion. The grace allowance does not refill after a reset; it resets with the next round. Existing rounds apply grace only from October 12, 2026 onward.

## Outputs and boundaries

The card contains the member's display name, optional portrait, day count, level, creator branding, and public creator join link. It may show a concise training or recovery label. It never contains the private check-in token, contact details, payment information, or private personal context.

The implementation lives in `lib/members.ts`, `lib/domain.ts`, `lib/training.ts`, `lib/rewards.ts`, the check-in UI, and the card renderer. Reminder delivery and Stripe fulfillment are separate functions. Share buttons require the member's action; this function does not post to social accounts.

The terms "agent," "loop," and "graph" describe these responsibilities. The public library supplies inspectable JSON specifications for six named functions. Follow saves a browser bookmark; Fork downloads an edited specification draft. These actions do not deploy a separate agent, call a model, or change the hosted rules.

Deployment preserves existing daily snapshots and earned rewards. New saves use the current daily requirements; weekly strength progress does not rewrite historical results.

## Private reflection

The member may save one optional line of up to 240 characters about today. It uses a separate authenticated endpoint and never affects completion, streaks, or rewards. It is scoped to today's active round; the member can edit it or clear it with an empty value. A stale-day request is rejected instead of writing yesterday's draft onto today. The note is never added to a public card, caption, creator report, or checkout.
