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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions addon-edge/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,25 @@
# Changelog

## 0.0.0-edge.28

- Refresh the Family summary when the household week changes while Overview is open.

## 0.0.0-edge.27

- Show completed tasks and posted earned points for the current Family week on Overview.
- Open Family from the localized summary to review the full report and pending values.

## 0.0.0-edge.26

- Let people with task configuration permission set optional base points when creating a task.
- Keep the household default for title-only creation and accept localized decimal input.
- Explain how to correct a fractional amount when the current allocation requires whole base points.

## 0.0.0-edge.22

- Show completed tasks and posted earned points for the current Family week on Overview in English and Spanish.
- Open Family from the summary to review pending work and the full report.

## 0.0.0-edge.21

- Use singular units when reviewing an intake of exactly one item in English and Spanish.
Expand Down
13 changes: 7 additions & 6 deletions addon-edge/DOCS.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# Installation and operation

Edge 0.0.0-edge.26 packages the immutable runtime declared in
[artifact.json](artifact.json). People with task configuration permission can set
optional base points when creating a task. Leaving the field empty uses the
household default. Home Assistant can read the same due-today and
overdue task counts shown on Overview through a dedicated installation grant.
Enable the [native deadline sensors](../docs/tasks/ha-deadline-sensors.md) using
Edge 0.0.0-edge.28 packages the immutable runtime declared in
[artifact.json](artifact.json). Overview shows the signed-in member's completed tasks and
posted earned points for the current Family week. Open Family for the full report.
People with task configuration permission can set optional base points when creating a task.
Leaving the field empty uses the household default. Home Assistant can read
the due-today and overdue task counts shown on Overview through a dedicated installation
grant. Enable the [native deadline sensors](../docs/tasks/ha-deadline-sensors.md) using
the optional `ha_deadline_digest` setting. The calendar uses its own
`ha_calendar_digest` setting. Both share the private app port `8100` when enabled.
This preview retains SQLite schema 31. Edge.13 introduced that schema and
Expand Down
8 changes: 4 additions & 4 deletions addon-edge/Dockerfile
Original file line number Diff line number Diff line change
@@ -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=691496c299ff371763e445acb9d36b9623a81404
ARG DOMUS_SOURCE_SHA256=535c0b95a2db96fe3ebc927596f4e74f6eaadb7b641f2a674c23e672489f0d3b
ARG DOMUS_SOURCE_COMMIT=b2718e41793d274d22f6f6532da894ed3f158557
ARG DOMUS_SOURCE_SHA256=e89f738343769db5d24ae5306c11d4c33ed2a4c3885eff46b64a6acbeed94a1a
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 \
Expand All @@ -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.26
ARG BUILD_VERSION=0.0.0-edge.28
ARG BUILD_ARCH
ARG DOMUS_SOURCE_COMMIT=691496c299ff371763e445acb9d36b9623a81404
ARG DOMUS_SOURCE_COMMIT=b2718e41793d274d22f6f6532da894ed3f158557
LABEL io.hass.type="app" \
io.hass.version="${BUILD_VERSION}" \
io.hass.arch="${BUILD_ARCH}" \
Expand Down
5 changes: 2 additions & 3 deletions addon-edge/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
Development preview of Domus installed as a Home Assistant app. Open it through
HA's Open Web UI using your existing Home Assistant session.

This preview lets people with task configuration permission set optional base
points when creating a task. It also includes Home Assistant sensors for the same due-today and
overdue task counts shown on Overview.
This Edge.28 preview shows the current Family week's completed tasks and posted
earned points on Overview. Open Family from the summary to see the full report.

