Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion application/single_app/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
EXECUTOR_TYPE = 'thread'
EXECUTOR_MAX_WORKERS = 30
SESSION_TYPE = 'filesystem'
VERSION = "0.261.331"
VERSION = "0.261.332"
IS_DEVELOPMENT = is_development_env_enabled()

# Opt-out for deployments where App Service Easy Auth is active but the platform
Expand Down
19 changes: 18 additions & 1 deletion application/single_app/functions_document_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
)
from functions_document_analysis_results import normalize_analysis_options
from functions_search import normalize_search_id_list
from functions_workflow_document_selection import (
MAX_RECENT_WINDOW_MINUTES, normalize_document_selection, validate_recent_window,

Check warning on line 14 in application/single_app/functions_document_actions.py

View workflow job for this annotation

GitHub Actions / malicious-pr-security-review

Important - Changed line contains security control, sanitization, or audit marker. Recommendation%3A Confirm the change does not weaken auth, CSRF, CSP, XSS defenses, settings sanitization, redaction, audit logging, or tests.
)
Comment thread
paullizer marked this conversation as resolved.


DOCUMENT_ACTION_TYPE_NONE = 'none'
Expand Down Expand Up @@ -181,7 +184,7 @@
normalized_value = int(value)
except (TypeError, ValueError):
normalized_value = DEFAULT_RECENT_DOCUMENT_WINDOW_MINUTES
return max(1, min(1440, normalized_value))
return max(1, min(MAX_RECENT_WINDOW_MINUTES, normalized_value))


def _coerce_document_action_limit(value, default_value, execution_context):
Expand Down Expand Up @@ -504,6 +507,20 @@
'target_mode': DOCUMENT_ACTION_TARGET_MODE_SELECTED,
'recent_window_minutes': DEFAULT_RECENT_DOCUMENT_WINDOW_MINUTES,
}
if 'document_selection' in source_action:
if source_action.get('target_mode') != DOCUMENT_ACTION_TARGET_MODE_RECENT or action_type == DOCUMENT_ACTION_TYPE_NONE:
raise ValueError('Document selection requires the Recent documents target mode.')
selection = normalize_document_selection(source_action['document_selection'])
validate_recent_window(source_action.get('recent_window_minutes'))

Check warning on line 514 in application/single_app/functions_document_actions.py

View workflow job for this annotation

GitHub Actions / malicious-pr-security-review

Important - Changed line contains security control, sanitization, or audit marker. Recommendation%3A Confirm the change does not weaken auth, CSRF, CSP, XSS defenses, settings sanitization, redaction, audit logging, or tests.
normalized_action['document_selection'] = selection
source_action = dict(source_action)
scopes = selection['scopes']
kinds = {scope['scope_type'] for scope in scopes}
source_action.update({
'doc_scope': next(iter(kinds)) if len(kinds) == 1 else 'all',
'active_group_ids': [scope['scope_id'] for scope in scopes if scope['scope_type'] == 'group'],
'active_public_workspace_id': [scope['scope_id'] for scope in scopes if scope['scope_type'] == 'public'],

Check warning on line 522 in application/single_app/functions_document_actions.py

View workflow job for this annotation

GitHub Actions / malicious-pr-security-review

Important - Changed line contains AI, plugin, agent, or workspace boundary marker. Recommendation%3A Check whether prompts, chat history, uploaded documents, embeddings, citations, settings, or identity can cross a new boundary.
})
if action_type == DOCUMENT_ACTION_TYPE_NONE:
return normalized_action

Expand Down
15 changes: 13 additions & 2 deletions application/single_app/functions_search_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
normalize_search_top_n,
)
from functions_settings import get_settings, get_user_settings
from functions_workflow_document_selection import selected_document_context_validator, selected_source_matches
Comment thread
paullizer marked this conversation as resolved.
from public_chat_scope_state import aggregate_public_workspace_ids, current_public_chat_scope


Expand Down Expand Up @@ -559,6 +560,8 @@
include_content=True,
visible_public_workspace_ids=None,
):
validator = selected_document_context_validator(user_id)
context_options = {'context_validator': validator} if validator is not None else {}
normalized_scope = normalize_search_scope(doc_scope)
if current_public_chat_scope(user_id):
normalized_scope = "public"
Expand All @@ -569,7 +572,7 @@

if normalized_scope in ("all", "personal"):
personal_context = _resolve_personal_document_context(document_id, user_id)
if personal_context:
if personal_context and (validator is None or validator(personal_context, document_id)):
return personal_context

if normalized_scope in ("all", "group"):
Expand All @@ -581,6 +584,7 @@
active_group_ids=active_group_ids,
fallback_to_memberships=True,
),
**context_options,
)
if group_context:
return group_context
Expand All @@ -594,6 +598,7 @@
active_public_workspace_id=active_public_workspace_id,
**public_visibility,
),
**context_options,
)
if public_context:
return public_context
Expand All @@ -606,7 +611,7 @@
conversation_id=conversation_id,
include_content=include_content,
)
if chat_upload_context:
if chat_upload_context and (validator is None or validator(chat_upload_context, document_id)):
return chat_upload_context

return None
Expand All @@ -624,6 +629,7 @@
context_validator=None,
):
"""Resolve documents, optionally requiring explicit scopes and an accepted access path."""
context_validator = selected_document_context_validator(user_id, context_validator)
normalized_scope = normalize_search_scope(doc_scope)
aggregate = current_public_chat_scope(user_id)
if aggregate:
Expand Down Expand Up @@ -781,6 +787,11 @@
include_all_public_workspaces=include_all_public_workspaces,
)
results = hybrid_search(**search_request) or []
results = [
result for result in results if selected_source_matches(
user_id, result.get('document_id'), result.get('scope'), result.get('scope_id'),
)
]
unique_document_ids = {
result.get("document_id")
for result in results
Expand Down
Loading
Loading