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
2 changes: 1 addition & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,4 +140,4 @@ Issues and specs live as GitHub issues (`mibrahimdev/Sharingan`); use the `gh` C

### Domain docs

Single-context: `CONTEXT.md` + `docs/adr/` at the repo root. See `docs/agents/domain.md`.
Domain docs use `GLOSSARY.md` for a single context or `GLOSSARY-MAP.md` for multiple contexts. See `docs/agents/domain.md`.
67 changes: 0 additions & 67 deletions CONTEXT.md

This file was deleted.

37 changes: 37 additions & 0 deletions GLOSSARY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Sharingan

Domain vocabulary for Sharingan. See [docs/ARCHITECTURE.md](docs/ARCHITECTURE.md) for system design.

## Terms

**Event**: One captured protocol interaction, such as an HTTP exchange, MQTT message, or BLE operation. An event is immutable once recorded.

**Protocol**: One of the traffic types Sharingan captures: HTTP, MQTT, or BLE. Each **Protocol** has its own view in the browser.

**Protocol Descriptor**: The description of how a **Protocol** is presented and explored, including its filters, search, rows, details, and exports.

**Capture**: The act of recording a protocol interaction as an **Event**. Capture follows the active recording state.

**Flight Recorder**: The persistent history of events from process lifetimes. The **Store** remains the live source of truth for the **Current Session**; the Flight Recorder is queried on demand to list or inspect **Past Sessions**.

**Logger**: A protocol-specific interface for recording an **Event** from a host app's network or device client.

**Session**: A collection of events associated with one process lifetime. The **Current Session** is active; previous lifetimes are **Past Sessions**.

**Current Session**: The live process lifetime backed by the **Store**.

**Past Session**: A previous process lifetime retrieved on demand from the **Flight Recorder**.

**Store**: The live collection of captured **Events** for the **Current Session**. It is the source of truth while the process is running.

**Write-Behind Seam**: The process that mirrors accepted **Events** to the **Flight Recorder** without blocking **Capture**.

**Capture Notification**: The Android notification that surfaces capture status and recent **Events**.

**Ticker**: A short preview of recent **Events** shown in the expanded **Capture Notification**.

**Agent Markdown**: The structured Markdown export intended to help an agent understand and debug captured **Events**.

**Share Action / Share Scope**: A Share Action chooses how data is shared; a Share Scope chooses whether it covers one **Event** or all **Events** in the current **Protocol**.