This candidate uses SQLite schema 31. Keep a
compatible image and cold data backup before upgrading a previous preview.
Expand Down
26 changes: 13 additions & 13 deletions addon-edge/artifact.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"schemaVersion": 1,
"version": "0.0.0-edge.26",
"sourceCommit": "691496c299ff371763e445acb9d36b9623a81404",
"sourceArchiveSHA256": "535c0b95a2db96fe3ebc927596f4e74f6eaadb7b641f2a674c23e672489f0d3b",
"version": "0.0.0-edge.28",
"sourceCommit": "b2718e41793d274d22f6f6532da894ed3f158557",
"sourceArchiveSHA256": "e89f738343769db5d24ae5306c11d4c33ed2a4c3885eff46b64a6acbeed94a1a",
"storageSchema": 31,
"wheelSHA256": "5bb060c69c0b2caf9b9f8d99ecff0b56e44a3096f6339582816f5dd52c5bf089",
"wheelSHA256": "7a675fc84a4ae9ae839d5f08aeb44cb15033be251d4973b9ef7ec231fec6c1ab",
"pythonFiles": {
"domus/__init__.py": "7182c88b92234b4328f94497f4e70222d4390d8093e4b62893dfa78ac5530ac6",
"domus/application/__init__.py": "1e8c0c87bf2a8ca947112543070583c0cc55d9d40b56eab0d86ed59a4ec1e82c",
Expand All @@ -18,7 +18,7 @@
"domus/application/commands.py": "6d1d735b4a725086b0d37f6895dd4201f3944e132763f6825142e038f7635354",
"domus/application/fair_recurrence.py": "ce4a9bbe48ed4762e0456669c21e1b6d573b3b9b7b53912a960bab797f7ad610",
"domus/application/family_ports.py": "f2d089eb617b311b305f1ff696437bc5075b9092750b06a1189e4e51e93c5b16",
"domus/application/family_queries.py": "5d3b4f4db4beab3209c7097774b55fdfc73376af614a045e9d3022baaae40274",
"domus/application/family_queries.py": "2945045adada3c7bacba211a565ef2c19de3227a3dc6c0ab934dbea9fc93568f",
"domus/application/fixed_batch_review.py": "ed4e8860c22dc2c0af3abd109eb2df0ad5d8d652ed76d770b043343e8b570f08",
"domus/application/fixed_exception_review.py": "d05039b1752f158c690011b0bab06c2b6bad53854f45ee9d067ea490bcd426aa",
"domus/application/fixed_materialization.py": "5f57bbbd92ed86caaa7751ab978ead0b95a9bf3c564065b2a2a25310be4f8289",
Expand Down Expand Up @@ -97,7 +97,7 @@
"domus/composition/recurrence.py": "62adda116cec8667e9142b03f422a138818575cf5814a79e219a65999dbed1e6",
"domus/composition/restore.py": "fe4f5040a99db1404938e402eefa54fc93139055a5bc92abdfb7bf35d0c87297",
"domus/composition/server.py": "f857338e254477cd7b1d452fc85434e75fd7a25781ed237bb0d5658ac13ad719",
"domus/composition/tasks.py": "c35704cbeb496dd929b89e541d2856f94edf10b57766c239089f4c9dcae8a522",
"domus/composition/tasks.py": "6ac7d47cb443b8fd955edd3d9d0b04df407792e910c161e500b0f84b8ca40974",
"domus/domain/__init__.py": "0aac8a2ba41471d7a174ef7baca6073c95009a9db96df3e032392aa4f80bd079",
"domus/domain/activation.py": "fcb2e47e939127d5e254e2136fb7f1459b40fa8c8561100579fced49666ad0fe",
"domus/domain/calendar_values.py": "5a0f3821391f10fbab05c00f775133683203e7f4b7c5861718bef1f98dedc219",
Expand Down Expand Up @@ -144,18 +144,18 @@
"domus/entrypoints/calendar_http.py": "5a7359ac2a876296a13bfe4bc63ac69bd36aec48e55c536a20470a789a6fef13",
"domus/entrypoints/console_recovery.py": "854a3f8d7a2e74f301ac5bd4b54682e409e2669a3bb7e05546e479c113c09026",
"domus/entrypoints/entry_context.py": "c3c8b64c603dd4de8330f9e336754c190f793e245d0a8e0455ac06e110919f78",
"domus/entrypoints/family_http.py": "2a4030193a4c6b9d98353127f7a225cacf62a5aa55d5a2305c6ca1c8211c99e8",
"domus/entrypoints/family_http.py": "2a82211898be9d5cf69fbb0fc67f706e47dfeca93c1307e498e700056085b4b7",
"domus/entrypoints/ha_calendar_http.py": "25f5d83257c5cf4ead15ad1232ee826be042387c01d609ecabc660ff4fbcf42e",
"domus/entrypoints/ha_deadline_http.py": "c01085af95c101e8837dd2a077822ae399af7adaf7be7dbf24507fe30c8c3e77",
"domus/entrypoints/ha_projection_http.py": "a061762e5088727351e8cdaefcaa909836d3a3c9c9e01dd64fe766acff5b5ea9",
"domus/entrypoints/household_http.py": "37e948848115bfa8714c9cccc50058389114f2e665cad965a66964b0dcd098c8",
"domus/entrypoints/http.py": "d6e318bad8731c4edcba4da3bc15a762b7aa17610cd8a4d04c71bfd370b5ac96",
"domus/entrypoints/http.py": "e330d600a9397cf057e9843b33ed989d2c57737da1065df126256c7e44119e83",
"domus/entrypoints/http_contract.py": "613be310d4ff6a6c7e2a699c20f1c4a142d0b34073629884e58e973c4b040039",
"domus/entrypoints/http_errors.py": "7d838b6a0169de57b79b80efb8aec455560aa96bbd956334bcb5479f95e934f9",
"domus/entrypoints/ingress_boundary.py": "1aa1d684b8625464b5d36d272f71d94b4cd32b84819ff8765a821c9a722f8f28",
"domus/entrypoints/ingress_http.py": "f6557eb5481d132131f66ad7691e30c223c63a66a6f0ae5754c9fba3bc7f3626",
"domus/entrypoints/inventory_http.py": "a62ee56429988b15e9ac5903cc78dfa7ea38884e3c1aaa5efc2c6722829d0437",
"domus/entrypoints/native_http.py": "067770c688cd044e2169a144ae4e53bd33586f948deac3239c2c601bbbd19088",
"domus/entrypoints/native_http.py": "38cf774fcf46c90ea12852ca87c50b7b4e7bb153f6b7b36c0ea227171ea0eff4",
"domus/entrypoints/openapi.py": "01a3fab9e5890ebcc1fb9c70bce9ced43d45b9190afd134db7dd45e0c5eb28f1",
"domus/entrypoints/point_allocation_http.py": "7339c88c083206c0778885b55793c80af219b15af7004c5a51d34dbc28f4da5c",
"domus/entrypoints/recurrence_dto.py": "094e6f64e1f963bfb053e830b214eed1189258e4f0eb8ff15ddba1f059649a1a",
Expand All @@ -164,7 +164,7 @@
"domus/entrypoints/schedule_creation_http.py": "2a3c3ea682f978eb2767dc8808a218c312861f31079cc2c76dbc3847ddec3197",
"domus/entrypoints/task_category_http.py": "e5443015f5e5cb2684eb6807e0a3bac5116703b5611508281afd7d1addee9672",
"domus/entrypoints/task_dto.py": "10657d1df0180bf05e71d1f38ac3214d2cea34c8822f50ea25ab331b9c014049",
"domus/entrypoints/task_http.py": "5189ade4f7ab546ba84d0b88a82b02bf7e53cc436bf312920ed6839761aa0810",
"domus/entrypoints/task_http.py": "e9a533d615be77f4b420f78aa5ac61212d0afd1ac1300add3e0cc22c02986e93",
"domus/entrypoints/task_response.py": "d2f4c0795aee429fc318b32495601031c559fa38af1d7da63b4735f7e6eb5d13",
"domus/entrypoints/ui_bundle.py": "beae3d4a7a57375ee195cca81efccdbc899d9db4286029d53eabaf30de6e14f7",
"domus/entrypoints/ui_http.py": "b6c47baa742f3862173a93e4121dc9914fd972eb6287ffffb9ffccecbf2ebe4a",
Expand Down Expand Up @@ -226,9 +226,9 @@
"domus/infrastructure/task_materials.py": "d5d2934e36f290c7bf44b473392f014eab8749f1f3b3d26a3402079e65d2818f"
},
"uiFiles": {
".vite/manifest.json": "734a1f5ba77da03257115ade8cb5f680b19febd79c853f95a3fa51993e0f2cdb",
".vite/manifest.json": "ff8264fde84e7207e3ba230fdb7935716ce36902a765fa71523e22bb5ff1195f",
"assets/index-CX10IRLI.js": "838cb6fdacbd2f7f6e27b302c231c4fb6d5d49cd50e1cb3685ea7e4722c45e7a",
"assets/index-CjJnHZzV.css": "0f2c8c2e31576c0b64fe60373150f09390dafb896df6c07777b2a220ad430e48",
"assets/index-CrrA8YHS.js": "c32342fbb48c4d5e7266a3a6272e77d6a4479290440c4e801887750470b99bb2",
"index.html": "1198c1ad6b3475ec0c03041f145522f4454e7782aec020a2779204a4bea2f399"
"index.html": "c709edea7d9a6607c1064bd52bb500a25dc22e18e2852c76ff42394bb5516d04"
}
}
2 changes: 1 addition & 1 deletion addon-edge/config.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: Domus Edge
version: "0.0.0-edge.26"
version: "0.0.0-edge.28"
slug: domus_edge
description: Development preview of the local Domus household application
url: https://github.com/vypdev/domus
Expand Down
38 changes: 32 additions & 6 deletions backend/src/domus/application/family_queries.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
"""Project private ledger and work facts from one authorized read transaction."""

from dataclasses import dataclass
from datetime import date, timedelta
from typing import Literal

from domus.application.authorization import HouseholdAccess
from domus.application.calendar_queries import calendar_boundary
from domus.application.family_ports import FamilyAllocationEvidence, FamilyLedgerEntry
from domus.application.fixed_materialization import MaintenanceScope
from domus.application.ports import Transactions
from domus.application.ports import Clock, Transactions, UnitOfWork
from domus.application.recurrence_ports import RecurrenceTimes
from domus.application.reward_funding import reward_balance
from domus.application.task_authorization import TaskAccess
from domus.application.task_authorization import TaskAccess, TaskActor
from domus.application.task_ports import TaskCursors
from domus.domain.calendar_values import CalendarRange
from domus.domain.identity import HumanIdentity, Permission
from domus.domain.points import conserved_shares
from domus.domain.recurrence_time import TimePolicy
from domus.domain.rewards import RewardSpend
from domus.domain.storage import JsonDocument
from domus.domain.storage import Household, JsonDocument
from domus.domain.task_values import VerificationState

PENDING_LIMIT = 4
Expand Down Expand Up @@ -54,6 +55,13 @@ class FamilyReport:
next_cursor: str | None


@dataclass(frozen=True, slots=True)
class FamilyWeek:
period: CalendarRange
earned_minor: int
completed_count: int


