Per-session workspace folder + structural identity reminder
- At the first interaction the session name locks and a personal folder is created under the workspace root (default ~/.strata-ctl/<slug>, configurable via workspace_root); slug is filesystem-safe and unique. Stored in sessions.folder (idempotent migration).
- build_request always prepends a structural identity reminder ('Il tuo nome è X. La tua cartella personale è Y.') before the session SP — not an editable setting; gives the agent awareness of its workspace. router_with_store takes the workspace root. 114 tests green; verified live (folder created, name locked).
This commit is contained in:
1 parent
0568b92e06
commit
c199953927
6 files changed
+148
-14
No files matched your search
@@ -80,6 +80,8 @@ pub struct Session {
|
||||
/// Once the first message is sent the name becomes immutable (it is the
|
||||
/// agent's identity and names its personal folder).
|
||||
pub name_locked: bool,
|
||||
/// Personal workspace folder, created at the first interaction (None until then).
|
||||
pub folder: Option<String>,
|
||||
pub created_at: i64,
|
||||
pub updated_at: i64,
|
||||
}
|
||||
@@ -131,6 +133,7 @@ pub trait Store: Send + Sync {
|
||||
fn rename_session(&self, id: &str, title: &str) -> Result<()>;
|
||||
fn update_settings(&self, id: &str, settings: &SessionSettings) -> Result<()>;
|
||||
fn set_name_locked(&self, id: &str, locked: bool) -> Result<()>;
|
||||
fn set_folder(&self, id: &str, folder: &str) -> Result<()>;
|
||||
fn delete_session(&self, id: &str) -> Result<()>;
|
||||
fn messages(&self, session_id: &str) -> Result<Vec<StoredMessage>>;
|
||||
fn append_message(&self, session_id: &str, msg: NewMessage<'_>) -> Result<StoredMessage>;
|
||||
@@ -166,6 +169,7 @@ CREATE TABLE IF NOT EXISTS sessions (
|
||||
system_prompt TEXT,
|
||||
settings_json TEXT,
|
||||
name_locked INTEGER NOT NULL DEFAULT 0,
|
||||
folder TEXT,
|
||||
created_at INTEGER NOT NULL,
|
||||
updated_at INTEGER NOT NULL
|
||||
);
|
||||
@@ -257,6 +261,9 @@ fn migrate(conn: &Connection) -> Result<()> {
|
||||
"ALTER TABLE sessions ADD COLUMN name_locked INTEGER NOT NULL DEFAULT 0;",
|
||||
)?;
|
||||
}
|
||||
if !has_col("sessions", "folder")? {
|
||||
conn.execute_batch("ALTER TABLE sessions ADD COLUMN folder TEXT;")?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -278,6 +285,7 @@ fn row_to_session(row: &rusqlite::Row<'_>) -> rusqlite::Result<Session> {
|
||||
model: row.get("model")?,
|
||||
settings,
|
||||
name_locked: row.get::<_, i64>("name_locked")? != 0,
|
||||
folder: row.get("folder")?,
|
||||
created_at: row.get("created_at")?,
|
||||
updated_at: row.get("updated_at")?,
|
||||
})
|
||||
@@ -305,6 +313,7 @@ impl Store for SqliteStore {
|
||||
model: model.to_string(),
|
||||
settings: settings.clone(),
|
||||
name_locked: false,
|
||||
folder: None,
|
||||
created_at: now,
|
||||
updated_at: now,
|
||||
})
|
||||
@@ -353,6 +362,15 @@ impl Store for SqliteStore {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn set_folder(&self, id: &str, folder: &str) -> Result<()> {
|
||||
let conn = self.lock();
|
||||
conn.execute(
|
||||
"UPDATE sessions SET folder = ?2 WHERE id = ?1",
|
||||
params![id, folder],
|
||||
)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn delete_session(&self, id: &str) -> Result<()> {
|
||||
let conn = self.lock();
|
||||
conn.execute("DELETE FROM sessions WHERE id = ?1", params![id])?;
|
||||
|
||||
Reference in new issue
Block a user