Metadata-Version: 2.4
Name: deped-hr
Version: 0.3.0
Summary: Cleans personnel CSV exports into a standalone SQLite database.
Requires-Python: >=3.14
Requires-Dist: deped-dcp-template>=0.4.2
Requires-Dist: pydantic>=2.13
Requires-Dist: rapidfuzz>=3.14.5
Description-Content-Type: text/markdown

# deped-hr

`deped-hr` cleans DepEd personnel CSV exports into a standalone SQLite artifact. It depends on a lookup database from `deped-dcp-template` and an entity artifact from `deped-entity`.

## What This Package Owns

- Personnel row cleaning and normalization
- Entity loading for the personnel domain
- Position title seeding from `lookups.db`
- A staged, auditable rebuild pipeline over `artifacts/personnel.db`
- Personnel and ESF7 views for downstream reporting
- Audit metadata, row rejects, and compatibility files

This package is the source of truth for the personnel database contract only.

## Main Workflow

```sh
just restart
```

This refreshes `artifacts/lookups.db`, incrementally rebuilds `artifacts/personnel.db` through the staged loader with the three ESF7 authority files, and runs `hr audit`.

## Docs

- Build and CLI usage: [`docs/operations/build.md`](./docs/operations/build.md)
- Database contract: [`docs/reference/data-contract.md`](./docs/reference/data-contract.md)
- Normalization and ESF7 matching: [`docs/source-contracts/normalization.md`](./docs/source-contracts/normalization.md)
- Downstream query patterns: [`docs/reference/downstream-queries.md`](./docs/reference/downstream-queries.md)
- Source data issues: [`docs/analysis/evidence-diagnostics/source-data-issues.md`](./docs/analysis/evidence-diagnostics/source-data-issues.md)

## Notes

- ESF7 is mandatory because it is authoritative for school-level staffing counts;
  the personnel survey is the email source after audited matching.
- `hr build` remains compatible, but it requires all three ESF7 files and runs
  the staged loader with reset semantics.
- `hr rebuild` requires all three ESF7 files while still skipping unchanged
  upstream stages.
- `TIN` and `phylsys_num` from ESF7 are never stored in the artifact.

## Tests

Run the package tests from this directory:

```bash
uv run pytest -q
```