@dataclass(frozen=True, slots=True)
class FamilyQueries:
transactions: Transactions
Expand All @@ -62,12 +70,30 @@ class FamilyQueries:
cursors: TaskCursors
times: RecurrenceTimes

def _access(self, unit: UnitOfWork) -> tuple[Household, TaskActor]:
home = self.scope.require(unit)
HouseholdAccess(self.human).require(unit, home.household_id, Permission.HOUSEHOLD_READ)
actor = TaskAccess(self.human).require(unit, home.household_id, Permission.TASKS_READ)
return home, actor

def overview(self, clock: Clock) -> FamilyWeek:
with self.transactions.read() as unit:
home, actor = self._access(unit)
policy = TimePolicy(home.time_zone, self.times.data_identity)
today = self.times.local_at(clock.now(), policy).local.date()
monday = today - timedelta(days=today.weekday())
period = CalendarRange(max(date(1970, 1, 1), monday), monday + timedelta(days=7))
start = calendar_boundary(period.start, self.times, policy)
end = calendar_boundary(period.end, self.times, policy)
household_id, member_id = home.household_id, actor.member.member_id
_, earned = unit.points.member_totals(household_id, member_id, start, end)
completed = sum(1 for _ in unit.points.member_work(household_id, member_id, start, end))
return FamilyWeek(period, earned, completed)

def report(self, period: CalendarRange, *, limit: int, cursor: str | None) -> FamilyReport:
with self.transactions.read() as unit:
home = self.scope.require(unit)
home, actor = self._access(unit)
household_id = home.household_id
HouseholdAccess(self.human).require(unit, household_id, Permission.HOUSEHOLD_READ)
actor = TaskAccess(self.human).require(unit, household_id, Permission.TASKS_READ)
member_id = actor.member.member_id
policy = TimePolicy(home.time_zone, self.times.data_identity)
start = calendar_boundary(period.start, self.times, policy)
Expand Down
6 changes: 5 additions & 1 deletion backend/src/domus/composition/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ def queries() -> TaskQueries:
schedule_data_identity=planner.times.data_identity,
)

def family() -> FamilyQueries:
return FamilyQueries(store, scope, actor.read(), cursors, planner.times)

return TaskHTTPContext(
queries,
lambda: queries().overview(clock, planner.times),
Expand All @@ -92,7 +95,8 @@ def queries() -> TaskQueries:
bind_household_policy=True,
),
TaskCategoryCommands(store, actor, actor.read, clock, identifiers),
lambda: FamilyQueries(store, scope, actor.read(), cursors, planner.times),
family,
lambda: family().overview(clock),
lambda: AllocationQueries(store, actor.read()),
AllocationCommands(store, actor, clock, identifiers),
lambda: RewardQueries(store, scope, actor.read(), cursors),
Expand Down
15 changes: 11 additions & 4 deletions backend/src/domus/entrypoints/family_http.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@
from fastapi import APIRouter, Query, Request
from fastapi.params import Depends

from domus.application.family_queries import FamilyQueries, FamilyReport
from domus.application.family_queries import FamilyReport, FamilyWeek
from domus.domain.calendar_values import CalendarRange
from domus.domain.errors import InvalidInput
from domus.entrypoints.calendar_http import LocalDate
from domus.entrypoints.household_http import _JSONRoute
from domus.entrypoints.household_http import _EmptyQuery, _JSONRoute
from domus.entrypoints.recurrence_http import _require_context
from domus.entrypoints.task_dto import PageQuery
from domus.entrypoints.task_http import TaskHTTPContext


class FamilyQuery(PageQuery):
Expand All @@ -28,12 +29,18 @@ def period(self) -> CalendarRange:


def create_family_router(
context: Callable[[Request], FamilyQueries], *, security: Depends
context: Callable[[Request], TaskHTTPContext], *, security: Depends
) -> APIRouter:
router = APIRouter(dependencies=[security, Depends(_require_context)], route_class=_JSONRoute)

@router.get("/api/v1/family", response_model=FamilyReport)
def family(request: Request, query: Annotated[FamilyQuery, Query()]) -> FamilyReport:
return context(request).report(query.period(), limit=query.limit, cursor=query.cursor)
return (
context(request).family().report(query.period(), limit=query.limit, cursor=query.cursor)
)

@router.get("/api/v1/family/overview", response_model=FamilyWeek)
def overview(request: Request, query: Annotated[_EmptyQuery, Query()]) -> FamilyWeek:
return context(request).family_overview()

return router
4 changes: 1 addition & 3 deletions backend/src/domus/entrypoints/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -440,8 +440,6 @@ def tasks(request: Request) -> TaskHTTPContext:
app.include_router(create_point_allocation_router(tasks, security=session_security))
app.include_router(create_reward_router(tasks, security=session_security))
app.include_router(create_inventory_router(tasks, security=session_security))
app.include_router(
create_family_router(lambda request: tasks(request).family(), security=session_security)
)
app.include_router(create_family_router(tasks, security=session_security))
attach_ui(app, ui_bundle, "standalone", lambda request: None)
return app
6 changes: 1 addition & 5 deletions backend/src/domus/entrypoints/native_http.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,11 +255,7 @@ def health() -> dict[str, str]:
app.include_router(create_point_allocation_router(task_context, security=Depends(security)))
app.include_router(create_reward_router(task_context, security=Depends(security)))
app.include_router(create_inventory_router(task_context, security=Depends(security)))
app.include_router(
create_family_router(
lambda request: task_context(request).family(), security=Depends(security)
)
)
app.include_router(create_family_router(task_context, security=Depends(security)))
if administration_context is not None:
app.include_router(
create_administration_router(administration_context, security=Depends(security))
Expand Down
3 changes: 2 additions & 1 deletion backend/src/domus/entrypoints/task_http.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

from domus.application.calendar_commands import CalendarCommands
from domus.application.calendar_queries import CalendarQueries
from domus.application.family_queries import FamilyQueries
from domus.application.family_queries import FamilyQueries, FamilyWeek
from domus.application.inventory import CatalogAction, InventoryCommands
from domus.application.inventory_queries import InventoryQueries
from domus.application.point_allocations import AllocationCommands, AllocationQueries
Expand Down Expand Up @@ -113,6 +113,7 @@ class TaskHTTPContext:
relative_creation: RelativeRecurrenceCommands
category_commands: TaskCategoryCommands
family: Callable[[], FamilyQueries]
family_overview: Callable[[], FamilyWeek]
allocation: Callable[[], AllocationQueries]
allocation_commands: AllocationCommands
rewards: Callable[[], RewardQueries]
Expand Down
Loading
Loading