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
12 changes: 12 additions & 0 deletions .github/workflows/delivery.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,18 @@ jobs:
distribution: temurin
java-version: '21'
cache: maven
- uses: actions/setup-node@249970729cb0ef3589644e2896645e5dc5ba9c38 # v6.5.0
with:
node-version: '24'
package-manager-cache: false
- name: Install browser test tooling
run: |
npm install --prefix "$RUNNER_TEMP/workboard-browser-tests" --no-save --package-lock=false playwright@1.62.1
"$RUNNER_TEMP/workboard-browser-tests/node_modules/.bin/playwright" install --with-deps chromium
- name: Run frontend browser tests
env:
NODE_PATH: ${{ runner.temp }}/workboard-browser-tests/node_modules
run: node --test src/test/frontend/projects.test.cjs
- name: Check deployment tooling
run: python3 -m unittest discover -s deploy/tests -v
- name: Build and run API tests
Expand Down
5 changes: 4 additions & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
# Learning project

This project is for the owner's education. The owner builds the application; agents act as coaches and reviewers.
This project is for the owner's backend education. The owner builds the backend; agents act as backend coaches and reviewers. The owner delegates frontend implementation to AI.

## Coaching first

- Frontend work is an ongoing exception to coaching mode: agents may implement and verify requested frontend changes directly, including HTML, CSS, JavaScript, and frontend tests. Keep documentation aligned with those changes. This does not authorize backend, dependency, configuration, or deployment changes.
- Backend work remains coaching-first under the rules below unless the owner explicitly authorizes a specific implementation step.

- Default to explaining what to do, why it matters, and how the owner can verify their work. Give manageable next steps rather than completing the implementation.
- Do not write or modify application code, tests, configuration, or dependencies, or run commands that perform implementation work, unless the owner explicitly asks you to do that specific work as an exception to coaching mode.
- Requests for help building or fixing something are requests for guidance by default, not permission to implement it. An exception applies only to the requested work; it does not disable coaching mode for future turns.
Expand Down
53 changes: 46 additions & 7 deletions README.md

Large diffs are not rendered by default.

8 changes: 5 additions & 3 deletions deploy/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ After configuration, commit the delivery files on a feature branch, push the bra

## What a release does

1. Builds on Java 21, runs the H2 API suite and deployment tests, then exercises the packaged application against PostgreSQL 16, including a restart against the migrated database. Smoke tickets are created only in the disposable CI database and are deleted after each check.
1. Builds on Java 21, runs the H2 API suite and deployment tests, and runs the frontend browser suite with Node.js 24 and pinned Playwright tooling installed outside the application. It then exercises the packaged application against PostgreSQL 16, including a restart against the migrated database. The disposable API exercise creates an empty project, assigns a ticket, checks deletion conflicts, renames the project, preserves and changes the assignment through ticket updates, and cleans up the ticket before the project, including on failure.
2. Uploads the full Quarkus fast-jar archive over restricted SSH. The server verifies its SHA-256 checksum, rejects traversal paths, links, special files, duplicate paths and oversized archives, and stages root-owned files outside the active release.
3. Takes a database backup through the existing `workboard-backup.service`. Backup failure leaves the active release untouched.
4. Saves release metadata, atomically switches `/opt/workboard/current`, and restarts `workboard.service`. A short interruption is expected.
5. Waits for local application and database readiness, then verifies authenticated HTTPS access and anonymous rejection through nginx. GitHub repeats external HTTPS, readiness, asset, API-list and anonymous API-method checks. Production smoke checks do not create or change tickets.
5. Waits for local application and database readiness, then verifies authenticated HTTPS access and anonymous rejection through nginx. GitHub repeats external HTTPS, readiness, asset and API-list checks, including `/picker.js` and `/api/projects`, and anonymous ticket/project method checks. Production smoke checks do not create or change tickets or projects. The privileged server helper retains its existing checks; these expanded checks run from the repository workflow and require no helper reinstallation.
6. Reports the result in GitHub Actions and the environment deployment history. Release metadata is saved in `/opt/workboard/current/.release.json`.

The normal workflow cannot install new privileged server helpers, alter nginx configuration, or update systemd units. Those changes require administrative installation. Database credentials remain in `/etc/workboard/workboard.env`; they are not sent to GitHub. The SSH host key is pinned from the already trusted administrative connection, not accepted from an unauthenticated key scan during deployment. Official GitHub Actions are pinned by commit; Dependabot proposes weekly action updates.
Expand Down Expand Up @@ -62,10 +62,12 @@ python3 -m unittest discover -s deploy/tests -v
actionlint .github/workflows/delivery.yml
```

CI pins Playwright 1.62.1 and installs it under the runner’s temporary directory, then installs Chromium and its Linux dependencies. No frontend runtime dependency is added to the application. Locally, run `node --test src/test/frontend/projects.test.cjs` with Playwright on `NODE_PATH` and, if needed, `PLAYWRIGHT_CHROMIUM_EXECUTABLE_PATH` pointing to an installed Chromium. The browser tests use mocked APIs; the packaged PostgreSQL exercise checks the real HTTP API separately.

For an already started disposable production-profile application backed by PostgreSQL:

```sh
python3 deploy/smoke-test.py http://127.0.0.1:18084 --exercise-api
```

`--exercise-api` writes a temporary ticket and is intended for a disposable test database. Public production verification uses `--check-auth`, with credentials supplied through `SMOKE_USERNAME` and `SMOKE_PASSWORD`, and performs read-only authenticated checks.
`--exercise-api` writes a temporary project and ticket and is intended for a disposable test database. It cleans up the ticket first, then attempts project cleanup even if ticket cleanup fails. Cleanup failures fail the check. Public production verification uses `--check-auth`, with credentials supplied through `SMOKE_USERNAME` and `SMOKE_PASSWORD`, and performs read-only authenticated checks.
96 changes: 74 additions & 22 deletions deploy/smoke-test.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,25 +44,73 @@ def wait_ready(base):


def exercise_api(base):
title = f"CI smoke test {uuid.uuid4()}"
status, body = request(base, "/api/tickets", "POST", {"title": title, "status": "TODO"})
require(status == 201, f"Create returned {status}")
ticket = json.loads(body)
path = f"/api/tickets/{uuid.UUID(ticket['id'])}"
name = f"CI smoke project {uuid.uuid4()}"
title = f"CI smoke ticket {uuid.uuid4()}"
status, body = request(base, "/api/projects", "POST", {"name": name})
require(status == 201, f"Project create returned {status}")
project_id = str(uuid.UUID(json.loads(body)["id"]))
project_path = f"/api/projects/{project_id}"
ticket_path = None
try:
update = {"title": title, "status": "DOING", "blocked": True, "blockedNote": "CI check"}
status, body = request(base, path, "PUT", update)
require(status == 200 and json.loads(body)["blocked"], "Blocking failed")
update.update(status="DONE", blocked=False, blockedNote=None)
status, body = request(base, path, "PUT", update)
require(status == 200 and json.loads(body)["completedAt"] is not None, "Completion failed")
status, body = request(base, path)
require(status == 200 and json.loads(body)["title"] == title, "Stored ticket read failed")
status, body = request(base, "/api/projects")
require(status == 200 and any(project["id"] == project_id and project["name"] == name
for project in json.loads(body)), "Empty project is missing from catalog")
status, body = request(base, "/api/tickets", "POST",
{"title": title, "status": "TODO", "projectId": project_id})
require(status == 201, f"Ticket create returned {status}")
ticket_id = str(uuid.UUID(json.loads(body)["id"]))
ticket_path = f"/api/tickets/{ticket_id}"
status, body = request(base, ticket_path)
ticket = json.loads(body)
require(status == 200 and ticket["projectId"] == project_id and ticket["projectName"] == name,
"Ticket creation did not persist its project assignment")
status, body = request(base, project_path, "DELETE")
require(status == 409 and json.loads(body).get("message"), "Assigned project deletion must return a clear 409")
renamed = name + " renamed"
status, body = request(base, project_path, "PUT", {"name": renamed})
require(status == 200 and json.loads(body)["name"] == renamed, "Project rename failed")
status, body = request(base, ticket_path)
require(status == 200 and json.loads(body)["projectName"] == renamed, "Ticket does not show renamed project")
update = {"title": title, "status": "DOING", "blocked": True,
"blockedNote": "CI check", "projectId": project_id}
status, body = request(base, ticket_path, "PUT", update)
require(status == 200 and json.loads(body)["blocked"]
and json.loads(body)["projectId"] == project_id, "Blocking or assignment preservation failed")
update.update(status="DONE", blocked=False, blockedNote=None, projectId=None)
status, body = request(base, ticket_path, "PUT", update)
ticket = json.loads(body)
require(status == 200 and ticket["completedAt"] is not None
and ticket["projectId"] is None and ticket["projectName"] is None, "Completion or unassignment failed")
update.update(projectId=project_id)
status, body = request(base, ticket_path, "PUT", update)
require(status == 200 and json.loads(body)["projectId"] == project_id, "Ticket reassignment failed")
status, body = request(base, ticket_path)
require(status == 200 and json.loads(body)["title"] == title
and json.loads(body)["projectName"] == renamed, "Stored assigned ticket read failed")
finally:
status, _ = request(base, path, "DELETE")
require(status == 204, "Smoke ticket cleanup failed")
status, _ = request(base, path)
cleanup_errors = []
if ticket_path:
try:
status, _ = request(base, ticket_path, "DELETE")
if status != 204:
cleanup_errors.append(f"Smoke ticket cleanup returned {status}")
except OSError as error:
cleanup_errors.append(f"Smoke ticket cleanup failed: {error}")
try:
status, _ = request(base, project_path, "DELETE")
if status != 204:
cleanup_errors.append(f"Smoke project cleanup returned {status}")
except OSError as error:
cleanup_errors.append(f"Smoke project cleanup failed: {error}")
require(not cleanup_errors, "; ".join(cleanup_errors))
status, _ = request(base, ticket_path)
require(status == 404, "Deleted ticket remains accessible")
status, body = request(base, project_path, "DELETE")
require(status == 404 and json.loads(body).get("message") == "Project not found.",
"Deleted project must return a clear 404")
status, body = request(base, "/api/projects")
require(status == 200 and all(project["id"] != project_id for project in json.loads(body)),
"Deleted smoke project remains in catalog")


def main():
Expand All @@ -75,17 +123,21 @@ def main():
if args.check_auth:
require(bool(os.environ.get("SMOKE_USERNAME") and os.environ.get("SMOKE_PASSWORD")),
"Public checks require smoke test credentials")
for path, method in [("/", "GET"), ("/app.js", "GET"), ("/api/tickets", "GET"),
("/api/tickets", "POST"), (f"/api/tickets/{uuid.uuid4()}", "PUT"),
(f"/api/tickets/{uuid.uuid4()}", "DELETE"), ("/q/health/ready", "GET")]:
protected = [("/", "GET"), ("/app.js", "GET"), ("/picker.js", "GET"),
("/styles.css", "GET"), ("/q/health/ready", "GET")]
for resource in ("tickets", "projects"):
protected.extend([(f"/api/{resource}", "GET"), (f"/api/{resource}", "POST"),
(f"/api/{resource}/{uuid.uuid4()}", "PUT"),
(f"/api/{resource}/{uuid.uuid4()}", "DELETE")])
for path, method in protected:
status, _ = request(base, path, method, authenticated=False)
require(status == 401, f"Anonymous {method} {path} returned {status}, expected 401")
wait_ready(base)
for path in ["/", "/app.js", "/styles.css", "/api/tickets"]:
for path in ["/", "/app.js", "/picker.js", "/styles.css", "/api/tickets", "/api/projects"]:
status, body = request(base, path)
require(status == 200, f"GET {path} returned {status}")
if path == "/api/tickets":
require(isinstance(json.loads(body), list), "Ticket list response is invalid")
if path in ("/api/tickets", "/api/projects"):
require(isinstance(json.loads(body), list), f"{path} list response is invalid")
if args.exercise_api:
exercise_api(base)
print("Smoke checks passed")
Expand Down
112 changes: 112 additions & 0 deletions deploy/tests/test_smoke.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
import importlib.util
import json
import os
from pathlib import Path
import sys
import unittest
from unittest.mock import call, patch


source = Path(__file__).resolve().parents[1] / "smoke-test.py"
spec = importlib.util.spec_from_file_location("workboard_smoke", source)
smoke = importlib.util.module_from_spec(spec)
spec.loader.exec_module(smoke)

PROJECT_ID = "00000000-0000-0000-0000-000000000001"
TICKET_ID = "00000000-0000-0000-0000-000000000002"
BASE = "http://127.0.0.1:18084"


def project_response(name):
return json.dumps({"id": PROJECT_ID, "name": name}).encode()


class SmokeTests(unittest.TestCase):
def test_failed_ticket_creation_still_cleans_up_project(self):
def request(base, path, method="GET", body=None):
if method == "POST" and path == "/api/projects":
self.name = body["name"]
return 201, project_response(self.name)
if method == "GET" and path == "/api/projects":
return 200, b"[" + project_response(self.name) + b"]"
if method == "POST" and path == "/api/tickets":
return 500, b""
return 204, b""

with patch.object(smoke, "request", side_effect=request) as requests:
with self.assertRaisesRegex(RuntimeError, "Ticket create returned 500"):
smoke.exercise_api(BASE)
self.assertEqual(requests.call_args, call(BASE, f"/api/projects/{PROJECT_ID}", "DELETE"))

def test_network_failure_after_ticket_creation_cleans_up_both_resources(self):
def request(base, path, method="GET", body=None):
if method == "POST" and path == "/api/projects":
self.name = body["name"]
return 201, project_response(self.name)
if method == "GET" and path == "/api/projects":
return 200, b"[" + project_response(self.name) + b"]"
if method == "POST" and path == "/api/tickets":
return 201, json.dumps({"id": TICKET_ID}).encode()
if method == "GET":
raise OSError("Connection lost")
return 204, b""

with patch.object(smoke, "request", side_effect=request) as requests:
with self.assertRaisesRegex(OSError, "Connection lost"):
smoke.exercise_api(BASE)
self.assertEqual(requests.call_args_list[-2:], [
call(BASE, f"/api/tickets/{TICKET_ID}", "DELETE"),
call(BASE, f"/api/projects/{PROJECT_ID}", "DELETE"),
])

def test_failed_ticket_cleanup_does_not_skip_project_cleanup(self):
def request(base, path, method="GET", body=None):
if method == "POST" and path == "/api/projects":
self.name = body["name"]
return 201, project_response(self.name)
if method == "GET" and path == "/api/projects":
return 200, b"[" + project_response(self.name) + b"]"
if method == "POST" and path == "/api/tickets":
return 201, json.dumps({"id": TICKET_ID}).encode()
if method == "DELETE" and path == f"/api/tickets/{TICKET_ID}":
return 500, b""
if method == "DELETE":
return 409, b""
raise OSError("Connection lost")

with patch.object(smoke, "request", side_effect=request) as requests:
with self.assertRaisesRegex(RuntimeError, "Smoke ticket cleanup returned 500; Smoke project cleanup returned 409"):
smoke.exercise_api(BASE)
self.assertEqual(requests.call_args, call(BASE, f"/api/projects/{PROJECT_ID}", "DELETE"))

def test_public_verification_checks_projects_and_picker_without_authenticated_writes(self):
def request(base, path, method="GET", body=None, authenticated=True):
if not authenticated:
return 401, b""
if path == "/q/health/ready":
return 200, b'{"status":"UP"}'
if path.startswith("/api/"):
return 200, b"[]"
return 200, b"asset"

with patch.object(smoke, "request", side_effect=request) as requests, \
patch.object(smoke, "exercise_api") as exercise, \
patch.object(sys, "argv", ["smoke-test.py", BASE, "--check-auth"]), \
patch.dict(os.environ, {"SMOKE_USERNAME": "test", "SMOKE_PASSWORD": "test"}):
smoke.main()
exercise.assert_not_called()
requests.assert_any_call(BASE, "/picker.js")
requests.assert_any_call(BASE, "/picker.js", "GET", authenticated=False)
requests.assert_any_call(BASE, "/api/projects")
anonymous_project_methods = set()
for entry in requests.call_args_list:
method = entry.args[2] if len(entry.args) > 2 else "GET"
if entry.kwargs.get("authenticated", True):
self.assertEqual(method, "GET")
elif entry.args[1].startswith("/api/projects"):
anonymous_project_methods.add(method)
self.assertEqual(anonymous_project_methods, {"GET", "POST", "PUT", "DELETE"})


if __name__ == "__main__":
unittest.main()
11 changes: 0 additions & 11 deletions src/main/java/be/alexanderclaes/workboard/CreateTicketRequest.java

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package be.alexanderclaes.workboard;

import be.alexanderclaes.workboard.ticket.BlockedNote;
import be.alexanderclaes.workboard.ticket.TicketTitle;
import com.fasterxml.jackson.databind.exc.ValueInstantiationException;
import jakarta.ws.rs.WebApplicationException;
import jakarta.ws.rs.core.MediaType;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package be.alexanderclaes.workboard.project;

import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Size;

public record CreateProjectRequest(
@NotBlank(message = "Project name cannot be blank.")
@Size(max = 200, message = "Project name cannot exceed 200 characters.")
String name
) {
}
Loading