diff --git a/addon-edge/CHANGELOG.md b/addon-edge/CHANGELOG.md index 2d7b4a2d..84be7a05 100644 --- a/addon-edge/CHANGELOG.md +++ b/addon-edge/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +## 0.0.0-edge.12 + +- Show assigned and unclaimed task summaries on Overview with exact authorized totals. +- Open a selected task through the existing protected Tasks detail in English and Spanish. + ## 0.0.0-edge.11 - Use singular English and Spanish stock units when the displayed quantity is exactly one. diff --git a/addon-edge/DOCS.md b/addon-edge/DOCS.md index f1d2e4dd..3eaa81d1 100644 --- a/addon-edge/DOCS.md +++ b/addon-edge/DOCS.md @@ -1,9 +1,9 @@ # Installation and operation -Edge 0.0.0-edge.11 packages the immutable runtime declared in -[artifact.json](artifact.json). It upgrades supported owned databases to -schema 30 and exposes storage locations and balanced stock transfers in -Inventory. Retain a compatible image and data backup before upgrading. +Edge 0.0.0-edge.12 packages the immutable runtime declared in +[artifact.json](artifact.json). Overview shows the current member's assigned +work and unclaimed household tasks. This preview uses SQLite schema 30. +Retain a compatible image and data backup before upgrading. A separate Supervisor repository source creates an independent app and data directory. Check the source, installed version and app slug before using a preview. diff --git a/addon-edge/Dockerfile b/addon-edge/Dockerfile index 0e7036c8..8eccd3e8 100644 --- a/addon-edge/Dockerfile +++ b/addon-edge/Dockerfile @@ -1,8 +1,8 @@ # The Supervisor builds this folder. Fetch only the reviewed immutable runtime and UI. FROM ghcr.io/astral-sh/uv:0.11.29@sha256:eb2843a1e56fd9e30c7276ce1a52cba86e64c7b385f5e3279a0e08e02dd058fc AS uv FROM python:3.14.6-slim-trixie@sha256:7bec7ddcddeff7975d6ba9b4be7dd6f6b2f55e7491539145e2978f7f97ce9144 AS source -ARG DOMUS_SOURCE_COMMIT=7e869ff0d1755def7d06046ba5ea48150a26ccfb -ARG DOMUS_SOURCE_SHA256=a65ec787de95548bbce7e70f834e9101055bba335301e22fb18d17c424b79200 +ARG DOMUS_SOURCE_COMMIT=3a803ddce3092abcd9da48c8533c65d24e2e0e37 +ARG DOMUS_SOURCE_SHA256=6eaaf75c60a7582e21da627dc17f9cb9dcad007e0ab90c433d61d311cbf8363b ADD https://codeload.github.com/vypdev/domus/tar.gz/${DOMUS_SOURCE_COMMIT} /tmp/source.tar.gz RUN printf '%s /tmp/source.tar.gz\n' "$DOMUS_SOURCE_SHA256" | sha256sum --check - \ && mkdir /app \ @@ -24,9 +24,9 @@ RUN uv sync --frozen --no-dev --package domus-server --no-editable RUN .venv/bin/python -c "from pathlib import Path; import domus; from domus.entrypoints.ui_bundle import load_bundle; assert load_bundle(Path(domus.__file__).parent / 'ui') is not None" FROM python:3.14.6-slim-trixie@sha256:7bec7ddcddeff7975d6ba9b4be7dd6f6b2f55e7491539145e2978f7f97ce9144 -ARG BUILD_VERSION=0.0.0-edge.11 +ARG BUILD_VERSION=0.0.0-edge.12 ARG BUILD_ARCH -ARG DOMUS_SOURCE_COMMIT=7e869ff0d1755def7d06046ba5ea48150a26ccfb +ARG DOMUS_SOURCE_COMMIT=3a803ddce3092abcd9da48c8533c65d24e2e0e37 LABEL io.hass.type="app" \ io.hass.version="${BUILD_VERSION}" \ io.hass.arch="${BUILD_ARCH}" \ diff --git a/addon-edge/README.md b/addon-edge/README.md index eb97944e..a7da851d 100644 --- a/addon-edge/README.md +++ b/addon-edge/README.md @@ -3,9 +3,9 @@ Development preview of Domus installed as a Home Assistant app. Open it through HA's Open Web UI using your existing Home Assistant session. -Edge 0.0.0-edge.11 includes the current household work, Family, Inventory and -Shopping workspaces. Inventory shows storage locations and exact stock -transfers, with English and Spanish labels and original-request recovery. +Edge 0.0.0-edge.12 shows assigned and unclaimed household tasks on Overview. +Each group has an exact count and links into the protected Tasks workspace. +The summary is available in English and Spanish. This candidate upgrades supported owned data to SQLite schema 30. Keep a compatible image and cold data backup before upgrading a previous preview. diff --git a/addon-edge/artifact.json b/addon-edge/artifact.json index 3ebd6343..517705d1 100644 --- a/addon-edge/artifact.json +++ b/addon-edge/artifact.json @@ -1,10 +1,8 @@ { "schemaVersion": 1, - "version": "0.0.0-edge.11", - "sourceCommit": "7e869ff0d1755def7d06046ba5ea48150a26ccfb", - "sourceArchiveSHA256": "a65ec787de95548bbce7e70f834e9101055bba335301e22fb18d17c424b79200", - "storageSchema": 30, - "wheelSHA256": "1606135b747a4705bb741c557c51ea4f224fc1fa8114284058a4ca984a75ebda", + "version": "0.0.0-edge.12", + "sourceCommit": "3a803ddce3092abcd9da48c8533c65d24e2e0e37", + "sourceArchiveSHA256": "6eaaf75c60a7582e21da627dc17f9cb9dcad007e0ab90c433d61d311cbf8363b", "pythonFiles": { "domus/__init__.py": "7182c88b92234b4328f94497f4e70222d4390d8093e4b62893dfa78ac5530ac6", "domus/application/__init__.py": "1e8c0c87bf2a8ca947112543070583c0cc55d9d40b56eab0d86ed59a4ec1e82c", @@ -82,8 +80,8 @@ "domus/application/task_material_scope.py": "f1d44c700578da0681872e4fac42d1ebb801e33fa843065b9dabb397f69888d1", "domus/application/task_material_views.py": "1f4e1b52c17064b73e3c6502b38fc578a7589d68044279312c783b656e5aa5bf", "domus/application/task_materials.py": "caa132a7b16fca293770deba3da149cf9bda2e24d4719abe9de39470d686698e", - "domus/application/task_ports.py": "20b4d6ecc29cce45a0df48c35e6c50889934bf2a239fa149e951932f0eb0c6ae", - "domus/application/task_queries.py": "577c50a09be8205cd836680b757693320d26ec6a0afd88effa49105e14fdc430", + "domus/application/task_ports.py": "fca67b4b08fedfdf2c61a9acdd58535620d0c6a8c7de283debb8eb27a12535b2", + "domus/application/task_queries.py": "7c810bcec8a5c0f16bda47d577cce5f060976b348b96bacad737c65da91d8101", "domus/application/task_requests.py": "2e9ead8f5458d45335ec55bad50f5f7e12b42ee9b00ff54634f3ff681b320897", "domus/application/task_reviews.py": "dcc288cda6cdcf5073bad4f24133b9d3496c0b0cf1272e8328e6df38129f3328", "domus/composition/__init__.py": "a902d8faf7dd19da6829fb730d81e32d34ec38ee6cfafd676966a95d0ad31366", @@ -161,7 +159,7 @@ "domus/entrypoints/schedule_creation_http.py": "f5bc369e5135229e9eb62ad1ac1046c3fb2d0c9c53e6acad6bd61631c2a7042e", "domus/entrypoints/task_category_http.py": "e5443015f5e5cb2684eb6807e0a3bac5116703b5611508281afd7d1addee9672", "domus/entrypoints/task_dto.py": "df12654a0917a06742ea4605f0aca552d339df610ecb0f7467f69aa89b5a7c9d", - "domus/entrypoints/task_http.py": "b56e13323473176d0cb2e6e6b03438dbaabb54c70f3c62db397ce2252f1ef6d5", + "domus/entrypoints/task_http.py": "bf62f9424c0352e08d5f67fcaf1a39ff34dd556ddccfaf163d9a9004ef8f39f2", "domus/entrypoints/task_response.py": "618c0b07680e35db446428e06fdf9d6baeba33e117f8168a234c68e01eba31f7", "domus/entrypoints/ui_bundle.py": "beae3d4a7a57375ee195cca81efccdbc899d9db4286029d53eabaf30de6e14f7", "domus/entrypoints/ui_http.py": "b6c47baa742f3862173a93e4121dc9914fd972eb6287ffffb9ffccecbf2ebe4a", @@ -217,15 +215,17 @@ "domus/infrastructure/sqlite_task_records.py": "ec46d74954b62b6f4618b2b12198c4587d829c1d711ec8f67b5adc125989d988", "domus/infrastructure/sqlite_task_reviews.py": "96984dc6f02f6e7a4cf88a328da94cac20ebc9ce405134859b141290ff1bd7ed", "domus/infrastructure/sqlite_task_schema.py": "25e3241cb6c30ceb1701c854c7c88a4051085cabc255b03e78847beda525214a", - "domus/infrastructure/sqlite_tasks.py": "f3785700505045ccf6f3e63dbb122c210166027ac296f85729c32d97b16d1126", + "domus/infrastructure/sqlite_tasks.py": "9ebbf88c1ac1bd75e6832c8e25c595d28b124110c4076639d226097164ef3cc1", "domus/infrastructure/standalone_sessions.py": "ec3fd7a848c2c2a57e416bc7361e416c823d76706b474d08120cdd9e1534655a", "domus/infrastructure/task_cursor.py": "b21dbb915ce874b51008689d05abb4480cb7a65aabc5851f9500e51238bb6b5f", "domus/infrastructure/task_materials.py": "d5d2934e36f290c7bf44b473392f014eab8749f1f3b3d26a3402079e65d2818f" }, + "storageSchema": 30, "uiFiles": { - ".vite/manifest.json": "40360e01a5c4d65902058c0f719644bb3a135a3283e2b3135d1c6f29a822c9aa", - "assets/index-CacQb2hQ.js": "c9e4d9642fa6990c9c8c53941f2c53abeb55ee873480ac3da73bd72b3dd1b137", + ".vite/manifest.json": "4ed436146d05865e5e60e2ef76b99a611b35208a39db3b770b4c039e1de0fb7f", "assets/index-CjJnHZzV.css": "0f2c8c2e31576c0b64fe60373150f09390dafb896df6c07777b2a220ad430e48", - "index.html": "e6c4761e022f08f0e32d1bfe9cc4eaa6646d5ef1c2816c3dff1d0dba4b2e3c11" - } + "assets/index-Co1HI4BR.js": "cf08dbc51e03912c2762adf261f770bf6fa5deaca70d55d0a06ddf902f5157ca", + "index.html": "ac2712a0405457448fb205d0de452f7a50f2f9c2a10e0772578a2fd18adef47a" + }, + "wheelSHA256": "c91bccef222b5206e61829c090b9719a969d2705ea8339c86b896ec39f30d328" } diff --git a/addon-edge/config.yaml b/addon-edge/config.yaml index 5f66a505..2eaec0e7 100644 --- a/addon-edge/config.yaml +++ b/addon-edge/config.yaml @@ -1,5 +1,5 @@ name: Domus Edge -version: "0.0.0-edge.11" +version: "0.0.0-edge.12" slug: domus_edge description: Development preview of the local Domus household application url: https://github.com/vypdev/domus diff --git a/backend/src/domus/application/task_ports.py b/backend/src/domus/application/task_ports.py index dfe89f01..5fb54ee0 100644 --- a/backend/src/domus/application/task_ports.py +++ b/backend/src/domus/application/task_ports.py @@ -24,6 +24,12 @@ class TaskReviewEvidence: acknowledgements: tuple[OperationEvidence, ...] = () +@dataclass(frozen=True, slots=True) +class TaskOccurrenceGroup: + total: int + items: tuple[TaskOccurrence, ...] + + class TaskRepository(Protocol): def lifecycle_sources( self, household_id: str, *, limit: int = 100, after: int = 0 @@ -94,6 +100,14 @@ def occurrences( assignee_id: str | None = None, open_only: bool = False, ) -> tuple[TaskOccurrence, ...]: ... + def occurrence_group( + self, + household_id: str, + states: tuple[OccurrenceState, ...], + assignee_id: str | None, + *, + limit: int = 25, + ) -> TaskOccurrenceGroup: ... def cycle(self, household_id: str, cycle_id: str) -> TaskCycle | None: ... def save_cycle(self, value: TaskCycle, expected_revision: int) -> None: ... def cycles( diff --git a/backend/src/domus/application/task_queries.py b/backend/src/domus/application/task_queries.py index 0c6e6f0f..b6c46f73 100644 --- a/backend/src/domus/application/task_queries.py +++ b/backend/src/domus/application/task_queries.py @@ -25,7 +25,7 @@ resolved_rules, ) from domus.application.task_material_views import MaterialOutcome, material_outcome -from domus.application.task_ports import TaskCursors +from domus.application.task_ports import TaskCursors, TaskOccurrenceGroup from domus.application.task_reviews import DependencyReviewView, review_cycle, review_items from domus.domain.errors import Conflict, Forbidden, InvalidInput, NotFound, StorageFailure from domus.domain.identity import HumanIdentity, Permission, validate_revision @@ -103,6 +103,35 @@ class OccurrenceSummary: current_cycle_id: str | None +@dataclass(frozen=True, slots=True) +class TaskOverviewItem: + occurrence_id: str + title: str + state: OccurrenceState + + +@dataclass(frozen=True, slots=True) +class TaskOverviewGroup: + total: int + items: tuple[TaskOverviewItem, ...] + + +@dataclass(frozen=True, slots=True) +class TaskOverview: + assigned: TaskOverviewGroup + unclaimed: TaskOverviewGroup + + +def _overview_group(group: TaskOccurrenceGroup) -> TaskOverviewGroup: + return TaskOverviewGroup( + group.total, + tuple( + TaskOverviewItem(item.occurrence_id, item.definition_snapshot.content.title, item.state) + for item in group.items + ), + ) + + CompletionPoints = Literal["automatic", "manual", "manager_required"] @@ -316,6 +345,19 @@ def occurrences( ) return self._page(summaries, limit, binding, lambda item: item.occurrence_id) + def overview(self) -> TaskOverview: + with self.transactions.read() as unit: + actor = self._read(unit) + assigned = unit.tasks.occurrence_group( + self.household_id, + (OccurrenceState.ASSIGNED, OccurrenceState.IN_PROGRESS, OccurrenceState.BLOCKED), + actor.member.member_id, + ) + unclaimed = unit.tasks.occurrence_group( + self.household_id, (OccurrenceState.AVAILABLE,), None + ) + return TaskOverview(_overview_group(assigned), _overview_group(unclaimed)) + def occurrence(self, occurrence_id: str) -> TaskDetail: with self.transactions.read() as unit: actor = self._read(unit) diff --git a/backend/src/domus/entrypoints/task_http.py b/backend/src/domus/entrypoints/task_http.py index f25369a7..cbbb7cf6 100644 --- a/backend/src/domus/entrypoints/task_http.py +++ b/backend/src/domus/entrypoints/task_http.py @@ -25,6 +25,7 @@ OccurrenceSummary, TaskHistoryItem, TaskMaterialsView, + TaskOverview, TaskPage, TaskPolicyView, TaskQueries, @@ -136,6 +137,10 @@ def create_task_router( def workspace(request: Request, query: Annotated[_EmptyQuery, Query()]) -> TaskWorkspaceView: return context(request).queries().workspace() + @router.get("/overview", response_model=TaskOverview) + def overview(request: Request, query: Annotated[_EmptyQuery, Query()]) -> TaskOverview: + return context(request).queries().overview() + @router.get("/policy", response_model=TaskPolicyView) def policy(request: Request, query: Annotated[_EmptyQuery, Query()]) -> TaskPolicyView: return context(request).queries().policy() diff --git a/backend/src/domus/infrastructure/sqlite_tasks.py b/backend/src/domus/infrastructure/sqlite_tasks.py index 79615e0f..aa90fe99 100644 --- a/backend/src/domus/infrastructure/sqlite_tasks.py +++ b/backend/src/domus/infrastructure/sqlite_tasks.py @@ -1,11 +1,11 @@ """Scoped task repositories with compare-and-swap writes and strict stored-header checks.""" import sqlite3 -from collections.abc import Callable +from collections.abc import Callable, Iterable from dataclasses import dataclass from typing import cast -from domus.application.task_ports import TaskRepository, TaskReviewEvidence +from domus.application.task_ports import TaskOccurrenceGroup, TaskRepository, TaskReviewEvidence from domus.domain.errors import Conflict, InvalidInput, StorageFailure from domus.domain.restoration import OperationEvidence, RetainedOperation from domus.domain.storage import validate_identifier @@ -410,6 +410,38 @@ def occurrences( + " ORDER BY occurrence_id LIMIT ?", (*parameters, limit), ) + return self._occurrence_rows(rows) + + def occurrence_group( + self, + household_id: str, + states: tuple[OccurrenceState, ...], + assignee_id: str | None, + *, + limit: int = 25, + ) -> TaskOccurrenceGroup: + where, parameters = _page(household_id, limit, None, "occurrence_id") + placeholders = ",".join("?" for _ in states) + where.append(f"state IN ({placeholders})") + parameters.extend(state.value for state in states) + if assignee_id is None: + where.append("json_array_length(document,'$.assignee_ids')=0") + else: + where.append( + "EXISTS (SELECT 1 FROM json_each(task_occurrences.document,'$.assignee_ids') " + "AS assigned WHERE assigned.value=?)" + ) + parameters.append(assignee_id) + selection = " FROM task_occurrences WHERE " + " AND ".join(where) + total = cast( + int, self.connection.execute("SELECT COUNT(*)" + selection, parameters).fetchone()[0] + ) + rows = self.connection.execute( + "SELECT *" + selection + " ORDER BY occurrence_id LIMIT ?", (*parameters, limit) + ) + return TaskOccurrenceGroup(total, self._occurrence_rows(rows)) + + def _occurrence_rows(self, rows: Iterable[sqlite3.Row]) -> tuple[TaskOccurrence, ...]: return tuple( cast( TaskOccurrence, diff --git a/docs/contracts/household-api.openapi.json b/docs/contracts/household-api.openapi.json index 64f76fa1..1aa3054e 100644 --- a/docs/contracts/household-api.openapi.json +++ b/docs/contracts/household-api.openapi.json @@ -8594,6 +8594,65 @@ "title": "TaskOverrides", "type": "object" }, + "TaskOverview": { + "properties": { + "assigned": { + "$ref": "#/components/schemas/TaskOverviewGroup" + }, + "unclaimed": { + "$ref": "#/components/schemas/TaskOverviewGroup" + } + }, + "required": [ + "assigned", + "unclaimed" + ], + "title": "TaskOverview", + "type": "object" + }, + "TaskOverviewGroup": { + "properties": { + "items": { + "items": { + "$ref": "#/components/schemas/TaskOverviewItem" + }, + "title": "Items", + "type": "array" + }, + "total": { + "title": "Total", + "type": "integer" + } + }, + "required": [ + "total", + "items" + ], + "title": "TaskOverviewGroup", + "type": "object" + }, + "TaskOverviewItem": { + "properties": { + "occurrence_id": { + "title": "Occurrence Id", + "type": "string" + }, + "state": { + "$ref": "#/components/schemas/OccurrenceState" + }, + "title": { + "title": "Title", + "type": "string" + } + }, + "required": [ + "occurrence_id", + "title", + "state" + ], + "title": "TaskOverviewItem", + "type": "object" + }, "TaskPage_DefinitionSummary_": { "properties": { "items": { @@ -22835,6 +22894,157 @@ "summary": "Operation" } }, + "/api/v1/tasks/overview": { + "get": { + "operationId": "overview_api_v1_tasks_overview_get", + "parameters": [ + { + "in": "header", + "name": "X-Domus-Context", + "required": false, + "schema": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "X-Domus-Context" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/TaskOverview" + } + } + }, + "description": "Successful Response" + }, + "400": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + }, + "description": "Bad Request" + }, + "401": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + }, + "description": "Unauthorized" + }, + "403": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + }, + "description": "Forbidden" + }, + "404": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + }, + "description": "Not Found" + }, + "405": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + }, + "description": "Method Not Allowed" + }, + "408": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + }, + "description": "Request Timeout" + }, + "409": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + }, + "description": "Conflict" + }, + "413": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + }, + "description": "Content Too Large" + }, + "422": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + }, + "description": "Unprocessable Content" + }, + "500": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + }, + "description": "Internal Server Error" + }, + "503": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + }, + "description": "Service Unavailable" + } + }, + "security": [ + { + "DomusSession": [] + } + ], + "summary": "Overview" + } + }, "/api/v1/tasks/policy": { "get": { "operationId": "policy_api_v1_tasks_policy_get", diff --git a/docs/contracts/native-household-api.openapi.json b/docs/contracts/native-household-api.openapi.json index d9f7b750..66c5360a 100644 --- a/docs/contracts/native-household-api.openapi.json +++ b/docs/contracts/native-household-api.openapi.json @@ -8556,6 +8556,65 @@ "title": "TaskOverrides", "type": "object" }, + "TaskOverview": { + "properties": { + "assigned": { + "$ref": "#/components/schemas/TaskOverviewGroup" + }, + "unclaimed": { + "$ref": "#/components/schemas/TaskOverviewGroup" + } + }, + "required": [ + "assigned", + "unclaimed" + ], + "title": "TaskOverview", + "type": "object" + }, + "TaskOverviewGroup": { + "properties": { + "items": { + "items": { + "$ref": "#/components/schemas/TaskOverviewItem" + }, + "title": "Items", + "type": "array" + }, + "total": { + "title": "Total", + "type": "integer" + } + }, + "required": [ + "total", + "items" + ], + "title": "TaskOverviewGroup", + "type": "object" + }, + "TaskOverviewItem": { + "properties": { + "occurrence_id": { + "title": "Occurrence Id", + "type": "string" + }, + "state": { + "$ref": "#/components/schemas/OccurrenceState" + }, + "title": { + "title": "Title", + "type": "string" + } + }, + "required": [ + "occurrence_id", + "title", + "state" + ], + "title": "TaskOverviewItem", + "type": "object" + }, "TaskPage_DefinitionSummary_": { "properties": { "items": { @@ -22476,6 +22535,157 @@ "summary": "Operation" } }, + "/api/v1/tasks/overview": { + "get": { + "operationId": "overview_api_v1_tasks_overview_get", + "parameters": [ + { + "in": "header", + "name": "X-Domus-Context", + "required": false, + "schema": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "X-Domus-Context" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/TaskOverview" + } + } + }, + "description": "Successful Response" + }, + "400": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + }, + "description": "Bad Request" + }, + "401": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + }, + "description": "Unauthorized" + }, + "403": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + }, + "description": "Forbidden" + }, + "404": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + }, + "description": "Not Found" + }, + "405": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + }, + "description": "Method Not Allowed" + }, + "408": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + }, + "description": "Request Timeout" + }, + "409": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + }, + "description": "Conflict" + }, + "413": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + }, + "description": "Content Too Large" + }, + "422": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + }, + "description": "Unprocessable Content" + }, + "500": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + }, + "description": "Internal Server Error" + }, + "503": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + }, + "description": "Service Unavailable" + } + }, + "security": [ + { + "HomeAssistantIngress": [] + } + ], + "summary": "Overview" + } + }, "/api/v1/tasks/policy": { "get": { "operationId": "policy_api_v1_tasks_policy_get", diff --git a/docs/evidence/overview-task-qualification.md b/docs/evidence/overview-task-qualification.md new file mode 100644 index 00000000..e319fb78 --- /dev/null +++ b/docs/evidence/overview-task-qualification.md @@ -0,0 +1,24 @@ +# Overview task summary qualification + +[Issue #92](https://github.com/vypdev/domus/issues/92) adds assigned and unclaimed +task summaries to Overview. The protected read uses the same Tasks authority as +the detail workspace. + +| Published case | Evidence | +| --- | --- | +| `inventory1-C01` | The [protected read tests](../../tests/backend/test_task_overview.py) cover assigned, in-progress and blocked work, reassignment, ordering and exact counts beyond 25. The [compiled browser journey](../../frontend/tests/e2e/workspace-navigation.spec.ts) opens the detail from Overview with desktop keyboard and narrow touch in both compositions. | +| `inventory1-C02` | The protected read tests verify exact totals and bounded Available rows. The [controller and component tests](../../frontend/tests/task-overview.test.ts) distinguish a successful empty result from an unavailable read. The compiled journey retries an interrupted read. | +| `inventory1-C03` | The protected read tests revoke Tasks access in both compositions. The controller tests check late responses, denied and retired contexts. The [HTTP adapter tests](../../frontend/tests/task-http.test.ts) reject incomplete groups and incorrect task states. | +| `overview-task-evidence-C01` | The backend fixture includes 29 assigned and 27 unclaimed tasks. The browser transport verifies a bounded list of 25 and rejects truncated, duplicate and inconsistent replies. | +| `overview-task-evidence-C02` | The browser controller test switches verified subject with a pending read, retires the view during a refresh and resolves each old read after retirement. No old result is published. | + +The read uses the current database schema and returns the current member's +task groups from one snapshot. Image CI runs the compiled workflow on amd64 and ARM64. + +Home Assistant Supervisor reported `0.0.0-edge.12` before the Ingress +test. The disposable household first showed two empty groups. Creating +two tasks and claiming one gave an exact count of one in each group. +English desktop keyboard selection and narrow Spanish pointer selection +opened the correct task details. After claiming the second task, Overview +showed two assigned and zero unclaimed. The temporary app, its store +source and its test data were removed. diff --git a/docs/evidence/task-navigation-integration.json b/docs/evidence/task-navigation-integration.json index 8693f98a..43fda4a5 100644 --- a/docs/evidence/task-navigation-integration.json +++ b/docs/evidence/task-navigation-integration.json @@ -3,12 +3,12 @@ "historicalTaskHead": "8c0a36c0b9804bdaf33a301a4dc85ae3dc12ee21", "developParent": "5b7bdcdee3a9e98d6669bfd34ce750ae30a8c775", "command": "pnpm build:frontend", - "scope": "Compiled household workspace with protected Pantry, shared Shopping, purchase sessions, receipt corrections, physical returns, stock locations, transfers and original operation recovery in English and Spanish.", + "scope": "Compiled household workspace with assigned and unclaimed task summaries, protected Pantry, shared Shopping, purchase sessions, receipt corrections, physical returns, stock locations, transfers and original operation recovery in English and Spanish.", "actualProductFiles": { - ".vite/manifest.json": "40360e01a5c4d65902058c0f719644bb3a135a3283e2b3135d1c6f29a822c9aa", - "assets/index-CacQb2hQ.js": "c9e4d9642fa6990c9c8c53941f2c53abeb55ee873480ac3da73bd72b3dd1b137", + ".vite/manifest.json": "4ed436146d05865e5e60e2ef76b99a611b35208a39db3b770b4c039e1de0fb7f", "assets/index-CjJnHZzV.css": "0f2c8c2e31576c0b64fe60373150f09390dafb896df6c07777b2a220ad430e48", - "index.html": "e6c4761e022f08f0e32d1bfe9cc4eaa6646d5ef1c2816c3dff1d0dba4b2e3c11" + "assets/index-Co1HI4BR.js": "cf08dbc51e03912c2762adf261f770bf6fa5deaca70d55d0a06ddf902f5157ca", + "index.html": "ac2712a0405457448fb205d0de452f7a50f2f9c2a10e0772578a2fd18adef47a" }, "localValidation": { "commit": "9a10d8114869be754962953903e773fe8e12c723", diff --git a/docs/installation-home-assistant.md b/docs/installation-home-assistant.md index 293c843c..0be97ed7 100644 --- a/docs/installation-home-assistant.md +++ b/docs/installation-home-assistant.md @@ -9,15 +9,15 @@ published. Source, package and adoption evidence are recorded in [task workspace evidence](evidence/task-workspace.json). Historical receipts below retain their original Edge.1–3 observations and do not describe the current installation. -## Edge.11 candidate +## Edge.12 candidate -The storage-location candidate uses the same Supervisor repository flow -with the [managed issue branch](https://github.com/vypdev/domus/issues/88). +The Overview task candidate uses the Supervisor repository flow with the +[managed issue branch](https://github.com/vypdev/domus/issues/92). The [artifact declaration](../addon-edge/artifact.json) pins the source commit, archive and installed files. Check that Supervisor reports -`0.0.0-edge.11` before testing. Edge.11 retains the schema 30 storage used by Edge.10. When using a separate -repository source, keep existing preview data in its original app and -use a disposable household in the candidate. +`0.0.0-edge.12` before testing. Edge.12 uses SQLite schema 30. When using a +separate repository source, keep existing preview data in its original app +and use a disposable household in the candidate. ## Edge.9 installation and update history diff --git a/docs/roadmap.md b/docs/roadmap.md index 1f616bee..7dd01ea6 100644 --- a/docs/roadmap.md +++ b/docs/roadmap.md @@ -48,7 +48,9 @@ implementation, verification and packaging gates. The Family increments now cove records a move as two linked ledger entries. Multiple lists, prices, refunds, location editing and archiving, lot and package management, barcodes and optional online lookup remain open. - M4: the shared automation engine, both editors and Domus-owned HA entities/services remain open. The existing gateway is already integrated; its MCP/business behavior is outside this work. -- M5: complete cross-domain overview/acceptance, both deployment journeys and Stable release acceptance remain open. Foundational UI reuse is scheduled in M2, not deferred to this final milestone. +- M5 includes the [assigned and unclaimed task summaries on Overview](evidence/overview-task-qualification.md). + Date-based and cross-domain summaries, full integrated acceptance and Stable release + acceptance remain open. ## Shared components, Domus-owned experience diff --git a/docs/tasks/execution.md b/docs/tasks/execution.md index bcf6ecfc..85b4528e 100644 --- a/docs/tasks/execution.md +++ b/docs/tasks/execution.md @@ -33,6 +33,13 @@ Definition lists accept `state`; occurrence lists additionally accept `assignee_ `definition_id`. Unknown or duplicate query parameters fail. Cursors expire after five minutes by default and can become invalid after a process restart. Pages are not a cross-page snapshot. +GET `/overview` returns `assigned` and `unclaimed` groups. Each has an exact `total` and up to +25 task summaries ordered by occurrence ID. The response includes each item's occurrence ID, title, +and state. Assigned work uses the verified member and the assigned, in-progress, and blocked +states. Unclaimed work uses the available state. Both groups use one protected household snapshot +and the current Tasks read grant. The route accepts an empty query and delegates item detail to +the existing occurrence route. + GET `/definitions/{id}` returns current definition facts. GET `/occurrences/{id}` returns its frozen definition snapshot, current policy rules, required work, current cycle and action hints. Hints do not authorize a later change; the command checks again. GET `/policy` returns defaults with revision diff --git a/docs/user-guide.md b/docs/user-guide.md index 8c1ea308..880a3134 100644 --- a/docs/user-guide.md +++ b/docs/user-guide.md @@ -17,6 +17,13 @@ standalone. Use Tab and Enter or the browser's Back and Forward actions. Moving sections keeps an unsent draft in the current page; reload verifies access again and does not restore an unsent administration draft. +### Task summary on Overview + +**Assigned to me** shows your assigned, in-progress, and blocked tasks. **Unclaimed tasks** +shows household work in the available state. Both groups show exact totals with up to 25 +items per group. Select a task to open its current details in Tasks. Use **Retry task summary** +if the summary could not be loaded. Access follows your current Tasks read permission. + ## Current task workspace The current source increment adds a real task workspace. Published Edge.7 remains administration-only until the next verified preview package is adopted; refreshing that older app does not install this source change. diff --git a/frontend/src/adapters/task-http.ts b/frontend/src/adapters/task-http.ts index a1fa2659..c98be1a1 100644 --- a/frontend/src/adapters/task-http.ts +++ b/frontend/src/adapters/task-http.ts @@ -1,15 +1,16 @@ /** Same-origin task transport with bounded reads and no automatic write retry. */ import {EntryReadError} from '../application/ports'; import type {TaskCommandResult, TaskOriginal, TaskRequest, TaskServer} from '../application/task-ports'; +import type {TaskOverview, TaskOverviewGroup} from '../application/task-overview'; import type {JournalContext} from '../domain/journal'; import {isCategoryCommand} from '../domain/tasks'; -import type {TaskCommand} from '../domain/tasks'; -import {taskSchedulePolicy} from '../domain/tasks'; +import type {TaskCommand, TaskState} from '../domain/tasks'; +import {taskSchedulePolicy, taskText, TASK_TEXT_LIMITS} from '../domain/tasks'; import {BoundedHTTP, reason} from './http-transport'; import type {FetchTransport} from './http-transport'; import type {EntryEndpoint} from './http-values'; import {assertion, csrf, failure} from './http-values'; -import {boolean, check, fields, identifier, responseRevision} from './json-values'; +import {boolean, check, choice, fields, identifier, integer, responseRevision} from './json-values'; import {taskCategoryCatalog, taskCommandBody, taskDetail, taskPage, taskReceipt, taskRequest} from './task-values'; function route(command: TaskCommand): string { if (command.action === 'task.create') return command.payload.schedule === undefined @@ -22,6 +23,19 @@ function route(command: TaskCommand): string { const action = command.action.slice(5); return 'tasks/occurrences/' + command.occurrenceId + '/' + action; } +function overviewGroup(value: unknown, states: readonly TaskState[]): TaskOverviewGroup { + const group = fields(value, ['total', 'items'], []); + const total = integer(group.total, 0); + check(Array.isArray(group.items) && group.items.length === Math.min(total, 25)); + const items = group.items.map(value => { + const item = fields(value, ['occurrence_id', 'title', 'state'], []); + return {id: identifier(item.occurrence_id), title: taskText(item.title, TASK_TEXT_LIMITS.title, true), + state: choice(item.state, states)}; + }); + check(new Set(items.map(item => item.id)).size === items.length); + return {total, items}; +} + export class HttpTaskServer implements TaskServer { private readonly network: BoundedHTTP; constructor(target: EntryEndpoint, transport: FetchTransport) {this.network = new BoundedHTTP(target, transport);} @@ -38,6 +52,13 @@ export class HttpTaskServer implements TaskServer { ...policy === null ? {} : {schedulePolicy: taskSchedulePolicy({...policy, revision: responseRevision(policy.revision)})}}); }); } + overview(expected: JournalContext) { + return this.network.owned(async signal => { + const result = fields(await this.network.get('tasks/overview', expected, signal), ['assigned', 'unclaimed'], []); + return {assigned: overviewGroup(result.assigned, ['assigned', 'in_progress', 'blocked']), + unclaimed: overviewGroup(result.unclaimed, ['available'])}; + }); + } list(expected: JournalContext, cursor: string | null) { return this.network.owned(async signal => { check(cursor === null || typeof cursor === 'string' && cursor.length > 0 && cursor.length <= 512); diff --git a/frontend/src/application/task-overview.ts b/frontend/src/application/task-overview.ts new file mode 100644 index 00000000..637e8b3d --- /dev/null +++ b/frontend/src/application/task-overview.ts @@ -0,0 +1,72 @@ +import type {JournalContext} from '../domain/journal'; +import type {TaskState} from '../domain/tasks'; +import {EntryReadError} from './ports'; +import type {EntryRead} from './ports'; + +export interface TaskOverviewItem { + readonly id: string; + readonly title: string; + readonly state: TaskState; +} + +export interface TaskOverviewGroup { + readonly total: number; + readonly items: readonly TaskOverviewItem[]; +} + +export interface TaskOverview { + readonly assigned: TaskOverviewGroup; + readonly unclaimed: TaskOverviewGroup; +} + +export type TaskOverviewView = Readonly<{state: 'loading' | 'denied' | 'unavailable'}> + | Readonly<{state: 'ready'; overview: TaskOverview}>; + +interface OverviewScope { + readonly key: string; + readonly context: JournalContext; +} + +export interface TaskOverviewServer { + overview(context: JournalContext): EntryRead; +} + +/** Retire private results before switching contexts or starting a retry. */ +export class TaskOverviewController { + private scope: OverviewScope | null = null; + private pending: EntryRead | null = null; + + constructor(private readonly server: TaskOverviewServer, + private readonly publish: (view: TaskOverviewView | null) => void) {} + + bind(scope: OverviewScope | null): void { + if (this.scope?.key === scope?.key) return; + this.scope = scope; + if (scope !== null) { + void this.refresh(); + return; + } + this.pending?.cancel(); + this.pending = null; + this.publish(null); + } + + async refresh(): Promise { + if (this.scope === null) return; + this.pending?.cancel(); + const pending = this.server.overview(this.scope.context); + this.pending = pending; + this.publish({state: 'loading'}); + try { + const overview = await pending.result; + if (this.pending === pending) this.publish({state: 'ready', overview}); + } catch (error) { + if (this.pending !== pending) return; + const denied = error instanceof EntryReadError + && (error.code === 'forbidden' || error.code === 'authentication_required'); + this.publish({state: denied ? 'denied' : 'unavailable'}); + } finally { + if (this.pending === pending) this.pending = null; + } + } +} diff --git a/frontend/src/composition/entry-page.ts b/frontend/src/composition/entry-page.ts index b5e29acf..78907616 100644 --- a/frontend/src/composition/entry-page.ts +++ b/frontend/src/composition/entry-page.ts @@ -1,3 +1,5 @@ +import {HttpTaskServer} from '../adapters/task-http'; +import {TaskOverviewController} from '../application/task-overview'; import {HttpInventoryServer} from '../adapters/inventory-http'; import {INVENTORY_JOURNAL_KEY, InventorySessionJournal} from '../adapters/inventory-journal'; import {InventoryController} from '../application/inventory-controller'; @@ -205,13 +207,14 @@ export function mountEntry(page: EntryPage): PageMount { let family: FamilyController | null = null; let rewards: RewardsController | null = null; let inventory: InventoryController | null = null; + let taskOverview: TaskOverviewController | null = null; let allocation: AllocationController | null = null; let calendar: CalendarController | null = null, review: RecurrenceReviewController | null = null; let stopped = false, runtime: EntryRuntime | null = null, app: DomusApp | null = null, error: HTMLElement | null = null; let localeOwner:string|null=null,preferenceIdentity:string|null=null,hadPreference=false,temporaryLanguage=false,temporaryContext:string|null=null; const dispose = () => { if (stopped) return; - stopped = true; widget.abort(); lifetime.abort(); runtime?.dispose(); calendar?.bind(null); family?.bind(null); rewards?.bind(null); inventory?.bind(null); allocation?.bind(null); calendarPreference?.bind(null); review?.bind(null); error?.remove(); + stopped = true; widget.abort(); lifetime.abort(); runtime?.dispose(); calendar?.bind(null); family?.bind(null); rewards?.bind(null); inventory?.bind(null); allocation?.bind(null); calendarPreference?.bind(null); review?.bind(null); taskOverview?.bind(null); error?.remove(); if (mounts.get(doc) === dispose) mounts.delete(doc); }; mounts.set(doc, dispose); @@ -220,7 +223,7 @@ export function mountEntry(page: EntryPage): PageMount { }, {signal: lifetime.signal}); const fail = () => { if (stopped || error !== null) return; - widget.abort(); runtime?.dispose(); calendar?.bind(null); family?.bind(null); rewards?.bind(null); inventory?.bind(null); allocation?.bind(null); calendarPreference?.bind(null); review?.bind(null); app?.remove(); + widget.abort(); runtime?.dispose(); calendar?.bind(null); family?.bind(null); rewards?.bind(null); inventory?.bind(null); allocation?.bind(null); calendarPreference?.bind(null); review?.bind(null); taskOverview?.bind(null); app?.remove(); const locale = language(null, page.navigator.language); doc.documentElement.lang = locale; error = doc.createElement('main'); error.id = 'domus-entry-error'; const heading = doc.createElement('h1'), body = doc.createElement('p'), action = doc.createElement('p'), reload = doc.createElement('button'); @@ -408,16 +411,28 @@ export function mountEntry(page: EntryPage): PageMount { if (intent?.type === 'more-shopping-sources') await inventoryController.moreShoppingSources(); if (intent?.type === 'submit') await inventoryController.submit(intent.command); }, {signal:widget.signal}); + const overviewController = new TaskOverviewController(new HttpTaskServer(source.target, browser.transport), + view => {element.taskOverview = view;}); + taskOverview = overviewController; + const syncOverview = () => { + const entry = element.view, tasks = element.tasks, destination = element.workspaceDestination; + if ((destination === null || destination === 'overview') && entry?.phase === 'ready' + && entry.decision?.state === 'active' && entry.session && tasks?.phase === 'ready') { + const {context, access} = entry.session; + const key = JSON.stringify([context.installationId, context.channel, context.subject, access, tasks.scopeKey]); + overviewController.bind({key, context}); + } else overviewController.bind(null); + }; const syncWorkspace = () => { const fragment = new URL(page.location.href).hash; element.workspaceDestination = fragment === '#overview' ? 'overview' : fragment === '#household' ? 'household' : fragment === '#tasks' ? 'tasks' : fragment === '#calendar' ? 'calendar' : fragment === '#family' ? 'family' : fragment === '#inventory' ? 'inventory' : null; - syncCalendar(); syncReview(); syncFamily(); syncAllocation(); syncInventory(); + syncCalendar(); syncReview(); syncFamily(); syncAllocation(); syncInventory(); syncOverview(); }; syncWorkspace(); page.addEventListener('hashchange', syncWorkspace, {signal: widget.signal}); const active = new EntryRuntime(source.target, browser, (view,administration,tasks) => { - element.view=view;element.administration=administration;element.tasks=tasks;syncCalendar();syncReview();syncFamily();syncAllocation();syncInventory(); + element.view=view;element.administration=administration;element.tasks=tasks;syncCalendar();syncReview();syncFamily();syncAllocation();syncInventory();syncOverview(); const context=administration?.session?.context,member=administration?.access?.member; const contextKey=context?JSON.stringify([context.installationId,context.channel,context.subject]):null; const owner=contextKey!==null&&administration?.access?.state==='active'&&member?JSON.stringify([contextKey,member.memberId]):null; @@ -491,6 +506,15 @@ export function mountEntry(page: EntryPage): PageMount { } }catch{fail();} },{signal:widget.signal}); + element.addEventListener('domus-task-overview-intent', async event => { + if (event.target !== element) return; + const intent = decodeTaskIntent((event as CustomEvent).detail); + if (intent?.type === 'refresh') await overviewController.refresh(); + if (intent?.type === 'select') { + page.location.assign('#tasks'); + await active.taskWork(controller => controller.select(intent.occurrenceId)); + } + }, {signal: widget.signal}); element.addEventListener('domus-task-intent', async event => { if (event.target !== element) return; try { diff --git a/frontend/src/presentation/domus-app.ts b/frontend/src/presentation/domus-app.ts index c258c3a0..6e10611e 100644 --- a/frontend/src/presentation/domus-app.ts +++ b/frontend/src/presentation/domus-app.ts @@ -8,6 +8,8 @@ import type {PropertyValues} from 'lit'; import type {EntryView} from '../application/entry-controller'; import type {TaskView} from '../application/task-controller'; import './domus-tasks'; +import './domus-task-overview'; +import type {TaskOverviewView} from '../application/task-overview'; import './domus-calendar'; import './domus-family'; import './domus-rewards'; @@ -42,11 +44,12 @@ export type EntryIntent = Readonly<{type: 'refresh' | 'request_membership' | 'lo /** Owned rendering only; intents cross a semantic boundary and never grant command authority. */ export class DomusApp extends LitElement { static properties = {inventory: {attribute:false}, rewards: {attribute:false}, allocation: {attribute:false}, family: {attribute:false}, familyScopeKey: {attribute:false}, familyToday: {attribute:false}, recurrenceReview: {attribute:false}, calendar: {attribute:false}, calendarPreference: {attribute:false}, calendarScopeKey: {attribute:false}, calendarToday: {attribute:false}, tasks: {attribute: false}, view: {attribute: false}, administration: {attribute:false}, deployment: {attribute: false}, language: {attribute: false}, - workspaceDestination: {attribute: false}, nameDraft: {state: true}, zoneDraft: {state: true}}; + taskOverview: {attribute: false}, workspaceDestination: {attribute: false}, nameDraft: {state: true}, zoneDraft: {state: true}}; static styles = styles; declare view: EntryView | null; declare administration:AdministrationView|null; declare tasks: TaskView | null; + declare taskOverview: TaskOverviewView | null; declare calendar: CalendarView | null; declare family: FamilyView | null; declare rewards: RewardsView | null; @@ -69,7 +72,7 @@ export class DomusApp extends LitElement { super(); this.view = null; this.administration = null; this.tasks = null; this.deployment = 'standalone'; this.language = 'en'; this.recurrenceReview = null; this.calendar = null; this.calendarPreference = null; this.calendarScopeKey = null; this.calendarToday = DATE_MIN; this.family = null; this.rewards = null; this.inventory = null; this.allocation = null; this.familyScopeKey = null; this.familyToday = DATE_MIN; - this.workspaceDestination = null; this.nameDraft = ''; this.zoneDraft = ''; + this.workspaceDestination = null; this.taskOverview = null; this.nameDraft = ''; this.zoneDraft = ''; } disconnectedCallback(): void {super.disconnectedCallback(); this.dispatchEvent(new Event('domus-detached'));} private text(key: MessageKey): string {return message(key, this.language);} @@ -215,6 +218,7 @@ export class DomusApp extends LitElement { ${!taskWorkspace ? this.button('refresh', 'refresh', decision?.action === 'refresh') : nothing}` : nothing} ${!loading && decision?.action === 'contact_administrator' ? html`

