resurface

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 21, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package resurface는 오래 안 본 context 문서를 다시 꺼낸다. 재발견 커맨드 중 유일하게 상태를 읽고 쓴다. 제시 이력은 .engram/resurface.json 에 두며 사라져도 중복 제시가 생길 뿐이므로 이력이 깨졌다고 도구가 멈추지 않는다. ADR 0028.

Index

Constants

View Source
const CooldownDays = 21

CooldownDays는 한 번 제시한 문서를 후보에서 빼 두는 기간이다. 설정으로 노출하지 않는다(ADR 0010 과 같은 이유). upstream 과 같은 값이다.

Variables

This section is empty.

Functions

func BaseDate

func BaseDate(d doc.Doc) (time.Time, bool)

BaseDate는 문서의 기준 날짜를 반환한다. updated 를 우선하고 없으면 created 를 쓴다. 둘 다 없으면 false 다. digest 의 노후 집계도 이 규칙을 쓰므로 노후 판정의 단일 진실원을 여기에 둔다.

func IsStale

func IsStale(d doc.Doc, now time.Time, staleDays int) bool

IsStale는 문서의 기준 날짜가 staleDays 를 넘었는지를 판정한다. 기준 날짜가 없는 문서는 노후가 아니라 대상 밖이다(개수는 따로 센다).

func LoadHistory

func LoadHistory(wikiRoot string) map[string]time.Time

LoadHistory는 제시 이력을 읽는다. 파일이 없거나 파싱에 실패하거나 스키마 버전이 다르면 빈 이력으로 취급한다. 재생성 가능한 캐시가 깨졌다고 도구가 멈추면 안 된다.

func SaveHistory

func SaveHistory(wikiRoot string, shown map[string]time.Time) error

SaveHistory는 제시 이력을 .engram/resurface.json 에 쓴다. 슬러그 키는 encoding/json 이 정렬하므로 같은 상태를 두 번 저장하면 바이트까지 같다.

Types

type Candidate

type Candidate struct {
	Slug      string     `json:"slug"`
	Title     string     `json:"title"`
	Path      string     `json:"path"`
	AgeDays   int        `json:"daysSinceUpdate"`
	Inbound   int        `json:"inboundLinks"`
	Score     float64    `json:"score"`
	LastShown *time.Time `json:"lastShown"`
	Cooldown  bool       `json:"cooldown"`
}

Candidate는 다시 꺼낼 문서 하나다. 근거가 되는 경과일과 제시 이력을 함께 실는다. 문장은 만들지 않는다(design.md 재발견 절).

type Result

type Result struct {
	StaleDays      int         `json:"staleDays"`
	Now            time.Time   `json:"now"`
	SkippedNoDate  int         `json:"skippedNoDate"`
	Candidates     []Candidate `json:"candidates"`
	CooldownDays   int         `json:"cooldownDays"`
	CooldownFilled int         `json:"cooldownFilled"`
	NoInbound      []Unlinked  `json:"noInbound"`
	Reason         string      `json:"reason,omitempty"`
}

Result는 resurface 실행 결과다. 후보가 없으면 Reason 에 이유가 들어간다.

func Run

func Run(wikiRoot string, cfg config.Config, now time.Time, limit int, dryRun bool) (Result, error)

Run은 오래 안 본 context 문서를 골라 낸다. dryRun 이 아니면 낸 문서의 제시 시각을 now 값으로 기록한다. 상태를 쓰는 유일한 조회 커맨드라 같은 위키라도 실행마다 결과가 달라진다.

type Unlinked

type Unlinked struct {
	Slug  string `json:"slug"`
	Title string `json:"title"`
	Path  string `json:"path"`
}

Unlinked는 아무도 가리키지 않는 context 문서다. 재발견의 고아 판정은 인바운드만 본다. lint 의 graph.orphan 과 다른 것을 재므로 형도 이름도 나눠 둔다(ADR 0066).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL