# Project Instructions — UBT EPS-TOPIK Practice

You are the engineering agent for a training/practice exam product. Read `PRD.md`, `docs/DECISIONS.md`, and the relevant technical document before implementing a feature.

## Product truth
- This is an independent practice simulator, not an official HRD Korea / EPS / TOPIK system.
- Do not copy official logos, claim official affiliation, scrape protected exam systems, or imply an official result/certificate.
- The complete source-of-truth screenshot set is in `references/design/`; read `docs/REFERENCE_MAPPING.md` and `docs/UX_DESIGN_SPEC.md` before UI work. Match the admin upload reference and participant profile/catalog, question overview, Reading/Listening, review, and result layouts. Use project-owned branding; never copy official seals, watermarks, or imply affiliation.

## Non-negotiable engineering rules
1. Work in milestones. First inspect the repository and environment, then propose a plan. Do not generate a giant application in one pass.
2. Preserve existing user code. Never overwrite or delete files without inspecting them first.
3. Use Laravel conventions, Form Requests, Policies, service/action classes for domain logic, migrations, factories, and automated tests.
4. Admin CRUD belongs in Filament. Participant/exam UI belongs in Vue 3 + Inertia. Do not build the exam page inside Filament.
5. Keep exam business rules on the server. The client must never decide score, expiration, eligibility, or correct answers.
6. Use database transactions for import commit, answer persistence where needed, exam submission, and grading.
7. Import is staged: upload → parse → validate → preview → explicit commit. Invalid rows must be reported with row numbers. A failed import must not leave partially imported questions.
8. Validate uploaded files using extension, MIME/content checks, size limits, safe ZIP extraction, and generated storage names. Reject path traversal and executable content.
9. Keep media private by default. Serve it through authorized routes when needed.
10. Use policies/authorization on every protected admin operation and exam action. Hiding a button is not authorization.
11. Never expose answer keys in participant props, HTML, API responses, logs, or browser state before permitted result release.
12. Timer is server-authoritative (`started_at`, `expires_at`). The frontend countdown is only a display. Refresh/reconnect must restore the attempt from the server.
13. Add tests for happy paths, validation failures, authorization, boundary conditions, and regressions.
14. Run formatter, static analysis if installed, unit/feature tests, and frontend build after changes. Report commands and actual outcomes; never claim a test passed if it was not run.
15. Verify UI against the supplied reference set: admin upload at desktop 1536×1024; participant overview, Reading/Listening, review and result at tablet/phone landscape; profile/catalog and results at portrait. Capture screenshots for each key page.
16. Use current official docs for installed package versions. Do not invent APIs or use deprecated APIs because of old training examples.
17. Keep Indonesian language for admin copy and labels unless the content is intentionally Korean/English. Korean question text must be stored as Unicode without destructive normalization.

## Working protocol
- Start with: inspect files, `composer.json`, `package.json`, routes, migrations, tests, PHP/Node versions, and git status.
- State assumptions and list any blocker that genuinely prevents safe implementation.
- Write/update the implementation plan for non-trivial work.
- Implement the smallest complete slice; test; inspect diff; summarize changed files and remaining risks.
- Do not install packages, alter deployment configuration, run destructive commands, migrate production, or publish content without explicit approval.

## Source of truth order
1. User-approved decisions in `docs/DECISIONS.md`.
2. `PRD.md` and the relevant docs in `docs/`.
3. Existing project conventions, if they do not conflict with approved requirements.
4. Current official documentation for the exact installed versions.

If requirements conflict, report the conflict and propose a resolution rather than silently guessing.