${this.text('contact')}

` : nothing} ${!closed && view?.busy ? html`

${this.text('busy')}

` : nothing} +
diff --git a/frontend/src/presentation/domus-task-overview.ts b/frontend/src/presentation/domus-task-overview.ts new file mode 100644 index 00000000..8fbb782c --- /dev/null +++ b/frontend/src/presentation/domus-task-overview.ts @@ -0,0 +1,75 @@ +import {LitElement, css, html, nothing} from 'lit'; +import {registerButton} from '@vypdev/ha-ui/button'; +import {buttonState} from '@vypdev/ha-ui/button-contracts'; +import {registerCard} from '@vypdev/ha-ui/card'; +import {cardState} from '@vypdev/ha-ui/card-contracts'; +import {registerFeedback} from '@vypdev/ha-ui/feedback'; +import {feedbackState} from '@vypdev/ha-ui/feedback-contracts'; +import type {TaskOverviewGroup, TaskOverviewView} from '../application/task-overview'; +import type {Language} from './messages'; +import {taskMessage} from './task-messages'; +import type {TaskMessageKey} from './task-messages'; + +type OverviewIntent = {readonly type: 'refresh'} | {readonly type: 'select'; readonly occurrenceId: string}; + +export class DomusTaskOverview extends LitElement { + static properties = {view: {attribute: false}, language: {attribute: false}}; + static styles = css` + :host {--vyp-ha-surface:var(--surface);--vyp-ha-surface-raised:var(--surface);--vyp-ha-text:var(--text); + --vyp-ha-text-secondary:var(--muted);--vyp-ha-border:var(--line);--vyp-ha-primary:var(--accent); + --vyp-ha-focus-ring:3px solid var(--accent)} + section {margin-block-start:20px} h2 {margin-block:0 12px} + .groups {display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,16rem),1fr));gap:12px} + ul {list-style:none;margin:0;padding:0} li+li {border-block-start:1px solid var(--line)} + vyp-ha-button {--vyp-ha-button-padding:8px} + vyp-ha-feedback + vyp-ha-button {margin-block-start:8px} + `; + + declare view: TaskOverviewView | null; + declare language: Language; + + constructor() {super(); this.view = null; this.language = 'en';} + + private text(key: TaskMessageKey): string {return taskMessage(key, this.language);} + + private intent(detail: OverviewIntent): void { + this.dispatchEvent(new CustomEvent('domus-task-overview-intent', { + detail, bubbles: true, composed: true, + })); + } + + private group(key: 'overviewAssigned' | 'overviewUnclaimed', group: TaskOverviewGroup) { + const total = new Intl.NumberFormat(this.language).format(group.total); + return html` + ${group.total === 0 ? html`

${this.text('overviewEmpty')}

` : html`
    ${group.items.map(item => { + const title = item.title.replace(/[\u007f-\u009f]/gu, ' '); + const label = title + ' · ' + this.text(`state_${item.state}`); + return html`
  • this.intent({type: 'select', occurrenceId: item.id})}>
  • `; + })}
`} + ${group.total > group.items.length ? html`

${this.text('overviewMore')}

` : nothing} +
`; + } + + protected render() { + const view = this.view; + if (view === null) return nothing; + return html`
+

