From 5ab6e07ad267e6ce070ad1bc03f5ca08b6196f9b Mon Sep 17 00:00:00 2001 From: Hsukqi Lee Date: Tue, 17 Nov 2026 23:56:40 +0800 Subject: [PATCH 1/3] feat: ingest and classify software and machine learning conferences --- .agents/skills/conference-ingestion/SKILL.md | 38 +++ .agents/skills/field-briefing/SKILL.md | 2 +- .../field-briefing/references/corpus.md | 19 +- .github/workflows/conf_release.yml | 9 +- README.md | 8 +- cmd/fastnews/conference_sources_test.go | 193 +++++++++++++++ internal/ai/service.go | 4 +- internal/catalog/catalog.go | 31 ++- internal/httpapi/server_test.go | 2 +- internal/jobs/conference.go | 24 +- internal/jobs/conference_api.go | 222 ++++++++++++++++++ internal/jobs/report.go | 2 +- web/src/pages/Generate.tsx | 24 +- web/src/pages/Home.tsx | 2 +- web/src/pages/Papers.tsx | 10 +- web/tests/workspace.spec.ts | 22 ++ 16 files changed, 568 insertions(+), 44 deletions(-) create mode 100644 .agents/skills/conference-ingestion/SKILL.md create mode 100644 cmd/fastnews/conference_sources_test.go create mode 100644 internal/jobs/conference_api.go diff --git a/.agents/skills/conference-ingestion/SKILL.md b/.agents/skills/conference-ingestion/SKILL.md new file mode 100644 index 0000000..1649f30 --- /dev/null +++ b/.agents/skills/conference-ingestion/SKILL.md @@ -0,0 +1,38 @@ +--- +name: conference-ingestion +description: "Collect, classify and render a requested conference/year in FastNews, or extend its conference source registry. Use for conference ingestion and domain coverage, including software engineering and Coding Agents; use field-briefing for literature search alone." +--- + +# Conference ingestion + +Use the production Go pipeline and the source registry in `internal/catalog/catalog.go`. + +## Existing sources + +- Security: `usenix`, `ieee-sp`, `ndss`, `ccs` use official conference pages. +- Machine learning: `iclr`, `icml`, `neurips` use OpenReview API v2 and the exact accepted conference venue for the requested year. +- Software engineering: `icse`, `ase` use DBLP conference/workshop bibliography records for the requested stream/year. Preserve the actual venue; these records do not establish main-track-only coverage or provide paper abstracts. + +For a requested conference/year, run the stages the user requested: + +```bash +go run ./cmd/fastnews fetch-conf --conference --year +go run ./cmd/fastnews summarize-conf --conference --year +go run ./cmd/fastnews conference-report --conference --year +``` + +Fetching writes the local corpus. Summarization uses the configured model and resumes existing per-paper checkpoints. HTML rendering is local; `--pdf` additionally requires Chromium. A retrieval-only request uses `search-papers` instead. + +Inspect the records in `top-conf/data/conferences/_.jsonl`, the category/summary output and the rendered report. Check stable identities, original links, authors, source provenance, requested year and actual scope. Source errors, authentication challenges, unavailable proceedings and incomplete pagination remain explicit failures; do not replace them with unrelated pages or claim a successful empty collection. An override URL must expose the same provider protocol. Do not trigger release/deployment workflows merely to validate collection. + +## Classification + +Supply the available title, abstract, keywords and venue to the model. Keep its structured category and summary. Detailed topics such as Coding Agents are semantic choices based on this evidence, not substring filters. When only bibliography/title evidence exists, the summary must say so and avoid invented methods, results or experiments. A successful fixture run proves protocol handling; live acquisition and model quality require their own observations. + +## Extending sources + +1. Identify the authoritative endpoint and its declared record identities, scope and pagination. Confirm a real response when access is available. +2. Add the conference's name/domain/provider/remote identifier to the existing registry. Reuse an existing provider when its protocol fits; add parsing in `internal/jobs` only for a distinct protocol. +3. Keep accepted-venue or stream/year validation and stable-ID deduplication before corpus writes. Preserve source fields needed by the classifier. +4. Verify the production CLI path through fetch, classification checkpoints, HTTP catalog and HTML report, with remote services replaced only at their HTTP boundary. +5. Update the report workflow choices and docs. Run Go race/vet and the frontend/browser CI before merging. Report separately any live endpoint or model verification still blocked by external access. diff --git a/.agents/skills/field-briefing/SKILL.md b/.agents/skills/field-briefing/SKILL.md index b294c71..6a25884 100644 --- a/.agents/skills/field-briefing/SKILL.md +++ b/.agents/skills/field-briefing/SKILL.md @@ -20,7 +20,7 @@ go run ./cmd/fastnews search-papers --query "" --limit 16 The Go command reads the existing corpus without generating content or starting a server. It uses the same vector retriever as the application. Add `--category`, `--conference`, `--year`, or `--source top-conf|arxiv` to narrow the evidence. If hits are weak, rerun with English aliases or a broader category, then inspect the JSON `items`. -3. Use web search only for canonical surveys or seminal papers that FastNews does not cover (the local top-conference set is recent Big4, not a historical archive). Open a real page before citing an external paper. Skip web search when local hits already answer a narrow request. +3. Use web search only for canonical surveys or seminal papers that FastNews does not cover. Inspect the actual local conference/year coverage; registered sources do not imply their papers have been fetched and summarized. Open a real page before citing an external paper. Skip web search when local hits already answer a narrow request. 4. Write the briefing from the retrieved papers plus established field knowledge. Do not invent FastNews papers, venues, years, or links. ## Output diff --git a/.agents/skills/field-briefing/references/corpus.md b/.agents/skills/field-briefing/references/corpus.md index 1fa0686..019df91 100644 --- a/.agents/skills/field-briefing/references/corpus.md +++ b/.agents/skills/field-briefing/references/corpus.md @@ -11,26 +11,13 @@ Local sources used by `go run ./cmd/fastnews search-papers`. | arXiv + news | `secnews/data/articles/YYYY-MM-DD.jsonl` | Filter `source` to arXiv feeds | | Daily Chinese blurbs | `secnews/data/daily_summaries/YYYY-MM-DD.json` | Join by `_id` / `link` when present | -Conference file stems: `usenix`, `ieee-sp`, `ndss`, `ccs`. Labels: USENIX Security, IEEE S&P, NDSS, ACM CCS. +Conference file stems are registered in `internal/catalog/catalog.go`: `usenix`, `ieee-sp`, `ndss`, `ccs`, `iclr`, `icml`, `neurips`, `icse`, `ase`. -FastNews covers summarized Big4 papers from the years present in the corpus, plus the last 90 days of fetched arXiv feeds (`cs.CR`, `cs.AI+cs.CL`). Inspect the actual files for coverage; this is not a complete historical library. +FastNews searches summarized conference papers from the years actually present in the corpus, plus the last 90 days of fetched arXiv feeds (`cs.CR`, `cs.AI+cs.CL`, `cs.SE`). Source registration does not imply that a conference/year is present. Inspect the actual files for coverage; this is not a complete historical library. The separate arXiv reading page can browse older dated files without the research index's 90-day cutoff. ## Categories -Use these exact English names when passing `--category`: - -- Web Security -- Network Security -- System & OS Security -- Hardware Security -- Cryptography & Protocols -- Privacy & Anonymity -- ML/AI Security -- Human Factors & Usable Security -- Binary & Forensics -- Miscellaneous - -A few summary rows may use `Network & System Security`; treat them as network/system papers, do not rename the files. +Read the actual category strings from the summary records or `/api/catalog` before passing `--category`. Classification uses source evidence and the conference domain, so fine-grained categories can vary between corpora. Pass the stored value exactly; do not rename files or silently force software/ML papers into the older security taxonomy. ## Search output diff --git a/.github/workflows/conf_release.yml b/.github/workflows/conf_release.yml index 6282eef..f086bb3 100644 --- a/.github/workflows/conf_release.yml +++ b/.github/workflows/conf_release.yml @@ -8,7 +8,7 @@ on: required: true default: usenix type: choice - options: [usenix, ieee-sp, ndss, ccs] + options: [usenix, ieee-sp, ndss, ccs, iclr, icml, neurips, icse, ase] year: description: Conference year required: true @@ -68,10 +68,7 @@ jobs: RELEASE_TAG: report-${{ inputs.conference }}-${{ inputs.year }} run: | case "$CONFERENCE" in - usenix) PREFIX=USENIX ;; - ieee-sp) PREFIX=IEEE-SP ;; - ndss) PREFIX=NDSS ;; - ccs) PREFIX=CCS ;; + usenix|ieee-sp|ndss|ccs|iclr|icml|neurips|icse|ase) PREFIX="$(printf '%s' "$CONFERENCE" | tr '[:lower:]' '[:upper:]')" ;; *) exit 2 ;; esac REPORT="top-conf/data/report/${PREFIX}_${YEAR}_Report" @@ -79,5 +76,5 @@ jobs: gh release upload "$RELEASE_TAG" "$REPORT.html" "$REPORT.pdf" --clobber else gh release create "$RELEASE_TAG" "$REPORT.html" "$REPORT.pdf" \ - --target main --title "$PREFIX $YEAR Summary" --notes '安全顶会论文中文报告。' + --target main --title "$PREFIX $YEAR Summary" --notes '会议论文分类与中文报告。' fi diff --git a/README.md b/README.md index 3b12eb9..ce6aaaa 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # FastNews -安全研究报告工作台:Go 后端与 React / TypeScript 前端分离,前端使用 **FastUI 0.3.0**。总览、安全资讯、四大顶会论文、领域导读、总结汇报、关注作者、每日私信及账号管理共用同一套 JSON API。 +安全研究报告工作台:Go 后端与 React / TypeScript 前端分离,前端使用 **FastUI 0.3.0**。总览、安全资讯、多领域会议论文、领域导读、总结汇报、关注作者、每日私信及账号管理共用同一套 JSON API。 ## 开发 @@ -70,7 +70,7 @@ FastRead 保留现有授权边界:Research 会话申请 `fast-read` 一次性 ```bash ./bin/fastnews search-papers --query 'LLM jailbreak' --limit 16 # 只读 JSON 检索 ./bin/fastnews field-briefing --query 'LLM jailbreak' --limit 5 --format text -./bin/fastnews summary-brief --query '四大顶会全景' +./bin/fastnews summary-brief # 会议论文全景 ``` ## Go 数据任务 @@ -100,7 +100,9 @@ FastRead 保留现有授权边界:Research 会话申请 `fast-read` 一次性 ./bin/fastnews index ``` -会议支持 `usenix / ieee-sp / ndss / ccs`,采集地址可通过 `--url` 指定。官方页面改版导致解析不到论文时返回错误,不用空结果覆盖历史文件。新闻以 ID / URL 去重,论文摘要按 ID 续跑,日报保持原 `source_hash` 检查点算法。`enrich-metrics` 使用 OpenAlex 并要求标题规范化后完全匹配。 +会议支持安全四会 `usenix / ieee-sp / ndss / ccs`、机器学习 `iclr / icml / neurips` 以及软件工程 `icse / ase`。安全会议读取官方页面;机器学习会议读取 OpenReview API v2 中指定年份的正式会议 venue;ICSE/ASE 读取 DBLP 中对应年份、会议流的会议及研讨会论文记录,并保留原始 venue。DBLP 不提供摘要时,生成结果必须说明仅依据标题,不补造实验。分类参考会议领域,支持 Coding Agents 等细分方向,不通过标题关键词自动判定类别。 + +采集地址可通过 `--url` 指定同协议的来源。OpenReview/DBLP 分页全部校验完成后才追加数据;来源要求登录、返回验证页、分页不完整或会议/年份不符时返回错误并保留已有文件。新闻以 ID / URL 去重,结构化会议记录和论文摘要按稳定 ID 续跑,日报保持原 `source_hash` 检查点算法。`update-range` 仍按原安全四会运行,其他会议按 `fetch-conf → summarize-conf → conference-report` 单独选择年份;手动报告工作流支持全部已接入会议。`enrich-metrics` 使用 OpenAlex 并要求标题规范化后完全匹配。 HTML 报告由 Go 模板生成。PDF 使用 Chromium,通过 `FASTNEWS_CHROME` 指定可执行文件;不请求 PDF 时不需要浏览器。周报同时输出到 `output/` 及 `secnews/data/report/`。CI 的采集、摘要与报告工作流已改为 Go CLI。 diff --git a/cmd/fastnews/conference_sources_test.go b/cmd/fastnews/conference_sources_test.go new file mode 100644 index 0000000..455651c --- /dev/null +++ b/cmd/fastnews/conference_sources_test.go @@ -0,0 +1,193 @@ +package main + +import ( + "context" + "encoding/json" + "fmt" + "io" + "net/http" + "net/http/httptest" + "net/url" + "os" + "path/filepath" + "strconv" + "strings" + "sync/atomic" + "testing" + + "github.com/FastR-D/FastNews/internal/catalog" + "github.com/FastR-D/FastNews/internal/config" + "github.com/FastR-D/FastNews/internal/httpapi" + "github.com/FastR-D/FastNews/internal/store" +) + +func TestConferenceSourcesThroughCLIClassificationCatalogAndReport(t *testing.T) { + for _, conf := range []string{"iclr", "icml", "neurips", "icse", "ase"} { + t.Run(conf, func(t *testing.T) { + var mode atomic.Int32 + var modelCalls atomic.Int32 + upstream := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + if r.URL.Path == "/chat/completions" { + modelCalls.Add(1) + body, _ := io.ReadAll(r.Body) + if !strings.Contains(string(body), "Study") { + t.Error("model did not receive source paper evidence") + } + if conf == "iclr" || conf == "icml" || conf == "neurips" { + if !strings.Contains(string(body), "Official abstract") || !strings.Contains(string(body), "Declared keyword") { + t.Error("available abstract or keywords were lost before classification") + } + } + json.NewEncoder(w).Encode(map[string]any{"choices": []any{map[string]any{"finish_reason": "stop", "message": map[string]string{"content": `{"category":"Coding Agents / 评测","summary_zh":"基于提供的论文材料归纳研究问题与评测方法。"}`}}}}) + return + } + if mode.Load() == 3 { + fmt.Fprint(w, `Verification required`) + return + } + if mode.Load() == 4 { + fmt.Fprint(w, `{}`) + return + } + offset, _ := strconv.Atoi(catalog.First(r.URL.Query().Get("offset"), r.URL.Query().Get("f"), "0")) + paperOffset := offset + if mode.Load() == 6 { + paperOffset = 0 + } + if mode.Load() == 1 && offset > 0 { + w.WriteHeader(503) + return + } + if conf == "iclr" || conf == "icml" || conf == "neurips" { + venue := r.URL.Query().Get("content.venueid") + if mode.Load() == 2 { + venue = "Different.cc/2026/Conference" + } + note := map[string]any{"id": fmt.Sprintf("%s-%d-%d", conf, mode.Load(), paperOffset), "content": map[string]any{ + "title": map[string]any{"value": "Study shared title"}, "abstract": map[string]any{"value": "Official abstract"}, + "authors": map[string]any{"value": []string{"Alice", "Bob"}}, "keywords": map[string]any{"value": []string{"Declared keyword"}}, + "venueid": map[string]any{"value": venue}, "venue": map[string]any{"value": "Accepted paper"}, + }} + notes, total := []any{note}, 2 + if mode.Load() == 5 && offset > 0 { + notes = nil + } + if mode.Load() == 7 && offset > 0 { + total++ + } + json.NewEncoder(w).Encode(map[string]any{"count": total, "notes": notes}) + } else { + stream := "icse" + if conf == "ase" { + stream = "kbse" + } + year := "2026" + if mode.Load() == 2 { + year = "2025" + } + author := any(map[string]string{"text": "Alice"}) + if offset > 0 { + author = []any{map[string]string{"text": "Alice"}, map[string]string{"text": "Bob"}} + } + hit := map[string]any{"info": map[string]any{"key": fmt.Sprintf("conf/%s/paper-%d-%d", stream, mode.Load(), paperOffset), + "title": "Study shared title", "year": year, "type": "Conference and Workshop Papers", "venue": "Published Track", + "authors": map[string]any{"author": author}, "ee": "https://doi.org/10.1000/" + conf + strconv.Itoa(offset), + "url": "https://dblp.org/rec/conf/" + stream + "/record"}} + hits := []any{hit} + if offset == 0 { + hits = append(hits, map[string]any{"info": map[string]any{"type": "Editorship", "title": "Proceedings"}}) + } + total := 3 + if mode.Load() == 5 && offset > 0 { + hits = nil + } + if mode.Load() == 7 && offset > 0 { + total++ + } + json.NewEncoder(w).Encode(map[string]any{"result": map[string]any{"hits": map[string]any{"@total": strconv.Itoa(total), "hit": hits}}}) + } + })) + defer upstream.Close() + local, _ := url.Parse(upstream.URL) + original := http.DefaultTransport + http.DefaultTransport = newsTransport(func(r *http.Request) (*http.Response, error) { + if r.URL.Host == local.Host { + return original.RoundTrip(r) + } + if r.URL.Host != "api2.openreview.net" && r.URL.Host != "dblp.org" { + return nil, fmt.Errorf("unexpected upstream %s", r.URL) + } + copy := r.Clone(r.Context()) + address := *r.URL + address.Scheme, address.Host = local.Scheme, local.Host + copy.URL = &address + return original.RoundTrip(copy) + }) + t.Cleanup(func() { http.DefaultTransport = original }) + c := config.Config{Root: t.TempDir(), LLMKey: "fixture", LLMURL: upstream.URL} + args := []string{"--conference", conf, "--year", "2026"} + ctx := context.Background() + for range 2 { + if err := job(ctx, c, "fetch-conf", args); err != nil { + t.Fatal(err) + } + } + file := filepath.Join(c.Root, "top-conf/data/conferences", conf+"_2026.jsonl") + rows, err := catalog.Rows(file) + if err != nil || len(rows) != 2 { + t.Fatalf("pagination/deduplication: %v rows, %v", len(rows), err) + } + for range 2 { + if err := job(ctx, c, "summarize-conf", args); err != nil { + t.Fatal(err) + } + } + if modelCalls.Load() != 2 { + t.Fatalf("repeated paid generation: %d", modelCalls.Load()) + } + if err := job(ctx, c, "conference-report", args); err != nil { + t.Fatal(err) + } + report, err := os.ReadFile(filepath.Join(c.Root, "top-conf/data/report", strings.ToUpper(conf)+"_2026_Report.html")) + if err != nil || !strings.Contains(string(report), catalog.Str(rows[0], "link")) || !strings.Contains(string(report), catalog.Str(rows[1], "link")) { + t.Fatalf("report lost papers: %v", err) + } + database, err := store.Open(filepath.Join(c.Root, "accounts")) + if err != nil { + t.Fatal(err) + } + defer database.Close() + app, err := httpapi.New(c, database) + if err != nil { + t.Fatal(err) + } + recorder := httptest.NewRecorder() + app.Handler().ServeHTTP(recorder, httptest.NewRequest("GET", "/api/papers?source=top-conf&conference="+conf+"&year=2026", nil)) + var result struct { + Papers []catalog.Paper `json:"papers"` + } + if err := json.Unmarshal(recorder.Body.Bytes(), &result); err != nil || recorder.Code != 200 || len(result.Papers) != 2 { + t.Fatalf("catalog response %d: %s", recorder.Code, recorder.Body.String()) + } + for _, paper := range result.Papers { + if paper.Category != "Coding Agents / 评测" { + t.Fatal("model category was lost", paper) + } + } + before, err := os.ReadFile(file) + if err != nil { + t.Fatal(err) + } + for _, invalid := range []int32{1, 2, 3, 4, 5, 6, 7} { + mode.Store(invalid) + if err := job(ctx, c, "fetch-conf", args); err == nil { + t.Fatalf("invalid/incomplete source mode %d succeeded", invalid) + } + after, err := os.ReadFile(file) + if err != nil || string(before) != string(after) { + t.Fatalf("failed source mode %d changed historical corpus: %v", invalid, err) + } + } + }) + } +} diff --git a/internal/ai/service.go b/internal/ai/service.go index d5df2c5..88bd1c4 100644 --- a/internal/ai/service.go +++ b/internal/ai/service.go @@ -165,9 +165,9 @@ func (s *Service) Run(ctx context.Context, kind string, req Request) (map[string if kind == "related-work" { query = strings.TrimSpace(req.Topic + " " + req.Keywords + " " + req.Impression) } - landscape := kind == "summary-brief" && (query == "" || strings.Contains(query, "四大顶会全景")) + landscape := kind == "summary-brief" && query == "" if landscape { - query = "四大顶会全景" + query = "会议论文全景" } if query == "" { return nil, store.Fail(400, "请输入研究方向,或先保存研究印象") diff --git a/internal/catalog/catalog.go b/internal/catalog/catalog.go index ab61f64..d804690 100644 --- a/internal/catalog/catalog.go +++ b/internal/catalog/catalog.go @@ -54,8 +54,30 @@ type Catalog struct { papers []Paper } -var Labels = map[string]string{"usenix": "USENIX Security", "ieee-sp": "IEEE S&P", "ndss": "NDSS", "ccs": "ACM CCS"} -var confRE = regexp.MustCompile(`^(usenix|ieee-sp|ndss|ccs)_(\d{4})_summary\.jsonl$`) +type Conference struct { + Name, Domain, Provider, RemoteID string +} + +var Conferences = map[string]Conference{ + "usenix": {"USENIX Security", "security", "html", ""}, + "ieee-sp": {"IEEE S&P", "security", "html", ""}, + "ndss": {"NDSS", "security", "html", ""}, + "ccs": {"ACM CCS", "security", "html", ""}, + "iclr": {"ICLR", "ml", "openreview", "ICLR.cc"}, + "icml": {"ICML", "ml", "openreview", "ICML.cc"}, + "neurips": {"NeurIPS", "ml", "openreview", "NeurIPS.cc"}, + "icse": {"ICSE", "software", "dblp", "icse"}, + "ase": {"ASE", "software", "dblp", "kbse"}, +} + +var Labels = func() map[string]string { + labels := map[string]string{} + for id, conference := range Conferences { + labels[id] = conference.Name + } + return labels +}() +var confRE = regexp.MustCompile(`^([a-z][a-z0-9-]*)_(\d{4})_summary\.jsonl$`) func Rows(path string) ([]map[string]any, error) { f, e := os.Open(path) @@ -143,6 +165,9 @@ func (c *Catalog) Papers() ([]Paper, error) { if m == nil { continue } + if _, ok := Conferences[m[1]]; !ok { + continue + } year, _ := strconv.Atoi(m[2]) src, e := Rows(filepath.Join(c.Root, "top-conf/data/conferences", m[1]+"_"+m[2]+".jsonl")) if e != nil { @@ -168,7 +193,7 @@ func (c *Catalog) Papers() ([]Paper, error) { continue } summary := First(Str(p, "summary_zh"), Str(s, "description")) - v := Paper{ID: id, Source: "top-conf", Title: title, Author: First(Str(p, "author"), Str(s, "author")), Year: year, Venue: Labels[m[1]], Conference: m[1], Category: First(Str(r, "category"), "Uncategorized"), Link: First(Str(p, "link"), Str(s, "link"), id), Summary: Clip(summary, 1200), SearchSummary: summary + " " + Str(s, "description"), DOI: Str(s, "doi"), Award: awards[m[1]+m[2]+NormalizeTitle(title)]} + v := Paper{ID: id, Source: "top-conf", Title: title, Author: First(Str(p, "author"), Str(s, "author")), Year: year, Venue: First(Str(s, "venue"), Labels[m[1]]), Conference: m[1], Category: First(Str(r, "category"), "Uncategorized"), Link: First(Str(p, "link"), Str(s, "link"), id), Summary: Clip(summary, 1200), SearchSummary: summary + " " + Str(s, "description"), DOI: Str(s, "doi"), Award: awards[m[1]+m[2]+NormalizeTitle(title)]} if award := CanonicalAward(Str(s, "award")); award != "" { v.Award = award } diff --git a/internal/httpapi/server_test.go b/internal/httpapi/server_test.go index 33068f8..25b9e63 100644 --- a/internal/httpapi/server_test.go +++ b/internal/httpapi/server_test.go @@ -237,7 +237,7 @@ func TestOfflineBriefingAndStatisticsRemainAvailable(t *testing.T) { for _, kind := range []string{"field-briefing", "summary-brief"} { body := map[string]any{"query": "LLM prompt injection", "source": "top-conf"} if kind == "summary-brief" { - body["query"] = "四大顶会全景" + body["query"] = "" } status, v, _ := h.request(t, "POST", "/api/"+kind, body, "", false) if status != 200 || v["fallback"] != true || len(v["papers"].([]any)) != 1 { diff --git a/internal/jobs/conference.go b/internal/jobs/conference.go index 9b287dc..650967a 100644 --- a/internal/jobs/conference.go +++ b/internal/jobs/conference.go @@ -4,6 +4,7 @@ import ( "context" "encoding/json" "fmt" + "net/url" "path/filepath" "regexp" "strconv" @@ -15,6 +16,18 @@ import ( ) func ConferenceURLs(conf string, year int) ([]string, error) { + metadata, ok := catalog.Conferences[conf] + if !ok { + return nil, fmt.Errorf("unknown conference %q", conf) + } + if metadata.Provider == "openreview" { + query := url.Values{"content.venueid": {fmt.Sprintf("%s/%d/Conference", metadata.RemoteID, year)}} + return []string{"https://api2.openreview.net/notes?" + query.Encode()}, nil + } + if metadata.Provider == "dblp" { + query := url.Values{"q": {fmt.Sprintf("stream:conf/%s: year:%d:", metadata.RemoteID, year)}, "format": {"json"}} + return []string{"https://dblp.org/search/publ/api?" + query.Encode()}, nil + } switch conf { case "usenix": base := fmt.Sprintf("https://www.usenix.org/conference/usenixsecurity%02d/", year%100) @@ -157,6 +170,9 @@ func (p *Pipeline) FetchConference(ctx context.Context, conf string, year int, o if year < 2000 || year > 2100 { return fmt.Errorf("invalid conference year") } + if catalog.Conferences[conf].Provider != "html" { + return p.fetchStructuredConference(ctx, conf, year, catalog.First(override, urls[0])) + } if override != "" { urls = []string{override} } @@ -253,7 +269,13 @@ func (p *Pipeline) SummarizeConference(ctx context.Context, conf string, year in Category string `json:"category"` Summary string `json:"summary_zh"` } - if e = p.AI.Complete(ctx, `你是安全顶会论文编辑。仅根据提供的标题和摘要归纳问题、方法、结果与局限;无摘要时明确说明仅据标题,禁止捏造实验。返回JSON {"category":"Web Security/System Security/Cryptography/Privacy/ML/AI Security/Network Security/Software Security/Hardware Security/Usable Security/Other 中一个类别","summary_zh":"中文深度摘要"}。`, string(b), &result); e != nil { + taxonomy := map[string]string{ + "security": "Web Security、System Security、Cryptography、Privacy、ML/AI Security、Network Security、Software Security、Hardware Security、Usable Security、Other", + "ml": "模型架构与训练、推理与规划、Coding Agents、智能体评测、对齐与安全、视觉与多模态、强化学习、机器学习理论等", + "software": "Coding Agents、代码生成、程序修复、软件测试、程序分析、需求与设计、软件维护、实证软件工程等", + }[catalog.Conferences[conf].Domain] + prompt := fmt.Sprintf(`你是%s论文编辑。仅根据提供的标题、摘要与关键词归纳问题、方法、结果与局限;无摘要时明确说明仅据标题,禁止捏造实验。按论文实际贡献给出具体研究类别,参考方向:%s。返回JSON {"category":"具体研究类别","summary_zh":"中文深度摘要"}。`, catalog.Labels[conf], taxonomy) + if e = p.AI.Complete(ctx, prompt, string(b), &result); e != nil { return e } if result.Category == "" || result.Summary == "" { diff --git a/internal/jobs/conference_api.go b/internal/jobs/conference_api.go new file mode 100644 index 0000000..bee715e --- /dev/null +++ b/internal/jobs/conference_api.go @@ -0,0 +1,222 @@ +package jobs + +import ( + "context" + "encoding/json" + "fmt" + "net/url" + "path/filepath" + "strconv" + "strings" + "time" + + "github.com/FastR-D/FastNews/internal/catalog" +) + +type reviewNote struct { + ID string `json:"id"` + Forum string `json:"forum"` + Content struct { + Title struct { + Value string `json:"value"` + } `json:"title"` + Abstract struct { + Value string `json:"value"` + } `json:"abstract"` + Authors struct { + Value []string `json:"value"` + } `json:"authors"` + Keywords struct { + Value []string `json:"value"` + } `json:"keywords"` + VenueID struct { + Value string `json:"value"` + } `json:"venueid"` + Venue struct { + Value string `json:"value"` + } `json:"venue"` + } `json:"content"` +} + +type bibliographyHit struct { + Info struct { + Key string `json:"key"` + Title string `json:"title"` + Year string `json:"year"` + Type string `json:"type"` + URL string `json:"url"` + EE json.RawMessage `json:"ee"` + Venue json.RawMessage `json:"venue"` + Authors struct { + Author json.RawMessage `json:"author"` + } `json:"authors"` + } `json:"info"` +} + +// DBLP declares scalar fields and author lists as either one value or an array. +func bibliographyValues(raw json.RawMessage) ([]string, error) { + if len(raw) == 0 || string(raw) == "null" { + return nil, nil + } + values := []json.RawMessage{raw} + if raw[0] == '[' { + if err := json.Unmarshal(raw, &values); err != nil { + return nil, err + } + } + out := []string{} + for _, item := range values { + var value string + if len(item) > 0 && item[0] == '"' { + if err := json.Unmarshal(item, &value); err != nil { return nil, err } + } else { + var named struct { Text string `json:"text"` } + if err := json.Unmarshal(item, &named); err != nil { return nil, err } + value = named.Text + } + if value == "" { return nil, fmt.Errorf("empty bibliographic value") } + out = append(out, value) + } + return out, nil +} + +func (p *Pipeline) fetchStructuredConference(ctx context.Context, conf string, year int, endpoint string) error { + metadata := catalog.Conferences[conf] + u, err := url.Parse(endpoint) + if err != nil { + return err + } + rows := []map[string]any{} + seen := map[string]bool{} + offset := 0 + expectedTotal := -1 + for { + query := u.Query() + total, count := 0, 0 + if metadata.Provider == "openreview" { + venue := fmt.Sprintf("%s/%d/Conference", metadata.RemoteID, year) + query.Set("content.venueid", venue) + query.Set("limit", "1000") + query.Set("offset", strconv.Itoa(offset)) + u.RawQuery = query.Encode() + body, err := get(ctx, u.String()) + if err != nil { + return err + } + var page struct { + Notes []reviewNote `json:"notes"` + Count *int `json:"count"` + } + if err := json.Unmarshal(body, &page); err != nil { + return fmt.Errorf("OpenReview response: %w", err) + } + if page.Count == nil { + return fmt.Errorf("OpenReview response missing count") + } + total, count = *page.Count, len(page.Notes) + for _, note := range page.Notes { + if note.ID == "" || note.Content.Title.Value == "" || note.Content.VenueID.Value != venue { + return fmt.Errorf("OpenReview note lacks identity/title or accepted venue %s", venue) + } + link := "https://openreview.net/forum?" + url.Values{"id": {catalog.First(note.Forum, note.ID)}}.Encode() + if seen[link] { + return fmt.Errorf("source repeated a paper across pages: %s", link) + } + seen[link] = true + rows = append(rows, map[string]any{"_id": link, "title": note.Content.Title.Value, "link": link, + "description": note.Content.Abstract.Value, "author": strings.Join(note.Content.Authors.Value, ", "), + "keywords": note.Content.Keywords.Value, "presentation": note.Content.Venue.Value, "source_url": u.String()}) + } + } else { + query.Set("q", fmt.Sprintf("stream:conf/%s: year:%d:", metadata.RemoteID, year)) + query.Set("format", "json") + query.Set("h", "1000") + query.Set("f", strconv.Itoa(offset)) + u.RawQuery = query.Encode() + body, err := get(ctx, u.String()) + if err != nil { + return err + } + var page struct { + Result struct { + Hits struct { + Total string `json:"@total"` + Hits []bibliographyHit `json:"hit"` + } `json:"hits"` + } `json:"result"` + } + if err := json.Unmarshal(body, &page); err != nil { + return fmt.Errorf("DBLP response: %w", err) + } + total, err = strconv.Atoi(page.Result.Hits.Total) + if err != nil { + return fmt.Errorf("DBLP response missing valid total") + } + count = len(page.Result.Hits.Hits) + for _, hit := range page.Result.Hits.Hits { + v := hit.Info + if v.Type != "Conference and Workshop Papers" { + continue + } + if v.Year != strconv.Itoa(year) || !strings.HasPrefix(v.Key, "conf/"+metadata.RemoteID+"/") || v.Title == "" { + return fmt.Errorf("DBLP record is outside the requested conference/year or lacks a title") + } + authors, err := bibliographyValues(v.Authors.Author) + if err != nil { + return err + } + links, err := bibliographyValues(v.EE) + if err != nil { + return err + } + venues, err := bibliographyValues(v.Venue) + if err != nil { + return err + } + link := v.URL + if len(links) > 0 { + link = links[0] + } + if link == "" || seen[v.Key] { + return fmt.Errorf("DBLP record has no URL or repeats identity: %s", v.Key) + } + seen[v.Key] = true + rows = append(rows, map[string]any{"_id": "https://dblp.org/rec/" + v.Key, "title": v.Title, "link": link, + "description": "", "author": strings.Join(authors, ", "), "venue": strings.Join(venues, ", "), "source_url": u.String()}) + } + } + if expectedTotal >= 0 && total != expectedTotal { + return fmt.Errorf("source total changed during pagination: %d to %d", expectedTotal, total) + } + expectedTotal = total + if total < 0 || offset+count > total || (count == 0 && offset < total) { + return fmt.Errorf("incomplete source pagination at %d of %d", offset, total) + } + offset += count + if offset == total { + break + } + } + if len(rows) == 0 { + return fmt.Errorf("no papers returned for %s %d", conf, year) + } + file := filepath.Join(p.Config.Root, "top-conf/data/conferences", fmt.Sprintf("%s_%d.jsonl", conf, year)) + existing, err := catalog.Rows(file) + if err != nil { + return err + } + known := map[string]bool{} + for _, row := range existing { + known[catalog.Str(row, "_id")] = true + } + out := []map[string]any{} + for _, row := range rows { + if known[catalog.Str(row, "_id")] { + continue + } + row["source"] = metadata.Name + " " + strconv.Itoa(year) + row["fetched_at"] = time.Now().UTC().Format(time.RFC3339) + out = append(out, row) + } + return appendRows(file, out) +} diff --git a/internal/jobs/report.go b/internal/jobs/report.go index 0ccf67e..bc15d3c 100644 --- a/internal/jobs/report.go +++ b/internal/jobs/report.go @@ -125,7 +125,7 @@ func (p *Pipeline) ConferenceReport(conf string, year int, pdf bool) error { cats = append(cats, c) } sort.Strings(cats) - filename := map[string]string{"usenix": "USENIX", "ieee-sp": "IEEE-SP", "ndss": "NDSS", "ccs": "CCS"}[conf] + fmt.Sprintf("_%d_Report.html", year) + filename := strings.ToUpper(conf) + fmt.Sprintf("_%d_Report.html", year) return p.render(reportData{Title: fmt.Sprintf("%s %d", catalog.Labels[conf], year), Subtitle: "顶会论文分类与中文深度摘要", Generated: time.Now().UTC().Format(time.RFC3339), Papers: out, Categories: cats, Base: p.Config.PublicPath}, filepath.Join(p.Config.Root, "top-conf/data/report", filename), pdf) } func (p *Pipeline) Weekly(days int, pdf bool) error { diff --git a/web/src/pages/Generate.tsx b/web/src/pages/Generate.tsx index cdc4d50..1932f1f 100644 --- a/web/src/pages/Generate.tsx +++ b/web/src/pages/Generate.tsx @@ -85,7 +85,7 @@ export default function Generate({ kind }: { kind: 'field-briefing' | 'summary-b [error, setError] = useState(''), [result, setResult] = useState(null) const isSummary = kind === 'summary-brief' - async function run(value = query) { + async function run(value = query, impression = profile?.impression.text || '') { setBusy(true) setError('') setResult(null) @@ -96,7 +96,7 @@ export default function Generate({ kind }: { kind: 'field-briefing' | 'summary-b query: value, source, category, - impression: profile?.impression.text || '', + impression, limit: 12, }), }) @@ -134,7 +134,7 @@ export default function Generate({ kind }: { kind: 'field-briefing' | 'summary-b aria-label="研究方向" placeholder={ isSummary - ? '留空生成四大顶会全景,或使用研究印象' + ? '留空生成会议论文全景,或使用研究印象' : '输入方向,例如 LLM jailbreak;留空使用研究印象' } value={query} @@ -151,7 +151,7 @@ export default function Generate({ kind }: { kind: 'field-briefing' | 'summary-b onChange={(e) => setSource(e.target.value)} > - + @@ -176,7 +176,19 @@ export default function Generate({ kind }: { kind: 'field-briefing' | 'summary-b
- {(isSummary ? ['四大顶会全景', ...examples] : examples).map((q) => ( + {isSummary && ( + + )} + {examples.map((q) => (