Skip to content

feat: turn repeated requests into Hide global instruction fixes and keep Memory tidy - #1816

Merged
yansfil merged 16 commits into
mainfrom
feat/memory-self-improve
Oct 28, 2026
Merged

yansfil merged 16 commits into
mainfrom
feat/memory-self-improve

Conversation

@yansfil

@yansfil yansfil commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Related: PRD agents/prd/memory-self-improve/prd.md (로컬 계약; 아래 Summary와 Evidence가 검토할 내용입니다) · 선행 #1779, #1780

Summary

  • 운영자가 세션마다 같은 부탁을 다시 하고, 같은 취향이 기억 여러 장으로 흩어지고, 준 기억이 먹혔는지 아무도 몰랐습니다.
  • 이제 Hide pane의 모든 새 세션이 Hide 전역 지시(~/.hide/state/global-instruction.md, 4 KiB)를 운영자가 승인한 지시로 받습니다.
  • 제안 탭이 되풀이한 요청과 줬는데도 안 먹힌 기억을 찾아, 전역 지시에 넣을 줄을 근거와 함께 보여 줍니다. 누르면 Hide가 넣고, 되돌리기는 그 줄만 뺍니다.
  • Memory는 같은 뜻의 기억을 합치고(되돌리기 가능), 60일 안 쓴 기억은 보관하고, 운영자 말인지 다시 확인할 수 있습니다.
  • 에이전트가 전역 지시 파일을 쓰는 도구 호출은 hook이 막습니다(운영자 선택 A: best-effort 가드).

제안 탭: 되풀이한 요청에서 나온 전역 지시 줄과 운영자 말 근거, 넣은 뒤 되돌리기와 다시 말함
제안 탭: 되풀이한 요청에서 나온 전역 지시 줄과 운영자 말 근거, 넣은 뒤 되돌리기와 다시 말함

Memory 탭: 합치기와 다시 확인이 남긴 변경 기록과 되돌리기, 60일 안 쓴 기억의 보관과 되살리기
Memory 탭: 합치기와 다시 확인이 남긴 변경 기록과 되돌리기, 60일 안 쓴 기억의 보관과 되살리기

Review

  • 판단해 주세요: 운영자 선택 A로 전역 지시 쓰기 가드는 best-effort입니다. 따옴표로 쪼갠 이름, glob, 계산한 이름, PowerShell 표기는 못 봅니다(아래 수용한 위험).
  • 판단해 주세요: 수용한 위험이자 후속 B: 파일 지문을 두고, 바뀌었으면 제안 탭에서 한 번 확인받는 방식입니다. 이슈는 운영자가 직접 엽니다.
  • 판단해 주세요: 전역 지시를 흔한 이름의 파일(AGENTS.md 등)에 링크하면, 그 이름을 담은 셸 호출은 읽기여도 막힙니다. 셸 호출은 읽기와 쓰기를 구분할 수 없기 때문입니다.
  • 조심해서 볼 파일: hide-memory/src/store.rs, store/upkeep.rs - 운영자 Memory 저장소 스키마 21→22 마이그레이션(21 백업을 남김), failure path.
  • 조심해서 볼 파일: herdr-core/src/global_instruction.rs - 모든 세션에 들어가는 파일 쓰기. 미리 보인 줄의 token이 맞을 때만 쓰고, 그사이 손으로 고친 저장은 덮지 않으며, 링크는 이미 있는 .md/.txt로만 따라갑니다.
  • 조심해서 볼 파일: hide-agent-hooks/src/global_guard.rs, OpenCode·Pi·omp 스크립트 - 모든 pre-tool 호출의 고빈도 경로. 이름이 없는 payload는 바이트 검색과 상태 폴더마다 링크 읽기 한 번으로 끝납니다.
  • 조심해서 볼 파일: herdr-core/src/node_migration/copy.rs - 코어 이동이 링크된 전역 지시를 코어의 상한 읽기(4 KiB, UTF-8, 링크 재추적 없음)로 옮깁니다. 못 읽으면 남기고 진단만 씁니다.
  • 조심해서 볼 파일: herdr-core/src/runtime/suggestion_evidence.rs - 근거 발췌 읽기는 lock 밖 worker에서 (workspace, row)별로 한 번에 하나만 돌고, panic은 읽지 못한 발췌로 떨어집니다.
  • 비용 검토: 분석, 합치기, 보관, 다시 확인은 기존 Memory 분석 worker 위에서 돕니다. 다시 확인 대기는 프로젝트당 20장, 변경 기록은 상한까지 잘리고, 근거 읽기는 single-flight입니다.

Evidence

  • 확인한 것: sasu implement verify가 최종 head에서 PASS: workspace nextest 전체와 clippy -D warnings.
  • 확인한 것: 같은 변경의 앞선 head에서 hooks·memory 590개, core·hided 4048개, web 2220개, desktop 289개 통과. design contract와 workstation identity 검사 통과.
  • 확인한 것: 마지막 수정 뒤 hide-agent-hooks 395개 통과. 링크 대상에 쓰는 Claude Write를 컴파일된 hook으로 보내 거절되고, 로그에 명령이나 경로가 남지 않음을 확인했습니다.
  • 확인한 것: policy lane(scripts 테스트 713개와 구조 검사)을 로컬에서 통과. 외부 lane의 remote_core Memory 여정을 pinned Herdr로 로컬에서 통과.
  • 확인한 것: 제안 탭, Memory 탭 화면(ko, en)과 전역 지시가 너무 큰 상태를 gallery에서 캡처했습니다.
  • 확인하지 못한 것: 격리한 후보 앱의 native QA는 돌리지 않았습니다. 화면은 gallery 캡처뿐입니다.
  • 확인하지 못한 것: 실제 Claude Code, Codex, OpenCode 세션이 전역 지시를 받는지, 쓰기가 거절되는지 실측하지 않았습니다(B30). Windows와 Linux는 CI lane에만 맡깁니다.
  • 확인하지 못한 것: core_move lane은 로컬 디스크가 모자라 CI에만 맡깁니다.
  • 확인하지 못한 것: Claude Code 컨텍스트 10,000자 상한 안에서 전역 지시와 Memory가 함께 들어가는지 재지 않았습니다.
후속 개선 (Follow-up improvements)
  • 후속 B: 전역 지시 파일 지문을 두고, 바뀌었으면 제안 탭에서 한 번 확인받습니다(운영자가 이슈를 엽니다).
  • 가드가 못 보는 표기: 따옴표로 쪼갠 이름, glob, python -c로 계산한 이름, cd ~/.hide && cd state, 256 KiB 이후에만 이름이 있는 payload, Claude Code PowerShell 도구 matcher.
  • 가드 비용과 범위: 링크 대상 이름이 흔하면 파싱이 넓어집니다. 거절 로그에 rate limit이 없습니다. 링크는 한 단계만 따라갑니다. .hide-new 임시 파일 이름은 예측할 수 있습니다.
  • 테스트: B15 전달 배지 흐름, B12 에스컬레이션, 근거 읽기 panic, from_card 같은 세션 경우, 경로를 넣은 JS route decode, OpenCode 2·Pi 링크 경우.
  • 동작: B11은 세션 시작 시각으로 "받은 세션"을 근사합니다. B13은 켠 날의 소급 계산이 없습니다. stale writing 표시가 남는 crash 구간이 있고, 손으로 넣은 줄을 채택할 때 되돌리기 힌트가 없습니다.
  • 그 밖: is_invisible 목록 확장, 줄의 > 거절, trim_changes 다시 확인 행, 두 클라이언트의 근거 슬롯 공유, 다시 확인 읽기의 순차 처리, 같은 batch 합치기 undo id, alias 재시도, receipt 상한.
Verification record
  • PRD: agents/prd/memory-self-improve/prd.md (sha256 1ec0f473831342cddec15936561f70fbadf390d53016db2786a103bb212ae9c8)
  • Base e86a1f4 → head 8bd8a5c, verified 2026-10-28T19:09:34.724Z: PASS
  • Verification report: agents/runs/memory-self-improve/verification-report.json and agents/runs/memory-self-improve/verification-report.md; source fingerprint f5e066833570caae5a5621e62f7a1a93336d9ff0a96b58e8fb8fc072392b0bc4
  • Suites:
    • S1: GREEN bash scripts/verify-cargo.sh test (exit 0)
    • S2: GREEN bash scripts/verify-cargo.sh lint (exit 0)
  • Reviews (advisory, native subagents):
    • Fidelity: 28f6903 Fix now 2개(D-37 새 카드의 정정 억제, AI 꺼짐 다시 확인 core 테스트와 오류 문구) -> 52113f680에서 고침; 52113f6, 6cb74d2 Fix now 없음. Follow-up: from_card 해석 테스트, 링크 한 단계, B15/B12 테스트, B11 근사, B13 소급.
    • Code: 28f6903 Fix now 3개 -> f56aca3, 52113f680에서 고침; 52113f6 Fix now 1개(server.js export, Low) -> 6cb74d2; d99d074 Fix now 1개(링크된 전역 지시면 코어 이동 거절, Medium) -> b730419, c1403906f에서 고침; 3237405 fixture 수정 확인; 마지막 리뷰 c140390, 3237405 Fix now 없음. Follow-up: 흔한 링크 이름의 파싱 비용, may_name 중복 검색, JS route decode 테스트, 링크를 평평하게 옮긴 기록(link_copied).
    • Security: 28f6903 Fix now 4개 -> 52113f6(256 KiB 이후 이름은 수용한 한계); 52113f6 Fix now 1개(링크 대상이 hook 사전 검사를 못 지남, Medium) -> 6cb74d2; b730419 Follow-up(이동 복사에 상한 없음, 검사-복사 경합)을 c1403906f에서 상한 읽기로 닫음; c140390 Fix now 없음. Follow-up: 흔한 이름 링크 시 셸 읽기 거절, 거절 로그 rate limit, .hide-new 예측 가능 이름, PowerShell matcher.
    • 8bd8a5c87은 c140390 이후 테스트 두 파일만 바꿨습니다(remote_core fixture 시각, SessionStart receipt 기대).
  • Evidence: 5 registered (5 screenshot); paths are local to the run directory
    • agents/runs/memory-self-improve/evidence/global_unusable-ko.png
    • agents/runs/memory-self-improve/evidence/upkeep-ko.png
    • agents/runs/memory-self-improve/evidence/upkeep-en.png
    • agents/runs/memory-self-improve/evidence/global-ko.png
    • agents/runs/memory-self-improve/evidence/global-en.png
  • Changed paths: 96 (see Files changed)
  • Delivery: mode pr, branch feat/memory-self-improve, base main

A session start's hook answer now carries global-instruction.md from the
core's state folder in its own slot and cap (4 KiB, 1,600 estimated tokens),
whether or not Memory answers. Claude Code, Codex and Antigravity get it at
SessionStart, OpenCode, Pi and omp with the first prompt. The core module
also owns the one-line apply and revert the 제안 tab will use.
Schema 22 ages cards no one was given or said (stale after 30 days,
archived after 60, protected when the operator said a rule or decision
in two sessions), records SessionStart index receipts apart from body
receipts, counts ignored and missed cards, folds same-meaning cards on
the analysis answer, keeps the operator's repeated requests, and lets
the operator or a given agent recheck a card (hide memory recheck).
Every automatic change is in a per-card history with its undo, and the
Memory snapshot carries the archive list, the history and the new
actions.
The Memory tab marks a memory unused for 30 days, folds archived ones
under one line with Bring back, adds Check again to a memory shown in
full, and lists what Hide changed on it by itself (aging, added words,
merges, rechecks) with Undo or the reason there is none. Architecture,
UI behavior and hook docs describe aging, ignored and missed counts,
merges, repeats, rechecks and the session-start index receipt.
Memory's analysis now hands the suggestion ledger two signals: each time
the operator repeated a request it named (with the sessions behind the
card that says the same) and each session that was given a rule or
preference card and still had to say it again. Their lines are grouped
by meaning at once and scored by where it was said again, rising at
4, 3 or 2 points by quantity, or after two ignored sessions. A personal
line is written into the Hide global instruction on the operator's press
with no pull request, can be taken back alone, and is offered again when
a session that was given it repeats it; a project line goes through the
existing pull request ladder, as a skill for a procedure. Opening a row's
evidence reads the masked words again and a row none of whose words can
be read is not applied.
…ions tab