${this.text('overviewHeading')}

+ ${view.state === 'ready' ? html`
+ ${this.group('overviewAssigned', view.overview.assigned)} + ${this.group('overviewUnclaimed', view.overview.unclaimed)} +
` : html` + ${view.state === 'unavailable' ? html` this.intent({type: 'refresh'})}>` : nothing}`} +
`; + } +} + +registerButton(); registerCard(); registerFeedback(); +customElements.define('domus-task-overview', DomusTaskOverview); +declare global {interface HTMLElementTagNameMap {'domus-task-overview': DomusTaskOverview;}} diff --git a/frontend/src/presentation/task-messages.ts b/frontend/src/presentation/task-messages.ts index d2bb6904..1d526fd9 100644 --- a/frontend/src/presentation/task-messages.ts +++ b/frontend/src/presentation/task-messages.ts @@ -35,6 +35,10 @@ const english = Object.freeze({ rejected: 'Change not accepted', rejectedBody: 'Review the current task and your permissions before trying again.', requests: 'Saved requests', check: 'Check saved request', dismiss: 'Dismiss saved request', action_create: 'Create task', action_claim: 'Claim task', action_complete: 'Complete task', action_verify: 'Review task', action_reopen: 'Reopen task', + overviewHeading: 'Task summary', overviewAssigned: 'Assigned to me', overviewUnclaimed: 'Unclaimed tasks', + overviewEmpty: 'No tasks in this group.', overviewMore: 'Open Tasks for the full list.', + overviewLoading: 'Loading task summary…', overviewDenied: 'Your current access does not allow viewing tasks.', + overviewUnavailable: 'The task summary could not be loaded.', overviewRetry: 'Retry task summary', state_draft: 'Draft', state_available: 'Available', state_assigned: 'Assigned', state_in_progress: 'In progress', state_blocked: 'Blocked', state_completed: 'Done', state_cancelled: 'Cancelled', state_skipped: 'Skipped', verification_none: 'No approval required', verification_pending: 'Pending approval', verification_approved: 'Approved', verification_rejected: 'Rejected', @@ -89,6 +93,10 @@ const spanish: Readonly> = Object.freeze({ rejected: 'Cambio no aceptado', rejectedBody: 'Revisa la tarea actual y tus permisos antes de volver a intentarlo.', requests: 'Solicitudes guardadas', check: 'Comprobar solicitud guardada', dismiss: 'Descartar solicitud guardada', action_create: 'Crear tarea', action_claim: 'Reclamar tarea', action_complete: 'Completar tarea', action_verify: 'Revisar tarea', action_reopen: 'Reabrir tarea', + overviewHeading: 'Resumen de tareas', overviewAssigned: 'Asignadas a mí', overviewUnclaimed: 'Tareas sin asignar', + overviewEmpty: 'No hay tareas en este grupo.', overviewMore: 'Abre Tareas para ver la lista completa.', + overviewLoading: 'Cargando el resumen de tareas…', overviewDenied: 'Tu acceso actual no permite ver las tareas.', + overviewUnavailable: 'No se ha podido cargar el resumen de tareas.', overviewRetry: 'Volver a cargar el resumen de tareas', state_draft: 'Borrador', state_available: 'Disponible', state_assigned: 'Asignada', state_in_progress: 'En curso', state_blocked: 'Bloqueada', state_completed: 'Hecha', state_cancelled: 'Cancelada', state_skipped: 'Omitida', verification_none: 'No necesita aprobación', verification_pending: 'Pendiente de aprobación', verification_approved: 'Aprobada', verification_rejected: 'Rechazada', diff --git a/frontend/tests/e2e/workspace-navigation.spec.ts b/frontend/tests/e2e/workspace-navigation.spec.ts index aae2e3b4..f844f03a 100644 --- a/frontend/tests/e2e/workspace-navigation.spec.ts +++ b/frontend/tests/e2e/workspace-navigation.spec.ts @@ -78,6 +78,8 @@ for (const mode of ['native', 'standalone'] as const) { await expect(overview).toHaveAttribute('aria-current', 'page'); await expect(overview).toHaveCSS('border-bottom-width', '2px'); await tabs.screenshot({path: info.outputPath('en-light-wide.png')}); + await expect(overviewRegion.getByRole('heading', {name:'Assigned to me · 0', exact:true})).toBeVisible(); + await expect(overviewRegion.getByRole('heading', {name:'Unclaimed tasks · 0', exact:true})).toBeVisible(); await overview.focus(); await page.keyboard.press('Tab'); @@ -854,5 +856,43 @@ for (const mode of ['native', 'standalone'] as const) { await page.keyboard.press('Enter'); await expect(hogar).toHaveAttribute('aria-current', 'page'); await expect(page).toHaveURL(base + '#household'); + + await tabs.evaluate(element => {element.style.removeProperty('width');}); + await page.setViewportSize({width:1100,height:760}); + await page.emulateMedia({colorScheme:'light'}); + const assigned = await post('definitions', 'overview-assigned', {title:'Check the filters'}); + await post('occurrences/' + assigned.occurrence_id + '/claim', 'overview-claim', + {expected_revision:assigned.revision}); + await post('definitions', 'overview-unclaimed', {title:'Sort the recycling'}); + await page.getByLabel('Idioma',{exact:true}).selectOption('en'); + await page.route(base + 'api/v1/tasks/overview', route => route.abort('failed'), {times:1}); + await overview.click(); + await expect(overviewRegion.getByText('The task summary could not be loaded.')).toBeVisible(); + await expect(overviewRegion.getByRole('heading',{name:/Assigned to me ·/u})).toHaveCount(0); + await overviewRegion.getByRole('button',{name:'Retry task summary'}).press('Enter'); + const taskSummary = overviewRegion.getByRole('region',{name:'Task summary',exact:true}); + const assignedItem = taskSummary.getByRole('button',{name:'Check the filters · Assigned',exact:true}); + await expect(assignedItem).toBeVisible(); + await expect(taskSummary.getByRole('article',{name:/^Assigned to me ·/u})) + .toHaveCSS('background-color','rgb(255, 255, 255)'); + await taskSummary.screenshot({path:info.outputPath('task-overview-en-wide.png')}); + await assignedItem.press('Enter'); + await expect(page).toHaveURL(base + '#tasks'); + await expect(tasksRegion).toBeFocused(); + await expect(tasksRegion.getByRole('heading',{name:'Check the filters',exact:true})).toBeVisible(); + + await page.getByLabel('Language',{exact:true}).selectOption('es'); + await page.setViewportSize({width:390,height:844}); + await page.emulateMedia({colorScheme:'dark'}); + await tabs.getByRole('link',{name:'Inicio',exact:true}).tap(); + const resumen = overviewRegion.getByRole('region',{name:'Resumen de tareas',exact:true}); + const unclaimedItem = resumen.getByRole('button',{name:'Sort the recycling · Disponible',exact:true}); + await expect(unclaimedItem).toBeVisible(); + await expect(resumen.getByRole('article',{name:/^Tareas sin asignar ·/u})) + .toHaveCSS('background-color','rgb(24, 36, 47)'); + await resumen.screenshot({path:info.outputPath('task-overview-es-narrow.png')}); + await unclaimedItem.tap(); + await expect(page).toHaveURL(base + '#tasks'); + await expect(tasksRegion.getByRole('heading',{name:'Sort the recycling',exact:true})).toBeVisible(); }); } diff --git a/frontend/tests/page.test.ts b/frontend/tests/page.test.ts index d596e8cb..a9a7d390 100644 --- a/frontend/tests/page.test.ts +++ b/frontend/tests/page.test.ts @@ -69,6 +69,10 @@ function fixture(deployment: 'native' | 'standalone' = 'standalone', locale = 'e else if (route==='administration/capabilities') raw=JSON.stringify({state:'available',contract_version:2,household_id:'home',exact_revisions:'json-integer-int64', actions:['household.update','member.update','policy.update','member.presentation.update','member.preferences.update'], journal:{namespace:'administration',version:1,maximum_records:8,maximum_bytes:65536,lifetime_ms:3600000}}); + else if (route === 'tasks/overview') raw = JSON.stringify({ + assigned: {total: 1, items: [{occurrence_id: 'work-1', title: 'Wipe table', state: 'assigned'}]}, + unclaimed: {total: 0, items: []}, + }); else if (route==='tasks/access') raw=JSON.stringify({household_id:'home',member_id:memberId,can_create:true,can_review_schedule:canReview, can_manage_points:canManagePoints,can_record_for_others:canManagePoints}); else if (route === 'family/allocation' || route.startsWith('family/allocation?')) raw = JSON.stringify({household:null,override:null}); @@ -732,3 +736,21 @@ test('Inventory owns the current protected destination and accepts only closed u navigate('#tasks'); expect(app.inventory).toBeNull(); }); + +test('Overview summary dispatches an authorized detail read through the Tasks workspace', async () => { + const f = fixture(); f.phase('active'); + const {app} = await f.open(); + await vi.waitFor(() => expect(app.taskOverview?.state).toBe('ready')); + const event = (detail: unknown) => new CustomEvent('domus-task-overview-intent', {detail, bubbles: true, composed: true}); + const unrelated = document.createElement('div'); app.append(unrelated); + unrelated.dispatchEvent(event({type: 'select', occurrenceId: 'work-1'})); + app.dispatchEvent(event({type: 'select', occurrenceId: '../forged'})); + expect(f.navigation).toEqual([]); + const before = f.fetch.mock.calls.filter(([path]) => path.endsWith('/tasks/overview')).length; + app.dispatchEvent(event({type: 'refresh'})); + await vi.waitFor(() => expect(app.taskOverview?.state).toBe('ready')); + expect(f.fetch.mock.calls.filter(([path]) => path.endsWith('/tasks/overview'))).toHaveLength(before + 1); + app.dispatchEvent(event({type: 'select', occurrenceId: 'work-1'})); + await vi.waitFor(() => expect(f.fetch.mock.calls.some(([path]) => path.endsWith('/tasks/occurrences/work-1'))).toBe(true)); + expect(f.navigation).toEqual(['#tasks']); +}); diff --git a/frontend/tests/task-http.test.ts b/frontend/tests/task-http.test.ts index 0b83978f..1ab20623 100644 --- a/frontend/tests/task-http.test.ts +++ b/frontend/tests/task-http.test.ts @@ -294,3 +294,29 @@ test('task detail decodes the current completion allocation affordance before se f.transport.mockResolvedValueOnce(reply({...detail(), completion_points: 'other'})); await expect(f.server.detail('work-1', 'home', context).result).rejects.toThrow('invalid_response'); }); + +test('Overview reads the exact authorized count with a bounded list of validated task rows', async () => { + const f = fixture('native'); + const items = Array.from({length: 25}, (_, index) => ({occurrence_id: 'work-' + index, + title: 'Clean table', state: 'assigned'})); + f.transport.mockResolvedValueOnce(reply({assigned: {total: 37, items}, unclaimed: {total: 0, items: []}})); + const result = await f.server.overview(context).result; + expect(result.assigned.total).toBe(37); + expect(result.assigned.items).toHaveLength(25); + expect(result.assigned.items[0]).toEqual({id: 'work-0', title: 'Clean table', state: 'assigned'}); + const [path, init] = f.transport.mock.calls[0]; + expect(path).toBe(f.target.applicationBase + 'api/v1/tasks/overview'); + expect(init.method).toBe('GET'); + expect(new Headers(init.headers).has('X-Domus-Context')).toBe(true); +}); + +test.each([ + {total: 1, items: null}, + {total: 1, items: []}, + {total: 1, items: [{occurrence_id: 'work', title: 'Clean', state: 'completed'}]}, + {total: 2, items: Array.from({length: 2}, () => ({occurrence_id: 'same', title: 'Clean', state: 'assigned'}))}, +])('Overview rejects an incomplete or inconsistent group', async assigned => { + const f = fixture(); + f.transport.mockResolvedValueOnce(reply({assigned, unclaimed: {total: 0, items: []}})); + await expect(f.server.overview(context).result).rejects.toMatchObject({code: 'invalid_response'}); +}); diff --git a/frontend/tests/task-overview.test.ts b/frontend/tests/task-overview.test.ts new file mode 100644 index 00000000..e5fe20b2 --- /dev/null +++ b/frontend/tests/task-overview.test.ts @@ -0,0 +1,110 @@ +import {afterEach, expect, test, vi} from 'vitest'; +import {EntryReadError} from '../src/application/ports'; +import {TaskOverviewController} from '../src/application/task-overview'; +import type {TaskOverview} from '../src/application/task-overview'; +import '../src/presentation/domus-task-overview'; + +const context = {installationId: '01234567-89ab-cdef-0123-456789abcdef', channel: 'edge' as const, subject: 'a'.repeat(32)}; +const scope = {key: 'first', context}; +const overview: TaskOverview = {assigned: {total: 2, items: [{id: 'work-1', title: 'Fold laundry', state: 'assigned'}]}, + unclaimed: {total: 0, items: []}}; + +function deferred() { + let resolve!: (value: TaskOverview) => void; + let reject!: (error: unknown) => void; + const result = new Promise((done, failed) => {resolve = done; reject = failed;}); + return {result, resolve, reject, cancel: vi.fn()}; +} + +test('Overview retires obsolete responses on refresh and account change', async () => { + const first = deferred(), refresh = deferred(), next = deferred(), closed = deferred(); + const read = vi.fn().mockReturnValueOnce(first).mockReturnValueOnce(refresh) + .mockReturnValueOnce(next).mockReturnValueOnce(closed); + const publish = vi.fn(); + const controller = new TaskOverviewController({overview: read}, publish); + await controller.refresh(); + controller.bind(null); + expect(read).not.toHaveBeenCalled(); + controller.bind(scope); + controller.bind(scope); + expect(read).toHaveBeenCalledTimes(1); + expect(publish).toHaveBeenLastCalledWith({state: 'loading'}); + const retry = controller.refresh(); + expect(first.cancel).toHaveBeenCalledOnce(); + first.resolve(overview); + await first.result; + expect(publish).toHaveBeenLastCalledWith({state: 'loading'}); + + const nextContext = {...context, subject: 'b'.repeat(32)}; + controller.bind({key: 'second', context: nextContext}); + expect(refresh.cancel).toHaveBeenCalledOnce(); + refresh.reject(new Error('stale read')); + await retry; + expect(read).toHaveBeenLastCalledWith(nextContext); + expect(publish).toHaveBeenLastCalledWith({state: 'loading'}); + next.resolve(overview); + await next.result; + expect(publish).toHaveBeenLastCalledWith({state: 'ready', overview}); + + const retired = controller.refresh(); + controller.bind(null); + expect(closed.cancel).toHaveBeenCalledOnce(); + closed.resolve(overview); + await retired; + expect(publish).toHaveBeenLastCalledWith(null); +}); + +test.each([ + [new EntryReadError('forbidden'), 'denied'], + [new EntryReadError('authentication_required'), 'denied'], + [new EntryReadError('invalid_response'), 'unavailable'], + [new Error('local service unavailable'), 'unavailable'], +] as const)('Overview maps %s without exposing an empty count', async (error, state) => { + const request = deferred(), publish = vi.fn(); + const controller = new TaskOverviewController({overview: () => request}, publish); + controller.bind(scope); + request.reject(error); + await request.result.catch(() => {}); + expect(publish).toHaveBeenLastCalledWith({state}); +}); + +afterEach(() => document.querySelectorAll('domus-task-overview').forEach(item => item.remove())); + +test('Overview shows localized states and emits only task selection or retry', async () => { + const element = document.createElement('domus-task-overview'); + document.body.append(element); + const intent = vi.fn(); + element.addEventListener('domus-task-overview-intent', intent); + await element.updateComplete; + expect(element.shadowRoot!.querySelector('section')).toBeNull(); + element.view = {state: 'loading'}; + await element.updateComplete; + const feedback = () => element.shadowRoot!.querySelector('vyp-ha-feedback')!; + expect(feedback().state).toMatchObject({message: 'Loading task summary…'}); + element.view = {state: 'denied'}; + element.language = 'es'; + await element.updateComplete; + expect(feedback().state).toMatchObject({message: expect.stringContaining('Tu acceso actual')}); + expect(element.shadowRoot!.querySelector('vyp-ha-card')).toBeNull(); + element.view = {state: 'unavailable'}; + await element.updateComplete; + expect(feedback().state).toMatchObject({message: expect.stringContaining('No se ha podido cargar')}); + const press = async () => { + const button = element.shadowRoot!.querySelector('vyp-ha-button')!; + await button.updateComplete; + button.shadowRoot!.querySelector('button')!.click(); + return button; + }; + expect((await press()).state.label).toBe('Volver a cargar el resumen de tareas'); + expect(intent.mock.calls.at(-1)![0].detail).toEqual({type: 'refresh'}); + + element.language = 'en'; + element.view = {state: 'ready', overview}; + await element.updateComplete; + expect(Array.from(element.shadowRoot!.querySelectorAll('vyp-ha-card'), card => card.state.title)) + .toEqual(['Assigned to me · 2', 'Unclaimed tasks · 0']); + expect(element.shadowRoot!.textContent).toContain('No tasks in this group.'); + expect(element.shadowRoot!.textContent).toContain('Open Tasks for the full list.'); + expect((await press()).state.label).toBe('Fold laundry · Assigned'); + expect(intent.mock.calls.at(-1)![0].detail).toEqual({type: 'select', occurrenceId: 'work-1'}); +}); diff --git a/specs/CATALOG.md b/specs/CATALOG.md index f3e33e6f..514b78aa 100644 --- a/specs/CATALOG.md +++ b/specs/CATALOG.md @@ -12,7 +12,7 @@ debt or convert unknown historic intent into a design decision. |---|---|---|---|---| | `platform-foundation` | Proposed | One local modular application serves the complete household product in both a Supervisor-managed App and standalone Docker from the first release. Home Assistant owns user authentication; Domus owns its business records. | [Local application platform and persistence](./platform-foundation.md) + 2 companion | 189 paths · 2026-11-01 | | `household-identity` | Proposed | Each participating person uses their own Home Assistant account. Domus associates that verified user with one household member and applies explicit backend permissions independently of an optional person entity. | [Household members, Home Assistant identity and permissions](./household-identity.md) + 4 companion | 222 paths · 2026-11-02 | -| `household-tasks` | Proposed | Members create and perform household responsibilities with explicit assignments, actual performers and history. A recurring definition survives completion of each individual occurrence. | [Task definitions, occurrences and household execution](./household-tasks.md) + 2 companion | 32 paths · 2026-11-01 | +| `household-tasks` | Proposed | Members create and perform household responsibilities with explicit assignments, actual performers and history. A recurring definition survives completion of each individual occurrence. | [Task definitions, occurrences and household execution](./household-tasks.md) + 2 companion | 42 paths · 2026-11-11 | | `recurrence-calendar` | Proposed | A bounded scheduler turns task definitions into stable occurrences and a family calendar distinguishes planned start, deadline and actual completion. Original recurrence outcomes bind receipt status, action, result and source-cycle identity before replay and snapshot acceptance. | [Recurrence engine and family calendar](./recurrence-calendar.md) + 3 companion | 37 paths · 2026-11-09 | | `points-rewards` | Proposed | Task completion produces auditable point entries. Household-configurable collaboration policies determine each share and the actual award total; corrections preserve history and optional rewards never control basic participation. | [Auditable points, participation and optional rewards](./points-rewards.md) | 51 paths · 2026-11-10 | | `shopping-management` | Proposed | Shopping combines manual intent, replenishment and task materials without losing provenance. Buying an item and physically receiving it are separate recorded facts. | [Shared shopping demand, purchases and receipt](./shopping-management.md) | 38 paths · 2026-11-10 | @@ -49,13 +49,13 @@ debt or convert unknown historic intent into a design decision. ### `household-tasks` — Task definitions, occurrences and household execution - Owner: Domus maintainers (review assignment pending) -- Last verified: 2026-11-01 +- Last verified: 2026-11-11 - Specifications: [`specs/household-tasks.md`](./household-tasks.md) · [`specs/task-execution-foundation.md`](./task-execution-foundation.md) · [`specs/household-task-categories.md`](./household-task-categories.md) - Workflows: [`.github/workflows/ci_check.yml`](../.github/workflows/ci_check.yml) -- Entrypoints: Not yet implemented (proposed capability). -- Core code: [`backend/src/domus/domain/task_values.py`](../backend/src/domus/domain/task_values.py) · [`backend/src/domus/domain/task_policy.py`](../backend/src/domus/domain/task_policy.py) · [`backend/src/domus/domain/tasks.py`](../backend/src/domus/domain/tasks.py) · [`backend/src/domus/application/task_ports.py`](../backend/src/domus/application/task_ports.py) · [`backend/src/domus/infrastructure/sqlite_task_records.py`](../backend/src/domus/infrastructure/sqlite_task_records.py) · [`backend/src/domus/infrastructure/sqlite_task_schema.py`](../backend/src/domus/infrastructure/sqlite_task_schema.py) · [`backend/src/domus/infrastructure/sqlite_tasks.py`](../backend/src/domus/infrastructure/sqlite_tasks.py) · [`backend/src/domus/infrastructure/sqlite_task_integrity.py`](../backend/src/domus/infrastructure/sqlite_task_integrity.py) · [`backend/src/domus/application/task_authorization.py`](../backend/src/domus/application/task_authorization.py) · [`backend/src/domus/application/task_commands.py`](../backend/src/domus/application/task_commands.py) · [`backend/src/domus/application/task_requests.py`](../backend/src/domus/application/task_requests.py) -- Tests: [`tests/backend/test_task_values.py`](../tests/backend/test_task_values.py) · [`tests/backend/test_task_policy.py`](../tests/backend/test_task_policy.py) · [`tests/backend/test_tasks.py`](../tests/backend/test_tasks.py) · [`tests/backend/test_sqlite_task_records.py`](../tests/backend/test_sqlite_task_records.py) · [`tests/backend/test_sqlite_tasks.py`](../tests/backend/test_sqlite_tasks.py) · [`tests/backend/test_sqlite_task_integrity.py`](../tests/backend/test_sqlite_task_integrity.py) · [`tests/backend/test_task_restoration.py`](../tests/backend/test_task_restoration.py) · [`tests/backend/test_task_authorization.py`](../tests/backend/test_task_authorization.py) · [`tests/backend/test_task_commands.py`](../tests/backend/test_task_commands.py) · [`tests/backend/test_task_execution_commands.py`](../tests/backend/test_task_execution_commands.py) · [`tests/backend/test_task_edit_commands.py`](../tests/backend/test_task_edit_commands.py) -- User documentation: [`docs/product-vision.md`](../docs/product-vision.md) · [`docs/architecture.md`](../docs/architecture.md) · [`docs/operations.md`](../docs/operations.md) · [`docs/user-guide.md`](../docs/user-guide.md) · [`docs/contracts/home-assistant.md`](../docs/contracts/home-assistant.md) · [`docs/evidence/task-execution-foundation.json`](../docs/evidence/task-execution-foundation.json) · [`docs/tasks/operator-recovery.md`](../docs/tasks/operator-recovery.md) · [`docs/tasks/migration.md`](../docs/tasks/migration.md) · [`docs/tasks/execution.md`](../docs/tasks/execution.md) +- Entrypoints: [`backend/src/domus/entrypoints/task_http.py`](../backend/src/domus/entrypoints/task_http.py) +- Core code: [`backend/src/domus/domain/task_values.py`](../backend/src/domus/domain/task_values.py) · [`backend/src/domus/domain/task_policy.py`](../backend/src/domus/domain/task_policy.py) · [`backend/src/domus/domain/tasks.py`](../backend/src/domus/domain/tasks.py) · [`backend/src/domus/application/task_ports.py`](../backend/src/domus/application/task_ports.py) · [`backend/src/domus/infrastructure/sqlite_task_records.py`](../backend/src/domus/infrastructure/sqlite_task_records.py) · [`backend/src/domus/infrastructure/sqlite_task_schema.py`](../backend/src/domus/infrastructure/sqlite_task_schema.py) · [`backend/src/domus/infrastructure/sqlite_tasks.py`](../backend/src/domus/infrastructure/sqlite_tasks.py) · [`backend/src/domus/infrastructure/sqlite_task_integrity.py`](../backend/src/domus/infrastructure/sqlite_task_integrity.py) · [`backend/src/domus/application/task_authorization.py`](../backend/src/domus/application/task_authorization.py) · [`backend/src/domus/application/task_commands.py`](../backend/src/domus/application/task_commands.py) · [`backend/src/domus/application/task_requests.py`](../backend/src/domus/application/task_requests.py) · [`backend/src/domus/application/task_queries.py`](../backend/src/domus/application/task_queries.py) · [`frontend/src/application/task-overview.ts`](../frontend/src/application/task-overview.ts) · [`frontend/src/adapters/task-http.ts`](../frontend/src/adapters/task-http.ts) · [`frontend/src/presentation/domus-task-overview.ts`](../frontend/src/presentation/domus-task-overview.ts) +- Tests: [`tests/backend/test_task_values.py`](../tests/backend/test_task_values.py) · [`tests/backend/test_task_policy.py`](../tests/backend/test_task_policy.py) · [`tests/backend/test_tasks.py`](../tests/backend/test_tasks.py) · [`tests/backend/test_sqlite_task_records.py`](../tests/backend/test_sqlite_task_records.py) · [`tests/backend/test_sqlite_tasks.py`](../tests/backend/test_sqlite_tasks.py) · [`tests/backend/test_sqlite_task_integrity.py`](../tests/backend/test_sqlite_task_integrity.py) · [`tests/backend/test_task_restoration.py`](../tests/backend/test_task_restoration.py) · [`tests/backend/test_task_authorization.py`](../tests/backend/test_task_authorization.py) · [`tests/backend/test_task_commands.py`](../tests/backend/test_task_commands.py) · [`tests/backend/test_task_execution_commands.py`](../tests/backend/test_task_execution_commands.py) · [`tests/backend/test_task_edit_commands.py`](../tests/backend/test_task_edit_commands.py) · [`tests/backend/test_task_overview.py`](../tests/backend/test_task_overview.py) · [`frontend/tests/task-overview.test.ts`](../frontend/tests/task-overview.test.ts) · [`frontend/tests/task-http.test.ts`](../frontend/tests/task-http.test.ts) · [`frontend/tests/e2e/workspace-navigation.spec.ts`](../frontend/tests/e2e/workspace-navigation.spec.ts) +- User documentation: [`docs/product-vision.md`](../docs/product-vision.md) · [`docs/architecture.md`](../docs/architecture.md) · [`docs/operations.md`](../docs/operations.md) · [`docs/user-guide.md`](../docs/user-guide.md) · [`docs/contracts/home-assistant.md`](../docs/contracts/home-assistant.md) · [`docs/evidence/task-execution-foundation.json`](../docs/evidence/task-execution-foundation.json) · [`docs/tasks/operator-recovery.md`](../docs/tasks/operator-recovery.md) · [`docs/tasks/migration.md`](../docs/tasks/migration.md) · [`docs/tasks/execution.md`](../docs/tasks/execution.md) · [`docs/evidence/overview-task-qualification.md`](../docs/evidence/overview-task-qualification.md) ### `recurrence-calendar` — Recurrence engine and family calendar diff --git a/specs/catalog.json b/specs/catalog.json index 138e57c4..465573b7 100644 --- a/specs/catalog.json +++ b/specs/catalog.json @@ -477,7 +477,7 @@ "status": "proposed", "scope": "Members create and perform household responsibilities with explicit assignments, actual performers and history. A recurring definition survives completion of each individual occurrence.", "owner": "Domus maintainers (review assignment pending)", - "lastVerified": "2026-11-01", + "lastVerified": "2026-11-11", "specs": [ "specs/household-tasks.md", "specs/task-execution-foundation.md", @@ -486,7 +486,9 @@ "workflows": [ ".github/workflows/ci_check.yml" ], - "entrypoints": [], + "entrypoints": [ + "backend/src/domus/entrypoints/task_http.py" + ], "code": [ "backend/src/domus/domain/task_values.py", "backend/src/domus/domain/task_policy.py", @@ -498,7 +500,11 @@ "backend/src/domus/infrastructure/sqlite_task_integrity.py", "backend/src/domus/application/task_authorization.py", "backend/src/domus/application/task_commands.py", - "backend/src/domus/application/task_requests.py" + "backend/src/domus/application/task_requests.py", + "backend/src/domus/application/task_queries.py", + "frontend/src/application/task-overview.ts", + "frontend/src/adapters/task-http.ts", + "frontend/src/presentation/domus-task-overview.ts" ], "tests": [ "tests/backend/test_task_values.py", @@ -511,7 +517,11 @@ "tests/backend/test_task_authorization.py", "tests/backend/test_task_commands.py", "tests/backend/test_task_execution_commands.py", - "tests/backend/test_task_edit_commands.py" + "tests/backend/test_task_edit_commands.py", + "tests/backend/test_task_overview.py", + "frontend/tests/task-overview.test.ts", + "frontend/tests/task-http.test.ts", + "frontend/tests/e2e/workspace-navigation.spec.ts" ], "documentation": [ "docs/product-vision.md", @@ -522,11 +532,12 @@ "docs/evidence/task-execution-foundation.json", "docs/tasks/operator-recovery.md", "docs/tasks/migration.md", - "docs/tasks/execution.md" + "docs/tasks/execution.md", + "docs/evidence/overview-task-qualification.md" ], "readiness": { "state": "draft", - "implementationEvidence": "partial: task lifecycle/rules, schema-5 storage/restore, shared current authority, typed requests and durable lifecycle/policy/definition/occurrence/dependency editors; 2044 whole-backend tests, 5741 statements and 1624 branches at 100%; public queries/history/HTTP and actual material/consumer/review projections remain incomplete", + "implementationEvidence": "partial: task lifecycle/rules, schema-5 storage/restore, shared current authority, typed requests and durable lifecycle/policy/definition/occurrence/dependency editors; 2044 whole-backend tests, 5741 statements and 1624 branches at 100%; public queries/history/HTTP and actual material/consumer/review projections remain incomplete; protected Overview summary exercised in compiled native and standalone browser journeys with exact authorized group counts and task detail navigation", "blockingDecisions": "A34 prerequisite gating and A35 same-task points remainder rotation are owner-confirmed. Bounded queries/history/APIs, material intents/settlement, dependency-review projection and actual Inventory/Points/recurrence consumers, task UI and deployment acceptance remain implementation gates; first-release advanced task-type review remains separate.", "copilotChangesAllowed": false } diff --git a/specs/household-tasks.md b/specs/household-tasks.md index b71f031d..3b97ab23 100644 --- a/specs/household-tasks.md +++ b/specs/household-tasks.md @@ -353,3 +353,321 @@ These are internal implementation steps within the first integrated release; the Primary sources: [Copilot standard](https://github.com/vypdev/copilot/blob/f5e5a4cf9a80248994469cd88ad55eecab5b95ca/specs/README.md), [original template](https://github.com/vypdev/copilot/blob/f5e5a4cf9a80248994469cd88ad55eecab5b95ca/specs/_template.md), and the linked [reference investigation](../docs/reference-investigation.md). Confirmed owner choices and unresolved proposals are separated in [decisions](../docs/decisions.md). [Issue #2](https://github.com/vypdev/domus/issues/2) tracks the documentation foundation. The [adoption note](../docs/copilot-adoption.md) records the current catalog evidence limitation. Optional future depth remains explicitly deferred in the product vision; the gateway's installation and MCP internals are outside Domus scope. + +## Proposed change: Show assigned and unclaimed household tasks on Overview + +- Status: Draft +- Catalog capability: household-tasks + +### 1. Executive summary + +This update adds two task summaries to Overview. “Assigned to me” shows the current member’s tasks in the existing Assigned, In progress, and Blocked states; “Unclaimed” shows Available tasks with no assignees. Both use current Tasks read authority, the authoritative household snapshot, and existing bounded Tasks ordering. A selected task opens its protected detail in Tasks. + +```text +Open Overview -> read authorized household snapshot -> show the two task groups and exact counts -> open a selected task in Tasks +``` + +The existing `specs/household-tasks.md` contract and cases remain authoritative for task states, permissions, ordering, and protected details. This delta adds Overview visibility; it does not claim the behavior is implemented. + +### 2. Problem, current behavior, and evidence + +#### 2.1 Problem + +Members currently go to the paginated Tasks workspace to find their assigned or unclaimed work. The visible page cannot establish totals. The proposed Overview summaries let a member see relevant open work on entry and proceed directly to a protected task detail. + +#### 2.2 Current behavior + +The retained task contract defines task states, assignment, household authorization, and history in `specs/household-tasks.md`. This update proposes surfacing a bounded summary of those existing task facts on Overview; it does not change their meaning or imply that the new summaries already exist. + +#### 2.3 Evidence + +The requested behavior and current limitation are described in issue https://github.com/vypdev/domus/issues/92. The immutable selected owner is `specs/household-tasks.md`; its sections 1–6 define the prospective task contract, including separate task definitions and occurrences, assignments, state transitions, and household-scoped permissions. The owner records implementation as pending, so this update makes no claim of runtime verification. The issue’s proposed summaries, counts, ordering, navigation, and failure distinction are acceptance requirements for this delta. + +### 3. Actors, surfaces, and terminology + +The household member is the actor. Overview is the entry surface and shows the two task groups. Tasks remains the protected workspace for task details and the existing task journeys. + +“Assigned to me” means tasks assigned to the current member in Assigned, In progress, or Blocked state. “Unclaimed” means Available tasks with no assignees. The count is the exact count from the authoritative household snapshot, subject to the existing bounded Tasks ordering. A visible page of paginated tasks is not the source of a total. “Empty” means a successful authorized read with no matching tasks; it is distinct from a read failure. + +### 4. Goals, non-goals, and fixed invariants + +#### 4.1 Goals + +1. On Overview, show the current member’s Assigned, In progress, and Blocked tasks in “Assigned to me,” and Available tasks with no assignees in “Unclaimed.” +2. Show each group’s exact count from the authoritative household snapshot, apply existing bounded Tasks ordering, distinguish an empty group from a read failure, and open selected task details in the protected Tasks workspace using keyboard or touch. + +#### 4.2 Non-goals + +1. Changing task states, assignment rules, authorization policy, pagination, or task-detail behavior defined by the retained owner. +2. Adding task creation, claiming, reassignment, or other task mutations to Overview. + +#### 4.3 Fixed product/safety invariants + +1. Both groups and their counts require current Tasks read authority. Without it, Overview must not disclose protected task data or counts and must communicate read failure distinctly from an empty result. +2. Group membership, counts, and ordering must derive from the authoritative household snapshot and existing Tasks behavior; the visible paginated page must not be used to infer totals. +3. Opening a task must lead to its protected detail in Tasks and preserve existing authorization checks. + +| Requirement | Behavior | +| --- | --- | +| SDD-I92-U1-R1 | Overview MUST show an Assigned to me group for the current member using existing Assigned, In progress, and Blocked states, and an Unclaimed group using existing Available tasks with no assignees. Both groups MUST respect current Tasks read authority, show exact counts from the authoritative household snapshot using existing bounded Tasks ordering, distinguish an empty group from a read failure, and open selected task details in the protected Tasks workspace with keyboard and touch input. | + +### 5. Current versus proposed product journey + +For issue [#92](https://github.com/vypdev/domus/issues/92), extend the Overview journey with two task summaries. A member with current Tasks read authority sees “Assigned to me” for their Assigned, In progress, and Blocked tasks, and “Unclaimed” for Available tasks with no assignees. Each group shows the exact count from the authoritative household snapshot and follows the existing bounded Tasks ordering. The member can open a task’s protected detail in Tasks using keyboard or touch. An empty group is presented as empty; a read failure remains visibly distinct. Without current Tasks read authority, neither group nor its count reveals protected task data. This increment adds the task summaries to the existing owner journey; other Overview summaries remain outside this delta. + +### 6. Functional behavior and state model + +The Overview derives both groups from the current authoritative household snapshot under current Tasks read authority. “Assigned to me” includes only tasks assigned to the current member in the existing Assigned, In progress, or Blocked states. “Unclaimed” includes only Available tasks with no assignees. Use the existing bounded Tasks ordering and exact snapshot counts; do not infer a household total from a paginated visible page. Refresh or otherwise obtain a current authorized snapshot before presenting the summaries, and do not treat unavailable or incomplete data as zero. + +Render each task as an accessible, keyboard- and touch-operable selection that opens its protected detail in the Tasks workspace. Preserve the existing task state and authorization rules. Distinguish a successful empty result from a failed or unauthorized read: failures must not disclose task content or counts and must provide truthful failure feedback rather than an empty-state message. + +### 7. User-facing configuration + +No new user-facing configuration is introduced. The summaries use the current member, existing task states, assignees, Tasks read authority, and established Tasks ordering. + +### 8. Clean Architecture design + +Add the Overview summary as a presentation of the existing Tasks read contract. The application-side read must enforce current Tasks authority and return only the authorized task facts and exact counts needed for these groups; the Overview must not derive protected data or household totals from client state or a paginated page. Keep task-state and authorization semantics in the existing domain and application boundaries, with presentation limited to rendering the authorized result and its loading, empty, and failure states. + +Selecting a summary item routes to the existing protected task detail in Tasks. Keep the summary and detail authorization checks current; a rendered item or stale Overview snapshot grants no access. Build the interaction with the published ha-ui components and preserve keyboard and touch operation. The existing owner contract remains in `specs/household-tasks.md`; the roadmap identifies authoritative permission-scoped Overview projections and the shared component ownership in `docs/roadmap.md`. + +### 9. UI/UX and content contract + +The Overview adds two task summaries within the existing household surface. “Assigned to me” includes only the current member’s tasks in Assigned, In progress, or Blocked states. “Unclaimed” includes only Available tasks with no assignees. Both summaries use current Tasks read authority, the authoritative household snapshot for exact counts, and the existing bounded Tasks ordering; a paginated page is not a source for totals. These are summaries, not new task states or assignment controls. Selecting a task opens its protected detail in the Tasks workspace. + +```text +Assigned to me · 3 +Laundry — In progress +Take out recycling — Assigned +Fix the tap — Blocked + +Unclaimed · 1 +Water the plants — Available +``` + +Each group has a localized heading and count. Each task is a descriptive, keyboard-focusable and touch-operable link or control with an accessible name that identifies the task and its state; state is conveyed by text, not color alone. An empty group has a clear empty message and a zero count. Loading, unavailable data, and denied authority must not be rendered as an empty group or zero. Follow the existing English/Spanish translation-key, base-language matching, and English-fallback conventions. Preserve responsive narrow and wide layouts, visible focus, light/dark contrast, and reduced-motion behavior. Existing task labels and state terminology are defined in `frontend/src/presentation/task-messages.ts`; the established shell and Overview region are in `frontend/src/presentation/domus-app.ts`. Acceptance covers the assigned summary, unclaimed summary, empty-versus-failure distinction, and protected navigation as specified by `inventory1-C01`, `inventory1-C02`, and `inventory1-C03`. + +### 10. Failure, recovery, and cleanup + +If the task summary read is loading, unavailable, or incomplete, identify that the summary could not be loaded and offer the existing safe retry or navigation path when available. Keep failure visibly distinct from a successful empty result; never substitute zero or a count inferred from one page. If access is denied or no longer current, hide task rows and counts and explain that current Tasks access is required. Do not retry indefinitely or change task state as part of summary recovery. A task that changes between summary display and selection is resolved by the protected Tasks detail flow, which remains authoritative. These are read-only summaries and create no task-side effects or cleanup work. The distinction between unavailable or incomplete projections and zero totals is also required by `docs/roadmap.md`. + +### 11. Security, permissions, and privacy + +Both groups and their counts are protected by current Tasks read authority. Derive the member and household context from the authenticated application context; do not treat a selected member, URL fragment, task identifier, or rendered component event as authority. On denial, expired access, or a context change, disclose neither rows nor counts and present a failure state rather than an empty result. Only validated summary data may reach the Overview renderer; task detail navigation must return to the protected Tasks workspace, where its existing authorization checks apply. Render task titles and other user-controlled values as inert text, without arbitrary HTML or executable links. Do not add credentials, household details, or task data to diagnostics. These rules extend the existing read authorization and untrusted-input contract in `specs/household-tasks.md`. + +### 12. Observability and operational UX + +Members can tell whether each group is loading, populated, empty, or unavailable, and can reach the Tasks workspace for the full list or a selected detail. A failed read must not be reported as a successful count. Operational evidence may distinguish denied, unavailable, and incomplete summary reads using existing sanitized error handling; it must not include task titles, member names, household identifiers, credentials, or unrestricted payloads. Do not add telemetry leaving the installation or duplicate notifications for these read outcomes. No concrete new metric, logging hook, or verification invocation is established for this delta; its implementation prerequisite remains unverified. + +### 13. Compatibility, migration, rollout, and rollback + +This is a read-only presentation and projection change. Keep existing task states, authorization rules, bounded ordering, Tasks detail behavior, and persisted read schema compatible; do not add stored task records or migrate existing task data for these summaries. The summary must be based on the authoritative household snapshot and remain correct beyond the visible paginated Tasks page. Verify the behavior in both supported locales, relevant responsive compositions and deployment architectures, with disposable test data, as called for by the issue. Installed Edge-candidate acceptance remains an explicit product-validation outcome; no result is established by this draft. No specific installed invocation for the full specification/catalog checks or Edge acceptance is established here, so those concrete invocations and prerequisites remain unverified. + +### 14. Testing strategy and numeric budget + +Add a minimum of three distinct cases for this delta, one for each supplied Overview behavior: authorized assigned-task presentation and protected detail navigation; authorized unclaimed-task presentation with empty-result distinction; and denial without task-data disclosure. These cases supplement the immutable testing strategy and retained cases in `specs/household-tasks.md` (sections 14 and 16); they do not replace its existing coverage or establish that any test has run. Each case must use the authoritative household snapshot, verify exact counts and the existing bounded Tasks ordering where applicable, and cover keyboard and touch navigation. Exercise read failure separately from an empty group and verify that missing current Tasks read authority protects both task groups and their counts. Verify the specification satisfies the required format; check internal and cross-document consistency; and verify reciprocal catalog ownership, paths, and evidence agree with the generated view. The selected root `package.json` declares pnpm 10.34.0 and scripts including `test`, but does not declare the `validate:specifications` or `generate:specifications` invocations recommended in `specs/README.md`. The concrete publication-check invocation and prerequisites remain unverified; declarations are not execution, passing checks, or product acceptance. + +| Area | Minimum distinct cases | Behaviors/risks covered | +|---|---:|---| +| Overview | 2 | Observable scenarios in the case inventory. | +| Security and recovery | 1 | Observable scenarios in the case inventory. | +| Total | 3 | Distinct inventory cases; repeated executions do not add cases. | + +| Case ID | Area | Requirements | Scenario | +| --- | --- | --- | --- | +| inventory1-C01 | Overview | SDD-I92-U1-R1 | With Tasks read authority, the current member sees only their Assigned, In progress, and Blocked tasks in Assigned to me, ordered by the existing bounded Tasks ordering; the displayed count matches the authoritative household snapshot, and selecting a task opens its protected detail in Tasks by keyboard or touch. | +| inventory1-C02 | Overview | SDD-I92-U1-R1 | With Tasks read authority, Unclaimed contains only Available tasks with no assignees; its displayed count matches the authoritative household snapshot, and an empty group is distinguishable from a read failure. | +| inventory1-C03 | Security and recovery | SDD-I92-U1-R1 | Without current Tasks read authority, neither task group nor its counts disclose protected task data, and the Overview distinguishes the read failure from an empty result. | + +### 15. Documentation and discoverability + +Update the existing household-task user guidance to explain that Overview summarizes the current member’s Assigned, In progress, and Blocked tasks and household Available tasks with no assignees. Explain exact snapshot counts, bounded ordering, the difference between an empty group and a read failure, and that selecting a task opens its protected detail in Tasks. Document that current Tasks read authority governs both groups and their counts, and that keyboard and touch input are supported. Keep this delta within the existing ownership and documentation structure in `specs/household-tasks.md`; the concrete user-document location and any additional path changes are not established by the supplied inventory. The inventory declares only the update to `specs/household-tasks.md`; it is an operation declaration, not evidence of changed files. Publication checks and their concrete invocation remain as described in section 14. + +| Path | Change | +| --- | --- | +| specs/household-tasks.md | update | + +[specs/household-tasks.md](household-tasks.md) + +### 16. Acceptance scenarios + +1. With current Tasks read authority, the current member sees only their Assigned, In progress, and Blocked tasks in “Assigned to me,” in the existing bounded Tasks ordering. Its count matches the authoritative household snapshot, and selecting a task opens its protected detail in Tasks by keyboard or touch. This is the observable assertion for `inventory1-C01`. +2. With current Tasks read authority, “Unclaimed” contains only Available tasks with no assignees, and its count matches the authoritative household snapshot. An empty group is distinguishable from a read failure. This is the observable assertion for `inventory1-C02`. +3. Without current Tasks read authority, neither task group nor its count discloses protected task data, and Overview distinguishes the read failure from an empty result. This is the observable assertion for `inventory1-C03`. + +These are the three supplied new case identities. Existing task and companion owner cases remain references under their immutable contracts; no new case identity is inferred for them. + +### 17. Requirements traceability + +`SDD-I92-U1-R1` requires Overview to show the current member’s Assigned, In progress, and Blocked tasks and the household’s Available tasks with no assignees; respect current Tasks read authority; show exact authoritative-snapshot counts using existing bounded Tasks ordering; distinguish empty results from read failures; and open protected task details in Tasks by keyboard and touch. `inventory1-C01` exercises assigned-task filtering, ordering, count, and protected keyboard/touch detail navigation. `inventory1-C02` exercises unclaimed-task filtering, count, and empty-versus-failure distinction. `inventory1-C03` exercises denial and non-disclosure for both groups and counts, including failure-versus-empty presentation. Existing behavior and cases remain owned by the immutable `specs/household-tasks.md` contract. Publication acceptance also requires required-format conformance, an internal and cross-document consistency check, and reciprocal catalog ownership, paths, and evidence agreeing with the generated view; the concrete invocation and prerequisites remain unverified in the selected source. + +| Requirement | Cases | +|---|---| +| SDD-I92-U1-R1 | inventory1-C01, inventory1-C02, inventory1-C03 | + +### 18. Implementation sequence + +1. Finalize the Overview query and presentation contract against the retained task state, authorization, bounded ordering, and protected detail behavior in `specs/household-tasks.md` and `specs/task-execution-foundation.md`. +2. Implement the authoritative, permission-scoped summary so it returns the current member’s Assigned, In progress, and Blocked tasks and Available tasks with no assignees, preserving existing ordering and bounded limits. +3. Add the Overview groups, exact snapshot counts, distinct empty and read-failure states, and protected Tasks detail navigation. Keep keyboard and touch interaction accessible and localized in English and Spanish. +4. Add focused acceptance coverage for both groups, counts, ordering, selection, empty results, and denied or failed reads; include the Overview in supported compositions and architectures and use disposable test data for the installed Edge candidate. +5. Update the owning contract and reciprocal catalog evidence with the verified paths and validation evidence before publication. The selected declarations establish pnpm 10.34.0 with Node `>=24.20.0 <25` and uv/Python `>=3.14,<3.15`; no task-specific verification invocation or prerequisite was verified here. + +### 19. Definition of Done + +- [ ] Overview shows only the current member’s Assigned, In progress, and Blocked tasks under “Assigned to me,” and only Available tasks with no assignees under “Unclaimed.” Both groups use the authoritative household snapshot, exact counts, and existing bounded Tasks ordering. +- [ ] Current Tasks read authority protects both groups and their counts. A read failure is visibly distinct from a successful empty result, and failure or denied authority discloses no protected task data. +- [ ] Selecting a task opens its protected detail in the Tasks workspace with keyboard and touch input. The groups and states remain accessible and localized in both supported locales and compositions. +- [ ] The three supplied Overview cases are implemented with their concrete observable assertions; requirement `SDD-I92-U1-R1` maps to cases that exercise each specified behavior. +- [ ] Required test, coverage, architecture, localization, and product-validation outcomes are satisfied. The concrete task-specific invocation and prerequisites remain unverified; no command declaration is execution or passing evidence. +- [ ] The specification satisfies the required format; internal and cross-document consistency is checked; reciprocal catalog ownership, paths, and evidence agree with the generated view. +- [ ] No publication outcome is inferred from structural inventory counts or from a declared check alone. + +### 20. References and decisions + +- Issue: https://github.com/vypdev/domus/issues/92. +- This is a bounded update to the immutable retained owner `specs/household-tasks.md`; its existing contract and cases remain in force. `specs/task-execution-foundation.md` supplies the existing task lifecycle, authorization, bounded query, and protected task-detail context. `specs/household-task-categories.md` remains unchanged. +- The delta adds assigned and unclaimed task summaries to Overview while retaining the existing task states, read authority, ordering, and detail workspace. It adds no task mutations or changes to the task read schema. +- Selected declarations identify pnpm 10.34.0 with Node `>=24.20.0 <25` and uv/Python `>=3.14,<3.15`. The concrete invocation and prerequisites for complete coverage, both locales, compositions, architectures, and installed Edge-candidate validation remain unverified. + +## Qualify bounded and scoped Overview task summaries + +- Status: Draft +- Owners: Domus maintainers and Tasks +- Scope: Additional qualification of the already published Overview task read +- Open decisions blocking readiness: none + +### 1. Executive summary + +Record two focused acceptance cases for the Overview read. Verify the +difference between a group total and a bounded preview, and prove that +a delayed read cannot survive a household context change. + +### 2. Problem, current behavior, and evidence + +Issue 92's first published SDD defines both task groups and three cases. +The implementation uses a fixed 25-item preview with exact counts and +cancellable browser reads. It has distinct witnesses for large groups +and delayed replies, beyond the original basic group and denial cases. + +### 3. Actors, surfaces, and terminology + +A current member reads Overview. A preview is the bounded set of task +rows from the same authorized snapshot as the exact count. A context +retirement invalidates every pending read bound to the old identity. + +### 4. Goals, non-goals, and fixed invariants + +| Requirement | Behavior | +|---|---| +| overview-task-evidence-R01 | A group larger than the existing Tasks page bound keeps its exact authorized total, includes only its bounded ordered preview, and is unavailable if the transport returns an incomplete or inconsistent preview. | +| overview-task-evidence-R02 | Replacing or retiring the verified Overview context clears its private result, cancels its owned read and discards a response delivered after retirement. | + +Preserve all three previously published cases and the existing user +journey. These assertions qualify the authorized read already in issue 92. + +### 5. Current versus proposed product journey + +Observe exact counts on Overview even when the group exceeds one page. +After leaving a verified context, only a current authorized response +can fill the next Overview. + +### 6. Functional behavior and state model + +The read returns one exact total and at most 25 rows per group. The UI +checks that each preview has the expected size and unique task IDs. +Loading, unavailable and retired states carry no private rows or counts. + +### 7. User-facing configuration + +Use the current household membership, Tasks read permission, locale +and existing page bound. + +### 8. Clean Architecture design + +Application owns the authorized snapshot and group meaning. SQLite reads +counts and ordered bounded rows in the same transaction. The HTTP adapter +validates the private response. The browser controller owns cancellation +and does not use retired results. + +### 9. UI/UX and content contract + +Display the exact count beside the group title. A shortened preview +points to the existing Tasks workspace. A failed or superseded read +cannot populate the summary. + +### 10. Failure, recovery, and cleanup + +A malformed or incomplete result shows the existing unavailable state. +Retry rechecks current authority. Retirement clears old facts while +retaining the existing application navigation. + +### 11. Security, permissions, and privacy + +The transport uses the verified installation, channel and subject. +The application resolves the current household member and permission. +A late reply never authorizes disclosure in a new context. + +### 12. Observability and operational UX + +Record test evidence for count completeness and discarded late results. +Use the existing sanitized read errors in the user interface. + +### 13. Compatibility, migration, rollout, and rollback + +The read uses the existing SQLite schema 30. Verify the pinned Edge.12 +runtime and the same-head application and image checks. + +### 14. Testing strategy and numeric budget + +Minimum two distinct cases. + +| Area | Minimum distinct cases | Behaviors/risks covered | +|---|---:|---| +| Bounded snapshot | 1 | Observable scenarios in the case inventory. | +| Context retirement | 1 | Observable scenarios in the case inventory. | +| Total | 2 | Distinct inventory cases; repeated executions do not add cases. | + +| Case ID | Area | Requirements | Scenario | +|---|---|---|---| +| overview-task-evidence-C01 | Bounded snapshot | overview-task-evidence-R01 | Seed more than 25 matching rows in both groups. Verify exact totals and the ordered first 25. Pass an incomplete or duplicated preview to the transport decoder and verify the read fails. | +| overview-task-evidence-C02 | Context retirement | overview-task-evidence-R02 | Delay a valid read while changing verified subject or retiring the view. Complete the old read after the change and verify that no old rows or counts appear. Resolve a current read and observe its own result. | + +### 15. Documentation and discoverability + +[specs/household-tasks.md](household-tasks.md) · [docs/evidence/overview-task-qualification.md](../docs/evidence/overview-task-qualification.md) · [tests/backend/test\_task\_overview.py](../tests/backend/test_task_overview.py) · [frontend/tests/task-overview.test.ts](../frontend/tests/task-overview.test.ts) · [frontend/tests/task-http.test.ts](../frontend/tests/task-http.test.ts) + +| Path | Change | +|---|---| +| specs/household-tasks.md | update | +| docs/evidence/overview-task-qualification.md | reference | +| tests/backend/test_task_overview.py | reference | +| frontend/tests/task-overview.test.ts | reference | +| frontend/tests/task-http.test.ts | reference | + +### 16. Acceptance scenarios + +Run the bounded snapshot and context retirement witnesses. Keep the +three original Overview cases under their published identifiers. + +### 17. Requirements traceability + +| Requirement | Cases | +|---|---| +| overview-task-evidence-R01 | overview-task-evidence-C01 | +| overview-task-evidence-R02 | overview-task-evidence-C02 | + +### 18. Implementation sequence + +Trace the existing backend, transport and controller checks to the two +qualification cases and run the same-head application and image checks. + +### 19. Definition of Done + +Both new witnesses pass with the already published Overview contract, +complete coverage and the exact installed Edge.12 candidate. + +### 20. References and decisions + +Issue 92 and its first verified publication own the Overview behavior. +This revision adds explicit evidence for the page bound and delayed reads. diff --git a/tests/backend/test_app_package.py b/tests/backend/test_app_package.py index b06d157f..4bd76cd1 100644 --- a/tests/backend/test_app_package.py +++ b/tests/backend/test_app_package.py @@ -15,7 +15,7 @@ def test_repository_and_edge_manifest_offer_native_ha_entry_without_user_credent manifest = yaml.safe_load((ROOT / "addon-edge/config.yaml").read_text()) assert repository["url"] == "https://github.com/vypdev/domus" assert manifest["slug"] == "domus_edge" and manifest["stage"] == "experimental" - assert manifest["boot"] == "manual" and manifest["version"] == "0.0.0-edge.11" + assert manifest["boot"] == "manual" and manifest["version"] == "0.0.0-edge.12" assert manifest["ingress"] is True and manifest["ingress_port"] == 8099 assert manifest["panel_admin"] is False and manifest["homeassistant_api"] is True assert manifest["options"] == {"public_origins": []} @@ -53,15 +53,15 @@ def test_build_pins_source_checksum_bases_lock_and_nonroot_native_entrypoint() - commits = re.findall(r"^ARG DOMUS_SOURCE_COMMIT=(\w+)$", source, re.MULTILINE) assert len(commits) == 2 and len(set(commits)) == 1 assert re.fullmatch(r"[a-f0-9]{40}", commits[0]) - assert commits[0] == "7e869ff0d1755def7d06046ba5ea48150a26ccfb" + assert commits[0] == "3a803ddce3092abcd9da48c8533c65d24e2e0e37" assert ( - "DOMUS_SOURCE_SHA256=a65ec787de95548bbce7e70f834e9101055bba335301e22fb18d17c424b79200" + "DOMUS_SOURCE_SHA256=6eaaf75c60a7582e21da627dc17f9cb9dcad007e0ab90c433d61d311cbf8363b" in source ) - assert "ARG BUILD_VERSION=0.0.0-edge.11" in source + assert "ARG BUILD_VERSION=0.0.0-edge.12" in source candidate = json.loads((ROOT / "addon-edge/artifact.json").read_text()) assert candidate["sourceCommit"] == commits[0] - assert candidate["version"] == "0.0.0-edge.11" + assert candidate["version"] == "0.0.0-edge.12" assert "DOMUS_SOURCE_SHA256=" + candidate["sourceArchiveSHA256"] in source assert re.search(r"^ARG DOMUS_SOURCE_SHA256=[a-f0-9]{64}$", source, re.MULTILINE) assert "sha256sum --check" in source @@ -129,8 +129,8 @@ def test_edge_artifact_declares_exact_reviewed_runtime_without_rebinding_histori "pythonFiles", "uiFiles", } - assert artifact["schemaVersion"] == 1 and artifact["version"] == "0.0.0-edge.11" - assert artifact["sourceCommit"] == "7e869ff0d1755def7d06046ba5ea48150a26ccfb" + assert artifact["schemaVersion"] == 1 and artifact["version"] == "0.0.0-edge.12" + assert artifact["sourceCommit"] == "3a803ddce3092abcd9da48c8533c65d24e2e0e37" assert artifact["storageSchema"] == 30 for field in ["sourceArchiveSHA256", "wheelSHA256"]: assert re.fullmatch("[a-f0-9]{64}", artifact[field]) diff --git a/tests/backend/test_task_overview.py b/tests/backend/test_task_overview.py new file mode 100644 index 00000000..54ed3cd0 --- /dev/null +++ b/tests/backend/test_task_overview.py @@ -0,0 +1,91 @@ +"""Read authoritative Overview counts through both protected task compositions.""" + +from dataclasses import replace + +from test_task_runtime import api as api +from test_tasks import definition + +from domus.domain.identity import Member, MemberStatus, Permission, PermissionRule, Role +from domus.domain.task_values import OccurrenceState, TaskRules +from domus.domain.tasks import HouseholdTaskPolicy + +OVERVIEW = "/api/v1/tasks/overview" +OTHER_USER = "b" * 32 + + +def test_overview_groups_authorized_records_and_counts_beyond_the_page(api): + empty = {"total": 0, "items": []} + assert api.client.get(OVERVIEW).json() == {"assigned": empty, "unclaimed": empty} + assert api.client.get(OVERVIEW, params={"member_id": "other"}).status_code == 422 + + task = definition() + with api.store.write() as unit: + member = unit.members.list("home")[0] + unit.members.save( + Member("other", "home", OTHER_USER, Role.ADULT, MemberStatus.ACTIVE, 1), 0 + ) + unit.tasks.save_policy(HouseholdTaskPolicy("home", TaskRules()), 0) + unit.tasks.save_definition(task, 0) + for number in range(27): + unit.tasks.save_occurrence(task.new_occurrence(f"unclaimed-{number:02}", 20), 0) + unit.tasks.save_occurrence( + task.new_occurrence(f"assigned-{number:02}", 20, assignees=(member.member_id,)), + 0, + ) + blocked = task.new_occurrence("blocked", 20, assignees=(member.member_id,)) + unit.tasks.save_occurrence(blocked, 0) + unit.tasks.save_occurrence(blocked.transition(OccurrenceState.BLOCKED, "Waiting"), 1) + started = task.new_occurrence("started", 20, assignees=(member.member_id,)) + unit.tasks.save_occurrence(started, 0) + unit.tasks.save_occurrence(started.transition(OccurrenceState.IN_PROGRESS), 1) + other = task.new_occurrence("other-task", 20, assignees=("other",)) + unit.tasks.save_occurrence(other, 0) + closed = task.new_occurrence("closed", 20, assignees=(member.member_id,)) + unit.tasks.save_occurrence(closed, 0) + unit.tasks.save_occurrence(closed.transition(OccurrenceState.CANCELLED, "Done"), 1) + + response = api.client.get(OVERVIEW) + assert response.status_code == 200, response.text + report = response.json() + assert report["assigned"] == { + "total": 29, + "items": [ + {"occurrence_id": f"assigned-{number:02}", "title": "Wipe table", "state": "assigned"} + for number in range(25) + ], + } + assert report["unclaimed"] == { + "total": 27, + "items": [ + {"occurrence_id": f"unclaimed-{number:02}", "title": "Wipe table", "state": "available"} + for number in range(25) + ], + } + assert api.client.get("/api/v1/tasks/occurrences/assigned-00").status_code == 200 + + with api.store.write() as unit: + for number in range(27): + item = unit.tasks.occurrence("home", f"assigned-{number:02}") + unit.tasks.save_occurrence(item.assign(("other",)), item.revision) + refreshed = api.client.get(OVERVIEW).json() + assert refreshed["assigned"] == { + "total": 2, + "items": [ + {"occurrence_id": "blocked", "title": "Wipe table", "state": "blocked"}, + {"occurrence_id": "started", "title": "Wipe table", "state": "in_progress"}, + ], + } + assert refreshed["unclaimed"] == report["unclaimed"] + + +def test_overview_requires_current_task_read_authority(api): + assert api.client.get(OVERVIEW).status_code == 200 + with api.store.write() as unit: + member = unit.members.list("home")[0] + unit.members.save( + replace(member, exceptions=(PermissionRule(Permission.TASKS_READ, False),), revision=2), + 1, + ) + denied = api.client.get(OVERVIEW) + assert denied.status_code == 403 + assert "assigned" not in denied.json() and "unclaimed" not in denied.json()