Compare commits
6 Commits
36fc5d54e7
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 5f835e54a9 | |||
| 8699ae4f42 | |||
| 0b6f4b39eb | |||
| f7dc22e5e7 | |||
| 3e1057d951 | |||
| d1fcd23087 |
@@ -111,7 +111,8 @@ jobs:
|
||||
done
|
||||
test "$parser_install_succeeded" = true
|
||||
PIP_CACHE_DIR="$parser_pip_cache" python3 /tmp/pip.pyz install --upgrade --target .python-ci pytest==8.3.5 httpx2==2.12.0
|
||||
PYTHONPATH="$PWD/.python-ci" AI_SERVICE_SKIP_MODEL_LOAD=1 python3 -m pytest -q
|
||||
python3 --version
|
||||
PYTHONFAULTHANDLER=1 PYTHONPATH="$PWD/.python-ci" AI_SERVICE_SKIP_MODEL_LOAD=1 python3 -m pytest -q
|
||||
|
||||
- name: Restore backend
|
||||
# The runner/proxy has occasionally supplied checksum-invalid NuGet cache entries (NU3008).
|
||||
@@ -312,9 +313,16 @@ jobs:
|
||||
# checksum-valid npm download (`true` became `tr<garbage>e`, or a stray `break` appeared).
|
||||
# Retry only that unmistakable source-corruption signature from a new isolated cache.
|
||||
# Ordinary Axe violations and application assertions remain terminal.
|
||||
if grep -q "AxeBuilder.analyze" "$smoke_log" \
|
||||
&& grep -Eq "page\.evaluate: (ReferenceError|SyntaxError)" "$smoke_log"; then
|
||||
echo "Axe runtime source appears corrupted — reinstalling the locked dependencies from a fresh cache and retrying the complete suite once..."
|
||||
if { grep -q "AxeBuilder.analyze" "$smoke_log" \
|
||||
&& grep -Eq "page\.evaluate: (ReferenceError|SyntaxError)" "$smoke_log"; } \
|
||||
|| { grep -Eq 'node_modules/playwright-core/lib/utilsBundle\.js:[0-9]+' "$smoke_log" \
|
||||
&& grep -Fq 'const { items }$= this;' "$smoke_log" \
|
||||
&& grep -Fq 'SyntaxError: Missing initializer in destructuring declaration' "$smoke_log"; }; then
|
||||
echo "Browser runtime source appears corrupted — reinstalling the locked dependencies from a fresh cache and retrying the complete suite once..."
|
||||
mkdir -p .artifacts/browser-runtime-attempt-1
|
||||
cp "$smoke_log" .artifacts/browser-runtime-attempt-1/smoke.log
|
||||
if [ -d test-results ]; then cp -a test-results .artifacts/browser-runtime-attempt-1/; fi
|
||||
if [ -f .artifacts/playwright-results.json ]; then cp .artifacts/playwright-results.json .artifacts/browser-runtime-attempt-1/; fi
|
||||
rm -rf node_modules
|
||||
npm_cache="$(mktemp -d)"
|
||||
npm ci --no-audit --no-fund --cache "$npm_cache"
|
||||
@@ -336,6 +344,7 @@ jobs:
|
||||
name: browser-diagnostics
|
||||
path: |
|
||||
job-tracker-ui/.artifacts/playwright-results.json
|
||||
job-tracker-ui/.artifacts/browser-runtime-attempt-1/
|
||||
job-tracker-ui/test-results
|
||||
retention-days: 7
|
||||
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
# Browser fixture portability and confirmation focus contracts
|
||||
|
||||
Run832 at main `d1fcd2308755dfc112a2bd6a736dd763bbc895f9` completed its331-case browser suite:314 passed,16 failed, one flaky Rules draft case. Deployment was skipped. The Playwright runtime-corruption signature did not recur in this completed run. These outcomes do not establish production readiness or resolve the existing intermittent Rules observation.
|
||||
|
||||
Eleven failures came from `seed-operation.py` calling Python3.12's `Path.is_junction` on the Debian runner's Python3.11.2 PosixPath. This was independently reproduced by running the unchanged helper in an isolated, network-disabled `node:20-bookworm` container on the runner host; host Python3.12.3 passed. Junction checks now execute only on Windows, where the existing Python3.12 guard is preserved. Absolute/direct-temp-root, symlink, hardlink, exact owner/schema and insert-only SQL protections remain unchanged. All29 self-checks pass both on local Windows and in that same Python3.11 container after the correction. No existing application data or production container is mounted into the test container.
|
||||
|
||||
Five failures were stale keyboard expectations after the verified shared confirmation scroll-body accessibility correction. The focusable named body now belongs in the native tab cycle. The tests explicitly verify Cancel → reverse Tab to named body → reverse Tab to Confirm → forward Tab to body → forward Tab to Cancel, followed by the original cancellation/focus/draft/action proofs. No focus assertion, axe rule, timeout or application behavior is relaxed. All five affected native cases pass with zero skips/flaky/retries,20October18:03:21–18:04:21UTC.
|
||||
|
||||
The bounded repair changes only the offline fixture and those two browser test consumers. Full release CI and deployed identity still require a new successful run. Production readiness remains NO-GO independently of the owner's authorization to publish main. The Qwen3.5 adapter preparation is separately tested; model activation and P5-13 qualification remain separate.
|
||||
@@ -0,0 +1,13 @@
|
||||
# Confirmation transition must preserve deliberate focus
|
||||
|
||||
Release833 at main `f7dc22e5e7efe1fd1d64f6ace2c04cf2f95bf558` exposes a distinct confirmation failure after the earlier complete tab-cycle test correction: Cancel initially receives focus and reverse traversal succeeds, but the later opening-transition callback can reset focus while forward keyboard traversal is already under way. This is a user-visible shared-owner race, not permission to relax the tab sequence or increase its timeout.
|
||||
|
||||
A deterministic new component regression focuses the named scroll body before advancing the opening transition. Existing code fails with focus moved back to Cancel:2existing cases pass/1new case fails (`p712-confirm-transition-red-20261020T184351Z`). Removing the redundant `onEntered` forced focus and its button ref leaves the existing Cancel `autoFocus` and MUI focus trap/restoration in place. All3component cases then pass (`p712-confirm-transition-green-20261020T184416Z`). No confirmation resolution, destructive guard, data write or dialog body accessibility changes.
|
||||
|
||||
All5affected native journeys pass after this repair on20October18:44–18:46UTC, with zero skips/flaky/retries. They retain explicit Cancel → reverse Tab body → reverse Tab Confirm → forward Tab body → forward Tab Cancel, the original cancellation/focus/draft assertions, and Discovery create/delete persistence. App/browser TypeScript, lint and production build pass. Full integrated successor validation follows; Linux CI/deployed acceptance is not inferred from Windows.
|
||||
|
||||
The interrupted P7-12 whole-browser attempt also exposed two stale English-only `Technical` template selectors after the approved Bokmål gallery localisation. That separate development test consumer now uses the existing locale key without changing template entitlement or any assertion. Original failing evidence is retained and the fresh successor run must use the repaired committed source.
|
||||
|
||||
Release833 also records Chromium page crashes in the CV-controls and administrator route census. An18:39UTC runner observation reports no cgroup OOM events, no container memory limit,1GiB shared memory and no kernel errors in the queried interval. This observation neither explains the crashes nor proves hardware health. Keep this infrastructure/reliability qualification separate from the deterministically reproduced focus race.
|
||||
|
||||
Production readiness remains NO-GO independently of the owner's release authorization. No model activation or P5-13 qualification is part of this repair.
|
||||
@@ -0,0 +1,9 @@
|
||||
# Playwright runtime corruption signature — 20 October 2026
|
||||
|
||||
Corrected release run831 did not reach deployment. Its browser lane encountered Chromium target crashes and an installed Playwright parser failure at `node_modules/playwright-core/lib/utilsBundle.js:35841`: `const { items }$= this;`, followed by `SyntaxError: Missing initializer in destructuring declaration`. A worker then exited before executing its cases. Only46 browser attempts appear in the terminal log; this is not a completed331-case regression. An ordinary preview-visibility assertion also failed and is retained, rather than labelled an infrastructure success.
|
||||
|
||||
This resembles earlier runner dependency/download corruption, but the job container was removed before its installed bytes could be compared with the lockfile archive. Neither persistent filesystem corruption nor faulty hardware is proven. The full900-entry diagnostic ZIP was downloaded and CRC-checked: SHA256 `f6d8e9659ca824bb12d283913f6e16f3933974bbc5e11c78e3524d8712e75632`. Original logs and traces remain retained.
|
||||
|
||||
The workflow already allows one complete-suite retry after its narrowly recognized Axe source-corruption signature, using a new npm cache and the unchanged lockfile. Extend that same bounded policy only when all three observed Playwright indicators occur together: the exact dependency path/line marker, the exact malformed statement and the exact parser error. Ordinary application assertion failures, target crashes alone, user-source syntax errors and incomplete signatures remain terminal. The six policy tests execute the actual Bash guard and pass. No assertion, browser inventory, timeout, ordinary retry, dependency integrity or release gate is relaxed.
|
||||
|
||||
Before the existing reinstall/retry, preserve the first smoke log, JSON report if available and complete traces/screenshots under `.artifacts/browser-runtime-attempt-1`; include them in the same always-uploaded artifact. A subsequent successful retry must still complete the entire browser suite; failure remains blocking. This does not repair or qualify the underlying runner, prove the preview assertion resolved or establish deployment success. Production/operator, physical hardware/runtime and manual application qualifications remain open. P5-13 and model activation are unchanged.
|
||||
@@ -0,0 +1,9 @@
|
||||
# Qwen3.5 compatibility preparation
|
||||
|
||||
The owner requested `qwen3.5:9b-q4_K_M` after live deployment. The model is downloaded, but the active sidecar still uses the previous model. This change prepares the existing adapter; it does not activate a model or qualify the withheld P5-13 capability.
|
||||
|
||||
The existing adapter consumes Ollama's final `response`. A synthetic local probe found an empty response with the Qwen3.5 thinking default; a20October probe with `think:false` returned the requested synthetic JSON and no thinking text. The adapter now sets that request field only when the configured base family is exactly `qwen3.5`. Existing temperature, JSON mode, timeouts, response parsing, other model payloads and external-provider consent/fallback remain unchanged. Custom namespace aliases are outside this exact family match.
|
||||
|
||||
Seven new offline cases verify both text/JSON for the requested tag and bare family, and unchanged payloads for qwen2.5, qwen3 and a lookalike family. Four Qwen3.5 cases failed ordinarily before the two-line change; three compatibility cases passed. The full sidecar suite then passed **56/56**, zero failures/errors/skips,8.45seconds,20October13:32UTC. The prior49-case baseline grows by seven; no model calls are part of these tests. Raw RED/GREEN logs and JUnit are retained under `.artifacts/release-20261020/model-compat/`.
|
||||
|
||||
Live activation, deployed adapter identity, GPU residency and final-response smoke remain pending behind the release. P5-13's deployed-identity/366-call/independent-human-review/UI requirements remain unmet and its review feature stays disabled. Production readiness remains NO-GO independently of the owner's release authorization.
|
||||
@@ -0,0 +1,11 @@
|
||||
# Bounded follow-redirects security patch
|
||||
|
||||
The21October fresh npm audit identifies production-classified transitive `follow-redirects`1.16.0 with high-severity [array-header credential stripping](https://github.com/advisories/GHSA-q3jh-wrc6-jgq8) and [custom sensitive-header escaping](https://github.com/advisories/GHSA-8r9p-f939-6h3c) advisories. Both advisory records identify1.16.1as patched. This is a dependency finding, not evidence that Jobjakt was exploited or that its browser adapter exercises either vector.
|
||||
|
||||
`npm update follow-redirects --ignore-scripts --no-audit --no-fund` changes exactly one package. The only tracked dependency diff is that lock entry's version, tarball URL and integrity:1.16.0→1.16.1. Existing package ranges, Axios, frameworks, other dependencies, audit policy and the owner's temporary dev-only braces exception remain unchanged. No override or new dependency is introduced.
|
||||
|
||||
Fresh production audit reports0vulnerabilities. The full audit policy passes with only the previously approved dev-only braces-derived high chain accepted through31October; moderate development findings remain recorded. No additional exception is added. Two synthetic loopback contracts verify array-form Authorization/Cookie/Proxy-Authorization stripping and custom credential names containing`^`/`|`, while retaining a public header. Both pass against the installed1.16.1; no real credentials or external target is involved.
|
||||
|
||||
Raw pre/post audit records are `.artifacts/phase7/current/p712-final-security/` and `.artifacts/phase7/current/p712-follow-redirects/`. The bounded helper is `.artifacts/phase7/current/p712-redirect-contract.cjs`. Production build and application/browser TypeScript/lint are rerun; final whole-application/browser proof uses the patched dependency set. The active pre-patch browser candidate is interrupted and retained rather than presented as validating the new lock.
|
||||
|
||||
This patch does not resolve the independent runner's Python/.NET native crashes, qualify deployed identity, activate Qwen3.5or complete P5-13. Production readiness remains NO-GO independently of the owner's release authorization. No Phase8 implementation.
|
||||
@@ -0,0 +1,50 @@
|
||||
# Parser CI native exit investigation, 2026-10-21
|
||||
|
||||
## Verified evidence
|
||||
|
||||
CI run 834, API test job 1721, failed in `Test document parser boundary`.
|
||||
The fetched log is `.artifacts/phase7/p7-09/instrumented-release-ci/20261021T050601Z/failed-job-logs.log`;
|
||||
the adjacent `api-observation.json` records the GET of job 1721's logs.
|
||||
The runner's internal task ID 1689 is separate from the API job ID.
|
||||
|
||||
At 2026-10-20 20:36:38 UTC, pytest reported `56 passed, 1 warning in 5.36s`.
|
||||
The shell subsequently reported a segmentation fault and exit 139. Passing assertions
|
||||
did not constitute successful process completion. Later browser steps did not run;
|
||||
deployment remained blocked.
|
||||
|
||||
Read-only host inspection with
|
||||
`coredumpctl --no-pager info 3804681` confirmed:
|
||||
|
||||
- Signal: 11 (SIGSEGV).
|
||||
- Command: `python3 -m pytest -q`.
|
||||
- Executable: `/usr/bin/python3.11`.
|
||||
- Timestamp: 2026-10-20 22:36:38 CEST (20:36:38 UTC).
|
||||
- Docker scope: `040c0b99c92e0a5a48c00994e10a264884ca8172f5eac94d49e3d7aa1d92fd27`,
|
||||
matching the failed job's container.
|
||||
- Stored core: `/var/lib/systemd/coredump/core.python3.0.7aab2b376ce94d92bf796bbeb62063a4.3804681.1792528598000000.zst`.
|
||||
|
||||
The core was inaccessible to SSH user `pi`; `sudo -n` required a password.
|
||||
No native backtrace was obtained. Kernel journal error entries for
|
||||
20:30-20:40 UTC were empty; that does not establish host health.
|
||||
|
||||
## Interpretation and bounded diagnostic
|
||||
|
||||
The timing is consistent with interpreter shutdown or cleanup, but the root cause
|
||||
is unproven. `AI_SERVICE_SKIP_MODEL_LOAD=1` prevents model weight loading;
|
||||
`app.py` still imports Torch and Transformers. Native extension cleanup is therefore
|
||||
a candidate, not an identified cause. Previous download corruption and browser
|
||||
crashes do not prove the cause of this Python crash.
|
||||
|
||||
The workflow now prints the Python version and enables `PYTHONFAULTHANDLER=1`
|
||||
for the unchanged pytest command. It preserves the existing dependency installs,
|
||||
all tests, and process exit status, without adding retries or suppressing signals.
|
||||
The existing pip log already records installed distribution versions. In this run,
|
||||
the test-runtime install upgraded locked AnyIO 4.14.2 to 4.15.1 and IDNA 3.19 to
|
||||
3.20; this is a reproducibility observation, not a demonstrated cause, and no
|
||||
dependency change is included here.
|
||||
|
||||
Next evidence: inspect the retained core with authorized access, or capture the
|
||||
faulthandler output from a subsequent normal CI run before choosing a fix.
|
||||
The diagnostic change has only received workflow text and whitespace checks;
|
||||
it has not been exercised in CI. No production mutation, model qualification,
|
||||
or successful release is claimed.
|
||||
@@ -69,11 +69,11 @@ def seed_operation(payload: object) -> str:
|
||||
except OSError as error:
|
||||
raise SeedDenied("The isolated dataRoot must already exist") from error
|
||||
if (root != requested or root.parent != temporary or not root.is_dir()
|
||||
or requested.is_symlink() or requested.is_junction()
|
||||
or requested.is_symlink() or (sys.platform == "win32" and requested.is_junction())
|
||||
or not re.fullmatch(r"jobtracker-e2e-[A-Za-z0-9][A-Za-z0-9_-]*", root.name)):
|
||||
raise SeedDenied("Only an unlinked jobtracker-e2e-* direct child of system temp is allowed")
|
||||
database = root / "jobtracker.db"
|
||||
if (not database.is_file() or database.is_symlink() or database.is_junction()
|
||||
if (not database.is_file() or database.is_symlink() or (sys.platform == "win32" and database.is_junction())
|
||||
or database.resolve(strict=True) != database or database.stat().st_nlink != 1):
|
||||
raise SeedDenied("The unlinked existing direct jobtracker.db file is required")
|
||||
# EF's SQLite Guid converter writes uppercase canonical text.
|
||||
@@ -110,7 +110,7 @@ def temporary_fixture():
|
||||
yield root
|
||||
finally:
|
||||
assert root.parent == Path(tempfile.gettempdir()).resolve()
|
||||
assert root.name.startswith("jobtracker-e2e-operation-selftest-") and not root.is_symlink() and not root.is_junction()
|
||||
assert root.name.startswith("jobtracker-e2e-operation-selftest-") and not root.is_symlink() and not (sys.platform == "win32" and root.is_junction())
|
||||
|
||||
|
||||
def self_test() -> dict:
|
||||
|
||||
@@ -171,8 +171,13 @@ for (const [mode, language, width] of [["light", "en", 1440], ["dark", "nb", 144
|
||||
await expect(cancel).toBeFocused();
|
||||
await expect(confirm).toHaveAccessibleDescription(t.attachmentsDeleteConfirm.replace("{name}", "Reviewed æøå.txt"));
|
||||
await cancel.press("Shift+Tab");
|
||||
const messageRegion = confirm.getByRole("region", { name: t.attachmentsDeleteTitle, exact: true });
|
||||
await expect(messageRegion).toBeFocused();
|
||||
await messageRegion.press("Shift+Tab");
|
||||
await expect(confirm.getByRole("button", { name: t.attachmentsDelete, exact: true })).toBeFocused();
|
||||
await page.keyboard.press("Tab");
|
||||
await expect(messageRegion).toBeFocused();
|
||||
await page.keyboard.press("Tab");
|
||||
await expect(cancel).toBeFocused();
|
||||
await scan(page, info, "confirm", true);
|
||||
await capture(page, info, `confirm-${suffix}`);
|
||||
|
||||
@@ -366,7 +366,11 @@ test('[P7-05 Discovery] keyboard native create and alert updates persist; delete
|
||||
const cancel = dialog.getByRole('button', { name: t.cancel, exact: true });
|
||||
await expect(cancel).toBeFocused();
|
||||
await page.keyboard.press('Shift+Tab');
|
||||
const messageRegion = dialog.getByRole('region', { name: await dialog.getByRole('heading').innerText(), exact: true });
|
||||
await expect(messageRegion).toBeFocused();
|
||||
await messageRegion.press('Shift+Tab');
|
||||
await expect(dialog.getByRole('button', { name: t.adminUsersDelete, exact: true })).toBeFocused();
|
||||
await page.keyboard.press('Tab'); await expect(messageRegion).toBeFocused();
|
||||
await page.keyboard.press('Tab'); await expect(cancel).toBeFocused();
|
||||
await page.keyboard.press('Enter');
|
||||
await expect(dialog).toHaveCount(0); await expect(deleteButton).toBeFocused();
|
||||
|
||||
Generated
+3
-3
@@ -7729,9 +7729,9 @@
|
||||
"license": "ISC"
|
||||
},
|
||||
"node_modules/follow-redirects": {
|
||||
"version": "1.16.0",
|
||||
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.16.0.tgz",
|
||||
"integrity": "sha512-y5rN/uOsadFT/JfYwhxRS5R7Qce+g3zG97+JrtFZlC9klX/W5hD7iiLzScI4nZqUS7DNUdhPgw4xI8W2LuXlUw==",
|
||||
"version": "1.16.1",
|
||||
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.16.1.tgz",
|
||||
"integrity": "sha512-FNvFGzoMLWmE6Yj9spb/zjd7yiNCHiAW9/Tg9CXrQ8wuu32HtlJOwWO11OJafl5FfY3DxTdQ0vj42zU1kvv5jg==",
|
||||
"funding": [
|
||||
{
|
||||
"type": "individual",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import React from 'react';
|
||||
import '@testing-library/jest-dom';
|
||||
import { render, screen, fireEvent } from '@testing-library/react';
|
||||
import { render, screen, fireEvent, act } from '@testing-library/react';
|
||||
import { ConfirmProvider, useConfirm } from './confirm';
|
||||
import { I18nProvider } from './i18n/I18nProvider';
|
||||
|
||||
@@ -52,3 +52,18 @@ test('uses the selected language for shared dialog defaults', async () => {
|
||||
expect(screen.getByRole('button', { name: 'Bekreft' })).toBeInTheDocument();
|
||||
window.localStorage.removeItem('uiLanguage');
|
||||
});
|
||||
|
||||
test('finishing the opening transition preserves focus already moved inside the dialog', async () => {
|
||||
jest.useFakeTimers();
|
||||
try {
|
||||
render(<ConfirmProvider><Demo /></ConfirmProvider>);
|
||||
fireEvent.click(screen.getByRole('button', { name: /open confirm/i }));
|
||||
expect(screen.getByRole('button', { name: 'Cancel' })).toHaveFocus();
|
||||
const message = screen.getByRole('region', { name: 'Delete job' });
|
||||
act(() => message.focus());
|
||||
await act(async () => { jest.advanceTimersByTime(1000); });
|
||||
expect(message).toHaveFocus();
|
||||
} finally {
|
||||
jest.useRealTimers();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -25,7 +25,6 @@ export function ConfirmProvider({ children }: { children: React.ReactNode }) {
|
||||
const messageId = useId();
|
||||
const titleId = useId();
|
||||
const resolverRef = useRef<((value: boolean) => void) | null>(null);
|
||||
const cancelButtonRef = useRef<HTMLButtonElement>(null);
|
||||
const [state, setState] = useState<ConfirmState>({
|
||||
open: false,
|
||||
message: "",
|
||||
@@ -64,7 +63,6 @@ export function ConfirmProvider({ children }: { children: React.ReactNode }) {
|
||||
<Dialog open={state.open} onClose={() => closeWith(false)} aria-labelledby={titleId} aria-describedby={messageId} fullWidth maxWidth="xs"
|
||||
slotProps={{
|
||||
paper: { sx: { borderRadius: 3, border: 1, borderColor: "divider", backgroundImage: "none" } },
|
||||
transition: { onEntered: () => cancelButtonRef.current?.focus() },
|
||||
}}>
|
||||
<DialogTitle id={titleId} sx={{ pb: 1, fontWeight: 800 }}>{state.title}</DialogTitle>
|
||||
<DialogContent role="region" aria-labelledby={titleId} tabIndex={0}>
|
||||
@@ -76,7 +74,7 @@ export function ConfirmProvider({ children }: { children: React.ReactNode }) {
|
||||
<Typography id={messageId} sx={{ color: "text.secondary" }}>{state.message}</Typography>
|
||||
</DialogContent>
|
||||
<DialogActions sx={{ px: 3, pb: 2.5, gap: 1 }}>
|
||||
<Button ref={cancelButtonRef} autoFocus onClick={() => closeWith(false)}>{state.cancelLabel}</Button>
|
||||
<Button autoFocus onClick={() => closeWith(false)}>{state.cancelLabel}</Button>
|
||||
<Button color={state.destructive ? "error" : "primary"} variant="contained" onClick={() => closeWith(true)}>
|
||||
{state.confirmLabel}
|
||||
</Button>
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
"""Exercise the actual workflow's narrow corruption guard, without starting CI."""
|
||||
import os
|
||||
from pathlib import Path
|
||||
import shutil
|
||||
import subprocess
|
||||
import tempfile
|
||||
import unittest
|
||||
|
||||
WORKFLOW = Path(__file__).resolve().parents[1] / '.gitea/workflows/ci-deploy.yml'
|
||||
BASH = str(Path('C:/Program Files/Git/bin/bash.exe')) if os.name == 'nt' else shutil.which('bash')
|
||||
|
||||
|
||||
class BrowserRuntimeRetryTests(unittest.TestCase):
|
||||
def permits_retry(self, log):
|
||||
text = WORKFLOW.read_text(encoding='utf-8')
|
||||
end = text.index(' echo "Browser runtime source appears corrupted')
|
||||
start = text.rfind('\n if ', 0, end) + 1
|
||||
guard = text[start:end]
|
||||
self.assertTrue(guard.strip().startswith('if '))
|
||||
with tempfile.TemporaryDirectory() as folder:
|
||||
fixture = Path(folder) / 'smoke.log'
|
||||
fixture.write_text(log, encoding='utf-8')
|
||||
result = subprocess.run([BASH, '-c', guard + '\nexit 0\nelse\nexit 1\nfi'],
|
||||
env={**os.environ, 'smoke_log': fixture.as_posix()}, capture_output=True, text=True)
|
||||
self.assertIn(result.returncode, [0, 1], result.stderr)
|
||||
return result.returncode == 0
|
||||
|
||||
def test_captured_playwright_source_corruption(self):
|
||||
self.assertTrue(self.permits_retry('/workspace/node_modules/playwright-core/lib/utilsBundle.js:35841\n'
|
||||
'const { items }$= this;\nSyntaxError: Missing initializer in destructuring declaration'))
|
||||
|
||||
def test_existing_axe_source_corruption(self):
|
||||
self.assertTrue(self.permits_retry('AxeBuilder.analyze\npage.evaluate: ReferenceError: invalid runtime source'))
|
||||
|
||||
def test_application_assertion_stays_terminal(self):
|
||||
self.assertFalse(self.permits_retry('expect(region).not.toBeVisible() failed'))
|
||||
|
||||
def test_browser_crash_alone_stays_terminal(self):
|
||||
self.assertFalse(self.permits_retry('Error: page.evaluate: Target crashed'))
|
||||
|
||||
def test_user_javascript_syntax_error_stays_terminal(self):
|
||||
self.assertFalse(self.permits_retry('src/example.js:1\nconst { items }$= this;\nSyntaxError: Missing initializer in destructuring declaration'))
|
||||
|
||||
def test_incomplete_signature_stays_terminal(self):
|
||||
self.assertFalse(self.permits_retry('node_modules/playwright-core/lib/utilsBundle.js:35841\nSyntaxError: Missing initializer in destructuring declaration'))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
@@ -646,6 +646,8 @@ def _ollama_generate(prompt: str, *, json_mode: bool, temperature: float, timeou
|
||||
"stream": False,
|
||||
"options": {"temperature": temperature},
|
||||
}
|
||||
if OLLAMA_MODEL.split(":", 1)[0] == "qwen3.5":
|
||||
payload["think"] = False
|
||||
if json_mode:
|
||||
payload["format"] = "json"
|
||||
body = _http_post_json(f"{OLLAMA_BASE_URL}/api/generate", payload, {}, timeout)
|
||||
|
||||
@@ -8,6 +8,7 @@ import textwrap
|
||||
import zipfile
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
from docx import Document
|
||||
from fastapi.testclient import TestClient
|
||||
from PIL import Image
|
||||
@@ -253,6 +254,55 @@ def test_provider_defaults_to_ollama_and_is_unchanged(monkeypatch):
|
||||
assert captured["body"]["options"]["temperature"] == 0.1
|
||||
|
||||
|
||||
@pytest.mark.parametrize("ollama_model", ["qwen3.5:9b-q4_K_M", "qwen3.5"])
|
||||
@pytest.mark.parametrize("json_mode", [False, True])
|
||||
def test_qwen35_requests_nonthinking_output_without_consuming_thinking(monkeypatch, ollama_model, json_mode):
|
||||
module = load_app_module(monkeypatch, ollama_model=ollama_model)
|
||||
captured = {}
|
||||
output = '{"score": 7}' if json_mode else "Rewritten CV text"
|
||||
|
||||
def fake_urlopen(req, timeout=None):
|
||||
captured["body"] = json.loads(req.data.decode("utf-8"))
|
||||
captured["timeout"] = timeout
|
||||
captured["url"] = req.full_url
|
||||
return _FakeResponse({
|
||||
"response": output if captured["body"].get("think") is False else "",
|
||||
"thinking": "Private reasoning must never become candidate text.",
|
||||
})
|
||||
|
||||
monkeypatch.setattr(module.urllib_request, "urlopen", fake_urlopen)
|
||||
result = module._ollama_generate_json("synthetic prompt") if json_mode else module._ollama_generate_text("synthetic prompt")
|
||||
|
||||
assert result == ({"score": 7} if json_mode else output)
|
||||
expected = {
|
||||
"model": ollama_model,
|
||||
"prompt": "synthetic prompt",
|
||||
"stream": False,
|
||||
"options": {"temperature": 0.1 if json_mode else 0.2},
|
||||
"think": False,
|
||||
}
|
||||
if json_mode:
|
||||
expected["format"] = "json"
|
||||
assert captured["body"] == expected
|
||||
assert captured["url"] == f"{module.OLLAMA_BASE_URL}/api/generate"
|
||||
assert captured["timeout"] == (120 if json_mode else 180)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("ollama_model", ["qwen2.5:7b", "qwen3:8b", "qwen3.5-plus:9b"])
|
||||
def test_other_ollama_model_payloads_remain_unchanged(monkeypatch, ollama_model):
|
||||
module = load_app_module(monkeypatch, ollama_model=ollama_model)
|
||||
captured = {}
|
||||
_install_fake_urlopen(monkeypatch, module, {"response": " Candidate text ", "thinking": "Reasoning"}, captured)
|
||||
|
||||
assert module._ollama_generate_text("synthetic prompt") == "Candidate text"
|
||||
assert captured["body"] == {
|
||||
"model": ollama_model,
|
||||
"prompt": "synthetic prompt",
|
||||
"stream": False,
|
||||
"options": {"temperature": 0.2},
|
||||
}
|
||||
|
||||
|
||||
def test_local_success_wins_even_when_external_fallback_is_permitted(monkeypatch):
|
||||
monkeypatch.setenv("AI_PROVIDER", "gemini")
|
||||
monkeypatch.setenv("GEMINI_API_KEY", "test-key")
|
||||
|
||||
Reference in New Issue
Block a user