Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions .github/workflows/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,23 @@ jobs:
verify:
needs: changes
if: needs.changes.outputs.code == 'true'
runs-on: ubuntu-latest
runs-on: windows-latest
steps:
- uses: actions/checkout@v5
- uses: actions/setup-python@v6
with:
python-version: '3.11'
- name: Install CivicCore release wheel
run: python -m pip install https://github.com/CivicSuite/civiccore/releases/download/v0.4.0/civiccore-0.4.0-py3-none-any.whl
- name: Checkout townlight/core
uses: actions/checkout@v5
with:
repository: townlight/core
ref: 2f6ba9be4a95e3772dc47a3682ac780c5283b626
path: townlight-core-source
persist-credentials: false
- name: Install townlight core
run: python -m pip install --no-deps ./townlight-core-source
- name: Install package
run: python -m pip install -e ".[dev]"
- name: Run release gate
shell: bash
run: bash scripts/verify-release.sh
16 changes: 10 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
> **Parked foundation — outside the released Windows suite.** This repository contains exploratory/support code, not a completed Townlight product. It is not installed or supported by Windows 1.8.1.1. Historical examples, package names and dependency pins below describe this foundation and must not be used as current suite installation instructions. Use the [released Windows suite, current modules and acceptance limits](https://townlight.github.io/versions.html).
> Townlight Data 0.2.0 targets the next Windows candidate. Windows 1.9.2.1 does not include Data.

<a id="civicdata-bridge"></a>

# Townlight Data

Townlight Data is the Townlight open-data preparation module. Version 0.1.2 ships the local package, FastAPI runtime, deterministic helper functions, optional database-backed publication workpapers, bearer-token protection for persisted retrieval, tests, release gates, public documentation, and browser-verified sample UI for preparing municipal datasets before human-approved publication.
Townlight Data is the Townlight open-data preparation module. Version 0.2.0 ships the local package, FastAPI runtime, deterministic helper functions, optional database-backed publication workpapers, bearer-token protection for persisted retrieval, tests, release gates, public documentation, and browser-verified sample UI for preparing municipal datasets before human-approved publication.

## Shipping in v0.1.2
## Windows staff workflow

In Townlight Data 0.2.0 candidate on Windows Suite full profile, existing Contracts grants let staff select signed agreements and preview only contract ID, title, vendor, start/expiration. An admin explicitly confirms the actual SHA-256 preview before an unattended queue sends to the configured resident Portal. Status states cover selection, hash confirmation, queueing, acknowledgement, correction, and withdrawal. No public link appears until the receiving portal acknowledges. Public outputs include CSV, JSON, and dictionary. Corrections proceed through a new review; withdrawal removes anonymous downloads when delivered. Legacy standalone workpaper APIs remain separate.

## Standalone workpapers

- Dataset field normalization for CKAN-friendly names, date/time hints, and geospatial-review notes.
- Data-dictionary draft generation from source schema metadata.
Expand All @@ -25,17 +29,17 @@ Townlight Data is the Townlight open-data preparation module. Version 0.1.2 ship
- Data warehouse storage or long-term operational data storage beyond archive-bundle planning.
- Autonomous redaction or automatic exemption decisions.
- External connector runtime, approval queues, or Townlight Records exemption-engine integration.
- Staff SSO and role-based publication approvals. v0.1.2 protects persisted retrieval only; broader workflow auth comes later.
- Staff SSO and role-based publication approvals. v0.2.0 protects persisted retrieval only; broader workflow auth comes later.

## Install and run locally

Townlight Data v0.1.2 is pinned to `civiccore==0.4.0`.
Townlight Data v0.2.0 is pinned to `townlight-core==1.3.0.dev2`.

```bash
python -m venv .venv
. .venv/Scripts/activate # Windows PowerShell: .venv\Scripts\Activate.ps1
python -m pip install -e ".[dev]"
python -m uvicorn civicdata.main:app --host 127.0.0.1 --port 8137
python -m uvicorn townlight_data.main:app --host 127.0.0.1 --port 8137
```

Open `http://127.0.0.1:8137/civicdata` for the browser sample and `http://127.0.0.1:8137/docs` for FastAPI docs.
Expand Down
16 changes: 10 additions & 6 deletions README.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
Parked foundation — outside the released Windows suite. This repository contains exploratory/support code, not a completed Townlight product. It is not installed or supported by Windows 1.8.1.1. Historical examples, package names and dependency pins below describe this foundation and must not be used as current suite installation instructions. Use the released Windows suite, current modules and acceptance limits.
Townlight Data 0.2.0 targets the next Windows candidate. Windows 1.9.2.1 does not include Data.

Townlight Data

Townlight Data is the Townlight open-data preparation module. Version 0.1.2 ships the local package, FastAPI runtime, deterministic helper functions, optional database-backed publication workpapers, bearer-token protection for persisted retrieval, tests, release gates, public documentation, and browser-verified sample UI for preparing municipal datasets before human-approved publication.
Townlight Data is the Townlight open-data preparation module. Version 0.2.0 ships the local package, FastAPI runtime, deterministic helper functions, optional database-backed publication workpapers, bearer-token protection for persisted retrieval, tests, release gates, public documentation, and browser-verified sample UI for preparing municipal datasets before human-approved publication.

Shipping in v0.1.2
Shipping in v0.2.0

- Dataset field normalization for CKAN-friendly names, date/time hints, and geospatial-review notes.
- Data-dictionary draft generation from source schema metadata.
Expand All @@ -23,16 +23,16 @@ Not shipped yet
- Data warehouse storage or long-term operational data storage beyond archive-bundle planning.
- Autonomous redaction or automatic exemption decisions.
- External connector runtime, approval queues, or Townlight Records exemption-engine integration.
- Staff SSO and role-based publication approvals. v0.1.2 protects persisted retrieval only; broader workflow auth comes later.
- Staff SSO and role-based publication approvals. v0.2.0 protects persisted retrieval only; broader workflow auth comes later.

Install and run locally

Townlight Data v0.1.2 is pinned to civiccore==0.4.0.
Townlight Data v0.2.0 is pinned to townlight-core==1.3.0.dev2.

python -m venv .venv
. .venv/Scripts/activate # Windows PowerShell: .venv\Scripts\Activate.ps1
python -m pip install -e ".[dev]"
python -m uvicorn civicdata.main:app --host 127.0.0.1 --port 8137
python -m uvicorn townlight_data.main:app --host 127.0.0.1 --port 8137

Open http://127.0.0.1:8137/civicdata for the browser sample and http://127.0.0.1:8137/docs for FastAPI docs.

Expand Down Expand Up @@ -63,3 +63,7 @@ Verification
Licensing

Code: AGPL-3.0-only, with the TownLight Public Institution Exception for qualifying deployments. See LICENSE and LICENSE-EXCEPTION.md. Documentation is CC BY 4.0 unless otherwise noted. Townlight Data is designed for local municipal operation and does not require outbound runtime calls in the default profile.

Windows staff workflow

In Townlight Data 0.2.0 candidate on Windows Suite full profile, existing Contracts grants let staff select signed agreements and preview only contract ID, title, vendor, start/expiration. An admin explicitly confirms the actual SHA-256 preview before an unattended queue sends to the configured resident Portal. Status states cover selection, hash confirmation, queueing, acknowledgement, correction, and withdrawal. No public link appears until the receiving portal acknowledges. Public outputs include CSV, JSON, and dictionary. Corrections proceed through a new review; withdrawal removes anonymous downloads when delivered. Legacy standalone workpaper APIs remain separate.
12 changes: 8 additions & 4 deletions USER-MANUAL.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ Townlight Data helps a city prepare datasets before they are published to an ope

Every dataset still needs staff approval before publication. Staff must confirm the source-system owner, redaction/exemption status, open-data license, retention schedule, and publication target.

### What v0.1.2 does not do
### What v0.2.0 does not do

Townlight Data does not publish directly to CKAN, does not host dashboards, does not store a data warehouse, does not make legal exemption decisions, and does not redact records automatically.

## IT and technical guide

### Runtime

Install with `python -m pip install -e ".[dev]"` and run with `python -m uvicorn civicdata.main:app --host 127.0.0.1 --port 8137`.
Install with `python -m pip install -e ".[dev]"` and run with `python -m uvicorn townlight_data.main:app --host 127.0.0.1 --port 8137`.

Set `CIVICDATA_PUBLICATION_DB_URL` to enable SQLAlchemy-backed CKAN package draft and publication-plan records. Set `CIVICDATA_AUTH_TOKEN_ROLES` to a JSON token-to-role map before exposing persisted retrieval. Leave the database variable unset for deterministic stateless operation.

Expand All @@ -48,12 +48,16 @@ flowchart LR

### Endpoints

The public endpoints are listed in `README.md`. All v0.1.2 endpoints are deterministic and local. They do not perform live connector calls or publish data to external services. Retrieval endpoints require both `CIVICDATA_PUBLICATION_DB_URL` and `CIVICDATA_AUTH_TOKEN_ROLES`.
The public endpoints are listed in `README.md`. All v0.2.0 endpoints are deterministic and local. They do not perform live connector calls or publish data to external services. Retrieval endpoints require both `CIVICDATA_PUBLICATION_DB_URL` and `CIVICDATA_AUTH_TOKEN_ROLES`.

### Dependency contract

Townlight Data depends on `civiccore==0.4.0`. Townlight Core must not import Townlight Data Bridge.
Townlight Data depends on `townlight-core==1.3.0.dev2`. Townlight Core must not import Townlight Data Bridge.

### Verification

Run `bash scripts/verify-release.sh` before release. The script checks docs, tests, Ruff, build artifacts, and package metadata.

## Windows staff workflow

In Townlight Data 0.2.0 candidate on Windows Suite full profile, existing Contracts grants let staff select signed agreements and preview only contract ID, title, vendor, start/expiration. An admin explicitly confirms the actual SHA-256 preview before an unattended queue sends to the configured resident Portal. Status states cover selection, hash confirmation, queueing, acknowledgement, correction, and withdrawal. No public link appears until the receiving portal acknowledges. Public outputs include CSV, JSON, and dictionary. Corrections proceed through a new review; withdrawal removes anonymous downloads when delivered. Legacy standalone workpaper APIs remain separate.
8 changes: 6 additions & 2 deletions USER-MANUAL.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ Townlight Data User Manual

For staff: Townlight Data prepares municipal datasets for open-data review. It normalizes fields, drafts data dictionaries, prepares CKAN package metadata, flags possible PII/exempt fields, creates archive/publication checklists, and optionally retrieves saved CKAN package/publication-plan workpapers.

Staff must approve every dataset before publication. v0.1.2 does not publish to CKAN, host dashboards, store a data warehouse, redact automatically, or make exemption decisions.
Staff must approve every dataset before publication. v0.2.0 does not publish to CKAN, host dashboards, store a data warehouse, redact automatically, or make exemption decisions.

For IT: install with python -m pip install -e ".[dev]" and run with python -m uvicorn civicdata.main:app --host 127.0.0.1 --port 8137. The package depends on civiccore==0.4.0 and runs locally. Set CIVICDATA_PUBLICATION_DB_URL to enable SQLAlchemy-backed CKAN package draft and publication-plan records. Set CIVICDATA_AUTH_TOKEN_ROLES to a JSON token-to-role map before exposing persisted retrieval. Leave the database variable unset for deterministic stateless operation.
For IT: install with python -m pip install -e ".[dev]" and run with python -m uvicorn townlight_data.main:app --host 127.0.0.1 --port 8137. The package depends on townlight-core==1.3.0.dev2 and runs locally. Set CIVICDATA_PUBLICATION_DB_URL to enable SQLAlchemy-backed CKAN package draft and publication-plan records. Set CIVICDATA_AUTH_TOKEN_ROLES to a JSON token-to-role map before exposing persisted retrieval. Leave the database variable unset for deterministic stateless operation.

Windows staff workflow

In Townlight Data 0.2.0 candidate on Windows Suite full profile, existing Contracts grants let staff select signed agreements and preview only contract ID, title, vendor, start/expiration. An admin explicitly confirms the actual SHA-256 preview before an unattended queue sends to the configured resident Portal. Status states cover selection, hash confirmation, queueing, acknowledgement, correction, and withdrawal. No public link appears until the receiving portal acknowledges. Public outputs include CSV, JSON, and dictionary. Corrections proceed through a new review; withdrawal removes anonymous downloads when delivered. Legacy standalone workpaper APIs remain separate.
3 changes: 0 additions & 3 deletions civicdata/__init__.py

This file was deleted.

6 changes: 3 additions & 3 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Townlight Data v0.1.2</title>
<title>Townlight Data v0.2.0</title>
<style>
:root{--ink:#17231d;--green:#1e6b4f;--mint:#e1f6eb;--gold:#bf8f35;--paper:#fffaf0}body{margin:0;font-family:"Aptos","Segoe UI",sans-serif;color:var(--ink);background:linear-gradient(135deg,#eef9f3,var(--paper))}header,main,footer{width:min(1080px,calc(100% - 32px));margin:auto}header{padding:54px 0 24px}.eyebrow{text-transform:uppercase;letter-spacing:.14em;color:var(--green);font-weight:900}h1{font:800 clamp(2.4rem,7vw,5.4rem)/.95 Georgia,serif;margin:.1em 0}.lede{font-size:1.2rem;line-height:1.6;max-width:850px}.grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:18px}.card{background:rgba(255,255,255,.92);border:1px solid #b9d8ca;border-radius:24px;padding:24px;box-shadow:0 18px 36px #263b3118}.badge{display:inline-block;background:var(--green);color:#fff;padding:.5rem .85rem;border-radius:999px;font-weight:900}code{background:var(--mint);padding:.1rem .35rem;border-radius:.35rem}a{color:var(--green);font-weight:800}:focus-visible{outline:4px solid var(--gold);outline-offset:3px}@media(max-width:720px){.grid{grid-template-columns:1fr}header{padding-top:34px}}
</style>
</head>
<body>
<header><p class="eyebrow">Townlight module</p><h1>Townlight Data</h1><p class="lede">Open-data preparation for municipalities: normalize fields, draft dictionaries, prepare CKAN metadata, persist optional publication workpapers, protect persisted retrieval with bearer roles, flag redaction review, and assemble retention-aware archive checklists.</p><p><span class="badge">v0.1.2 shipping</span></p></header>
<main><section class="grid" aria-label="Townlight Data documentation"><article class="card"><h2>For staff</h2><p>Use Townlight Data to prepare datasets before publication. Every dataset still needs human review, license confirmation, redaction or exemption clearance, and retention checks.</p></article><article class="card"><h2>For IT</h2><p>Install locally with <code>python -m pip install -e ".[dev]"</code>, run <code>python -m uvicorn civicdata.main:app</code>, set <code>CIVICDATA_PUBLICATION_DB_URL</code> for optional persistence, and set <code>CIVICDATA_AUTH_TOKEN_ROLES</code> before exposing persisted retrieval.</p></article><article class="card"><h2>Boundaries</h2><p>No live CKAN publication, BI dashboard, data warehouse, autonomous redaction, or connector runtime ships in v0.1.2.</p></article><article class="card"><h2>Repository</h2><p><a href="https://github.com/townlight/data">townlight/data</a></p></article><article class="card"><h2>Dependency</h2><p>Pinned to <code>civiccore==0.4.0</code>. Townlight Core remains dependency-only; it never imports Townlight Data Bridge.</p></article></section></main>
<header><p class="eyebrow">Townlight module</p><h1>Townlight Data</h1><p class="lede">Open-data preparation for municipalities: normalize fields, draft dictionaries, prepare CKAN metadata, persist optional publication workpapers, protect persisted retrieval with bearer roles, flag redaction review, and assemble retention-aware archive checklists.</p><p><span class="badge">0.2.0 Windows candidate</span></p></header>
<main><section class="grid" aria-label="Townlight Data documentation"><article class="card"><h2>For staff</h2><p>Use Townlight Data to prepare datasets before publication. Every dataset still needs human review, license confirmation, redaction or exemption clearance, and retention checks.</p></article><article class="card"><h2>For IT</h2><p>Install locally with <code>python -m pip install -e ".[dev]"</code>, run <code>python -m uvicorn townlight_data.main:app</code>, set <code>CIVICDATA_PUBLICATION_DB_URL</code> for optional persistence, and set <code>CIVICDATA_AUTH_TOKEN_ROLES</code> before exposing persisted retrieval.</p></article><article class="card"><h2>Boundaries</h2><p>No live CKAN publication, BI dashboard, data warehouse, autonomous redaction, or connector runtime ships in v0.2.0.</p></article><article class="card"><h2>Repository</h2><p><a href="https://github.com/townlight/data">townlight/data</a></p></article><article class="card"><h2>Dependency</h2><p>Pinned to <code>townlight-core==1.3.0.dev2</code>. Townlight Core remains dependency-only; it never imports Townlight Data Bridge.</p></article></section></main>
<footer><p>AGPL-3.0 code. CC BY 4.0 docs.</p></footer>
</body>
</html>
10 changes: 5 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ requires = ["hatchling>=1.27.0"]
build-backend = "hatchling.build"

[project]
name = "civicdata"
version = "0.1.2"
name = "townlight-data"
version = "0.2.0"
description = "Townlight Data foundation for open-data normalization, CKAN package drafts, archive bundles, and redaction review."
readme = "README.md"
requires-python = ">=3.11"
Expand All @@ -13,7 +13,7 @@ authors = [
{ name = "CivicSuite contributors" }
]
dependencies = [
"civiccore==0.4.0",
"townlight-core==1.3.0.dev2",
"fastapi>=0.115.0,<1.0.0",
"sqlalchemy>=2.0.0,<3.0.0",
"uvicorn[standard]>=0.30.0,<1.0.0",
Expand All @@ -32,11 +32,11 @@ dev = [
testpaths = ["tests"]

[tool.hatch.build.targets.wheel]
packages = ["civicdata"]
packages = ["townlight_data"]

[tool.hatch.build.targets.sdist]
include = [
"civicdata",
"townlight_data",
"scripts",
"tests",
"README.md",
Expand Down
2 changes: 1 addition & 1 deletion scripts/check-civiccore-placeholder-imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"search",
"verification",
)
SOURCE_ROOT = Path("civicdata")
SOURCE_ROOT = Path("townlight_data")
pattern = re.compile(r"^\s*(?:from|import)\s+civiccore\.(" + "|".join(PLACEHOLDERS) + r")\b")
violations: list[str] = []
for path in SOURCE_ROOT.rglob("*.py"):
Expand Down
4 changes: 2 additions & 2 deletions scripts/verify-docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ for file in "${current_files[@]}"; do
done
done

if ! grep -Fq "civiccore==0.4.0" README.md; then
echo "VERIFY-DOCS: FAILED README.md must mention civiccore==0.4.0"
if ! grep -Fq "townlight-core==1.3.0.dev2" README.md; then
echo "VERIFY-DOCS: FAILED README.md must mention townlight-core==1.3.0.dev2"
exit 1
fi
if ! grep -Fq "No live CKAN publication" docs/index.html; then
Expand Down
Loading