Repository navigation
feat(workspace): find Goal requirements and original evidence #8914
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
steven-kid
wants to merge
1
commit into
loopx-project:main
Choose a base branch
from
steven-kid:roadmap-auto/20261117-requirement-search
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+289
−7
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
apps/presentation/dashboard/smoke/goal-requirements-browser-smoke.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| // Packaged search and recovery over real SQLite and the production read API. | ||
| import assert from 'node:assert/strict'; | ||
| import {spawn} from 'node:child_process'; | ||
| import {createInterface} from 'node:readline'; | ||
| import {resolve} from 'node:path'; | ||
| import {fileURLToPath} from 'node:url'; | ||
| import {mkdir} from 'node:fs/promises'; | ||
| import {resolveTestPython} from '../../../../scripts/test-python.mjs'; | ||
| import {launchBrowser, loadPlaywright} from '../../../../examples/dashboard-browser-smoke-support.mjs'; | ||
| const repoRoot = fileURLToPath(new URL('../../../../', import.meta.url)); | ||
| const outputDir = resolve(repoRoot, 'output/playwright/requirements-search'); | ||
| await mkdir(outputDir, {recursive:true}); | ||
| const child=spawn(resolveTestPython({repoRoot}),['-u','apps/presentation/dashboard/smoke/goal-requirements-http-fixture.py'],{cwd:repoRoot,stdio:['pipe','pipe','pipe']}); | ||
| child.stderr.on('data',x=>process.stderr.write(x)); | ||
| const iter=createInterface({input:child.stdout})[Symbol.asyncIterator](); | ||
| async function next(){const row=await iter.next(); assert.equal(row.done,false); return JSON.parse(row.value);} | ||
| async function command(value){child.stdin.write(value+'\n');return next();} | ||
| let browser; | ||
| try { | ||
| const {origin}=await next(); | ||
| browser=await launchBrowser(loadPlaywright().chromium); | ||
| const page=await browser.newPage({viewport:{width:1440,height:1000}}); | ||
| await page.addInitScript(()=>localStorage.setItem('loopx-pw-locale','en')); | ||
| await page.route('**/api/**',route=>{ | ||
| const p=new URL(route.request().url()).pathname; | ||
| if(p==='/api/chat/goal-acceptance'||p==='/api/chat/delivery-review') return route.continue(); | ||
| return route.fulfill({status:404,json:{error:'Not part of read-only fixture'}}); | ||
| }); | ||
| await page.goto(origin+'/chat/?statusUrl=/status.json'); | ||
| await page.locator('.personal-goal-link').first().click(); | ||
| await page.getByRole('button',{name:'Overview',exact:true}).click(); | ||
| const section=page.locator('.goal-outcomes'); | ||
| const search=section.getByRole('searchbox',{name:'Find requirements and evidence'}); | ||
| await search.fill('ARTIFACT:SOURCE-4-29'); | ||
| await section.getByRole('status').filter({hasText:'1 of 150 requirements match'}).waitFor(); | ||
| const last=section.locator('.goal-outcome').filter({has:page.getByRole('heading',{name:'Retained result 4',exact:true})}); | ||
| await last.locator('.goal-outcome-disclosure > summary').click(); | ||
| await last.locator('.goal-outcome-requirement:visible > summary').click(); | ||
| await last.getByText('核验修订 4-29',{exact:true}).waitFor(); | ||
| await page.setViewportSize({width:1440,height:1600}); | ||
| await section.screenshot({path:resolve(outputDir,'requirements-search.png')}); | ||
| await page.setViewportSize({width:1440,height:1000}); | ||
| await last.getByText('Add a requirement',{exact:true}).click(); | ||
| const draft=last.getByRole('textbox'); | ||
| await draft.fill('Do not lose this unsent correction'); | ||
| await search.fill('no such requirement'); | ||
| assert.equal(await draft.inputValue(),'Do not lose this unsent correction'); | ||
| assert.equal(await draft.isVisible(),true); | ||
| await search.press('Escape'); | ||
| assert.equal(await last.locator('.goal-outcome-criteria > li:visible').count(),30); | ||
| assert.equal((await command('inspect')).unchanged,true); | ||
| await page.screenshot({path:resolve(outputDir,'requirements-real-sqlite.png')}); | ||
| await command('fault'); | ||
| await last.getByRole('button',{name:'Refresh result',exact:true}).click(); | ||
| await page.locator('.delivery-acceptance-contract').getByRole('alert').waitFor(); | ||
| assert.equal(await draft.inputValue(),'Do not lose this unsent correction'); | ||
| assert.equal(await last.getByRole('button',{name:'Retain requirement',exact:true}).isDisabled(),true); | ||
| await command('recover'); | ||
| await last.getByRole('button',{name:'Refresh result',exact:true}).click(); | ||
| await search.fill('核验修订 4-29'); | ||
| await section.getByRole('status').filter({hasText:'1 of 150 requirements match'}).waitFor(); | ||
| assert.equal((await command('inspect')).unchanged,true); | ||
| console.log('PASS: packaged App / real SQLite and production HTTP; search, draft, source failure/recovery, unchanged authority.'); | ||
| } finally {await browser?.close(); child.stdin.end();} | ||
123 changes: 123 additions & 0 deletions
123
apps/presentation/dashboard/smoke/goal-requirements-http-fixture.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,123 @@ | ||
| """Disposable SQLite/HTTP reader for the packaged requirements search journey.""" | ||
|
|
||
| import sys | ||
| import json | ||
| import tempfile | ||
| import threading | ||
| from pathlib import Path | ||
|
|
||
| REPO = Path(__file__).resolve().parents[4] | ||
| sys.path.insert(0, str(REPO)) | ||
|
|
||
|
|
||
| def main(): | ||
| from pytest import MonkeyPatch | ||
| from tests.control_plane.canonical_authority_fixture import isolate_sqlite_runtime | ||
| from tests.test_delivery_review import make_project | ||
| from loopx.control_plane.goals.acceptance import ( | ||
| inspect_goal_acceptance, | ||
| refine_goal_outcome, | ||
| ) | ||
| from loopx.chat_server import ChatHTTPServer, ChatRequestHandler | ||
| from loopx.control_plane.effect_runtime import restart_effect_runtime | ||
|
|
||
| with ( | ||
| tempfile.TemporaryDirectory(prefix="requirements-real-") as directory, | ||
| MonkeyPatch.context() as patch, | ||
| ): | ||
| root = Path(directory) | ||
| isolate_sqlite_runtime(root, patch) | ||
| registry, runtime = make_project(root, provider="sqlite") | ||
| config = json.loads(registry.read_text()) | ||
| config["goals"][0]["coordination"] = { | ||
| "registered_agents": ["author", "builder", "reviewer"] | ||
| } | ||
| registry.write_text(json.dumps(config)) | ||
| basis = dict( | ||
| registry_path=registry, goal_id="release-demo", runtime_root=str(runtime) | ||
| ) | ||
| for index in range(5): | ||
| result = refine_goal_outcome( | ||
| **basis, | ||
| agent_id="author", | ||
| execute=True, | ||
| expected_provider_revision=inspect_goal_acceptance(**basis)[ | ||
| "provider_revision" | ||
| ], | ||
| operation_id=f"seed-{index}", | ||
| refinement={ | ||
| "outcome_id": f"result-{index}", | ||
| "owner_agent_id": "author", | ||
| "objective": f"Retained result {index}", | ||
| "source": { | ||
| "ref": f"message:owner-{index}", | ||
| "summary": "Preserve source evidence", | ||
| }, | ||
| "requirements": [ | ||
| { | ||
| "id": f"req-{i}", | ||
| "description": f"Retain source {index}-{i}. 保留完整要求。", | ||
| } | ||
| for i in range(30) | ||
| ], | ||
| "review": [ | ||
| { | ||
| "id": f"req-{i}", | ||
| "conclusion": "uncertain", | ||
| "note": f"核验修订 {index}-{i}", | ||
| "evidence_refs": [f"artifact:source-{index}-{i}"], | ||
| } | ||
| for i in range(30) | ||
| ], | ||
| }, | ||
| ) | ||
| assert result["status"] == "applied", result | ||
| before = inspect_goal_acceptance(**basis) | ||
|
|
||
| class Handler(ChatRequestHandler): | ||
| def _goal_acceptance_inspect(self): | ||
| if self.server.fault: | ||
| self._send_error("Synthetic source unavailable", status=503) | ||
| else: | ||
| super()._goal_acceptance_inspect() | ||
|
|
||
| server = ChatHTTPServer(("127.0.0.1", 0), Handler) | ||
| server.registry_path, server.runtime_root, server.runtime_root_override = ( | ||
| registry, | ||
| runtime, | ||
| str(runtime), | ||
| ) | ||
| server.assets_dir = REPO / "loopx/web/chat" | ||
| server.scan_roots, server.limit, server.selected_goal_id, server.verbose = ( | ||
| [], | ||
| 20, | ||
| None, | ||
| False, | ||
| ) | ||
| server.fault = False | ||
| thread = threading.Thread(target=server.serve_forever, daemon=True) | ||
| thread.start() | ||
| print( | ||
| json.dumps({"origin": f"http://127.0.0.1:{server.server_port}"}), flush=True | ||
| ) | ||
| try: | ||
| for command in sys.stdin: | ||
| if command.strip() == "inspect": | ||
| print( | ||
| json.dumps( | ||
| {"unchanged": before == inspect_goal_acceptance(**basis)} | ||
| ), | ||
| flush=True, | ||
| ) | ||
| else: | ||
| server.fault = command.strip() == "fault" | ||
| print(json.dumps({"fault": server.fault}), flush=True) | ||
| finally: | ||
| server.shutdown() | ||
| server.server_close() | ||
| thread.join(timeout=5) | ||
| restart_effect_runtime(wait_for_exit=True) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| main() |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[P2] 让故障和恢复断言等待验收读回更新。前面的
/api/actions404 已经触发此 alert,因此当前等待可以在验收 GET 返回 503 前结束。我在精确提交运行新 smoke,复现了第 57 行的失败。恢复段也可以靠旧读回命中。建议在每次 Refresh 前监听目标 GET,再等到 503 时按键禁用、200 时恢复可用,并核对同一份草稿。