A personal line shows the line it would put into the Hide global
instruction, adds it with the preview it was drawn from, and folds under
Applied with Undo; a held, changed, edited or failed write says why, with
Open file where the file itself needs a hand. Opening a row reads its
words back masked, says when they can no longer be confirmed, and holds
the press when none can. The tab says once when sessions are not given
the file, and settings name the two new signals.
A merge no longer keeps or absorbs an archived card, which took both out
of every hook. An agent's own hide memory show no longer counts as the
card being given for a recheck, and the Memory tab's recheck is refused
while Hide AI is off, as the command is. Each hourly aging run cuts the
change history back to its limit and logs how many rows went.
The pre-tool hook refuses an agent's file write or shell call naming the
global instruction, in every session and project. Hide's own writes go
through the editor's checked save, follow a link to its target, and
never overwrite an edit saved meanwhile; a pipe at the path is refused
without blocking. A line with markup, a hidden character or a secret is
never written, the same check a repeated request's line passes. OpenCode,
Pi and omp still get the instruction when their start guidance came
before the session-start capsule.
A press carries a token of the line and the file it was shown, so a
reworded line or a changed file gets a new preview instead of a write. A
line the operator already had is adopted and its Undo leaves it, and a
press repeated after a lost answer converges. Ignored-memory lines come
only from cards the operator said, a repeated turn raises no separate
correction, ignored evidence says whether the card came in the list or in
full, and the automatic mode passes over global instruction lines. The
evidence reader shows only the operator's words, keys what it read by
Project and runs one read at a time; Open file shows only on the core's
machine.
The guard now reads a bare file name beside a state folder or run in one,
compares names without case, follows a link at the file, refuses a call
cut before it could be read, logs each refusal, and the OpenCode, Pi and
omp plugins send a call naming the file to the helper with no guardrail
on.
Follow a link at the global instruction only to an existing text file and
never create through one, raise no correction for a card made at a repeat's
turn, refuse a Memory tab recheck with Hide AI off in words, free the
evidence read slot after a panic, and drop an unused evidence field.
@yansfil
yansfil merged commit a5c12bc into main Oct 28, 2026
85 of 87 checks passed
@yansfil
yansfil deleted the feat/memory-self-improve branch October 28, 2026 23:26
yansfil added a commit that referenced this pull request Oct 30, 2026
…e hooks (#1852)

## Summary

The agent journey's `guidance_memory` cell failed for Codex CLI and
OpenCode in the v1.0.4 release run while Claude Code passed, and the
same build had passed it an attempt earlier.
The journey seeds its one Memory card with `created_at_unix_ms: 1`, a
card dated 1970.
Since #1816, Memory ages cards: one quiet past the archive age is
archived and leaves the hooks.
So the first aging run during the journey (`cards.aged archived:[1]` in
the run's `hided.log`) took the card away, and every agent that started
after it was given no card; which agents that hit depended on when the
run happened.
The seed now dates the card at the moment it is made, as a real card is.
This is test tooling only (`hide-memory/examples/journey_memory.rs`); no
product code changes.

스크린샷 없음: 화면을 바꾸지 않는 journey 도구 수정입니다.

## Review

- `hide-memory/examples/journey_memory.rs`: the batch's
`created_at_unix_ms` is the current time; a clock before 1970 is refused
with `clock_before_epoch` rather than defaulted.

## Evidence

- Confirmed: release run attempt 2 at 4f9f8d9 failed `guidance_memory`
for codex and opencode with "no assistant message carries" the card's
token; Codex answered "I don't have the Project Memory card's title",
and the run's `hided.log` shows
`{"component":"memory","kind":"cards.aged",...,"archived":[1]}`.
`hide-memory/src/store/upkeep.rs` `age_cards` reads a card's clock from
`created_at_ms` when no aging clock or given time is newer.
- Confirmed: the example builds (`scripts/verify-cargo.sh build -p
hide-memory --example journey_memory`).
- In progress: the release journey rerun with this seed; its result goes
on the release record, not here.
yansfil added a commit that referenced this pull request Oct 30, 2026
… at the pin before blaming a release (#1862)

Closes with-hide/hide-private#358

## Summary

#1816 (Memory aging) broke the agent journey's `guidance_memory` cell,
but its pull request never ran the journey, and the nightly agent canary
then filed five agent releases for Hide's own break (hide-private#341,
#343-#346).
Two fixes:

- **Pull request CI runs the journey for product code.** A change to any
crate's product code (`src/` outside test modules, `build.rs`,
`Cargo.toml`) now plans the keyless `agent-journey` lane, which costs
about 4.4 min on Linux plus 0.4 min on Windows. Every crate builds into
a program the journey runs. The stand-in now also judges
`guidance_memory`: it answers from the Memory index its start hook
printed, using the fake model's own rule.
- **The canary tells a release's break from Hide's.** When an agent's
latest release misses a cell, the canary reruns that agent alone at its
pinned version, on the same commit and only on the systems where it
failed. If the pin passes, the issue goes against the release. If the
pin fails too, one issue goes against Hide. With no pinned measurement
the agent is marked `unknown` and nobody is blamed.

스크린샷 없음: CI 계획과 canary 스크립트만 바꾸며 화면이 없습니다.

## Review

- **판단해 주세요**: crate 변경 PR마다 job 2개(Linux 약 4.4분, Windows forms 약 0.4분)가
늘어납니다. herdr-core 변경은 18 -> 20 jobs입니다. Windows forms는 스크립트만 시험하므로 crate
변경에서 빼는 것도 가능하지만, plan 출력 계약을 늘리지 않으려고 lane 하나로 두었습니다.
- **조심해서 볼 파일**:
- `web/e2e/shims/live-check.h`: stand-in이 이제 부팅 5초를 start hook보다 먼저
기다립니다. 바로 실행되던 SessionStart hook은 Hide가 pane을 연결하기 전에
`pane_not_connected`로 거부되어 Memory를 받지 못했습니다(아래 질문).
- `scripts/agent-canary-record.py`: 놓친 셀이 누구 탓인지 가르는 부분(`verdicts`)입니다.
`install` 실패는 릴리스 탓, pin도 같은 셀을 놓치면 Hide 탓, pinned 측정이 없거나 pinned 설치가
실패하면 `unknown`입니다.
- `.github/workflows/agent-canary.yml`: `reruns` -> `pinned` -> `record`
흐름입니다. pinned 재실행이 cancelled면 record를 건너뛰고 다음 날 다시 잽니다.
- **따로 남긴 것**: Hide가 pane을 연결하기 전에 SessionStart hook이 돌면 그 세션은 Memory
index 없이 시작합니다. with-hide/hide-private#365로 남겼고, 이 PR은 고치지 않습니다.

## Evidence

- **확인한 것**: stand-in 여정 Linux, workflow_dispatch로 실행했습니다.
- 이 브랜치: run 40992711843 green이고, `guidance_memory`가 Claude Code와 Codex
모두 pass입니다.
- #1852의 seed를 1970으로 되돌린 브랜치: run 40992748014 red이고, Codex가
`guidance_memory` fail입니다. hided.log에 `cards.aged … "archived":[1]`가
남았습니다. 즉 이 PR의 라우팅이었다면 #1816은 PR CI에서 빨갛게 떴을 것입니다.
- **확인한 것**: fake model 여정을 `agents=codex`로 Linux에서 실행했습니다(run
40991943778 green, 약 5분). report의 `selected`는 `["codex"]`이고, Codex 12개 셀
모두 pass, 다른 agent는 `not measured`입니다. `--agents`가 붙은 lane 판정도 통과했습니다.
- **확인한 것**: 스크립트 suite 729개 테스트 OK(policy lane과 같은 명령)입니다. 새 테스트:
- `test_the_product_code_the_journey_runs_plans_the_journey_lane`(test
모듈은 제외)
  - canary의 release / Hide / unknown 판정과 재실행 대상
  - `--agents` lane 판정
  - "모든 miss를 릴리스 탓"으로 되돌리는 결함을 심으면 Hide 판정 테스트가 실패하는 것을 확인했습니다.
- **확인하지 못한 것**: canary workflow 전체(`reruns` -> `pinned` -> `record`)는
실행하지 않았습니다. 브랜치에서 돌리면 hide-private의 실제 support record와 issue를 다시 쓰기
때문이며, 첫 실행은 main 병합 후의 일일 canary입니다. 각 조각(reusable workflow의 `agents`,
`report-name` 입력과 record 판정)은 위 실행과 단위 테스트로만 확인했습니다. macOS stand-in과
Windows forms는 이 PR의 CI가 돌립니다.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant