Repository Public
1import Foundation2import Testing3@testable import VQuantKit4import VQuantKitTesting56/// VQuantKit 0.3: the additive fields of backend 6 (CONTRACT §4.2 "Renderer rules", §2.3–2.4, §9.6).7@Suite struct LabSchemaAdditionsTests {8 private func result(_ name: String, dir: String = "") throws -> VQLabResult {9 try #require(VQQuantJob(json: try Fixture.json("\(dir)job_\(name).json")["job"] ?? .null).labResult)10 }1112 /// History holds results recorded before the additions: they still decode, and the new fields read as absent.13 @Test(arguments: Fixture.labJobNames)14 func olderResultsStillDecode(_ name: String) throws {15 let r = try result(name, dir: "lab_v0/")16 #expect(r.success && !r.charts.isEmpty && !r.summary.isEmpty)17 #expect(r.charts.allSatisfy { $0.z == nil && $0.series.allSatisfy { $0.drawsCentreLine == nil && !$0.hasCandles } })18 #expect(r.tables.allSatisfy { $0.columns.allSatisfy { $0.type == nil && $0.currencyKey == nil } })19 for c in r.charts where c.matrix != nil { #expect(c.cellAxis.label == c.y.label && c.cellAxis.unit == c.y.unit) } // the cell unit falls back to y20 }2122 @Test(arguments: Fixture.labJobNames)23 func newResultsCarryTheRendererFields(_ name: String) throws {24 let r = try result(name)25 for m in r.summary where m.unit == .currency { #expect(m.currency?.count == 3, "\(name): \(m.label) has no currency") }26 for t in r.tables {27 for c in t.columns {28 #expect(c.type?.known != nil, "\(name): column \(c.key) has no type")29 if c.unit == .currency { #expect(c.currency != nil || c.currencyKey != nil) }30 }31 }32 for c in r.charts {33 if c.y.unit == .currency { #expect(c.y.currency != nil) }34 if c.x.unit == .currency { #expect(c.x.currency != nil) }35 if c.matrix != nil { #expect(c.z != nil && !c.cellAxis.label.isEmpty) }36 for s in c.series where s.hasInterval && s.style != .bar && s.style != .points { #expect(s.drawsCentreLine != nil, "\(name)/\(c.id)/\(s.name)") }37 for s in c.series where s.style == .bar { #expect(s.drawsCentreLine == nil) } // error bars have no `line`38 }39 }4041 @Test func currenciesYearsAndMatrixLegend() throws {42 let portfolio = try result("portfolio_lab")43 let holdings = try #require(portfolio.tables.first { t in t.columns.contains { $0.currencyKey != nil } })44 let price = try #require(holdings.columns.first { $0.currencyKey != nil })45 let row = try #require(holdings.rows.first)46 #expect(holdings.currency(of: row, price) == row[price.currencyKey!]?.stringValue)47 #expect(holdings.cell(row, price).text.hasSuffix("$\u{00A0}US") && holdings.cell(row, price, locale: .enCA).text.hasPrefix("US$"))48 // a row in another currency is written with its own code49 var cad = row; cad[price.currencyKey!] = "CAD"; cad[price.key] = 1234.550 let d = price.decimals ?? 251 #expect(holdings.cell(cad, price).text == VQFormat.currency(1234.5, "CAD", decimals: d) && holdings.cell(cad, price, locale: .enCA).text.hasPrefix("$1,234.5") && !holdings.cell(cad, price).text.contains("US"))52 var gbx = row; gbx[price.currencyKey!] = "GBX"; gbx[price.key] = 81253 #expect(holdings.cell(gbx, price).text.hasSuffix("\u{00A0}GBX") && holdings.cell(gbx, price).text.hasPrefix("812,"))5455 let backtest = try result("backtest")56 let years = try #require(backtest.tables.first { t in t.columns.contains { $0.type == .year } })57 #expect(years.yearLikeColumns == ["year"] && years.cell(years.rows[0], years.columns[0]).text.count == 4) // 2016, not 2 01658 let monthly = try #require(backtest.charts.first { $0.id == "monthly" })59 #expect(monthly.z?.label == "Monthly return" && monthly.cellAxis.unit == .percent)60 let surface = try #require(try result("options_chain").charts.first { $0.type == .surface })61 #expect(surface.z?.unit == .percent && surface.z?.label == "Implied volatility" && surface.x.unitName != nil)62 let payoff = try #require(try result("options_strategy").charts.first { $0.type == .payoff })63 #expect(payoff.x.unit == .currency && payoff.x.currency == "USD" && payoff.y.currency == "USD")6465 // a column typed integer has no decimals; a typed column wins over the inference66 let t = VQLabResult.Table(json: ["id": "t", "title": "T", "columns": [["key": "n", "label": "N", "type": "integer"], ["key": "y", "label": "Y", "type": "number"], ["key": "d", "label": "Dur", "unit": "years", "type": "number"]],67 "rows": [["n": 12345, "y": 2024, "d": 3.25]]])68 #expect(t.cell(t.rows[0], t.columns[0]).text == "12\u{00A0}345" && t.yearLikeColumns.isEmpty && t.cell(t.rows[0], t.columns[2]).text == "3,3\u{00A0}ans")69 #expect(VQFormat.byUnitName(1, "years") == "1,0\u{00A0}an" && VQFormat.byUnitName(3.25, "years", locale: .enCA) == "3.3\u{00A0}yr" && VQFormat.byUnitName(0.12, "percent") == "12,00\u{00A0}%")70 #expect(VQFormat.byUnitName(5, "furlongs") == "5,00" && VQFormat.byUnitName(nil, "years") == "—")71 let m = VQLabResult.Metric(json: ["label": "Duration", "value": 7.4, "unit": "years", "kind": "calculated"])72 #expect(m.unit == .none && m.unitName == "years" && m.formatted() == "7,4\u{00A0}ans")73 #expect(VQLabResult.Metric(json: ["label": "P", "value": 12.5, "unit": "currency", "currency": "CAD", "kind": "observed"]).formatted(locale: .enCA) == "$12.50")74 }7576 @Test func bandsAndCandles() throws {77 let fan = try #require(try result("time_series").charts.first { $0.type == .fan })78 #expect(fan.series.filter { $0.style == .band }.allSatisfy { $0.drawsCentreLine == false })79 #expect(fan.series.first { $0.name.hasPrefix("Forecast") }?.drawsCentreLine == true)80 // no engine emits candles yet: the encoding of CONTRACT §4.281 let chart = VQLabResult.Chart(json: ["id": "c", "title": "AAPL", "type": "candles", "x": ["label": "Date", "type": "time"], "y": ["label": "Price", "unit": "currency", "currency": "USD"],82 "series": [["name": "AAPL", "kind": "observed", "x": ["2026-11-18", "2026-11-19", "2026-11-20"], "open": [350, 352, 349], "high": [355, 353, 354.3], "low": [348, 346, 340.6], "close": [352, 349.2, 342.6], "y": [352, 349.2, 342.6], "volume": [1, 2, .null]]]])83 let s = chart.series[0]84 #expect(chart.type == .candles && s.hasCandles && s.open?.count == 3 && s.high?[2] == 354.3 && s.volume?[2] == nil && s.y == s.close)85 #expect(VQLabChartData.points(s, axis: .time).count == 3) // a renderer without candles can still draw the closes86 }8788 @Test func conditionalParameters() throws {89 let catalog = VQLabCatalog(json: try Fixture.json("quant_tools.json"))90 let options = try #require(catalog.tool("options_lab"))91 var form = VQLabForm(tool: options) // defaults: symbol SPY, mode price92 func names(_ f: VQLabForm) -> Set<String> { Set(f.visibleGroups.flatMap(\.params).map(\.name)) }93 func issues(_ f: VQLabForm) -> [String: String] { if case .failure(let i) = f.validate() { return Dictionary(i.issues.map { ($0.name, $0.message) }, uniquingKeysWith: { a, _ in a }) }; return [:] }94 #expect(form.isValid)95 #expect(!names(form).contains("market_price") && !names(form).contains("template") && !names(form).contains("max_dte") && names(form).contains("strike"))96 form["mode"] = "implied"97 let price = try #require(options.params.first { $0.name == "market_price" })98 #expect(names(form).contains("market_price") && form.isRequired(price) && form.isVisible(price))99 #expect(issues(form) == ["market_price": "Market price of the option is required when Analysis is implied."]) // the server's sentence100 form["market_price"] = "12,5"101 #expect(form.isValid)102 form["mode"] = "strategy"103 #expect(names(form).contains("template") && !names(form).contains("market_price") && !form.isRequired(price) && form.isValid) // template defaults to straddle: legs not required104 form["template"] = "custom"105 #expect(issues(form)["legs"] == "Legs is required when Analysis is strategy and Strategy template is custom.")106 form["legs"] = #"[{"type":"call","strike":700,"quantity":1}]"#107 #expect(form.isValid)108 form["mode"] = "chain"109 #expect(names(form).contains("max_dte") && !names(form).contains("template"))110111 // a list of accepted values, and a boolean condition112 let bootstrap = try #require(catalog.tool("bootstrap"))113 var b = VQLabForm(tool: bootstrap, values: ["symbol": "AAPL"])114 #expect(b.isValid)115 b["statistic"] = "beta"116 #expect(issues(b)["benchmark"]?.contains("is required when") == true && issues(b)["benchmark"]?.contains("correlation or beta or sharpe_difference") == true)117 let backtest = try #require(catalog.tool("backtest"))118 var bt = VQLabForm(tool: backtest)119 #expect(!names(bt).contains("train_days"))120 bt["walk_forward"] = true121 #expect(names(bt).contains("train_days"))122 bt["walk_forward"] = "true" // typed in a form: judged on the converted value123 #expect(names(bt).contains("train_days"))124 // an old catalogue has no conditions: everything is visible, nothing conditional125 let old = try #require(VQLabCatalog(json: try Fixture.json("lab_v0/quant_tools.json")).tool("options_lab"))126 #expect(old.params.allSatisfy { $0.requiredWhen == nil && $0.visibleWhen == nil } && VQLabForm(tool: old).visibleGroups.flatMap(\.params).count == old.params.count)127 #expect(VQLabCondition(json: ["mode": ["a", "b"], "n": 2])?.isMet(by: ["mode": "b", "n": 2]) == true && VQLabCondition(json: ["mode": "a"])?.isMet(by: [:]) == false && VQLabCondition(json: [:]) == nil)128 }129130 @Test func usageRoleUtilityAndBudgetApplied() throws {131 let stream = try Fixture.json("research/approval_stream.json")132 let events = stream["approved"]!.list("events")133 guard case .done(_, let usage) = VQGenerationEvent(json: try #require(events.last)) else { Issue.record("done"); return }134 #expect(usage?.byModel.map(\.isUtility) == [false, true] && usage?.byModel[1].role?.rawValue == "utility" && usage?.byModel[1].role?.known == nil)135 let first = try #require(events.first { $0.str("type") == "budget_applied" })136 let applied = try #require(VQBudgetApplied(event: first))137 #expect(applied.maxCostUsd == 1 && applied.maxMinutes == 10 && applied.source == .request)138 guard case .other(let type, _) = VQGenerationEvent(json: first) else { Issue.record("budget_applied must stay .other"); return }139 #expect(type == "budget_applied" && VQGenerationEvent.time(of: first) == Date(timeIntervalSince1970: 1_795_217_089.4) && VQBudgetApplied(event: events[0]) == nil)140 let trace = VQGenerationTrace(json: try Fixture.json("research/trace_v03_fbab3585.json"))141 #expect(trace.budgetApplied == applied && trace.mode == "research")142 #expect(VQStatements(json: ["commonSize": ["cashflow": [["key": "capex", "label": "Capex", "unit": "percent", "values": [0.1]]]]]).commonSizeCashflow.count == 1)143 }144}145146@Suite struct ResearchV03Tests {147 private func json(_ name: String) throws -> VQJSON { try Fixture.json("research/\(name)") }148149 /// The two real approval sequences recorded on 5059 (tests/fixtures/research/approval_stream.json of the web repo).150 @Test func approvedSequence() throws {151 let events = try json("approval_stream.json")["approved"]!.list("events")152 var s = VQResearchState()153 var pendingSeen = false154 for e in events {155 VQResearchReducer.reduce(&s, e)156 if e.str("type") == "approval_request" {157 pendingSeen = true158 let a = try #require(s.pendingApprovals.first)159 #expect(a.action == .openNetwork && a.reason?.contains("tips.csv") == true && a.details(.fr).map(\.label) == ["Code", "Exécution"] && a.statusLabel(.fr) == "en attente de votre réponse")160 #expect(a.isAnswerable(now: a.createdAt!.addingTimeInterval(1)) && a.countdown(now: a.createdAt!).label == "15:00")161 }162 }163 #expect(pendingSeen && s.finished && s.pendingApprovals.isEmpty)164 let a = try #require(s.approvals.first)165 #expect(s.approvals.count == 1 && a.status == .approved && a.resolvedAt != nil && a.resolvedAt! > a.createdAt!)166 #expect(s.budgetApplied?.maxCostUsd == 1 && s.budgetApplied?.source == .request)167 #expect(s.runs.count == 1 && s.runs[0].network == .open && s.runs[0].status == .done && s.runs[0].label == "Téléchargement du jeu de données tips.csv")168 #expect(s.gates.count == 1 && !s.report.isEmpty && s.workspaceId == "s-fbab3585-9407-4f58-8bd2-499ee22cd5a7")169 // every entry of the timeline now has the server's time, in order170 #expect(s.timeline.map(\.kind) == [.workspace, .approval, .run, .gate] && s.timeline.allSatisfy { $0.at != nil })171 #expect(zip(s.timeline, s.timeline.dropFirst()).allSatisfy { $0.at! <= $1.at! })172 // replaying the request after its resolution does not reopen it173 VQResearchReducer.reduce(&s, try #require(events.first { $0.str("type") == "approval_request" }))174 #expect(s.pendingApprovals.isEmpty && s.approvals[0].status == .approved)175 }176177 @Test func deniedSequence() throws {178 let s = VQResearchReducer.replay(try json("approval_stream.json")["denied"]!.list("events"))179 #expect(s.approvals.map(\.status.rawValue) == ["denied"] && s.pendingApprovals.isEmpty && s.runs.isEmpty && s.finished)180 #expect(s.approvals[0].resolvedAt != nil && s.gates.first?.passed == false && s.report.count > 20 && s.counts.executions == 0)181 #expect(s.timeline.map(\.kind) == [.workspace, .approval, .gate])182 }183184 @Test func aStudyReopenedFromRESTHasItsPlanAndFigureVerdicts() throws {185 let detail = VQResearchSessionDetail(json: try json("session_v03_439f8b56.json"))186 #expect(detail.generations.count == 1 && detail.generations[0].status == .done && detail.generations[0].mode == "research" && detail.generations[0].budgetApplied?.maxMinutes == 5)187 #expect(detail.plan.map(\.status) == [.done, .done, .done] && detail.figures.count == 1)188 let record = detail.figures[0]189 #expect(record.status == .fixed && record.fixes.count == 1 && record.findings.isEmpty && record.caption == "La fonction sin(x) sur [0, 10]" && record.files?.pdf != nil && record.url?.hasPrefix("/figures/") == true)190 let s = VQResearchState(detail: detail, conversation: try json("conversation_v03_439f8b56.json"))191 #expect(s.plan.count == 3 && s.plan.allSatisfy { $0.status == .done } && s.finished && s.budgetApplied?.source == .request && s.generations.count == 1)192 let f = try #require(s.figures.first)193 #expect(s.figures.count == 1 && f.lintStatus == .fixed && f.lintPassed == true && f.openIssues.isEmpty && f.fixes.count == 1 && f.caption != nil && f.at != nil && f.figureId == record.id)194 #expect(f.executionKey == s.executions.first?.key && s.executions.first?.figureKeys == [f.key])195 #expect(s.timeline.contains { $0.kind == .plan } && s.timeline.first { $0.kind == .figure }?.at == f.at)196197 // an older study: the plan is now served, the figures are not — they come from the files, verdict unknown198 let old = VQResearchSessionDetail(json: try json("session_v03_3d04acf2.json"))199 let o = VQResearchState(detail: old, conversation: try json("conversation.json"))200 #expect(old.figures.isEmpty && old.generations.count == 2 && o.plan.count == 7 && o.figures.count == 21 && o.figures.allSatisfy { $0.lintStatus == nil && $0.lintPassed == nil })201 #expect(o.counts.executions == 72 && o.generations.allSatisfy { $0.budgetApplied == nil })202 // a detail from a server that has none of the new keys203 let legacy = VQResearchState(detail: VQResearchSessionDetail(json: try json("session.json")))204 #expect(legacy.plan.isEmpty && legacy.generations.isEmpty && legacy.finished && legacy.figures.count == 21)205 #expect(VQResearchGeneration(json: ["generationId": "g", "status": "interrupted"]).status == .interrupted)206 }207208 @Test func answeredApprovalsComeFromTheList() throws {209 let all = try json("approvals_v03_all.json").models("approvals", as: VQResearchApproval.self)210 #expect(all.count == 2 && Set(all.map(\.status.rawValue)) == ["approved", "denied"] && all.allSatisfy { $0.workspaceId != nil && $0.generationId != nil })211 let detail = VQResearchSessionDetail(json: try json("session_v03_fbab3585.json"))212 #expect(detail.approvals.isEmpty) // the detail lists pending ones only213 let s = VQResearchState(detail: detail, conversation: try json("conversation_v03_fbab3585.json"), approvals: all)214 #expect(s.approvals.count == 1 && s.approvals[0].status == .approved && s.runs.count == 1 && s.runs[0].network == .open)215 #expect(s.timeline.contains { $0.kind == .approval } && s.budgetApplied?.maxCostUsd == 1)216 }217218 /// `code_execution_start`, `toolId` pairing and the new `figure_lint` shape did not occur in a recorded stream:219 /// these events are written from CONTRACT §9.6.220 @Test func cellsPairByToolIdAndFiguresCarryTheirVerdict() {221 var s = VQResearchState()222 let nb = VQResearchReducer.notebookTool223 func ev(_ o: VQJSONObject) { VQResearchReducer.reduce(&s, .object(o)) }224 ev(["type": "tool_start", "tool": .string(nb), "toolId": "t1", "input": ["code": "import numpy as np\nx = np.arange(10)…", "description": "A"], "at": 1000])225 ev(["type": "tool_start", "tool": .string(nb), "toolId": "t2", "input": ["code": "print(2)", "description": "A"], "at": 1001])226 ev(["type": "code_execution_start", "toolId": "t2", "agent": "lead", "description": "A", "codeHash": "h2", "lines": 1, "at": 2000])227 ev(["type": "code_execution_start", "toolId": "t1", "agent": "lead", "description": "A", "codeHash": "h1", "lines": 40, "at": 2001])228 #expect(s.executions.count == 2 && s.executions[0].codeIsTruncated && !s.executions[1].codeIsTruncated && s.executions[0].codePath == "logs/cells/h1.py" && s.executions[0].lines == 40)229 #expect(s.executions[1].startedAt == Date(timeIntervalSince1970: 2))230 // same description twice: only the toolId tells the cells apart231 ev(["type": "code_execution", "toolId": "t2", "agent": "lead", "description": "A", "codeHash": "h2", "code": "logs/cells/h2.py", "lines": 1, "ok": true, "durationMs": 5, "experimentId": "e2", "at": 2500])232 #expect(s.executions[1].status == .ok && s.executions[0].status == .running)233 ev(["type": "tool_result", "tool": .string(nb), "toolId": "t2", "result": ["output": "2"], "at": 2501]) // no tool_complete needed234 #expect(s.executions[1].output == "2" && s.executions[0].output == nil)235 // a cell seen only through its start (a viewer that attached late)236 ev(["type": "code_execution_start", "toolId": "t9", "agent": "worker-1", "description": "Late", "codeHash": "h9", "lines": 3, "at": 2600])237 #expect(s.executions.count == 3 && s.executions[2].status == .running && s.executions[2].code == nil && s.executions[2].agent == "worker-1")238239 // the image event first, then the verdict of each figure by index240 ev(["type": "custom_python_figures", "figureId": "fig-1", "toolId": "t2", "figureUrls": ["/figures/fig-1-0.png", "/figures/fig-1-1.png"], "description": "Deux figures", "at": 2700])241 #expect(s.figures.count == 2 && s.figures.allSatisfy { $0.lintStatus == nil })242 let fixed: VQJSON = ["code": "contrast", "severity": "warning", "message": "recoloured", "fixed": true]243 let left: VQJSON = ["code": "x_label", "severity": "warning", "message": "A numeric x axis has no label.", "fixed": false]244 ev(["type": "figure_lint", "figureId": "F0", "toolId": "t2", "index": 0, "title": "T0", "caption": "C0", "url": "/figures/fig-1-0.png", "ok": true, "status": "fixed", "fixes": [fixed], "findings": [], "issues": [fixed],245 "files": ["png": "artifacts/figures/a.png", "svg": "artifacts/figures/a.svg", "pdf": "artifacts/figures/a.pdf"], "at": 2800])246 ev(["type": "figure_lint", "figureId": "F1", "toolId": "t2", "index": 1, "title": "T1", "caption": "C1", "url": "/figures/fig-1-1.png", "ok": false, "status": "issues", "fixes": [fixed], "findings": [left], "issues": [fixed, left], "files": .null, "at": 2801])247 #expect(s.figures.count == 2 && s.figures.map(\.lintStatus?.known) == [.fixed, .issues] && s.figures.map(\.lintPassed) == [true, false])248 #expect(s.figures[0].caption == "C0" && s.figures[0].files?.pdf != nil && s.figures[0].openIssues.isEmpty && s.figures[1].openIssues.count == 1 && s.figures[1].findings.count == 1)249 #expect(s.figures.allSatisfy { $0.executionKey == s.executions[1].key })250 let before = s251 ev(["type": "figure_lint", "figureId": "F0", "toolId": "t2", "index": 0, "title": "T0", "status": "fixed", "url": "/figures/fig-1-0.png", "at": 2900]) // replayed252 #expect(s.figures == before.figures)253 // verdict first, image after (the other order)254 ev(["type": "figure_lint", "figureId": "F2", "toolId": "t1", "index": 0, "title": "T2", "url": "/figures/fig-2-0.png", "ok": true, "status": "passed", "fixes": [], "findings": [], "issues": [], "files": .null, "at": 3000])255 ev(["type": "custom_python_figures", "figureId": "fig-2", "toolId": "t1", "figureUrls": ["/figures/fig-2-0.png"], "at": 3001])256 #expect(s.figures.count == 3 && s.figures[2].lintStatus == .passed && s.figures[2].executionKey == s.executions[0].key)257 // a status this version does not know is kept, and falls back to `ok`258 ev(["type": "figure_lint", "figureId": "F3", "title": "T3", "ok": true, "status": "waived", "at": 3100])259 #expect(s.figures[3].lintStatus?.known == nil && s.figures[3].lintStatus?.rawValue == "waived" && s.figures[3].lintPassed == true)260 // experiments now carry notes, envHash and codeHash on the stream261 ev(["type": "experiment", "experiment": ["id": "x1", "seq": 4, "kind": "experiment", "title": "E", "status": "abandoned", "notes": "why", "envHash": "env", "codeHash": "code"], "at": 3200])262 ev(["type": "experiment", "experiment": ["id": "x1", "status": "ok"], "at": 3300])263 #expect(s.experiments[0].notes == "why" && s.experiments[0].envHash == "env" && s.experiments[0].codeHash == "code" && s.experiments[0].status == .ok)264 #expect(s.timeline.allSatisfy { $0.at != nil })265 }266267 @Test func newRoutes() async throws {268 let t = VQScriptedTransport([.init(json: ["ok": true, "path": "artifacts/old.csv"]), .init(status: 400, json: ["error": "This directory is part of the workspace layout."]),269 .init(json: try json("sandbox.json")), .init(status: 404, json: ["error": "Not found."]), .init(status: 202, json: ["generationId": "g", "sessionId": "s"])])270 let api = VQuantAPI(transport: t)271 #expect(try await api.researchAgent.deleteFile("s-1", path: "artifacts/old.csv") == "artifacts/old.csv")272 #expect(t.requests[0].method == .delete && t.requests[0].path == "/api/v2/research/sessions/s-1/files" && t.requests[0].query == [VQQueryItem("path", "artifacts/old.csv")])273 do { _ = try await api.researchAgent.deleteFile("s-1", path: "code"); Issue.record("layout directory deleted") } catch let e as VQError { #expect(e.kind == .rejected) }274 #expect(await api.researchAgent.researchModeAvailability()?.enforced == true) // the sandbox route answers: offer the mode275 #expect(await api.researchAgent.researchModeAvailability() == nil) // no research agent on this server276 _ = try await api.research.run(project: "p1", prompt: "Étudie", mode: VQAnalysisMode.research.rawValue)277 #expect(try VQJSON.parse(t.requests[4].body!)["mode"] == "research")278 }279}280