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
11 changes: 7 additions & 4 deletions .github/workflows/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,17 @@ jobs:
verify:
needs: changes
if: needs.changes.outputs.code == 'true'
runs-on: ubuntu-latest
runs-on: windows-latest
defaults:
run:
shell: bash
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.3.0/civiccore-0.3.0-py3-none-any.whl
python-version: "3.13"
- name: Install Townlight Core pinned revision
run: python -m pip install "git+https://github.com/townlight/core.git@2f6ba9be4a95e3772dc47a3682ac780c5283b626"
- name: Install package
run: python -m pip install -e ".[dev]"
- name: Run release gate
Expand Down
38 changes: 21 additions & 17 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,31 @@

# Townlight Communications Agent Board

## Operating Contract
## Current contract

- Upstream suite spec: `townlight/townlight/docs/CivicSuiteUnifiedSpec.md`, especially the Townlight Communications catalog entry and suite-wide non-negotiables.
- Townlight Communications supports source-backed public explainers, meeting summaries, ordinance summaries, newsletters, FAQs, and audience-specific draft variants.
- AGPL-3.0-only for code (with the TownLight Public Institution Exception for qualifying deployments), CC BY 4.0 for documentation.
- Every change must keep docs, tests, browser QA evidence, and version surfaces in sync.
- Townlight Communications `0.2.0` is a development candidate. Scope is defined by `COMMUNICATIONS-DESIGN.md`; this file replaces superseded `0.1.1` prototype mandates.
- Windows only. Hold software tag and software publication until explicitly authorized.
- Canonical verification is the Windows suite runtime plus the named affected checks. Do not add extra gates.
- The standalone `main.py` is a prototype, not the production workflow server.

## Hard Boundaries
## Publication authority

- Townlight Communications never publishes autonomously, creates campaign or advocacy content, provides legal advice, certifies translations, posts to social media, or updates a communications system of record.
- Townlight Communications v0.1.1 must not call live LLMs or live publishing/social-media/communications systems.
- Every generated artifact is a draft requiring staff review, citation verification, approval, and publication through official city channels.
- Townlight Communications depends on Townlight Core; Townlight Core must never depend on Townlight Communications.
- Townlight Communications may reference Townlight Meetings, Townlight Code, and Townlight Access concepts only through released APIs or deterministic sample data in v0.1.1.
- Unattended publication is authorized ONLY for the exact staff-approved revision, through the host, to website and email.
- Do not add social, advertising/campaign, legal-advice, or translation-certification capabilities.
- No silent fallback: missing, private, stale, mismatched, or unapproved content must remain blocked and visibly reported.
- Reuse existing administrator, city-staff, and clerk roles and native authentication.

## Verification
## Source and history boundaries

Run before push or release:
- Preserve the private/public source boundary. Source eligibility is verified at runtime against the actual module; user-supplied eligibility flags cannot authorize publication.
- Revisions are immutable with SHA256 provenance. Editing clears approval and correction preserves prior revisions.
- Records archive must contain the exact published revision, source references, attachments, and receipts, and return a real identifier before any correction.
- Use explicit migrations and preserve existing affected headless checks.
- Preserve ordered correction and withdrawal sequences; stale content must not be resurrected.

```bash
bash scripts/verify-release.sh
```
## Architecture and workflow

Browser QA evidence is required for `docs/index.html` and `/civiccomms` whenever visible UI changes.
- Preserve dependency direction: Townlight Core never depends on Townlight Communications.
- DeepSeek1017 performs low-risk implementation; Codex coordinates integration and review.
- Keep documentation, tests, and version surfaces synchronized with approved scope.
- Code is AGPL-3.0-only with the TownLight Public Institution Exception; documentation is CC BY 4.0.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,17 @@ All notable changes to CivicComms will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).

## [Unreleased]

### 0.2.0 candidate

- Added editorial immutable revision approval and correction/withdrawal without reviving stale revisions.
- Added approved source snapshot and public attachment capture.
- Added scheduled website and email publication through the host service.
- Added subscriber confirmation, preference management, and unsubscribe support.
- Added Records archive storage for published bytes and receipts behind the separate Records permission.
- Not included in the released Windows 1.9.3.2 suite; installed candidate acceptance is still pending.

## [0.1.1] - 2026-04-28

### Added
Expand Down
19 changes: 19 additions & 0 deletions COMMUNICATIONS-DESIGN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Communications implementation design — approved scope

Owner: Scott. Windows only. Build after311 source integration; installed acceptance in one combined signed candidate. No software tag/publication approval yet.

## Interface and roles
Reuse staff shell/navigation, native session and existing administrator/city-staff/clerk grants. New Communications workspace: saved draft list/filter, source picker, editor, exact-revision preview, Access review, review/approval, schedule, delivery status, correction/withdrawal and Records archive. Resident portal: approved article list/detail, subscriptions/preferences/unsubscribe. No resident account exposes staff drafts or private source data. Keyboard navigation, labelled controls, errors beside fields, visible queued/delivered/failed states, destructive actions confirmed.

## Durable domain contract
Use townlight-comms0.2.0 / townlight_comms, current townlight-core1.3.0.dev2. SQLAlchemy schema townlight_comms. Explicit migration; SQLite tests use schema translation, production bootstrap false. Immutable revisions with SHA256 canonical public content and source snapshots. Articles retain current revision/state, approval hash/actor/time, schedule and publication history. Edit clears approval; correction preserves old revision. Optimistic revision and database transactions prevent two-PC lost updates. HTML is not trusted: store/render plain text and escaped paragraphs. Attachments have actual bytes/hash/limits and public-review status.

Source references carry kind,id,revision,title,public URL,digest and public eligibility verified by runtime against actual module. User-supplied eligibility flags cannot authorize publication. Supported kinds meetings/code/notice/311 aggregate/parks; parks connector completed in Parks phase. Missing/private/stale source blocks approval; manual authored source-backed content does not need AI. Access report and translations retain exact source/output and revision provenance; staff approval remains explicit.

Publication task atomically snapshots exact approved revision, channels website/email and due time. Host claims due tasks with leases; native app need not stay open. Website manifest kind article travels through existing PublisherQueue/portal authenticated receiver, actual receipt URL/hash captured. Correction/withdrawal use ordered sequence, cannot resurrect stale content. Email uses existing311 SMTPTransport with separate Comms durable outbox: deterministic message ID, retries only known unsent, uncertain send is visible and not automatically retried. Subscriptions are opt-in, private tokens hashed, preferences/unsubscribe exclude future mail. No social/ad campaign channels.

## Boundaries
Runtime /desktop/v1/communications under native staff auth; browser commands use fixed native allowlist and shared-host gateway, no arbitrary URL. Portal incoming resident operations use encrypted authenticated inbox/pump patterns; desktop service stays private. Records archive contains actual published revisions/source refs/attachments/receipts and returns real identifier; Data only explicit approved aggregate publication metrics if required by existing plan, no subscriber list. Reuse existing city configuration and encrypted SMTP settings, no new auth provider.

## Meaningful acceptance
Domain tests prove edit invalidation, stale review, private source rejection, atomic concurrent edits, schedule leases, exact bytes, correction/withdrawal, subscriber privacy and safe retry. HTTP tests trace real receiving contracts and portal receiver, UI tests actual visible controls with explicit native doubles. Final installed Windows candidate proves staff two-PC sourced author/edit/approve/schedule, app closed host publishes to portal and controlled SMTP, correction/withdrawal/history/Records retrieval, restart survival. Source tests are not installed acceptance.
70 changes: 14 additions & 56 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,65 +1,23 @@
> **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 Communications 0.2.0 development candidate

<a id="civiccomms"></a>
Townlight Communications is the development candidate for the Townlight Windows staff Communications screen. It is not included in the released Windows 1.9.3.2 suite. Distribution name: `townlight-comms`; import name: `townlight_comms`; current dependency: Townlight Core 1.3.0.dev2 (`townlight-core 1.3.0.dev2`).

# Townlight Communications
The canonical application is the Communications workspace in the Townlight Windows staff shell, using existing administrator, city-staff and clerk roles, plus a separate Records permission for archive access. The repository's standalone `main.py` remains a prototype for draft helpers. It is not a secured workflow server, and its commands are not production deployment instructions.

Townlight Communications is the Townlight module for source-backed public explainers, meeting summaries, ordinance summaries, newsletters, FAQs, and audience-specific draft variants.
## Workflow

Current state: **v0.1.1 public communications foundation plus draft persistence release**. This repo ships a FastAPI package, health/root endpoints, documentation gates, deterministic source-readiness review, meeting summary draft outlines, optional database-backed source review and meeting summary draft records, ordinance explainer drafts, newsletter scaffolds, FAQ prompts, audience-variant drafts, and accessible public sample UI at `/civiccomms`. It does **not** ship autonomous publication, campaign or advocacy content, legal advice, certified translation, live LLM calls, social media posting, or communications system-of-record integrations.
- Draft and save content from selected Meetings, Code, Notice or 311 sources. The Parks adapter remains pending until the Parks phase.
- Run an Access check, review and approve one exact revision, then schedule website and email publication.
- Archive the published revision to Records BEFORE editing, correcting, or withdrawing it; Records access requires the separate Records permission.
- Correct or withdraw published content without reviving stale revisions.
- Capture approved source snapshots and public attachments. Private source content cannot be published.

<a id="what-civiccomms-does"></a>
Publication is transactional: approved revision snapshots, website and email tasks, and status are durable in PostgreSQL. A host service claims due work with leases, so the native app need not stay open. The website path uses the existing authenticated portal receiver.

## What Townlight Communications Does
Website publication uses the host-configured portal credential and origin. Normal operation uses an unattended host service, not an operator's open window. Email uses city settings shared with 311 SMTP. Subscribers must confirm email and can manage preferences or unsubscribe. Queued means pending, not SMTP accepted. Only sent means SMTP accepted the message, not human receipt; failed and uncertain sends are shown separately, and uncertain sends are never retried automatically.

- Check that draft work starts from named source material and citations.
- Create deterministic meeting summary draft outlines.
- Persist source review and meeting summary draft records when `CIVICCOMMS_DRAFT_DB_URL` is configured.
- Create plain-language ordinance explainer draft scaffolds.
- Build newsletter and FAQ draft structures from source items.
- Produce audience-specific variants without changing source facts.
- Demonstrate a public communications-support UI at `/civiccomms`.
The Records archive stores actual published bytes and receipts and returns a real identifier. It requires the separate Records role permission.

<a id="what-civiccomms-does-not-do"></a>
Status: source-level checks passed for this development candidate, but installed Windows candidate acceptance is still pending. Do not describe this module as completed or released. The existing download at https://github.com/townlight/townlight/releases/latest explicitly does not include Communications.

## What Townlight Communications Does Not Do

- It does not publish or post autonomously.
- It does not produce campaign, advocacy, or partisan content.
- It does not provide legal advice.
- It does not certify translations or accessibility compliance.
- It does not call live LLMs in v0.1.1.
- It does not replace a communications system of record.

## API Surface

- `GET /` returns the shipped/planned boundary.
- `GET /health` returns package and Townlight Core versions.
- `GET /civiccomms` returns the accessible public sample UI.
- `POST /api/v1/civiccomms/source-review` returns source-readiness checks.
- `GET /api/v1/civiccomms/source-review/{review_id}` retrieves a persisted source review when `CIVICCOMMS_DRAFT_DB_URL` is configured.
- `POST /api/v1/civiccomms/meeting-summary` returns a meeting summary draft outline and a `summary_id` when persistence is configured.
- `GET /api/v1/civiccomms/meeting-summary/{summary_id}` retrieves a persisted meeting summary when `CIVICCOMMS_DRAFT_DB_URL` is configured.
- `POST /api/v1/civiccomms/ordinance-summary` returns a plain-language explainer draft.
- `POST /api/v1/civiccomms/newsletter` returns a newsletter draft outline.
- `POST /api/v1/civiccomms/faq` returns source-backed FAQ prompts.
- `POST /api/v1/civiccomms/audience-variant` returns an audience-specific draft variant.

## Optional Persistence

Set `CIVICCOMMS_DRAFT_DB_URL` to enable local SQLAlchemy-backed source review and meeting summary records. Without that variable, Townlight Communications remains deterministic and stateless. Retrieval endpoints return actionable `503` responses that name the required configuration.

## Local Development

Townlight Communications v0.1.1 is pinned to `civiccore==0.3.0`.

```bash
python -m pip install -e ".[dev]"
python -m pytest -q
bash scripts/verify-release.sh
```

## License

Code: AGPL-3.0-only, with the TownLight Public Institution Exception for qualifying deployments. See [LICENSE](LICENSE) and [LICENSE-EXCEPTION.md](LICENSE-EXCEPTION.md).
Documentation is CC BY 4.0.
License: code AGPL-3.0-only with the TownLight Public Institution Exception; documentation CC BY 4.0.
Loading