Tasks are scoped by (user, task_id). Implement creation, mutation, TTL expiration, and snapshots.
Question
Tasks are scoped by `(user, task_id)`. Implement creation, mutation, TTL expiration, and snapshots.
```python
class TaskManager:
def add_task(self, timestamp: int, user: str, task_id: str,
title: str, ttl: int | None = None) -> bool: ...
def update_task(self, timestamp: int, user: str,
task_id: str, title: str) -> bool: ...
def complete_task(self, timestamp: int, user: str, task_id: str) -> bool: ...
def get_task_list(self, timestamp: int, user: str,
at_timestamp: int | None = None) -> list[str]: ...
```
## Requirements
- A task key can be created only once, even if the task later completes or expires.
- Only live incomplete tasks can be updated or completed.
- TTL is anchored at creation; a task is absent at and after `created_at + ttl`, and updates do not refresh it.
- Current lists contain live incomplete titles ordered by task ID.
- A historical list includes all events at or before the requested timestamp and applies expiration relative to that historical time.
- Calls arrive in nondecreasing command time, though historical query times may be earlier.
Timestamps are nonnegative integers. A supplied TTL is a positive integer; omit it or use `None` for no expiration. A historical query timestamp is between zero and the command timestamp, inclusive. Calls with the same command timestamp are processed in input order, and a query sees all earlier mutations in that order. Strings are compared lexicographically for task-ID ordering; equal IDs under different users are independent. Titles may be empty or repeated, so lists do not deduplicate titles.
Creation returns `True` only when the user/task key has never been created. Update and completion return `True` only when they succeed; otherwise return `False` without changing history. Unknown users have an empty list. A task created after a requested historical time is absent from that view; later updates and completion do not alter earlier views.
Each independent command sequence starts with a new TaskManager. The input envelope has `calls`, a list of method-name/positional-argument lists using the four methods above. Return one method result per call in input order. Historical lists are reconstructed views, not explicit backup/restore operations.
## Suggested implementation approach
These milestones organize the complete task rather than introducing new assessed requirements.
1. Implement add, update, complete, and current listing.
2. Add lazy TTL expiration.
3. Add historical reconstruction from an event log.
## Design discussion
How could checkpoints and indexed event streams improve historical-query performance? Discuss idempotency, concurrent writers, recurring tasks and durable persistence without changing the four-method contract.The public brief is identical for people and crawlers. Account access changes tools, not the indexed description.