Skip to content
Open
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
8 changes: 4 additions & 4 deletions reports/month-01/week-02-local-storage.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

Add one block for every fellow who contributed. Keep each block short.

## Fellow 1: Full Name
## Fellow 1: Alain Chan

- **Topic:** Topic worked on
- **What I did:** Describe the work you completed, the result you achieved, how you verified it, one challenge you addressed, and the main lesson you learned this week. Use at least 20 words.
- **Public output:** [Post title](https://example.com/post) - Medium, X, LinkedIn, or another public platform
- **Topic:** Capture / Create Context
- **What I did:** I implemented the `create_context_item` API for the Local Context Store. It validates context type, title, content, source, tags, and importance before saving a new context item into SQLite. I verified it with the Week 2 storage test script and learned that useful local-first AI memory starts with clean, structured context capture.
- **Public output:** [Why Local-First AI Starts With Good Context Capture](https://dev.to/alaindevs/why-local-first-ai-starts-with-good-context-capture-3d9g) - Dev.to

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add pictures and point to repository in your public post


## Fellow 2: Full Name

Expand Down
58 changes: 58 additions & 0 deletions src/python/local_first_ai/storage/create_context.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
from __future__ import annotations

from collections.abc import Iterable

from local_first_ai.storage.db_contract import (
database_connection,
normalize_optional_text,
normalize_tags,
utc_now,
validate_context_type,
validate_importance,
validate_required_text,
)


def create_context_item(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on the implemeted function.

context_type: str,
title: str,
content: str,
source: str | None = None,
tags: str | Iterable[str] | None = None,
importance: int = 1,
) -> int:
context_type = validate_context_type(context_type)
title = validate_required_text(title, "title")
content = validate_required_text(content, "content")
source = normalize_optional_text(source, "source")
tags = normalize_tags(tags)
importance = validate_importance(importance)
timestamp = utc_now()

with database_connection() as connection:
cursor = connection.execute(
"""
INSERT INTO context_items (
context_type,
title,
content,
source,
tags,
importance,
created_at,
updated_at
)
VALUES (?, ?, ?, ?, ?, ?, ?, ?)
""",
(
context_type,
title,
content,
source,
tags,
importance,
timestamp,
timestamp,
),
)
return int(cursor.lastrowid)
15 changes: 7 additions & 8 deletions tests/python/storage/week_02_test_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

> Think of this report as the Week 2 checklist: what works, what is still waiting, and exactly what to fix.

**Generated:** 2026-07-03T05:47:06+00:00
**Generated:** 2026-07-05T20:27:50+00:00

## Where We Are

Expand All @@ -12,7 +12,7 @@ The shared base works. The remaining checks are waiting for the four fellow-owne

| Passed | Waiting | Failed | Errors |
|---:|---:|---:|---:|
| 4 | 19 | 0 | 0 |
| 7 | 16 | 0 | 0 |

### What the labels mean

Expand All @@ -33,14 +33,14 @@ The shared base works. The remaining checks are waiting for the four fellow-owne
- **PASS:** Schema contains the shared columns and indexes - All assertions passed. (`test_schema_contains_the_shared_columns_and_indexes`)
- **PASS:** Shared validation helpers - All assertions passed. (`test_shared_validation_helpers`)

### Fellow 1 - Create context - WAITING
### Fellow 1 - Create context - PASS

- **File:** `src/python/local_first_ai/storage/create_context.py`
- **Status:** File not added.
- **Status:** All available asserted cases passed.

- **WAITING:** Create rejects empty title and content - Not active yet. (`test_create_rejects_empty_title_and_content`)
- **WAITING:** Create rejects invalid context type - Not active yet. (`test_create_rejects_invalid_context_type`)
- **WAITING:** Create returns unique IDs and stores complete items - Not active yet. (`test_create_returns_unique_ids_and_stores_complete_items`)
- **PASS:** Create rejects empty title and content - All assertions passed. (`test_create_rejects_empty_title_and_content`)
- **PASS:** Create rejects invalid context type - All assertions passed. (`test_create_rejects_invalid_context_type`)
- **PASS:** Create returns unique IDs and stores complete items - All assertions passed. (`test_create_returns_unique_ids_and_stores_complete_items`)

### Fellow 2 - Read context - WAITING

Expand Down Expand Up @@ -90,7 +90,6 @@ No implemented test case is failing right now.

These are the next pieces to build. They are not broken tests:

- **Fellow 1 - Create context:** `src/python/local_first_ai/storage/create_context.py` - file not added.
- **Fellow 2 - Read context:** `src/python/local_first_ai/storage/read_context.py` - file not added.
- **Fellow 3 - Search context:** `src/python/local_first_ai/storage/search_context.py` - file not added.
- **Fellow 4 - Manage context:** `src/python/local_first_ai/storage/manage_context.py` - file not added.
Expand Down