# Session Rules

This file records active working rules requested in this session.

## Decision Rules

- Keep JavaScript/TypeScript core files intact for upgrade safety whenever possible.
- Modularize at template/component level first.
- Keep main content as larger sections initially; split finer later.
- Use separate script includes (do not keep one monolithic script block).
- Use a staged rollout for AJAX navigation (pilot first, then expand by wave).

## File and Backup Rules

- For every touched existing file, create a fileNameOrig.ext backup.
- Keep change tracking docs up to date when implementation state changes.
- Maintain a manifest/inventory for modularization and AJAX rollout scope.

## Scope Rules

- Pilot AJAX routes are:
  - dist/indexOrig.html
  - dist/mailbox/inbox.html
  - dist/mailbox/read.html
  - dist/mailbox/compose.html
- Keep static/full-page navigation fallback available behind a feature flag.

## Testing Rules

- Validate lifecycle re-init and avoid duplicate listeners.
- Validate browser back/forward sync (URL/title/content/menu state).
- Validate accessibility focus and announcements after swaps.
- Validate error fallback and race handling before expanding waves.

## Documentation Rules

- Keep AJAX-NAVIGATION-PLAN.md and AJAX-PAGE-INVENTORY.md current.
- Record new decisions and constraints in this file as they are made.