**No-op Twin**: The inert release counterpart of Sharingan, preserving its public API without capturing events or displaying the browser.
4 changes: 3 additions & 1 deletion docs/ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ Sharingan is an on-device debug logger for Kotlin Multiplatform (Android API 24+
:sharingan debug artifact — capture core + Ktor plugin + Compose UI
+ Android notification/activity + iOS view controller
:sharingan-noop release artifact — same public API, inert bodies, no UI payload
:sharingan-db on-device SQLite flight recorder for persisted event sessions
:ktlint-rules custom lint rules for project-specific source conventions
:sample:composeApp demo app — deterministic IoT traffic via Ktor MockEngine;
can compile against either artifact (-Psharingan.noop)
```
Expand Down Expand Up @@ -221,7 +223,7 @@ The design explored three densities — **Terminal / Comfortable / Badged** —

### 5.4 Flight recorder (persistence)

The in-memory ring buffer stays the source of truth. Each accepted Event is also mirrored to an on-device SQLite database by a write-behind seam: `SharinganStore.onRecord` (internal callback, invoked after the ring-buffer CAS append) → `PersistenceController` ([sharingan-db](../sharingan-db), SQLDelight). Persistence ships ON by default in debug. The Flight Recorder is a post-mortem log, never queried back into the UI and never the source of truth; one session row groups the Events of each process lifetime (a Run). Redaction applies before disk, and request/response bodies are never written to disk — persisting bodies would change the security posture and is deliberately out of scope.
The **Store** remains the live source of truth for the **Current Session**. Each accepted Event is also mirrored to the on-device SQLite **Flight Recorder** by a write-behind seam: `SharinganStore.onRecord` (internal callback, invoked after the ring-buffer CAS append) → `PersistenceController` ([sharingan-db](../sharingan-db), SQLDelight). Persistence ships ON by default in debug. The Flight Recorder is queried on demand to list or inspect **Past Sessions**; each session groups the Events of one process lifetime. Redaction applies before disk, and request/response bodies are never written to disk — persisting bodies would change the security posture and is deliberately out of scope.

### 5.5 Sample iosApp Xcode project

Expand Down
18 changes: 9 additions & 9 deletions docs/agents/domain.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,45 +4,45 @@ How the engineering skills should consume this repo's domain documentation when

## Before exploring, read these

- **`CONTEXT.md`** at the repo root, or
- **`CONTEXT-MAP.md`** at the repo root if it exists: it points at one `CONTEXT.md` per context. Read each one relevant to the topic.
- **`GLOSSARY.md`** at the repo root, or
- **`GLOSSARY-MAP.md`** at the repo root if it exists: it points at one `GLOSSARY.md` per context. Read each one relevant to the topic.
- **`docs/adr/`**: read ADRs that touch the area you're about to work in. In multi-context repos, also check `src/<context>/docs/adr/` for context-scoped decisions.

If any of these files don't exist, **proceed silently**. Don't flag their absence; don't suggest creating them upfront. The `/domain-modeling` skill (reached via `/grill-with-docs` and `/improve-codebase-architecture`) creates them lazily when terms or decisions actually get resolved.

## File structure

This repo is **single-context**: one `CONTEXT.md` + `docs/adr/` at the repo root.
This repo is **single-context**: one `GLOSSARY.md` + `docs/adr/` at the repo root.

Single-context repo (most repos):

```
/
├── CONTEXT.md
├── GLOSSARY.md
├── docs/adr/
│ ├── 0001-event-sourced-orders.md
│ └── 0002-postgres-for-write-model.md
└── src/
```

Multi-context repo (presence of `CONTEXT-MAP.md` at the root):
Multi-context repo (presence of `GLOSSARY-MAP.md` at the root):

```
/
├── CONTEXT-MAP.md
├── GLOSSARY-MAP.md
├── docs/adr/ ← system-wide decisions
└── src/
├── ordering/
│ ├── CONTEXT.md
│ ├── GLOSSARY.md
│ └── docs/adr/ ← context-specific decisions
└── billing/
├── CONTEXT.md
├── GLOSSARY.md
└── docs/adr/
```

## Use the glossary's vocabulary

When your output names a domain concept (in an issue title, a refactor proposal, a hypothesis, a test name), use the term as defined in `CONTEXT.md`. Don't drift to synonyms the glossary explicitly avoids.
When your output names a domain concept (in an issue title, a refactor proposal, a hypothesis, a test name), use the term as defined in `GLOSSARY.md` and keep vocabulary consistent.

If the concept you need isn't in the glossary yet, that's a signal: either you're inventing language the project doesn't use (reconsider) or there's a real gap (note it for `/domain-modeling`).

Expand Down
7 changes: 4 additions & 3 deletions docs/api-parity.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,10 @@ consumer-facing public API:

- `:sample:composeApp` — the sample application, not a published library.
- `:sharingan-db` — the on-device SQLDelight database is an implementation
detail of `:sharingan`. Its generated surface changes with every schema edit in
slices 3–5, and no consumer codes against it. It is published only as a
required runtime dependency of `:sharingan`.
detail of `:sharingan`. It is BCV-guarded like `:sharingan` itself, but its
generated surface is **not** compared against `:sharingan-noop` (it is an
implementation dependency, not a consumer-facing twin). Its schema and public
query API evolve with slices 3–5.

In CI it runs as the `api-parity` job in
[`.github/workflows/api-check.yml`](../.github/workflows/api-check.yml), on a cheap
Expand Down
40 changes: 40 additions & 0 deletions sharingan-db/api/sharingan-db.api
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,31 @@ public final class dev/sharingan/db/PersistenceController {
public synthetic fun <init> (Lkotlin/jvm/functions/Function1;IJILkotlin/jvm/internal/DefaultConstructorMarker;)V
public final fun clear ()V
public final fun close (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public final fun getCurrentSessionId ()Ljava/lang/String;
public final fun pastSessions ()Ljava/util/List;
public final fun sessionEvents (Ljava/lang/String;)Ljava/util/List;
public final fun start ()V
public final fun stop (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public final fun submit (Ljava/lang/Object;)V
}

public final class dev/sharingan/db/SelectPastSessions {
public fun <init> (Ljava/lang/String;JJJ)V
public final fun component1 ()Ljava/lang/String;
public final fun component2 ()J
public final fun component3 ()J
public final fun component4 ()J
public final fun copy (Ljava/lang/String;JJJ)Ldev/sharingan/db/SelectPastSessions;
public static synthetic fun copy$default (Ldev/sharingan/db/SelectPastSessions;Ljava/lang/String;JJJILjava/lang/Object;)Ldev/sharingan/db/SelectPastSessions;
public fun equals (Ljava/lang/Object;)Z
public final fun getEventCount ()J
public final fun getFailureCount ()J
public final fun getId ()Ljava/lang/String;
public final fun getStarted_at ()J
public fun hashCode ()I
public fun toString ()Ljava/lang/String;
}

public final class dev/sharingan/db/Session {
public fun <init> (Ljava/lang/String;JLjava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V
public final fun component1 ()Ljava/lang/String;
Expand All @@ -73,6 +93,23 @@ public final class dev/sharingan/db/Session {
public fun toString ()Ljava/lang/String;
}

public final class dev/sharingan/db/SessionSummary {
public fun <init> (Ljava/lang/String;JII)V
public final fun component1 ()Ljava/lang/String;
public final fun component2 ()J
public final fun component3 ()I
public final fun component4 ()I
public final fun copy (Ljava/lang/String;JII)Ldev/sharingan/db/SessionSummary;
public static synthetic fun copy$default (Ldev/sharingan/db/SessionSummary;Ljava/lang/String;JIIILjava/lang/Object;)Ldev/sharingan/db/SessionSummary;
public fun equals (Ljava/lang/Object;)Z
public final fun getEventCount ()I
public final fun getFailureCount ()I
public final fun getId ()Ljava/lang/String;
public final fun getStartedAtMillis ()J
public fun hashCode ()I
public fun toString ()Ljava/lang/String;
}

public abstract interface class dev/sharingan/db/SharinganDatabase : app/cash/sqldelight/Transacter {
public static final field Companion Ldev/sharingan/db/SharinganDatabase$Companion;
public abstract fun getSharinganDatabaseQueries ()Ldev/sharingan/db/SharinganDatabaseQueries;
Expand All @@ -86,6 +123,7 @@ public final class dev/sharingan/db/SharinganDatabase$Companion {
public final class dev/sharingan/db/SharinganDatabaseQueries : app/cash/sqldelight/TransacterImpl {
public fun <init> (Lapp/cash/sqldelight/db/SqlDriver;)V
public final fun deleteAllEvents ()V
public final fun deleteEventsForSession (Ljava/lang/String;)V
public final fun deleteSession (Ljava/lang/String;)V
public final fun insertEvent (Ljava/lang/String;Ljava/lang/String;JLjava/lang/String;JLjava/lang/String;Ljava/lang/String;)V
public final fun insertSession (Ljava/lang/String;JLjava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V
Expand All @@ -95,6 +133,8 @@ public final class dev/sharingan/db/SharinganDatabaseQueries : app/cash/sqldelig
public final fun selectAllSessions (Lkotlin/jvm/functions/Function6;)Lapp/cash/sqldelight/Query;
public final fun selectEventsForSession (Ljava/lang/String;)Lapp/cash/sqldelight/Query;
public final fun selectEventsForSession (Ljava/lang/String;Lkotlin/jvm/functions/Function7;)Lapp/cash/sqldelight/Query;
public final fun selectPastSessions (Ljava/lang/String;)Lapp/cash/sqldelight/Query;
public final fun selectPastSessions (Ljava/lang/String;Lkotlin/jvm/functions/Function4;)Lapp/cash/sqldelight/Query;
public final fun selectSession (Ljava/lang/String;)Lapp/cash/sqldelight/Query;
public final fun selectSession (Ljava/lang/String;Lkotlin/jvm/functions/Function6;)Lapp/cash/sqldelight/Query;
}
Expand Down
Loading
Loading